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
glo
Newbie


Joined: 01 May 2002
Posts: 7

PostPosted: Wed May 01, 2002 3:35 am   

Trigger loops
 
I'm trying to check the last X lines of text in an alias to see if a room has certain mobs in a given order. I have tried the following trigger to read the last 3 lines of text from the mud into 3 variables, but it seems to go into a infinite loop. Any suggestions on how I might do this? I know it is simple but I can't seem to get it. Thanks!

TRIGGER Parameter: ^(%*)$
TRIGGER Contents:
@currentlinetext = %1
#if (@linenumber = 1) {
lastlineoftext = @currentlinetext
linenumber=2
}{#if (@linenumber = 2) {
lastlineoftext = @currentlinetext
linenumber=3
}{#if (@linenumber = 3) {
lastlineoftext3 = @currentlinetext
linenumber=1
}{#NOOP}}
}
Reply with quote
Pega
Magician


Joined: 08 Jan 2001
Posts: 341
Location: Singapore

PostPosted: Wed May 01, 2002 4:35 am   
 

*cringes*

@currentlinetext = %1 


should be:

currentlinetext = %1


I disable the '=' for variable assignment and use this instead:

#var currentlinetext {%1}


This creates a variable whose name is the contents of currentlinetext:

#var @currentlinetext {%1}
Reply with quote
glo
Newbie


Joined: 01 May 2002
Posts: 7

PostPosted: Wed May 01, 2002 4:46 am   
 
Thanks for the feedback. I changed the code within the trigger to be:

#var currentlinetext {%1}
#if (@linenumber = 1) {
lastlineoftext = currentlinetext
linenumber=2
}{#if (@linenumber = 2) {
lastlineoftext = currentlinetext
linenumber=3
}{#if (@linenumber = 3) {
lastlineoftext3 = currentlinetext
linenumber=1
}{#NOOP}}
}

And now I get a trigger loop detected. Am I correct when I assume that an IF loop short circuits? If it goes into the TRUE clause it will no then test the IF in the else clause?

Thanks again!
Reply with quote
Pega
Magician


Joined: 08 Jan 2001
Posts: 341
Location: Singapore

PostPosted: Wed May 01, 2002 5:31 am   
 
First of all I should have said that this code is not needed for what it is trying to do.

1) You can simply make use of '%line', '%line2' and '%line3' to retrive the last 3 lines received from the mud.

2) This was correct: 'lastlineoftext = @currentlinetext'.

3) An #IF statement is definately not a loop. A trigger loop usually happens when a trigger triggers itself.

4) Getting your trigger to fire on every line is makes ZMud work too hard for you.
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