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
gmueller
Apprentice


Joined: 06 Apr 2004
Posts: 173

PostPosted: Fri Aug 13, 2004 3:58 pm   

using an alias to call a dummy trigger
 
im trying to set up an alias called smoke_herb that basically sets off a multistate trigger...but i really dont understan the set and state commands...and it doesnt look like many people use a lot of them in their scripts.

if someone could help me write this i would really be greatfull.

heres the logic: NOTE: this will only be meta language as im not sure of the exact syntax...
#CLASS pipe_smoking
#VARIABLE pipe {pipe12345} {pipe12345}
#VARIABLE pipe_empty {1} {1}
#VARIABLE pipe_lit {0} {0}
#VARiABLE attempts {0} {0}
#VARIABLE has_herb_in_hand {0} {0}
#ALIAS smoke_herb {call smoke_herb_trigger}

#TRIGGER smoke_herb_trigger
state 0: {the pattern in this box is unimpotant} {attempts=0;#IF (@pipe_empty) {goto state 2} {goto state 5}}
state 1: {^You get 1 herb from your poecketbelt.$} {has_herb_in_hand=1;goto state 2}
--------if state 1 is requested but fails to match in 10 lines of text from the MUD, kick out of the trigger
state 2: {} {#IF (@has_herb_in_hand) {#SEND put herb in @pipe;goto state 3} {#SEND outb herb;goto state 1}}
state 3: {^You put an herb in your pipe.$} {pipe_empty=0;goto state 5}
--------if state 3 is requested but fails to match in 10 lines of text from the MUD, kick out of the trigger
state 4: {} {^Your pipe is lit and smoking nicely.$} {pipelit=1;goto state 5}
--------if state 4 is requested but fails to match in 10 lines of text from the MUD, kick out of the trigger
state 5: {} {#IF (@pipelit) {#SEND smoke @pipe;goto state 6} {#SEND light @pipe;goto state 4}}
state 6: {^You take a long drag off your pipe.$} {#ALARM {+115} {#ECHO WARNING: PIPE IS ABOUT TO GO OUT!!!}}
--------if state 6 is requested but fails to match in 10 lines of text from the MUD, kick out of the trigger
#CLASS 0



no matter what trigger types i put on these...and also what state and set values...i get wierd responses...any help would be very appreciated!!!
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Fri Aug 13, 2004 10:32 pm   
 
The first thing to remember about multi-state triggers is ONLY ONE state can be active at a time.

The way you described it in your meta example leads me to believe that you want more then 1 state to be active. This requires multiple triggers instead of multiple states. I think once you split up the possible repsonses to actions into an appropiate number of triggers you will find that states, for those triggers, tend to fall into place more readily.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sat Aug 14, 2004 12:03 am   
 
#SET alters the status (fired/not fired) of the specified state. If the state is set to true (fired), then the Value of that state is executed. Also, if this is the current state and it is set to true, then the trigger advances, otherwise the current state remains unchanged. When the trigger advances, if the next state has already been set to true then it will be skipped.

#STATE sets the status of the specified state to not fired and makes it the current state.

This would probably be better as a set of individual triggers, but it's an interesting exercise.
Code:

#CLASS pipe_smoking
#VARIABLE pipe {pipe12345} {pipe12345}
#VARIABLE pipe_empty {1} {1}
#VARIABLE pipe_lit {0} {0}
#VARiABLE attempts {0} {0}
#VARIABLE has_herb_in_hand {0} {0}
#AL smoke_herb {#STATE smoke_herb_trigger 0;#SET smoke_herb_trigger 1}
#TR smoke_herb_trigger {} {#NOOP State 0;#VAR attempts 0;#IF (@pipe_empty) {#STATE smoke_herb_trigger 2} {#STATE smoke_herb_trigger  5}}
#COND {^You get 1 herb from your pocketbelt.$} {#NOOP State 1;#VAR has_herb_in_hand 1;#STATE smoke_herb_trigger 2}  {Within|Param=10}
#COND {} {#NOOP State 2;#IF (@has_herb_in_hand) {#SEND put herb in @pipe} {#STATE smoke_herb_trigger 1;#SEND outb herb}} {Wait|Param=1}
#COND {^You put an herb in your pipe.$} {#NOOP State 3;#VAR pipe_empty 0;#STATE smoke_herb_trigger 5} {Within|Param=10}
#COND {^Your pipe is lit and smoking nicely.$} {#NOOP State 4;#SET #VAR pipelit 1;#STATE smoke_herb_trigger 5} {Within|Param=10}
#COND {} {#NOOP State 5;#IF (@pipelit) {#SEND smoke @pipe} {#STATE smoke_herb_trigger 4;#SEND light @pipe}} {Wait|Param=1}
#COND {^You take a long drag off your pipe.$} {#NOOP State 6;#ALARM {+115} {#ECHO WARNING: PIPE IS ABOUT TO GO OUT!!!}} {Within|Param=10}
#CLASS 0

Untested.

Sorry Vijilante, I took a long break in the middle of my response and had this all worked out before I read yours.
_________________
LightBulb
Senior member

Most scripts in this forum are written for Command Line entry.
Don't even open the Settings Editor unless its use is specified or obvious.
Reply with quote
gmueller
Apprentice


Joined: 06 Apr 2004
Posts: 173

PostPosted: Sat Aug 14, 2004 8:51 am   
 
Wow thanks you guys, I tried the script that LightBulb wrote...it fires and gets stuck at about state 3. I appreciate the explanation of SET and STATE go gave, they were kinda fuzzy in my mind as to whether or not you needed to use both or just one of them. Thanks Vigilante, i think i will take you up on that...and split it up into different triggers and just #T+ and #T- the devil out of them, thanks again to the both of 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