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
al666
Beginner


Joined: 20 Dec 2006
Posts: 13

PostPosted: Wed Dec 20, 2006 1:37 pm   

walk script
 
hello,

how to make a script that walks to every room in one zone using not shortname of room nor number, but whole room name? ie,
if i'd type where and a mobname for example, it'll show a room name after it. how can i trigger it to momentaniously walk to that room? i already know how to fix map to reset to the same zone i'm currently in (with teleport etc), its just the walk part that boggles me, and even though shortnames can be handly, at one point you can't keep in mind every single one of them anymore.

ideas?

EDIT (MattLofton): moved to ZMud General Discussions. Questions and comments about how things work in ZMud should be posted to the ZMud General Discussions forum. Finished Scripts is for things that already work that you want to share with everyone else.
Reply with quote
Full Throttle
Wanderer


Joined: 07 Dec 2004
Posts: 65

PostPosted: Thu Dec 21, 2006 1:27 am   
 
Here is my zone walking script

Code:
#class {Walking_Map}
#var where_target {0} {0}
#var walk_search {0} {0}
#var walk_db_room {0} {0}
#var walk_db_path {0} {0}
#noop
#alias walkzone {#if %isnumber(%1) {#if (%1 = 0) {#show {}
#loopdb @walk_db_room {#show {%ansi(8)Filter: %ansi(15)%format("&5.0f",%val) %ansi(8)Virtual: %ansi(15)%format("&5.0f",%key) %ansi(8)Path: %ansi(15)%replace(%db(@walk_db_path,%key),".","")}}} {
#loopdb @walk_db_room {#if (%val = %1) {#walk %key}}}} {
#if (%1 = %null) {#var walk_search @where_target} {#var walk_search {%-1}}
#call %mapfilter(%concat("Name"," LIKE ","'%",%replace(@walk_search,"'","''"),"%'"," AND ","ZoneID"," = ",%zonenum))
#var walk_db_room %null
#var walk_db_path %null
#loop %numrooms {#addkey walk_db_room %roomvnum(%i) %i}
#loop %numrooms {#addkey walk_db_path %roomvnum(%i) %walk(%roomvnum(%i))}
#if (%numkeys(@walk_db_room) = 1) {#loopdb @walk_db_room {#if (%val = 1) {#walk %key}}}
#if (%numkeys(@walk_db_room) > 1) {#show {}
#loopdb @walk_db_room {#show {%ansi(8)Filter: %ansi(15)%format("&5.0f",%val) %ansi(8)Virtual: %ansi(15)%format("&5.0f",%key) %ansi(8)Zone: %ansi(15)%zonename(%roomzone(%key)) %ansi(8)Room: %ansi(15)%roomname(%key) %ansi(8)%char(91)%numitems(%pathexpand(%db(@walk_db_path,%key)))%char(93)}}}
#if (@walk_db_path = %null) {#var walk_db_path 0}
#if (@walk_db_room = %null) {#var walk_db_room 0}
#call %mapfilter(%null)}}
#noop
#trigger {^&30 - (*)} {#var where_target {%1}}
#class 0


note: change the above trigger to match your muds "where <mob>" output


>walkzone fargo street
Filter: 1 Virtual: 151 Zone: Newbatia Room: The Intersection of Main and Fargo Streets [6]
Filter: 2 Virtual: 172 Zone: Newbatia Room: Fargo Street [7]
Filter: 3 Virtual: 174 Zone: Newbatia Room: Fargo Street [8]
Filter: 4 Virtual: 176 Zone: Newbatia Room: Corner of Court Lane and Fargo Street [9]

note: [7] means the room is 7 steps away

>walkzone 0
Filter: 1 Virtual: 151 Path: s3w2s
Filter: 2 Virtual: 172 Path: s3w2se
Filter: 3 Virtual: 174 Path: s3w2s2e
Filter: 4 Virtual: 176 Path: s3w2s3e

>walkzone 2
.s3w2se


if "fargo street" is stored in where_target variable, then use walkzone alias without a parameter

if "fargo street" was an unique room name within the zone, then walkzone alias would just issue the walk

if you want to do exact searches, then change the map filter to:

#call %mapfilter(%concat("Name"," LIKE ","'",%replace(@walk_search,"'","''"),"'"," AND ","ZoneID"," = ",%zonenum))

then

>walkzone fargo street
Filter: 1 Virtual: 172 Zone: Newbatia Room: Fargo Street [7]
Filter: 2 Virtual: 174 Zone: Newbatia Room: Fargo Street [8]


Also, take a look at 'Walk Location System' by Vijilante:
http://forums.zuggsoft.com/phpbb/viewtopic.php?t=23054
Reply with quote
al666
Beginner


Joined: 20 Dec 2006
Posts: 13

PostPosted: Thu Dec 21, 2006 2:56 pm   thanks a lot
 
going to try now if it works ... mud has where <mob> output as
where mobname, i changed the trigger you gave me just by removing the "-" and leaving a small space between instead of large one, no idea if it works like that tho. going to try :)
Reply with quote
al666
Beginner


Joined: 20 Dec 2006
Posts: 13

PostPosted: Thu Dec 21, 2006 3:26 pm   tried it
 
tried it now and it seems to work very nicely, though it doesn't seem to trigger itself from where <mobname> output so after i where'ed i just did walkzone with part of the room name (like with one word) and then it gave me possible matches with that very awesome filter function :) anyhow, it'd be cool if possible matches search would start right after i type where <mobname> in (its not like its any trouble to get a part of room name and make walkzone with it, but still...) another thing is that when i happen to hit a word that is likely to appear alot in the room names within the zone, it'll lag a lot and eventually turn up with a huge load of possible matches. i guess if the system could react upon the exact output of the room name, it'd cause less lag to begin with.
basically, is it possible to make the system trigger itself from the exact
where|-BLANK SPACE-|mobname and get the exact room name output off it? then it'd be perfect :)

ps i'm unsure myself how to script that pretty large blank space between mob and roomname on where. just one space as i just tried myself when i changed Your trig didn't seem to work...
Reply with quote
Full Throttle
Wanderer


Joined: 07 Dec 2004
Posts: 65

PostPosted: Thu Dec 21, 2006 9:12 pm   
 
post a sample of your where output

is the beginning of the room name located at a fixed width?
is there a standard output above the line with the room name?

here is a sample of my muds where <target> command:

>where zugg

Code:
Name                           - Location
-----------------------------------------
Zugg                           - The Inn


the '-' symbol is always at 32nd column on my screen, so I use a fixed width pattern '^&30 - (*)'
Reply with quote
al666
Beginner


Joined: 20 Dec 2006
Posts: 13

PostPosted: Thu Dec 21, 2006 10:42 pm   
 
my muds where <target> command looks exactly like yours, it only doesn't have the "-" symbol before room name. basically:
its:


mob location

so yeah, i guess it is a fixed width. and thats it though, there's no standard output above the line with room name, just <mob> -blank space- <location>
Reply with quote
al666
Beginner


Joined: 20 Dec 2006
Posts: 13

PostPosted: Thu Dec 21, 2006 10:44 pm   
 
uhm, somehow forum doesn't let long blank space through ... anyway, i think its sufficent enough to say that the blank space between mobname and wherelocation looks exactly like yours (cept i don't have "-" symbol as i said before)
Reply with quote
Full Throttle
Wanderer


Joined: 07 Dec 2004
Posts: 65

PostPosted: Fri Dec 22, 2006 3:55 am   
 
to quote monospaced text, use BBCode "code" tag:
http://en.wikipedia.org/wiki/BBCode

---

if the first letter of the room name is on the 34th column then

#trigger {^&32 (*)} {#var where_target {%1}}

and if the room name is always capitalized then

#trigger {^&32 (*)} {#if ((%ascii(%left(%1,1)) >= 65) and (%ascii(%left(%1,1)) <= 90)) {#var where_target {%1}}}

and if the line with the room name is white then you could use an ansi color trigger

#trigger {^%e[37m&32 (*)%e} {#if ((%ascii(%left(%1,1)) >= 65) and (%ascii(%left(%1,1)) <= 90)) {#var where_target {%1}}}

note: check "ANSI Trigger" under trigger options in settings editor

---

About the lag - I have a very small map so I don't see any lag here.

I could change the alias to issue walks only if a room name is unique within the zone.

In other words--

if the map filter only finds 1 room then it would issue the walk

if the map filter finds more than 1 room, then it would do nothing

You wouldn't see any lag using the alias then. (or at least at lot less)

---

BTW, the %walk function does not output door commands with default settings.

You need to check "Map Preferences/Speedwalking/Add door commands to Saved Paths" to change default.
Reply with quote
al666
Beginner


Joined: 20 Dec 2006
Posts: 13

PostPosted: Fri Dec 22, 2006 2:07 pm   
 
hmm, it doesn't seem to work with the one you suggested now tho, so i'm trying to paste here the exact where mobname output with monospaced text:

Code:
a mob name                  room it is in


i don't think colour might mean anything so i didn't try with that one and it really depends on room name output wheather its capitalized or not, so its best to not use that trig tho, which only leaves that first one.

about lag, well, sometimes there's some, sometimes there's none at all, i think i'll just live with it, making exact match searches might end up being bad when i have several identical rooms etc, so i guess its the best to leave it as it is atm :)

basically, ideal would be a system where 'where mobname' would trigger either a straight walk to room (in case its really an unique room and it doesn't find any other matches) or it'd trigger walkzone search based on room name where gives and then give me the matches. thats at least how i picture it.
Reply with quote
al666
Beginner


Joined: 20 Dec 2006
Posts: 13

PostPosted: Fri Dec 22, 2006 3:25 pm   
 
and one other thing ... seems that when during a walkthrough i'd get agro'd by some mob, the script becomes somewhat screwed. meaning, it'll give the walkzone info again while i'm at the room where i stopped because of the mob but the info i need isn't accurate anymore. any way to fix that? it might be hard to understand so let me clarify a bit:

1) i go to an area and make where mobname to get the loc
2) then i do walkzone partofroomname to get matches
3) then i run to one of them with walkzone again

what happends is that an agro mob stops me on my way and the rest of given sw 'runs through' while i need to deal with the mob. my guess is thats what screws the script when i try to load possible matches based on room again, ie for script i'm just cpl rooms from the loc i need but in reality i'm not and script doesn't seem to realize that.
Reply with quote
Full Throttle
Wanderer


Joined: 07 Dec 2004
Posts: 65

PostPosted: Fri Dec 22, 2006 6:04 pm   
 
try

Code:
#trigger {^&25   (*)} {#var where_target {%1}}


---

"script becomes somewhat screwed"

if you are saying that the current room in the mud is not the same as the current position on the map, then you could reset the map position with the #teleport command

Code:
#alias reset {#call %mapfilter(%concat("Name"," = ","'",%replace(@room_target,"'","''"),"'"," AND ","ZoneID"," = ",%zonenum))
#if (%numrooms = 1) {#teleport %roomvnum(1)}
#if (%numrooms > 1) {#show {}
#show {Error: reset position}}
#call %mapfilter(%null)}


if the room_target variable (current room) is unique within the zone then the map position would reset

if not unique, then states error and you could manually reset position

---

you could also reset the zone if you store the zone name in zone_target variable

Code:
#if !(%zonename = @zone_target) {
#loop %numzones {#if (%zonename(%zonevnum(%i)) = @zone_target) {
#teleport %item(%mapquery(%concat("ZoneID"," = ",%zonevnum(%i))),1)}}}


add that to the beginning of reset alias if want

---

you could change the walkzone alias to check if the current room in the mud is the same as the current position on the map

Code:
#alias walkzone {#if (@room_target = %roomname) {#if %isnumber(%1) {#if (%1 = 0) {#show {}
#loopdb @walk_db_room {#show {%ansi(8)Filter: %ansi(15)%format("&5.0f",%val) %ansi(8)Virtual: %ansi(15)%format("&5.0f",%key) %ansi(8)Path: %ansi(15)%replace(%db(@walk_db_path,%key),".","")}}} {
#loopdb @walk_db_room {#if (%val = %1) {#walk %key}}}} {
#if (%1 = %null) {#var walk_search @where_target} {#var walk_search {%-1}}
#call %mapfilter(%concat("Name"," LIKE ","'%",%replace(@walk_search,"'","''"),"%'"," AND ","ZoneID"," = ",%zonenum))
#var walk_db_room %null
#var walk_db_path %null
#loop %numrooms {#addkey walk_db_room %roomvnum(%i) %i}
#loop %numrooms {#addkey walk_db_path %roomvnum(%i) %walk(%roomvnum(%i))}
#if (%numkeys(@walk_db_room) = 1) {#loopdb @walk_db_room {#if (%val = 1) {#walk %key}}}
#if (%numkeys(@walk_db_room) > 1) {#show {}
#loopdb @walk_db_room {#show {%ansi(8)Filter: %ansi(15)%format("&5.0f",%val) %ansi(8)Virtual: %ansi(15)%format("&5.0f",%key) %ansi(8)Zone: %ansi(15)%zonename(%roomzone(%key)) %ansi(8)Room: %ansi(15)%roomname(%key) %ansi(8)%char(91)%numitems(%pathexpand(%db(@walk_db_path,%key)))%char(93)}}}
#if (@walk_db_path = %null) {#var walk_db_path 0}
#if (@walk_db_room = %null) {#var walk_db_room 0}
#call %mapfilter(%null)}} {#show {}
#show {Error: reset position}}}


if not equal, then states error and you run the reset alias above

i'll leave it to you to store the current room/zone into the variables (if it is even possible in your mud)
Reply with quote
al666
Beginner


Joined: 20 Dec 2006
Posts: 13

PostPosted: Fri Dec 22, 2006 9:37 pm   
 
i don't know .. i made pasted down the reset alias you gave me but that doesn't seem to reset the loc i'm currently at, meaning the map has ran already where i need to be but actually i'm not there.
tried with the new walkzone alias you gave me tho but it only gave me

Error: reset position

when i tried to issue a walkthrough. i have no idea what i should do to make map recognize that i'm not in the loc i need yet and how to make it run the last part which was interrupted because of agro mob.
thought about something with stopping path with #pause but i don't think it would help any, though

and automate walkzone triggering via where still doesn't work, not with 25 as well.
Reply with quote
Full Throttle
Wanderer


Joined: 07 Dec 2004
Posts: 65

PostPosted: Sat Dec 23, 2006 2:24 am   
 
what is your mud ip and port?

i'll login and write triggers to storage the where_variable, room_variable, and zone_variable if possible
Reply with quote
al666
Beginner


Joined: 20 Dec 2006
Posts: 13

PostPosted: Sat Dec 23, 2006 3:06 am   
 
its 66.162.28.88, port is 4010
Reply with quote
Full Throttle
Wanderer


Joined: 07 Dec 2004
Posts: 65

PostPosted: Sat Dec 23, 2006 5:26 am   
 
I logged into Aardwolf and created the triggers.

delete all the above scripts and import the following

Code:
#class {Walking_Map}
#var room_target {0} {0}
#var where_target {0} {0}
#var walk_search {0} {0}
#var walk_db_room {0} {0}
#var walk_db_path {0} {0}
#noop
#alias walkzone {#if %isnumber(%1) {#if (%1 = 0) {#show {}
#loopdb @walk_db_room {#show {%ansi(8)Filter: %ansi(15)%format("&5.0f",%val) %ansi(8)Virtual: %ansi(15)%format("&5.0f",%key) %ansi(8)Path: %ansi(15)%replace(%db(@walk_db_path,%key),".","")}}} {
#loopdb @walk_db_room {#if (%val = %1) {#walk %key}}}} {
#if (%1 = %null) {#var walk_search @where_target} {#var walk_search {%-1}}
#call %mapfilter(%concat("Name"," LIKE ","'%",%replace(@walk_search,"'","''"),"%'"," AND ","ZoneID"," = ",%zonenum))
#var walk_db_room %null
#var walk_db_path %null
#loop %numrooms {#addkey walk_db_room %roomvnum(%i) %i}
#loop %numrooms {#addkey walk_db_path %roomvnum(%i) %walk(%roomvnum(%i))}
#if (%numkeys(@walk_db_room) = 1) {#loopdb @walk_db_room {#if (%val = 1) {#walk %key}}}
#if (%numkeys(@walk_db_room) > 1) {#show {}
#loopdb @walk_db_room {#show {%ansi(8)Filter: %ansi(15)%format("&5.0f",%val) %ansi(8)Virtual: %ansi(15)%format("&5.0f",%key) %ansi(8)Zone: %ansi(15)%zonename(%roomzone(%key)) %ansi(8)Room: %ansi(15)%roomname(%key) %ansi(8)%char(91)%numitems(%pathexpand(%db(@walk_db_path,%key)))%char(93)}}}
#if (@walk_db_path = %null) {#var walk_db_path 0}
#if (@walk_db_room = %null) {#var walk_db_room 0}
#call %mapfilter(%null)}}
#noop
#alias reset {#show {}
#show {%ansi(8)Virtual: %ansi(15)%format("&5.0f",%roomvnum) %ansi(8)Zone: %ansi(15)%zonename(%roomzone(%roomvnum)) %ansi(8)Room: %ansi(15)%roomname(%roomvnum)}
#call %mapfilter(%concat("Name"," = ","'",%replace(@room_target,"'","''"),"'"," AND ","ZoneID"," = ",%zonenum))
#if (%numrooms = 1) {#teleport %roomvnum(1)
#show {%ansi(8)Virtual: %ansi(15)%format("&5.0f",%roomvnum) %ansi(8)Zone: %ansi(15)%zonename(%roomzone(%roomvnum)) %ansi(8)Room: %ansi(15)%roomname(%roomvnum)}}
#if (%numrooms > 1) {#show {}
#show {Error: reset position}}
#call %mapfilter(%null)}
#noop
#trigger {^You are in: (*) ~[*~].} {#var room_target {%1}}
#trigger {^[A-z]&26  (*)} {#var where_target {%1}}
#class 0


type 'where <mob>' then 'walkzone'

if you get caught by an aggressive mob then check to see if the current room is the same as the current position on the map

if it is the same then type 'walkzone' again (think that will work)

if it is not the same then type 'room' (aardwolf command) then 'reset' then 'walkzone'
Reply with quote
al666
Beginner


Joined: 20 Dec 2006
Posts: 13

PostPosted: Sat Dec 23, 2006 1:30 pm   
 
ok, tried the new script you gave now. where mob, then type walkzone etc works all perfectly fine atm, resetting correct room in an area where you'd get agroed doesn't seem to work though. i checked first if the map shows the same room i got stranded to because of the attack and no, map itself had run all the sw i told it to walk and it didn't stop or anyway when i got gunned down. then i tried room-reset-walkzone but it only gave me the correct room name (the room thats my destination) together with error msg:

Virtual: 4407 Zone: area Room: room

then Error: reset position

i figured myself that the room i got stranded to isn't an unique name, its one of many of the same sorts and maybe thats what screwing everything up ?
thats the only reason i can think of right now...
Reply with quote
al666
Beginner


Joined: 20 Dec 2006
Posts: 13

PostPosted: Sat Dec 23, 2006 3:47 pm   
 
oh and another quick thing i'd like to ask.
is there any way to fix a exact start loc for areas which have maze like things before entrance? meaning, for usual areas, i use #teleport to fix the start of area, but i can't really figure out how to do it with areas that have some sort of random exits maze before entrance. i tried to fix entrance room as teleport loc tho, but then the mapwalk will screw up, only thing i can do atm is to set the teleport loc manually once i'm past the maze and in entrance room, that way it seems to work properly. was just wondering if there's any way around that, setting in manually each time is pretty annoying.
Reply with quote
al666
Beginner


Joined: 20 Dec 2006
Posts: 13

PostPosted: Thu Dec 28, 2006 3:04 pm   
 
not sure if you're checking the thread anymore but =p
one more thing. having a really weird things happening with cpl maps when i try to issue a walk from one room to another. first off it doesn't run correctly from one room to another and when i do room-reset and try walk again, it doesn't go to correct place in most cases as well, it just gives in a bunch of wrong coordinates (directions) and thats it. if i run to all those rooms from start of area, meaning i won't run from one room to another etc, it all works well, but when i try to run from one room to another within area, it goes loco.
doubtful map is faulty because in that case it shouldn't be able to walk into room from start of area to begin with. any idea what might cause it ?

oh and merry xmas, although late wishes!
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