Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
thomaspepon
Beginner


Joined: 04 Sep 2008
Posts: 16

PostPosted: Wed Sep 10, 2008 3:33 am   

trigger question with variable comparison
 
I am building a simple combat bot to kill hobgoblins, however the hobgoblins assist each other,
so when there are more than 2 in a room, I don't want to attack.

I've put the following together.
variable @hobgoblin_count
alias attack_1_hob = "k hobgoblin;#wa 20000"
alias attack_2_hob = "k hobgoblin;#wa 20000;k hobgoblin;#wa 20000"
trigger on "A small hobgoblin seems to be searching for something." executes #ADD hobgoblin_count 1

I set @hobgoblin_count = 0 and then enter a room, for example
<from mud>
In the Mountains
You are walking on a rocky trail that winds through the mountains. From
here you can see the whole valley and Dark Realm Lake, and from this angle
it almost looks as if there is something at the bottom of the lake.

[Exits: north east]
A small hobgoblin seems to be searching for something.
A small hobgoblin seems to be searching for something.
</from mud>

If I do #show @hobgoblin_count at this point, it says 2, so the counter is working.

I am running an alias that says
#if (@hobgoblin_count = 1) {attack_1_hob}
#if (@hobgoblin_count = 2) {attack_2_hob}
sc

Yes, it's very rudimentary, and int the 2 case I k hobgoblin twice, in case I finish one before the second notices and assists.

However, when I run the script, the #if statements evaluate false, si I don't attack, and just moves the next step, showing my score.

But @hobgoblin_count = 2, so it should have run the attack_2_hob alias.

To further test, I added an alias named test as #if (@hobgoblin_count = 2) {say hi} {say bye}
And it says 'Hi', so it evaluated in that instance. I'm not sure why the earlier example didn't evaluate correctly.

In case the problem is within the whole of the alias, here is the whole alias that I pull the above example from:
#if (%char = "deadlock") {
@hobgoblin_count = 0
d
#if (@hobgoblin_count = 1) {attack_1_hob}
#if (@hobgoblin_count = 2) {attack_2_hob}
sc
}

it sets the count to 0 and enters the room. I can check the variable at that point, and it returns 2, the next input is the sc, it doesn't evaluate
true for either of the if statements, but running the test alias afterwards still says hi.

Any help would be appreciated.
Reply with quote
thomaspepon
Beginner


Joined: 04 Sep 2008
Posts: 16

PostPosted: Wed Sep 10, 2008 3:36 am   
 
Ok, right after I wrote the message, and clicked post, I figured out what was happening, the alias was sending the d command,
and then evaluating @hobgoblin_count before the mud returned the room description and mob list, so at that point,
@hobgoblin_count was still 0, and it just dumped sc.

I was able to work around this by adding a #wa 2000 statement after the d command, which gave the mud time to return the
room description and mob list, thus setting my @hobgoblin_count, and I attacked as expected.

Sorry, silly me.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net