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
Sir Runsalot
Beginner


Joined: 18 May 2002
Posts: 20

PostPosted: Wed Mar 24, 2004 1:50 pm   

Trigger fires more than once.
 
Alright, I am having troubles with triggers being
fired more than once. Any help is appreciated. As you
can see below, it triggers twice on "You search everywhere,
but find no herbs." Debug info marked in green (echoed or shown),
The trigger line is marked in red
Mud input is yellow.

Woot, the mapper has detected my move, proceeding with herbing
search here for herbs
You start to search.
>
You search everywhere, but find no herbs.
The small brown rabbit hops north.
Going to 4512, Called by _find_no_herbs_
ne
I am in 4511 waiting to go to 4512
In the southeast parts of the Eastfold.
There are three obvious exits: north, southwest and west.
A red brown deer.
>
Woot, the mapper has detected my move, proceeding with herbing
search here for herbs
Going to 4515, Called by _find_no_herbs_
n
You start to search.
>
I am in 4512 waiting to go to 4515
You are busy with other things right now. You must 'stop' to do something else.


These are the triggers:
#CLASS {HerbBot}
#ALIAS herbpath {roomstovisit="";#lmap {%alias( %1)} {#additem roomstovisit %i};herbbotwalk}
#ALIAS herbbotwalk {#show Going to %item( @roomstovisit, 1), Called by %-1;#if (@roomstovisit!="") {#walk %item( @roomstovisit, 1);herbbotherb} {#beep}}
#ALIAS herbbotherb {tosearchfor="";#while (%nextroom( )!="") {#show OK, the mapper suxxors!;#show I am in %roomnum( ) waiting to go to %nextroom( );#wait 1000};#show Woot, the mapper has detected my move;roomstovisit=%delnitem( @roomstovisit, 1);#loop %numitems( @priolist) {#if (%pos( %item( @priolist, %i), %roomnote( ))) {#if (@tosearchfor="") {tosearchfor=%item( @priolist, %i)}}};#if (@tosearchfor=="") {#if (@quickherb!="") {tosearchfor="herbs"}};#if (@tosearchfor!="") {search here for @tosearchfor} {herbbotwalk _herbbotherb_}}
#VAR quickherb {0}
#VAR priolist {garlic|suranie|frostheal|oakmoss|fordinfa|madwort|ginger|whitehorn|numbis|lore|soapweed|wilcol|attanar|basil|carlith|chervil|chicory|curugwath|hemlock|kuko|oregano|sargassum|sumac|tarragon}
#VAR tosearchfor {garlic}
#VAR roomstovisit {}
#TRIGGER {You search everywhere, but find no herbs.} {herbbotwalk _find no herbs trigger_}
#TRIGGER {Your search reveals nothing special.} {#if (@roomstovisit!="") {herbbotwalk _nothing special trigger_}}
#TRIGGER {You don't find any here for to search.} {herbbotwalk _dont find any here_} "" {disable}
#TRIGGER {You find a(*)!} {pp herb;herbbotherb}
#CLASS 0

I really can't see that I am doing anything to cause
this behaviour, but perhaps I am just being thick-headed... any help is greatly appreciated.

/Sir Runsalot
Reply with quote
Pega
Magician


Joined: 08 Jan 2001
Posts: 341
Location: Singapore

PostPosted: Thu Mar 25, 2004 12:27 pm   
 
Okay, where do i start.

First of all, can we assume that you assumed wrongly and that the trigger only fired once in that block of text?
Look at what made you think it fired twice, and then maybe you might find the answer. Wink
Reply with quote
Sir Runsalot
Beginner


Joined: 18 May 2002
Posts: 20

PostPosted: Thu Mar 25, 2004 3:03 pm   
 
Well, i have added some debug information in my aliases
so that it shows what trigger is calling the alias. (everything GREEN is client echoes with debug info.)

See this example:

#TRIGGER {You search everywhere, but find no herbs.} {herbbotwalk _find_no_herbs_}

the herbbotwalk alias will echo (I have changed it from show to echo since I dont really need to parse it, it is just info) according to this:

#ALIAS herbbotwalk {#echo Going to %item( @roomstovisit, 1), Called by %-1;#if (@roomstovisit!="") {#walk %item( @roomstovisit, 1);herbbotherb} {#beep}}

If you check my output text, there is only one line with "You search everywhere, but find no herbs" (marked in red), but two lines saying
Going to XXXX, Called by _find_no_herbs (which is the output of my alias).

So, the assumption is based on simple counting:
1 line which should cause the trigger to call the alias:
You search everywhere, but find no herbs.

2 lines which says the alias has been called by the trigger:
Going to 4512, Called by _find_no_herbs_
Going to 4515, Called by _find_no_herbs_


Nobody is happier than me if you can point out what an idiot I am and tell me what I am doing wrong ;) I just can't see why this happens.

/Sir Runsalot
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Fri Mar 26, 2004 1:24 am   
 
I do see a possible circumstance for this,

In your herbbotwalk alias this is this snippet:
{#walk %item( @roomstovisit, 1);herbbotherb}

In your herbbotherb alias there is this snippet:
{herbbotwalk _herbbotherb_}

This sets up a loop situation. Combined with your use of #WAIT it is understandable that you are getting some odd occurences. I would suggest redesigning the flow of your script to take advantage of multiple alarms. You might also be able to use the onwalkend special alias, since you use #WALK to move to the next room.
Reply with quote
Pega
Magician


Joined: 08 Jan 2001
Posts: 341
Location: Singapore

PostPosted: Fri Mar 26, 2004 1:40 am   
 
quote:
Originally posted by Sir Runsalot

Alright, I am having troubles with triggers being
fired more than once. Any help is appreciated. As you
can see below, it triggers twice on "You search everywhere,
but find no herbs." Debug info marked in green (echoed or shown),
The trigger line is marked in red
Mud input is yellow.

Woot, the mapper has detected my move, proceeding with herbing
search here for herbs
You start to search.
>
You search everywhere, but find no herbs.
The small brown rabbit hops north.
Going to 4512, Called by _find_no_herbs_
ne
I am in 4511 waiting to go to 4512
In the southeast parts of the Eastfold.
There are three obvious exits: north, southwest and west.
A red brown deer.
>
Woot, the mapper has detected my move, proceeding with herbing
search here for herbs
Going to 4515, Called by _find_no_herbs_
n
You start to search.
>
I am in 4512 waiting to go to 4515
You are busy with other things right now. You must 'stop' to do something else.


These are the triggers:
#CLASS {HerbBot}
#ALIAS herbpath {roomstovisit="";#lmap {%alias( %1)} {#additem roomstovisit %i};herbbotwalk}
#ALIAS herbbotwalk {#show Going to %item( @roomstovisit, 1), Called by %-1;#if (@roomstovisit!="") {#walk %item( @roomstovisit, 1);herbbotherb} {#beep}}
#ALIAS herbbotherb {tosearchfor="";#while (%nextroom( )!="") {#show OK, the mapper suxxors!;#show I am in %roomnum( ) waiting to go to %nextroom( );#wait 1000};#show Woot, the mapper has detected my move;roomstovisit=%delnitem( @roomstovisit, 1);#loop %numitems( @priolist) {#if (%pos( %item( @priolist, %i), %roomnote( ))) {#if (@tosearchfor="") {tosearchfor=%item( @priolist, %i)}}};#if (@tosearchfor=="") {#if (@quickherb!="") {tosearchfor="herbs"}};#if (@tosearchfor!="") {search here for @tosearchfor} {herbbotwalk _herbbotherb_}}
#VAR quickherb {0}
#VAR priolist {garlic|suranie|frostheal|oakmoss|fordinfa|madwort|ginger|whitehorn|numbis|lore|soapweed|wilcol|attanar|basil|carlith|chervil|chicory|curugwath|hemlock|kuko|oregano|sargassum|sumac|tarragon}
#VAR tosearchfor {garlic}
#VAR roomstovisit {}
#TRIGGER {You search everywhere, but find no herbs.} {herbbotwalk _find no herbs trigger_}
#TRIGGER {Your search reveals nothing special.} {#if (@roomstovisit!="") {herbbotwalk _nothing special trigger_}}
#TRIGGER {You don't find any here for to search.} {herbbotwalk _dont find any here_} "" {disable}
#TRIGGER {You find a(*)!} {pp herb;herbbotherb}
#CLASS 0

I really can't see that I am doing anything to cause
this behaviour, but perhaps I am just being thick-headed... any help is greatly appreciated.

/Sir Runsalot



You tell me. Smile
The above script obviously does not match the output shown if you look closely enough.
For all I know you have some additional stuff triggering off eg. gags, duplicate aliases.
Also, what is the value in Quickherb?
Reply with quote
Sir Runsalot
Beginner


Joined: 18 May 2002
Posts: 20

PostPosted: Fri Mar 26, 2004 10:29 am   
 
quote:
Originally posted by Vijilante

I do see a possible circumstance for this,

In your herbbotwalk alias this is this snippet:
{#walk %item( @roomstovisit, 1);herbbotherb}

In your herbbotherb alias there is this snippet:
{herbbotwalk _herbbotherb_}

This sets up a loop situation. Combined with your use of #WAIT it is understandable that you are getting some odd occurences. I would suggest redesigning the flow of your script to take advantage of multiple alarms. You might also be able to use the onwalkend special alias, since you use #WALK to move to the next room.



Well, I thought of that, which is why I added the debug texts to
the triggers. If it was that piece of code that called the herbbotwalk, the thing echoed would be Going to XXXX, Called by _herbbotherb_, which is never shown in my output.

As for the output not matching, yes, that is true, but the script is essentially the same, just that I have replaced some #shows with some #echoes. The quickherb is just a variable connected to a button, and the thought is that if I have that pressed it will just skip herbing if there is no prioritized herb in the room.

This is the new settings, if you are interested:

#CLASS {HerbBot}
#ALIAS herbpath {roomstovisit="";#lmap {%alias( %1)} {#additem roomstovisit %i};herbbotwalk _herbpath_}
#ALIAS herbbotwalk {TheRoom=%item( @roomstovisit, 1);#echo Going to @TheRoom, Called by %-1;#if (@roomstovisit!="") {roomstovisit=%delnitem( @roomstovisit, 1);#walk @TheRoom;herbbotherb @TheRoom} {#beep}}
#ALIAS herbbotherb {#loop %numitems( @priolist) {#if (%pos( %item( @priolist, %i), %roomnote( %1))) {#if (@tosearchfor="") {tosearchfor=%item( @priolist, %i)}}};#if (@tosearchfor=="") {#if (@quickherb!="") {tosearchfor="herbs"}};#if (@tosearchfor!="") {search here for @tosearchfor} {herbbotwalk _herbbotherb_}}
#VAR quickherb {0}
#VAR priolist {garlic|suranie|frostheal|oakmoss|fordinfa|madwort|ginger|whitehorn|numbis|lore|soapweed|wilcol|attanar|basil|carlith|chervil|chicory|curugwath|hemlock|kuko|oregano|sargassum|sumac|tarragon|black potato}
#VAR tosearchfor {herbs}
#VAR masterherb {}
#VAR roomstovisit {2307|2308|2309|2310|2311|2312|2313|2314|2315|4387|4388|4389|4390|4391|4392|4393|2319|2320|2321|2322|2323|4423|2318|2317|2316|4394|4395|4396|4397|4398|4400|4401|4402|4403|4404|4428|4427|4426|4425|4429|4430|4431|4432|4433|4434|4435}
#VAR TheRoom {2306}
#TRIGGER {You search everywhere, but find no herbs.} {herbbotwalk _find_no_herbs_}
#TRIGGER {You don't find any here for to search.} {herbbotwalk _dont_find_any_here}
#TRIGGER {Your search reveals nothing special.} {herbbotwalk _search_reveals_nothing_special_}
#TRIGGER {You find a(*)!} {pp herb;herbbotherb}
#CLASS 0

Anyway, I am going to nuke my settings file and re-import stuff a bit at a time so I can trace where it goes wrong.

Thanks for your input though.

Sir Runsalot
Reply with quote
Sir Runsalot
Beginner


Joined: 18 May 2002
Posts: 20

PostPosted: Fri Mar 26, 2004 10:56 am   
 
Imported the trigger classes again,
It works like a charm. Waste no more time on this one.
Thanks for the time and input though.
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