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

Joined: 11 Jan 2011
Posts: 3

PostPosted: Thu Mar 21, 2013 5:49 pm   

Exits: and variable

Can anyone help me out how to capture exits in to variable.

I have a lot of triggers For exits
My exit line can be

Exits: north, south, west.
Exits: north, (south), (west). etc
Exits: [north], south, (west). etc
Exits: -north-, -south-, =west=.
Exits: =north=, =south=, (west).
and so on a really lot of different combinations.

What i have now is
#trigger Exits: (%w), (%w), (%w).
#var exitnames %1%2%3
#trigger Exits: ~((%w)~), (%w), (%w).
#var exitnames %1%2%3
a really lot of triggers.

Is there any easier way to capture Exits? Perl expression %replace?
Or any other way?

Thanks for your
Reply with quote

Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Thu Mar 21, 2013 10:23 pm   
#trigger "tExits" {^Exits: ([%w%s,~[~]~(~)-=]).$} {}

That is what the pattern would look like. To keep it simple, you can just assign the entire exits string to a variable (Exits = %1). A more advanced solution is discussed below that allows you to handle each exit type more specifically (any code listed below is meant to go into the above trigger in the empty set of curly brackets).

To start out, I would initialize the Exits variable to a starting "no exits" state. This lets me include exits that are not available in the room, which I'm equating to 0 (ZMud uses 0 as a false value):

Exits = ""
#forall "north|south|east|west|up|down" {#addkey Exits %i 0}

I would then use a looping structure to step through each item in the list, and nested #if commands and #case commands to pry out both the direction name and any surrounding symbology:

#forall %replace("%1",", ","|") {
  #if (%ismember(%left(%i,1),"(|[|-|=")) {
    //this one is not a plain exit, figure out which symbol is being used
    #case %ismember(%left(%i,1),"(|[|-|=") {#addkey Exits %subchar(%i,"()","") 2} {#addkey Exits %subchar(%i,"[]","") 3} {#addkey Exits %subchar(%i,"-","") 4} {#addkey Exits %subchar(%i,"=","") 5}
  } {
    //this one is a plain exit
    #addkey Exits %i 1

If I have this all written correctly, the result will be a datarecord variable consisting of a numeric value assigned to each of the possible exit directions your game uses. To reference a particular value, use @Exits.direction (ie, @Exits.north).
EDIT: I didn't like my old signature
Reply with quote

Joined: 11 Jan 2011
Posts: 3

PostPosted: Fri Mar 22, 2013 7:55 am   
Thanks for reply,

But i did try this and what happened
Made trigger ^Exits: ([%w%s,~[~]~(~)-=]).$
#var exitnames %1

Now i move around in mud lets say room with exits Exits: east, south.
and #show @exitnames it shows me like this
east, nothing more.

or Exits: (north), east.
#show @exitnames (north),

or Exits: [north], east.
#show @exitnames north,

Seems that trigger don't understand -->,

So i made 6 triggers 1. trigger ^Exits: ([%w~[~]~(~)-=]).$
2.trigger ^Exits: ([%w~[~]~(~)-=]), ([%w~[~]~(~)-=]).$
and so on

So far thank You for Your help!
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