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


Joined: 11 Dec 2006
Posts: 9

PostPosted: Sun Mar 30, 2008 4:50 pm   

Manual states just not doing it for me?
 
I have the following manual multi-state trigger:
(That is to say, both states have it set to Manual state with param=0)

Code:
State 0:
Pattern: {^You quickly eat a juniper berry.}
Does: {#IF (@eaten = juniper) {#SET 0}}
State 1:
Pattern: {^{Your hearing disappears!|Being deaf, the juniper berry has no effect.}}
Does: {defgive deafness;eaten = "";#SET 1}


And whenever the first line triggers, I get this message:

Code:
Error parsing command:
Access violation at address 0084717E in module 'Zmud.exe'. Read of address 6874207B
#SET 0


So, I'm trying to figure out what I could possibly be doing wrong. I've tried this so many ways, I can't think of anything else.
I appreciate your help :)
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sun Mar 30, 2008 5:24 pm   
 
In any given situation, you probably don't need to use the #set command. I'd go so far as to say you probably shouldn't use it. This is a case where you don't need to use #set at all.

Although this file is for CMUD, many of the same rules apply. It explains in detail how to use #set with manual states.

The gist of it, however, is that manual states don't need patterns. The code of a state is run when its state is set to true - various things can cause this. If it's a pattern state, matching its pattern will cause it. If it's a wait state with no pattern, its time expiring will cause it. If it's a manual state, nothing will cause it except some other script issuing the #set command. Hopefully that explains why issuing the #set 0 command from inside state 0's script is nonsense - in order for the script to be run, state 0 must first be true, so setting it true again is pointless.

However, you would expect that since both states of your triggers are manual, neither of them will ever do anything since nothing sets them as true. The answer is that some trigger types cannot be used for the first state of a trigger (state 0) and manual is one of these types. This is why the trigger is firing even though you have both states set to manual - although you've set the type to manual, zMUD still treats the first state as if it were a pattern trigger.

To make your script work, you'll want to change its logic a bit. The second #set command is pointless and can be safely removed. State 0's script you'll want to replace with #if (@eaten!="juniper") {#state 0} which will reset the script to looking for the first pattern, ignoring the second entirely if you haven't eaten juniper. You'll probably want the first state to be a pattern state and the second to be within 1 line.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
DDMyth
Newbie


Joined: 11 Dec 2006
Posts: 9

PostPosted: Sun Mar 30, 2008 10:14 pm   
 
Thanks a bunch, it works. I really appreciate it. Fang Xianfu, you're my zmud coding hero :D
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