| View previous topic :: View next topic |
| Author |
Message |
gfbaer
Joined: 08 Oct 2007 Posts: 33
|
Posted: Wed Jun 11, 2008 3:55 pm Post subject: shortest #path |
|
|
Hello!
I think I might be able to swing this one on my own, but at the moment I'm stuck I was hoping to get a tip or two in the right direction..
I want to keep a #path of where I walk from a given starting point, but I don't want to record the path if I am backtracking..
IE: I walk :
n n w w e e n u
I don't want to record the (w w e e) part so that I can give my group mates shortest directions which in this case would be n n n u (it would be even better if i could just tell them 3nu but thats another question I suppose)
Here is the code i have so far, it works fine so long as I don't walk down a hallway with more than one direction of the same type. like the example above, it will only backtrack one room.
| Code: |
#ALIAS tpath {
#IF {$auto_path == 1} {
#VAR auto_path 0;
#path end;
#ECHO {%c%h} {{red} { PATHING OFF }}
} {
#VAR auto_path 1;
#VAR lastpath q;
#ECHO {%c%h} {{green} { PATHING ON }};
#PATH new;#PATH end;
#UNVAR result
}
}
#FUNCTION dopath {
#IF {$auto_path == 1} {
#IF {"$lastpath" == "n" && "%1" == "s"} {#path del;#var result s;#var lastpath s} {
#IF {"%1" == "s"} {#var lastpath s;#path ins s;#var result s}};
#IF {"$lastpath" == "e" && "%1" == "w"} {#path del;#var result w;#var lastpath w} {
#IF {"%1" == "w"} {#var lastpath w;#path ins w;#var result w}};
#IF {"$lastpath" == "s" && "%1" == "n"} {#path del;#var result n;#var lastpath n} {
#IF {"%1" == "n"} {#var lastpath n;#path ins n;#var result n}};
#IF {"$lastpath" == "w" && "%1" == "e"} {#path del;#var result e;#var lastpath e} {
#IF {"%1" == "e"} {#var lastpath e;#path ins e;#var result e}};
#IF {"$lastpath" == "d" && "%1" == "u"} {#path del;#var result u;#var lastpath u} {
#IF {"%1" == "u"} {#var lastpath u;#path ins u;#var result u}};
#IF {"$lastpath" == "u" && "%1" == "d"} {#path del;#var result d;#var lastpath d} {
#IF {"%1" == "d"} {#var lastpath d;#path ins d;#var result d}};
} {
#var result %1
}
}
#ACT {Alas, you cannot go that way. . . .} {#IF {$auto_path == 1} {#VAR lastpath q;#path del}}
|
Thanks for any help about this! |
|
| Back to top |
|
 |
Scandum Site Admin
Joined: 03 Dec 2004 Posts: 3274
|
Posted: Wed Jun 11, 2008 4:17 pm Post subject: |
|
|
The automapper would come in useful here, if you paste the following commands it should record and display the shortest path:
#map create
#map goto 1
#map name start
n;n;w;w;e;e;n;u
#map name end
#map goto start
#map find end
#path map
I've added a #path compress option to the todo list to create a speedwalk. |
|
| Back to top |
|
 |
gfbaer
Joined: 08 Oct 2007 Posts: 33
|
Posted: Wed Jun 11, 2008 4:39 pm Post subject: |
|
|
Ok that works great! Big ups for the help!
I don't suppose there is an easy way to convert that path into a speedwalkable variable is there? I'm thinking I'll have to save the path, then #system some awk-fu to conver the :
#ALIAS {mypath} {n;e;s;s;e;u;u;w}
TO
#VAR {mypath} {ne2se2uw}
... Maybe something else for a future release? You're awesome man thanks for the help again.
-G
(alks on torilmud.org 9999) |
|
| Back to top |
|
 |
Scandum Site Admin
Joined: 03 Dec 2004 Posts: 3274
|
Posted: Wed Jun 11, 2008 5:01 pm Post subject: |
|
|
I'm planning to add the following:
#path new
#PATH: YOU ARE NOW MAPPING A PATH.
n;n;n;e;s;w;u;d
#path compress
#OK. #PATH COMPRESS: {3neswud} {duwse3n}
#path map
#PATH: 3neswud |
|
| Back to top |
|
 |
|