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


Joined: 07 Oct 2004
Posts: 9

PostPosted: Thu Oct 07, 2004 3:52 am   

Request: Simple trigger w/variable
 
Finally upgraded to the latest zmud after using 4.62 since I purchased it in 1997. Surprised Lots of new and complicated commands, I see. What I'm looking for, I think, is to just store some info in a variable. Here's the situation:

When I 'bump' into a closed door (which may be named 'door', 'gate', or anything) I have been using the following:
#TR {The (%w) seems to be closed.}{open %1}
However, if the %w is locked, the name is NOT in the resulting line from the mud, but rather I see 'It seems to be locked'. Rather than having my first trigger waste time by doing "unlock %1;open %1" on every door, I need a way to capture (%w) to a variable, and feed that variable to the unlock trigger...I think. A fairly simple thing for many of you ppl here probably. Would appreciate any advice on how to make this work.
Reply with quote
mr_kent
Enchanter


Joined: 10 Oct 2000
Posts: 698

PostPosted: Thu Oct 07, 2004 1:28 pm   
 
#TRIGGER {^The (%w) seems to be closed.} {#VARIABLE curr_door %-1;open @curr_door}
#TRIGGER {^It seems to be locked.} {unlock @curr_door;open @curr_door}
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Thu Oct 07, 2004 1:57 pm   
 
Fix for mr_kent's trigger // added {} braces around %-1 to capture correctly

#TRIGGER {^The (%w) seems to be closed.} {#VARIABLE curr_door {%-1};open @curr_door}
_________________
Zmud Support Library
Zmud Knowledge Base
Reply with quote
Targa
Newbie


Joined: 07 Oct 2004
Posts: 9

PostPosted: Thu Oct 07, 2004 2:48 pm   
 
Thanks alot! Question tho: What's the diff in the new zmud that I would now use %-1 rather than %1? Am reading through the help docs and haven't found an explanation for that.

Here's another one I need, a bit more complex (for me at least). The mud I play on uses 'north' as the default door-opening direction (ie: 'open door' tells the mud to 'open door north'). Thus, if you already have an open door to the north and there's a closed door to the south, you *must* type 'open door s'. I use the numerical keypad for walking around, which as you know does not enter chars into the history buffer. My question is this:

If the above trigger fires in this type of situation, I get "But it's already open!" Is there any way to 'grab' the last direction I used with the numpad and feed that back to zmud in a trigger to open the correct direction?

Just in case I'm not explaining this well enough, here's an example, assuming I'm standing in a room with 4 closed doors in the 4 cardinal directions:

n
The door seems to be closed. (this fires the above trigger to 'open door', which the mud defaults to north)
#tr open door
You open the door
e
The door seems to be closed. (again, this fires the same trigger, but now I get:)
#tr open door
But it's already open!

I have 2 choices here. I can either have another trigger that fires on 'But it's already open!' to try to grab the last direction I entered on the numpad, or, to be more efficient, I need to modify the original door opening trigger to do this. ie:

#TR {^The (%w) seems to be closed.} {#VAR curr_door {%-1};(grab last dir typed in numpad);open @curr_door (direction)}
#TR {^It seems to be locked.} {unlock @curr_door (direction);open @curr_door (direction)}

Is this possible? Thanks!


Last edited by Targa on Thu Oct 07, 2004 3:09 pm; edited 1 time in total
Reply with quote
Rorso
Wizard


Joined: 14 Oct 2000
Posts: 1368

PostPosted: Thu Oct 07, 2004 2:51 pm   
 
That is a bug. Should be %1. As far as I know %-1 is supposed to be unsupported in zScript nowadays (if it ever was supported Mr. Green). %-1, %-2, etc are valid for use with aliases though.
Reply with quote
Targa
Newbie


Joined: 07 Oct 2004
Posts: 9

PostPosted: Thu Oct 07, 2004 3:16 pm   
 
Also, in the latest zmud help files, Zugg gives the following example:

#TRIGGER {Hp: (%d) Mana: (%d)} {#VAR HpVar %1;#VAR ManaVar %2}

This leads me to ask the question: Why, Nexela, do you state that when capturing the variable the %1 must be enclosed in curly brackets?
Reply with quote
Danlo
Magician


Joined: 28 Nov 2003
Posts: 313
Location: Australia

PostPosted: Thu Oct 07, 2004 5:39 pm   
 
Because if the value stored in %1 consists of more than 1 word, it will give the variable the value of the first word, and put the variable in a class labelled by the last word. You can also use "" instead of curly brackets.
Reply with quote
Rorso
Wizard


Joined: 14 Oct 2000
Posts: 1368

PostPosted: Thu Oct 07, 2004 6:02 pm   
 
Danlo wrote:
Because if the value stored in %1 consists of more than 1 word, it will give the variable the value of the first word, and put the variable in a class labelled by the last word. You can also use "" instead of curly brackets.

In this case it should always be a word as %w is used.
Reply with quote
Danlo
Magician


Joined: 28 Nov 2003
Posts: 313
Location: Australia

PostPosted: Thu Oct 07, 2004 6:10 pm   
 
At any rate, its good practice and a good thing to know.
Reply with quote
Targa
Newbie


Joined: 07 Oct 2004
Posts: 9

PostPosted: Thu Oct 07, 2004 7:05 pm   
 
OK, I'm testing the following now and can't see why it's not working:

#TR {^The (%w) seems to be closed.} {#VAR door {%1};open @door @lastcom3}
This results in the command "open gate" (when i hit a gate)
When I then type #var by itself, it shows that @lastcom3 is "east", yet it's not being sent to the mud. Any idea why? I've tried @lastcom and @lastcom2 also.

nvm, doh! should be 'open @door %lastcom3

Laughing
Reply with quote
Targa
Newbie


Joined: 07 Oct 2004
Posts: 9

PostPosted: Thu Oct 07, 2004 7:55 pm   
 
For future reference (for those who may find this thread through a search), here are the completed, functional triggers:

#TR {^The (%w) seems to be closed.} {#var door {%1};open @door %lastcom2}
#TR {^It seems to be locked.} {unlock @door %lastcom3}

These are made for Medievia's system.

Tr #1: If you "bump" into a "gate" when you type "s" or "south", feeds the word "gate" into the @door variable, retrieves "lastcom2" (which was you trying to move -south-), and sends the mud "open gate south".
If the gate is locked, the second trigger will fire, sending "unlock gate south" to the mud.
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Thu Oct 07, 2004 9:39 pm   
 
*Screams* Ok I give up thats at least three things Ive overlooked in as many days
_________________
Zmud Support Library
Zmud Knowledge Base
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