|
mo24 Wanderer
Joined: 31 Jan 2006 Posts: 55
|
Posted: Mon Feb 20, 2006 4:44 pm
Replace question |
Hello I have a difficult question I am having trouble with.
I used %walk(room) to get the path to a room using all nearest portal. These portals are in my aliases, which determine if I am high enough level to use them, and they are also designated on the mapper. zMud sends the commands like normal (n;w;s;s;e) to get to the room, and the path is shown in the %walk function like .nwsse
My mud uses a faster speedwalker with less lag built in, which is: "run nw2se". I would like to put what %walk(room) returns into "run" format. This was simple, to replace the period with 'run', but I also want it to work with my aliases and portals. Example, in this path that %walk returns, my alias is 'gar' which is a portal which transports me to a hub with closeby areas and then does the speedwalk. At the end, it does 'enter hole' to get into the area itself.
.(gar)s2wn4w;.(enter hole)
gar can be any alias with a portal in it that mapper decides will be quickest to get there. This I could handle by command like:
%word( %word( %walk( 8920), 1, %char( 41)), 2, %char( 40))
Which takes the word in first parentheses out. But my problem is, after that, I don't know where the next words in parentheses will be, or if there will be more than one. For example, it could be any of these:
.(gar)d2s;.(enter mandala)
.(gar)u2n7;.(enter tv);.(enter ferengi)3n4w
I need a way to 'catch all' of the things in parentheses automatically, without knowing where they will be, and replacing them, I would want to turn the above example into:
gar (alias)
run u2n7
enter tv
enter ferengi
run 3n4w
But also use the same script to turn the mandala one into:
gar
run d2s
enter mandala
I hope this made sense. I would much appreciate any help, I have tried many combinations but having troubule getting it perfect. |
|
|
|
Vitae Enchanter
Joined: 17 Jun 2005 Posts: 673 Location: New York
|
Posted: Tue Feb 21, 2006 2:41 pm |
That's part of what I had explained to you in my email.
The portals in the map.
Set the portals on there and it will pick the portals as part of the shortest walk route.
Like how I told ya about my lotus portal. |
|
|
|
JQuilici Adept
Joined: 21 Sep 2005 Posts: 250 Location: Austin, TX
|
Posted: Tue Feb 21, 2006 5:21 pm |
Fortunately, there is a function that does exactly what you need: %pathexpand.
Type the following into the command-line:
Code: |
#show %pathexpand(.(gar)u2n;.(enter tv);.(enter ferengi)3n4w) |
and you will get:
Code: |
gar|u|n|n|enter tv|enter ferengi|n|n|n|w|w|w|w |
Then you can manipulate the string list to your heart's content. For instance, I think the following will do what you're looking for:
Code: |
#CLASS {RunPathClass} {setdef}
#VAR Runnable "n|s|e|w|u|d|N|S|E|W|U|D"
#AL runp {
#VAR rpTempPath {}
#FORALL %pathexpand(%-1) {
#IF ((%len(%i)=1) & %ismember(%i,@Runnable)) {
#VAR rpTempPath %additem(%i,@rpTempPath)
} {
#IF (%numitems(@rpTempPath)>0) {run %delete(%pathcompress(@rpTempPath),1,1)}
rpTempPath={}
%i
}
}
#IF (%numitems(@rpTempPath)>0) {run %delete(%pathcompress(@rpTempPath),1,1)}
}
#CLASS 0 |
Sample run:
Code: |
> runp {.(gar)5w3u2e;.(enter airlock);.(push button)nws3d}
gar
run 5w3u2e
enter airlock
push button
run nws3d |
|
|
_________________ Come visit Mozart Mud...and tell an imm that Aerith sent you! |
|
|
|
JQuilici Adept
Joined: 21 Sep 2005 Posts: 250 Location: Austin, TX
|
Posted: Tue Feb 21, 2006 5:28 pm |
jquilici wrote: |
Type the following into the command-line:
Code: |
#show %pathexpand(.(gar)u2n;.(enter tv);.(enter ferengi)3n4w) |
and you will get:
Code: |
gar|u|n|n|enter tv|enter ferengi|n|n|n|w|w|w|w |
|
Correction to my earlier post. With 7.21, I actually get:
Code: |
gar|u|n|n|.(enter tv)|enter ferengi|n|n|n|w|w|w|w |
This strikes me as a bug - the 'enter tv' should have the dot-and-parens stripped. Regardless, my script given in the previous post works well enough in spite of this behavior. Comments? |
|
_________________ Come visit Mozart Mud...and tell an imm that Aerith sent you! |
|
|
|
Vitae Enchanter
Joined: 17 Jun 2005 Posts: 673 Location: New York
|
Posted: Wed Feb 22, 2006 3:14 am |
Comment: Actually 2 bugs:
runp .3n;aard;.9u
run 3n
aard
u
u
u
u
u
u
u
u
u
runp .3n6p;.aard
3n6p
aard
for this one, the run isn't issued because the p is not in the runnable var, but any commands after it are still issued. |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Wed Feb 22, 2006 10:48 am |
Use %subchr to clean up anything %pathexpand missed.
#FORALL %subchr(%pathexpand(%-1),".;)(","") { |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
JQuilici Adept
Joined: 21 Sep 2005 Posts: 250 Location: Austin, TX
|
Posted: Wed Feb 22, 2006 2:46 pm |
Vitae wrote: |
Comment: Actually 2 bugs:
runp .3n;aard;.9u
run 3n
aard
u
u
u
u
u
u
u
u
u |
Of course. You've issued three separate commands, separated by semicolons: 'runp .3n', '.aard', and '.9u'. The results are just what you'd expect. On the other hand, if you group the whole path into the argument to 'runp', it does what you want (and even aggregates commands that aren't aggregated in the input):
Code: |
> runp {.3n;.(aard);.9u}
run 3n
aard
run 9u
> #var foo {.4n2u;.(open door)eesd};runp @foo
run 4n2u
open door
run 2esd |
Which is correct behavior.
Vitae wrote: |
runp .3n6p;.aard
3n6p
aard
for this one, the run isn't issued because the p is not in the runnable var, but any commands after it are still issued. |
I'm not sure this is a bug. If 'p' is a direction command that 'run' can accept, then you should add it to the variable 'Runnable', as you say. You'd also have to have added it as a direction for the mapper, or #path would have captured that as '.3n;.(p);.(p);.(p);.(p);.(p);.(p);.(aard)' rather than aggregating. Also, note that you've issued two commands on that line again.
Vigilante wrote: |
Use %subchr to clean up anything %pathexpand missed.
#FORALL %subchr(%pathexpand(%-1),".;)(","") { |
True, but it could potentially strip out characters you didn't mean to strip. For example, the command '.(open 2.door)' would become 'open 2door'. However, I think it's unnecessary to do the stripping in this application, since issuing the command 'foo' and '.(foo)' are equivalent under most circumstances. I was just noting that there is some inconsistency in the way that %pathexpand operates. |
|
_________________ Come visit Mozart Mud...and tell an imm that Aerith sent you!
Last edited by JQuilici on Wed Feb 22, 2006 2:49 pm; edited 1 time in total |
|
|
|
Vitae Enchanter
Joined: 17 Jun 2005 Posts: 673 Location: New York
|
Posted: Wed Feb 22, 2006 2:48 pm |
Vijilante,
Did you mean like this?
Code: |
#CLASS {RunPathClass} {setdef}
#VAR Runnable "n|s|e|w|u|d|N|S|E|W|U|D"
#AL runp {
#VAR rpTempPath {}
#FORALL %subchr(%pathexpand(%-1),".;)(","") {
#IF ((%len(%i)=1) & %ismember(%i,@Runnable)) {
#VAR rpTempPath %additem(%i,@rpTempPath)
} {
#IF (%numitems(@rpTempPath)>0) {run %delete(%pathcompress(@rpTempPath),1,1)}
rpTempPath={}
%i
}
}
#IF (%numitems(@rpTempPath)>0) {run %delete(%pathcompress(@rpTempPath),1,1)}
}
#CLASS 0 |
Result:
runp .3n;aard;.9u
%subchr(%pathexpand(.3n),".;)(","")
aard
u
u
u
u
u
u
u
u
u |
|
|
|
JQuilici Adept
Joined: 21 Sep 2005 Posts: 250 Location: Austin, TX
|
Posted: Wed Feb 22, 2006 3:01 pm |
It's just a typo. Use %subchar in place of %subchr and it should work (if you put the whole path inside curly braces - see my previous post).
|
|
_________________ Come visit Mozart Mud...and tell an imm that Aerith sent you! |
|
|
|
Vitae Enchanter
Joined: 17 Jun 2005 Posts: 673 Location: New York
|
Posted: Wed Feb 22, 2006 3:57 pm |
ah, sorry, hadn't noticed the whole put curly braces around it part :-)
|
|
|
|
Vitae Enchanter
Joined: 17 Jun 2005 Posts: 673 Location: New York
|
Posted: Wed Feb 22, 2006 7:09 pm |
Hrmm... ran into 2 issues.
1) runp {.d3sws;.(open south;s)wd;.3wn}
run d3sws
open south
open south
s
run wd
w
w
w
n
Seems to break. I'm thinking it's something to do with auto opening of doors on the map.
2) My position on the map is not even moving under the runs. Like something as simple as:
runp {.d3sws}
will not move me on the map. but if i copy and paste the output on the screen, run d3sws, and i move right along.
from the end of the above:
runp {.(open south;s)wd}
will move me the one s on the map after the open south and again stop. The actual commands ARE shown on my screen, but the actual map moves dont seem to happen.
I stress MAP moving because I DO move on the mud.
I have a run alias that moves me on the map with the run command, but I don't think that's a part of the issue.
~run %1
#FORALL %pathexpand( "%1") {#MOVE %i}
(On second thought maybe the extra pathexpand might be the issue....)
Edit:
Made a slight change:
Code: |
#VAR rpTempPath {}
#FORALL %pathexpand( %-1) {
#IF ((%len( %i)=1) & %ismember( %i, @Runnable)) {#VAR rpTempPath %additem( %i, @rpTempPath)} {
#IF (%numitems( @rpTempPath)>0) {run %delete( %pathcompress( @rpTempPath), 1, 1)}
#VAR rpTempPath {}
%i
}
#MOVE %i
}
#IF (%numitems( @rpTempPath)>0) {run %delete( %pathcompress( @rpTempPath), 1, 1)} |
And the map moving works now. But the breaking after the opening doors still is an issue.
runp {.d3sws;.(open south;s)wd;.3wn}
The #MOVE %i was needed to move myself on the map. Some how it was bypassing it on the alias. Dunno why.
But I decided to combine part of my speedwalk alias with yours. And I kinda got it to work.
Code: |
#VAR rpTempPath {}
#VARIABLE path %walk( %1)
#VARIABLE path {~{@path~}}
#FORALL %pathexpand( @path) {
#IF ((%len( %i)=1) & %ismember( %i, @Runnable)) {#VAR rpTempPath %additem( %i, @rpTempPath)} {
#IF (%numitems( @rpTempPath)>0) {run %delete( %pathcompress( @rpTempPath), 1, 1)}
#VAR rpTempPath {}
%i
}
#move %i
}
#IF (%numitems( @rpTempPath)>0) {run %delete( %pathcompress( @rpTempPath), 1, 1)} |
I type runtest 11668 and it will speedwalk me to the room.
But this time along with the breaking mentioned in #1 it seems to issue a second down at the very end.
The actual speed walk to 11668 is: run d3sws;open south;s;run wd3wn2w2swnws3e2n2es4ese2sd3s;open down;d
What's getting issued is:
run d3sws
open south
open south
s
run wd
w
w
w
n
ETC ETC
s
s
open down
d
open down
d
I don't know why that is happening.
I did a small test and went to run 2d3sws;open south;s;run wd (runtest 5441) using my version, then from THERE did runtest 11668 and there was NO double down! What the heck?
BTW: the path variable is correct
#VAR path {{{.d3sws;.(open south;s)wd;.3wn2w2swnws3e2n2es4ese2sd3s;.(open down;d)}}} {} "RunPathClass"
So i'm at a loss to figure out why there are 2 downs at the end of the LONGER speedwalk, but no problem when it's broken up.
BTW#2: the reason I decided to merge a little of mine and all of yours is that my version at times will have an extra run in there that is blank
sw 11668
run d3sws;open south;s;run wd;run 3wn2w2swnws3e2n2es4ese2sd3s;open down;d;run
The extra run only appears at times and can be in the middle of the whole thing. Since it's blank and I don't even move anywhere it's not really an issue for me, just something that annoys me when ever i see "Run where?" |
|
|
|
JQuilici Adept
Joined: 21 Sep 2005 Posts: 250 Location: Austin, TX
|
Posted: Wed Feb 22, 2006 8:40 pm |
Hrm...let's see if we can get to the bottom of this.
- First, the reason that you're getting double-door-opens, etc. may be that your mapper is automatically issuing door-open commands along with directions AND your paths already contain a door-open command. So you get it twice. Once for the copy in your path, and again when the 's' is sent. FYI, You can configure the mapper to NOT include door commands in paths by unchecking the "Add door commands to saved paths" option under Speedwalking in the mapper config dialog.
Alternatively, if you've put in 'open door s;s' as the Other Command for that exit, you'll get the same doubling effect.
- There is definitely some weirdness here with the use of Other Commands for exits. For example, consider the sample map from the Speedwalking Tutorial
Speedwalking Tutorial wrote: |
If you are in room D and double-click on room G, you will see the commands "south", "open east", "east", "enter" sent to the MUD. Notice that the Door Script is sent, and that the custom direction command from room F to room G is sent. |
With a default mapper config, if you type '.sen' when in room D, you'll get the same commands - the mapper inserts the special commands. Now the fun begins. After issuing the commands above, the path-behind shows as '.s;.(open east)e;.(enter)n', which is wrong - the final 'n' should not be there.
It gets worse. Check out the following (using the same map, where room 4 is D):
input:
Code: |
#tel 4
#SAY Run 1
.sen
#tel 4
#say Run 2
#show %pathexpand(.sen)
#say Run 3
#show %exec(.sen) |
output:
Code: |
Run 1
s
open east
e
enter
Exits: e, n
>
Exits: s, w
>
Run 2
s|e|n
Run 3
s|e|n
|
Note that Run 1 has the right commands, but neither %pathexpand nor %exec (?!?) generates the same list. Sigh.
Your #MOVE commands bypass all of the speedwalking confirmations used by the Slow-Walk and Safe-Walk modes - it just assumes that you completed all the moves and sends the blue spot to the end of the run. On my MUD, the run command can abort if your char is attacked en route, and can fail outright if the number of moves is greater than your constitution. I have not found a satisfactory solution to this problem yet (though I've been experimenting with #queue) - any ideas would be appreciated.
The empty run commands stump me ATM. It should only be issuing runs when rpTempPath is non-empty. Try stripping out the %delete calls in those two lines (which should just be removing the leading '.') and see what's coming out of the %pathcompress call.
|
|
_________________ Come visit Mozart Mud...and tell an imm that Aerith sent you! |
|
|
|
Vitae Enchanter
Joined: 17 Jun 2005 Posts: 673 Location: New York
|
Posted: Thu Feb 23, 2006 1:13 am |
as i said, the empty runs are with the speedwalk that *I* use.
The reason I merged mine and yours was to get RID of those empties.
My only question is this.
Why in yours does it issue a double open d;d when there is none in the path.
And why does it NOT issue a double open when I do the speed walk in 2 (or more parts)
YOUR version works fine as is.
MY version which takes the roomid converts it into a variable called path, then adds {} around that path variable.
the problem is with MY version not yours. (other than the breaking of the speeds as i'd pointed out before):
run d3sws
open south
open south
s
run wd
w
w
w
n
ETC ETC
Code: |
#CLASS {RunPathClass}
#ALIAS runtest {
#VARIABLE rpTempPath {}
#VARIABLE path %walk( %1)
#VARIABLE path {~{@path~}}
#FORALL %pathexpand( @path) {
#MOVE %i
#IF ((%len( %i)=1) & %ismember( %i, @Runnable)) {#VARIABLE rpTempPath %additem( %i, @rpTempPath)} {
#IF (%numitems( @rpTempPath)>0) {run %delete( %pathcompress( @rpTempPath), 1, 1)}
#VARIABLE rpTempPath {}
%i
}
}
#IF (%numitems( @rpTempPath)>0) {run %delete( %pathcompress( @rpTempPath), 1, 1)}
}
#ALIAS runp {
#VARIABLE rpTempPath {}
#FORALL %pathexpand( %-1) {
#IF ((%len( %i)=1) & %ismember( %i, @Runnable)) {#VARIABLE rpTempPath %additem( %i, @rpTempPath)} {
#IF (%numitems( @rpTempPath)>0) {run %delete( %pathcompress( @rpTempPath), 1, 1)}
#VARIABLE rpTempPath {}
%i
}
#MOVE %i
}
#IF (%numitems( @rpTempPath)>0) {run %delete( %pathcompress( @rpTempPath), 1, 1)}
}
#VARIABLE Runnable {n|s|e|w|u|d|N|S|E|W|U|D} {n|s|e|w|u|d|N|S|E|W|U|D}
#VARIABLE rpTempPath {}
#VARIABLE path {{.d3sws;.(open south;s)wd;.3wn2w2swnws3e2n2es4ese2sd3s;.(open down;d)}} {}
#CLASS 0
|
Note: Incase I haven't stressed it. BOTH your code and my modified one has the "break" that I keep mentioning as well as the double open d;d
Please try it yourself and see. I know I may not be bright, but if I've run your code unmodified 50 times and each and everytime it breaks and issues a double then i know i am not nuts.
I think it might be a matter of the lenght of it, but I dont know. |
|
|
|
JQuilici Adept
Joined: 21 Sep 2005 Posts: 250 Location: Austin, TX
|
Posted: Thu Feb 23, 2006 2:54 pm |
Ah...I can see that I need to read more closely. You did say the empty runs were in your version.
Without having a copy of your map DB, I can't directly test the cases you're talking about, but let's see how close I can get.
First, I don't know WHY it's true, but I can say that the doubled 'open door' in your first example and the fact that it doesn't aggregate the last set of directions is related to what appears to be buggy behavior in %pathexpand. Look at the following three runs, all with the same logical path, but written differently:
Code: |
> runp {.d3sws;.(open south;s)wd;.3wn}
open south
s
run wd
w
w
w
n
> runp {.d3sws;.(open south;s)wd3wn}
run d3sws
open south
s
run wd3wn
> runp {.d3sws;.(open south)swd3wn}
run d3sws
open south
run swd3wn |
Note that the last form does what you really want. The reason it behaves this way is that %pathexpand doesn't expand the other forms into a simple set of commands:
Code: |
> #show %pathexpand(.d3sws;.(open south;s)wd;.3wn)
d|s|s|s|w|s|.(open south;s)|w|d|.3wn
> #show %pathexpand(.d3sws;.(open south;s)wd3wn)
d|s|s|s|w|s|.(open south;s)|w|d|w|w|w|n
> #show %pathexpand(.d3sws;.(open south)swd3wn)
d|s|s|s|w|s|.(open south)|s|w|d|w|w|w|n |
Interestingly, using %exec in place of %pathexpand DOES give the right expansion, no matter which form is used (at least in SAFE-walk mode, where I'm testing). Here's the comparison with your run to 11668:
Code: |
> #show %pathexpand(.d3sws;.(open south;s)wd;.3wn2w2swnws3e2n2es4ese2sd3s;.(open down;d))
d|s|s|s|w|s|.(open south;s)|w|d|.3wn2w2swnws3e2n2es4ese2sd3s|open down;d
> #show %exec(.d3sws;.(open south;s)wd;.3wn2w2swnws3e2n2es4ese2sd3s;.(open down;d))
d|s|s|s|w|s|open south|s|w|d|w|w|w|n|w|w|s|s|w|n|w|s|e|e|e|n|n|e|e|s|e|e|e|e|s|e|s|s|d|s|s|s|open down|d |
So...let's make a runp2 that uses %exec to expand:
Code: |
#CLASS {RunPathClass}
#ALIAS runtest {
#VARIABLE rpTempPath {}
#VARIABLE path %walk( %1)
#VARIABLE path {~{@path~}}
#FORALL %pathexpand( @path) {
#MOVE %i
#IF ((%len( %i)=1) & %ismember( %i, @Runnable)) {#VARIABLE rpTempPath %additem( %i, @rpTempPath)} {
#IF (%numitems( @rpTempPath)>0) {run %delete( %pathcompress( @rpTempPath), 1, 1)}
#VARIABLE rpTempPath {}
%i
}
}
#IF (%numitems( @rpTempPath)>0) {run %delete( %pathcompress( @rpTempPath), 1, 1)}
}
#ALIAS runp2 {
#VARIABLE rpTempPath {}
#FORALL %exec( %-1) {
#IF ((%len( %i)=1) & %ismember( %i, @Runnable)) {#VARIABLE rpTempPath %additem( %i, @rpTempPath)} {
#IF (%numitems( @rpTempPath)>0) {run %delete( %pathcompress( @rpTempPath), 1, 1)}
#VARIABLE rpTempPath {}
%i
}
#MOVE %i
}
#IF (%numitems( @rpTempPath)>0) {run %delete( %pathcompress( @rpTempPath), 1, 1)}
}
#ALIAS runp {
#VARIABLE rpTempPath {}
#FORALL %pathexpand( %-1) {
#IF ((%len( %i)=1) & %ismember( %i, @Runnable)) {#VARIABLE rpTempPath %additem( %i, @rpTempPath)} {
#IF (%numitems( @rpTempPath)>0) {run %delete( %pathcompress( @rpTempPath), 1, 1)}
#VARIABLE rpTempPath {}
%i
}
#MOVE %i
}
#IF (%numitems( @rpTempPath)>0) {run %delete( %pathcompress( @rpTempPath), 1, 1)}
}
#VARIABLE Runnable {n|s|e|w|u|d|N|S|E|W|U|D} {n|s|e|w|u|d|N|S|E|W|U|D}
#VARIABLE rpTempPath {}
#VARIABLE path {{.d3sws;.(open south;s)wd;.3wn2w2swnws3e2n2es4ese2sd3s;.(open down;d)}} {}
#CLASS 0 |
My runs (again, without your map, in a blank config):
Code: |
> runp @path
run d3sws
open south
s
run wd
w
w
w
n
w
w
s
s
w
n
w
s
e
e
e
n
n
e
e
s
e
e
e
e
s
e
s
s
d
s
s
s
open down
d
d
> runp2 @path
run d3sws
open south
run swd3wn2w2swnws3e2n2es4ese2sd3s
open down
run d |
I think that does it. I note that I'm getting a double-'d' at the end of 'runp @path' (still don't know why). You see a double-open as well probably because your mapper inserts the door-open command automatically on the final 'd'. |
|
_________________ Come visit Mozart Mud...and tell an imm that Aerith sent you! |
|
|
|
Vitae Enchanter
Joined: 17 Jun 2005 Posts: 673 Location: New York
|
Posted: Thu Feb 23, 2006 5:51 pm |
SLAMMING!
Worked perfectly!!
Actually, I dont get the double open at all.
I don't get ANY of the doubles either. weird.
Funny thing thos is that the rpTempPath var is left with one d in it after my example sw. Not that it matters in the least cause it clears out again on a rerun.
Thanks so much for this. It's a small thing, but the fact that there were extra runs in my script bugged the hell outta me. |
|
|
|
|
|
|
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
|
|