|
thalor Beginner
Joined: 15 Nov 2000 Posts: 23 Location: USA
|
Posted: Mon Feb 10, 2003 5:28 pm
Trigger to capture exits |
Greetings,
I need to capture exits from the text that shows up into individual variables.
I thought of doing what is bascially an If then model... if north -> set north var TRUE
etc etc. But im still a noob at vars on ZMUD.
What I need to do is bascially capture the exits, then choose one of them randomly.
Any help or pointers in the right direction of what to read would be very helpful.
A copy of some output is below.
A Link in the Ethereal Web Room: 6345
This is another link in the ethereal web. Various creatures
seem to get caught (or hypnotized) by its sticky strands.
Obvious exits from room 6345:
[ east south west ]
Thanks in Advance all
T |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Mon Feb 10, 2003 7:18 pm |
This will give you a list variable. You can then use the %numitems function to determine how many exits there are and the %item function to return any one of them.
#TR {Obvious exits from room %d:$~[(*)~]} {#VAR exits {%replace( %trim( %1), " ", "|")}}
LightBulb
Advanced Member |
|
|
|
thalor Beginner
Joined: 15 Nov 2000 Posts: 23 Location: USA
|
Posted: Mon Feb 10, 2003 9:01 pm |
Thanks, that gave me a start. however how would I handle this?...
[ (closed north) south up ]
ON my mud any direction enclosed with () are closed doors.... when it comes up on the list it lists it as
closed|north
south
up
Thanks.
T |
|
|
|
TonDiening GURU
Joined: 26 Jul 2001 Posts: 1958 Location: Canada
|
Posted: Mon Feb 10, 2003 9:58 pm |
Just strip those parts from LightBulb's example:
#TR {Obvious exits from room %d:$~[(*)~]} {#VAR exits {%replace(%replace(%replace( %trim( %1), " ", "|"),"(closed",""),")","")}}
The italic parts effectively should strip out "(closed " and ")"
Ton Diening
Edited 3:11ish - changed "(closed ") to "(closed" due to the first
part stripping out all the spaces. |
|
|
|
thalor Beginner
Joined: 15 Nov 2000 Posts: 23 Location: USA
|
Posted: Mon Feb 10, 2003 10:00 pm |
Ok got something like this....actually it is this...
#VAR exits {%replace( %trim( %1), " ", "|")}
#VAR movedir %item( @exits, %random( 1, %numitems( @exits)))
#WAIT 2000
@movedir
#MAP @movedir
#WAIT 2000
on the trigger. It fires and randomly selects a direction and moves...however the mapping is horrible and doesnt match anything that the bot is doing...what am I missing or doing wrong?
T |
|
|
|
TonDiening GURU
Joined: 26 Jul 2001 Posts: 1958 Location: Canada
|
Posted: Mon Feb 10, 2003 10:06 pm |
I'd avoid the use of #WAIT in case it hampers with processing of the mapper capturing the
rooms.
quote:
Syntax: #WA [time]
Delays processing of further commands on the line until text is received from the MUD. Sometimes commands from zMUD can be executed too fast for the MUD. This command is used to slow them down.
#VAR BotMapping 1
#VAR exits %replace(%replace(%replace( %trim( %1), " ", "|"),"(closed",""),")","")
#VAR movedir %item( @exits, %random( 1, %numitems( @exits)))
#IF (@BotMapping) {#ALARM BotMapping +2 {@movedir}
This allows you to stop the Mapping by changing the variable BotMapping.
I'd test to see if you really need to add the #MAP command as it
should see the direction and add it to the queue. You might be putting 2 directions
into the queue for the mapper to figure out.
What version of zMud you using btw?
Ton Diening
Edited 3:11ish - changed "(closed ") to "(closed" due to the first
part stripping out all the spaces. |
|
|
|
thalor Beginner
Joined: 15 Nov 2000 Posts: 23 Location: USA
|
Posted: Mon Feb 10, 2003 10:06 pm |
OH and the Trigger suggested by Ton puts all the exits into a single var list
IE
1 - closed|north|south|east
Whereas the other one would have had..
1 closed|north
2 south
3 east
Im looking through the manual thanks for the help. |
|
|
|
thalor Beginner
Joined: 15 Nov 2000 Posts: 23 Location: USA
|
Posted: Mon Feb 10, 2003 10:08 pm |
Version is 6.53 BETA
|
|
|
|
thalor Beginner
Joined: 15 Nov 2000 Posts: 23 Location: USA
|
Posted: Mon Feb 10, 2003 10:28 pm |
Allow me to rephrase that one about the trigger. It works FANTASTICALLY if the exits do not contain a (closed blah) exit.
It maps and sets it all correct. However when it encounters one of the (closed blah) exits it assigned all the exits into 1 cell of the string array.
Other than that its perfect. Thanks for all the help. |
|
|
|
TonDiening GURU
Joined: 26 Jul 2001 Posts: 1958 Location: Canada
|
Posted: Mon Feb 10, 2003 10:28 pm |
Oops, occured to me that all spaces were being changed into |
by the first replace. I modified all the above posts to
reflect that. The ( from (closed was causing nesting in the
variable.
So the end result should be:
#VAR exits %replace(%replace(%replace( %trim( %1), " ", "|"),"(closed",""),")","")
Ton Diening |
|
|
|
thalor Beginner
Joined: 15 Nov 2000 Posts: 23 Location: USA
|
Posted: Mon Feb 10, 2003 10:36 pm |
Perfect! Thanks for all the help.
|
|
|
|
thalor Beginner
Joined: 15 Nov 2000 Posts: 23 Location: USA
|
Posted: Mon Feb 10, 2003 10:44 pm |
Now...heh on tothe next subject of how would you make it a little less random as to which direction it would travel...IE I dont want to bounce between north and south for an hour. How would one set up that if it chooses east, it then eliminates west from the next choice UNLESS the only exit is west. :P Look like my "little project" is going to get big. Any suggestions are of course VERY helpful to this ZMUD trigger noob.
T |
|
|
|
TonDiening GURU
Joined: 26 Jul 2001 Posts: 1958 Location: Canada
|
Posted: Mon Feb 10, 2003 11:25 pm |
Have a read for conceptualization here.
But you can indeed remove the last direction travelled from the
current exits, the if there are still more than 1 exit left, move that way
or head back the way you came.
The other is to loop through the rooms and look for untested
links. Another interesting approach is what Talahaski did with colorizing
the rooms based on certain tests. This way you can visually
see the status of the mapping is and can easily use a similar
check to move to that room and go mapping that way.
Ton Diening |
|
|
|
thalor Beginner
Joined: 15 Nov 2000 Posts: 23 Location: USA
|
Posted: Tue Feb 11, 2003 4:02 pm |
I was thinking of a less than sophisticated way. More of something like this.
It wanders east. Based on the direction taken, the mapper then decides which string of directions to try. Wanting to take into consideration that the only way out might be the way you came in. We should make that one last, so if the mapper does the following....
Direction String of Directions
N -- U D E W S
S -- U D E W N
W -- U D N S E
E -- U D N S W
U -- N S E W D
D -- N S E W U
That way if it is a one way exit room, the last one it tries will get it out of the room. My only problem is how to implement it. |
|
|
|
TonDiening GURU
Joined: 26 Jul 2001 Posts: 1958 Location: Canada
|
Posted: Tue Feb 11, 2003 5:47 pm |
Why take a random direction choice when you can query if a direction is worthwhile to go?
quote:
roomlink
Syntax: %roomlink( room, dir, [i])
Return or set the link in direction dir to the room number i. To delete a link, i=-1, for an unknown link, i=-2, for a link back to the same room, i=-3. If room is omitted, the current room is used.
Untested but how about something like:
#VAR exits %replace(%replace(%replace( %trim( %1), " ", "|"),"(closed",""),")","")
#FORALL @exits {#IF (%roomlink(,%i,) == -2) {#ADDITEM BetterChoiceExit %i}
#IF (%numitems(@BetterChoiceExit) <=0) {%item( @exits, %random( 1, %numitems( @exits)))} {%item(@BetterChoiceExit,1)}
If it doesn't have a better choice exit it randomly moves. You can change the randomly
moves part to check for an untested link at the lowest vnum room, walk there and start
mapping again.
Ton Diening |
|
|
|
thalor Beginner
Joined: 15 Nov 2000 Posts: 23 Location: USA
|
Posted: Tue Feb 11, 2003 10:41 pm |
Ok tried that, but it wont work without the var in roomlink ie (%roomlink( ,%i, ) == -2)
gives an error. Ive replaced it with this:
(%roomlink( ,%i,-2) but i dont think thats going to work. when i test it all it does is move north...and the BetterChoiceExit is north|south|east|west..every time. Im checking out roomlink but i dont think it can function without that 3rd var. |
|
|
|
|
|