|
IvoL Newbie
Joined: 11 Jan 2011 Posts: 3
|
Posted: Thu Mar 21, 2013 5:49 pm
Exits: and variable |
Hello!
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
Examples
Exits: north, south, west.
or
Exits: north, (south), (west). etc
or
Exits: [north], south, (west). etc
or
Exits: -north-, -south-, =west=.
or
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
etc...
a really lot of triggers.
Is there any easier way to capture Exits? Perl expression %replace?
Or any other way?
Thanks for your |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: 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):
Code: |
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:
Code: |
#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 |
|
|
|
IvoL Newbie
Joined: 11 Jan 2011 Posts: 3
|
Posted: 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! |
|
|
|
|
|
|
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
|
|