 |
Carl Scott-Brown Newbie
Joined: 29 Sep 2002 Posts: 3
|
Posted: Thu Oct 17, 2002 4:50 pm
Basic trigger has driven author nuts!! |
Ok guys, this is a basic bit of code that should work fine, but doesnt.
After triggering on exits, it is supposed to count the number of mobs in the room (each mob has a new line), then send 'gl n.' for each line detected.
Anyway, code is below, please restore my sanity someone! =)
Trigger :
^~[Exits:*~]$(*)
Response:
#T+ Peekinv
#LOO @NoOfMobs {
gl %{i}~.
}
#T- Peekinv
NoOfMobs = 1
#CLASS {Peekinv}
#TRIGGER {^*$} {#AD NoOfMobs 1}
#CLASS 0 |
|
|
 |
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Thu Oct 17, 2002 5:40 pm |
Of course it doesn't work.
You start the #LOOP before you count the lines. You alter the #LOOP variable while the #LOOP is running.
You haven't defined any method to determine when you've reached the last mob. Instead, you just disable the counting whenever the #LOOP happens to finish running.
You'll need to start over, I'm afraid.
--------------------------------------
If there are 5 mobs, what happens when you send "gl 6"? If this provides a useful response (there aren't that many things here!), you could use that both to control the glancing and to count the mobs.
LightBulb
Senior Member |
|
|
 |
Carl Scott-Brown Newbie
Joined: 29 Sep 2002 Posts: 3
|
Posted: Thu Oct 17, 2002 11:21 pm |
Thanks LightBulb - all I need is an answer for counting the number of lines sent after the exits line then...can you post one?
Also, I assumed the #loo command was #loo @variable {} - closing at the end }. Obviously incorrect - can you tell me where am I altering the loop variable in the loop so I understand for the future?
Lastly, Glancing 'last mob + 1 wouldnt send a useful response to trigger a stop - however I can build the stop in later, so I've got no hastle there. |
|
|
 |
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Fri Oct 18, 2002 1:31 am |
Before the loop, you have #T+ Peekinv. In the Peekinv class you have #TRIGGER {^*$} {#AD NoOfMobs 1} which will change @NoOfMobs everytime a line is received. Since this is the loop variable, you are changing it everytime a line is received while the loop is running. Whether this will affect the loop's operation I don't know, since I avoid doing things like this.
Okay, counting lines is easy. The hard part is finding where to start and where to stop. The exits line gives you a starting point and in most cases you'll either have a blank line or a prompt for the stop point. You can also use the stop trigger to initiate the glance loop. I've used a blank-line trigger for this example. You may need to adjust the count up or down, depending on whether it counts the first or last lines (the ones in the other triggers), but a few tests should show if that's the case.
#TR {^~[Exits:*~]$*} {#VAR NoOfMobs 0;#T+ Peekinv}
#CLASS Peekinv disable
#TR {^*} {#ADD NoOfMobs 1}
#TR {$} {#T- Peekinv;#LOOP @NoOfMobs {gl %{i}.}
#CLASS 0
LightBulb
Senior Member |
|
|
 |
Carl Scott-Brown Newbie
Joined: 29 Sep 2002 Posts: 3
|
Posted: Fri Oct 18, 2002 3:43 am |
Ahh, wicked - Thanks, that worked a treat, and I got to learn something new =)
|
|
|
 |
|
|