|
Llohr Apprentice
Joined: 17 May 2005 Posts: 108
|
Posted: Mon Feb 24, 2014 4:49 am
Finding the length of a speedwalk |
So I'd like to figure out how I can either A) find the length of a speedwalk by name, or B) find the value of a speedwalk by name, so I can use %pathexpand on it to get the length. I was hoping %pathexpand would suit my purposes, but apparently it only works on the actual value of a speedwalk, not on the name, and I've no idea how to automatically extract that information.
Now, I could, instead of using speedwalks, set up my recording to use a string list, and then, when I have to retrace my steps, reverse the list and substitute opposites for each direction, but there must be a better way than that. I hope.
Is there? |
|
|
|
Scarn Apprentice
Joined: 24 Jul 2005 Posts: 137
|
Posted: Mon Feb 24, 2014 10:10 am |
Just to clarify, do you wish to expand the value of a PATH or expand the directions on your map (EG. from a room #WALK to another room).
|
|
|
|
Scarn Apprentice
Joined: 24 Jul 2005 Posts: 137
|
Posted: Mon Feb 24, 2014 10:13 am |
Paste me an example of the speedwalk you want to return the length of?
|
|
|
|
Llohr Apprentice
Joined: 17 May 2005 Posts: 108
|
Posted: Mon Feb 24, 2014 11:29 am |
Well, it's not a specific speedwalk I'm trying to get the length of, exactly. I have a script that creates speedwalks on the fly for reasons I won't go into right now, but it always uses the same name, thus copying over the previous iteration.
The name of the speedwalk is always "Scan", and it ranges from a single step to 4 steps in one direction. Outside of a script, I can easily get the length of a speedwalk with %numitems(%pathexpand(some path)), assuming I paste the value of a speedwalk in there.
The issue is finding the length of said speedwalk in a script, in which case it has to be by name, unless you know of a method to return the value of a speedwalk short of executing it. As of right now I've worked around it by setting a trigger on "(%a) assigned to <pathname>", which records the value of %1 to a variable, so that I can use the aforementioned method of getting the length by referencing that variable. This will work, I just thought there would be a way to skip that intermediary step, given that the %pathexpand function exists, and is not a tenth as useful as it might be if it won't accept the name of a path as input.
If you still want an example, here is one:
Of course, anybody could look at it and know it's 3 steps long, but I want to know how to make cMud look at it and know the same thing, without having to copy and paste or record the value redundantly. |
|
Last edited by Llohr on Tue Feb 25, 2014 5:37 am; edited 1 time in total |
|
|
|
Scarn Apprentice
Joined: 24 Jul 2005 Posts: 137
|
Posted: Mon Feb 24, 2014 11:47 am |
I don't personally use #PATH as its intended, I just use speedwalks in aliases and #WALK on my map, therefore unable to help sorry. :(
|
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Mon Feb 24, 2014 10:05 pm |
Don't think you can do this with native zscript actually, but perhaps you could use COM to access the path info?
|
|
_________________ EDIT: I didn't like my old signature |
|
|
|
Scarn Apprentice
Joined: 24 Jul 2005 Posts: 137
|
Posted: Mon Feb 24, 2014 10:33 pm |
Matt, whilst on the subject for COM. Is there a way to use it to save what is left of a speedwalk queue.
Example:
I speedwalk "#SLOW .20n"
however at 10 rooms north I #PAUSE and then from there run around the map a bit (if say I got attacked during PvP).
Therefore I would want to save what is left of the speedwalk, in this case 10n, to a variable.
I can then go back to that room and #SLOW .variable
I hope that made sense.
EDIT: The reason for the above is that if I leave the room I've paused in and go elsewhere on the map, when I return the path is lost and #STEP will not work to continue it (%lastdir/%nextdir are also empty). |
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Mon Feb 24, 2014 11:08 pm |
You can do it with COM, if you have CMUDPro:
Code: |
%session.GetPath("name", "class").value |
You can also do it with Lua:
Code: |
zs.getpath("name").value |
I glanced through the COM functions and didn't see anything to get the contents of the mapper queue. Pretty sure that's come up before and we haven't been able to find a way. |
|
|
|
Llohr Apprentice
Joined: 17 May 2005 Posts: 108
|
Posted: Tue Feb 25, 2014 5:28 am |
For what it's worth, if you're in the middle of a slow walk, typing #path without an argument gives you a complete list of your speedwalks,
and at the very end, shows "path ahead:" and "path behind." Path ahead contains what's left of the speedwalk.
Take note, it's not perfectly accurate, if you were to type "#slow .20n", and immediately type #path, you'll get a path ahead of 20n, and
a path behind of n, however, if you've #paused before entering #path, it should update the path ahead.
I imagine with some conditional gagging you could turn this into a usable function. |
|
|
|
Scarn Apprentice
Joined: 24 Jul 2005 Posts: 137
|
Posted: Tue Feb 25, 2014 7:11 am |
If instead of using #PAUSE you use {#OK;#PAUSE} that makes you always pause in the correct room on the map.
|
|
|
|
hadar Apprentice
Joined: 30 Aug 2009 Posts: 198 Location: my apt, in california
|
Posted: Tue Feb 25, 2014 7:46 pm |
you could do
scan
Code: |
$path=whatever
$steps=%replace(%numitems(%pathexpand($path)),"|","") steps
#path scan $path
|
or something like that |
|
|
|
|
|