|
mrkelley Beginner
Joined: 15 Aug 2006 Posts: 14
|
Posted: Sat Mar 07, 2009 5:05 am
Help with flee and mapper, please! |
i have my mapper working wonderfully now, but here's my problem:
Code: |
You panic, and attempt to flee.
The Dining Room
[Exits: n e] |
when i flee, this is the message i get. the %roomname variable sets fine when i flee,
however my mapper doesn't move my position. as you can see the mud doesn't tell
me which direction i flee, so i can't simple use a #MOVE trigger.
any ideas? |
|
|
|
Leitia Adept
Joined: 04 May 2007 Posts: 292 Location: Boston
|
Posted: Sun Mar 08, 2009 12:56 am |
can you set a variable of what room you are in, then when you flee get the path between those, then delete the period from the path string?
|
|
|
|
Progonoi Magician
Joined: 28 Jan 2007 Posts: 430
|
Posted: Sun Mar 08, 2009 1:53 am |
So you want the mapper to re-locate you correctly after you've fled?
I'd say the best way to work this out is to use a trigger with conditions.
First one would be the fleeing line which would have value part empty.
Second would capture room name with within lines=1 option and then loop the map DB to see if there's a room with that name.
When there is one, it would #teleport roomname or get the roomvnum based on the name and use that for teleport (I can't really
recall if #teleport worked with just roomname). If it works right off the bat like that then the script would set the trigger #state
back to the first trigger line (flee one), if it doesn't it would work with second condition which grabs exits and formats them to a
string list. Then it would compare the exits and the room name until there's a match. Usually very few MUDs are stupid enough to
have several matching room names AND matching exits. If that might be the case, then one would have to look for rooms that are
around the one you're currently in and that would need more scripting intervention than just a simple trigger.
I hope I gave some food for thought. If needed I could try to dig up my old 'find me' scripts at some later date if you'd think they'd
be helpful. |
|
_________________ The Proud new owner of CMud.
--------------------------------
Intel Core i5-650 3,2GHz
4 DD3 RAM
GTX 460 768MB
Win 7 Home Premium 64x
-------------------------------- |
|
|
|
mrkelley Beginner
Joined: 15 Aug 2006 Posts: 14
|
Posted: Sun Mar 08, 2009 3:58 pm |
that makes complete sense, Progonoi.
the only problem is i don't know how to do what you're saying.
I understand conditional triggers. but "loop the mapper"?
can you give me a generic code example? |
|
|
|
Progonoi Magician
Joined: 28 Jan 2007 Posts: 430
|
Posted: Sun Mar 08, 2009 7:45 pm |
Okay, yeah.
I don't have much time right now, but.
What I meant with 'mapper DB' was that your map file is basically a big database which you can query.
With %mapquery function.
So, given that the output you've given above always stays the same, in broad strokes something like this should work.
NOTE: I haven't tested nor syntax-checked the code below. You shouldn't take it 'as is'. Go over and copy-paste it piece by piece.
I've pieced-mealed it together, using your output and old map walker script I had lying around from way back when.
Code: |
#var RoomName {}
#var RawMudExits {}
#var SortedMudExits {}
#var Room_To_Find {}
#trigger "FleeLoc" {You panic, and attempt to flee.} {}
#cond {(*)} {RoomName=%1} {within|param=1}
#cond {~[Exits: (*)~]} {RawMudExits=%subchar(%subchar(%1," ","|"),"()][{}","");
#forall @RawMudExits {#additem SortedMudExits {%left( %i, 1)}}
SortedMudExits=%sort( @SortedMudExits)
#if (!%null(@RoomName)) {Room_To_Find=%mapquery( %concat( "Name LIKE '", @RoomName, "'"))}
#if (%numitems( @Room_To_Find)=1) {#te @Room_To_Find;#state FleeLoc 0} {#forall @room_to_find {#if (%sort( %roomexit( %i))=@sorted_mudexits) {#additem exact_matches {%i}}}}
#if (%numitems( @exact_matches)=1) {
#te @exact_matches
#state FleeLoc 0
} {within|param=1}
|
In a nutshell, you capture the room name and exits which you format to a string list and sort (because exits order of a room in Map DB isn't how you see them 'in real time'). Once exits line is also processed, the major bit of the script kicks in. First it checks if there's a room with that name in DB. If there is and it's an unique room, it teleports the map location there and you're done. If its one or more, it does the same type of test, only now it checks both room name AND exits. Usually it's when exact match comes up.
Feel free to ask more questions and I try to answer, but the above should give enough food for thought for now. |
|
_________________ The Proud new owner of CMud.
--------------------------------
Intel Core i5-650 3,2GHz
4 DD3 RAM
GTX 460 768MB
Win 7 Home Premium 64x
-------------------------------- |
|
|
|
mrkelley Beginner
Joined: 15 Aug 2006 Posts: 14
|
Posted: Sun Mar 08, 2009 8:53 pm |
been playing around with this, can't make it work.
i should mention two things:
i'm using cmud (posted this in the wrong forum).
and #te to a room name doesn't work. |
|
|
|
Progonoi Magician
Joined: 28 Jan 2007 Posts: 430
|
Posted: Sun Mar 08, 2009 9:53 pm |
What exactly isn't working? Remember I suggested going through the code piece by piece and learn what each part is doing.
There may very well be syntax errors if you'd just copy-paste it all into cmd line. As I said, I haven't tested nor really checked the code.
As I used the same script successfully in CMud too, only with very minor changes, I don't know what to tell you. This code is essentially
the same in CMud. Only difference is that my original version had room name trigger and exits trigger separately.
You may want to try the same thing and see how it works out. |
|
_________________ The Proud new owner of CMud.
--------------------------------
Intel Core i5-650 3,2GHz
4 DD3 RAM
GTX 460 768MB
Win 7 Home Premium 64x
-------------------------------- |
|
|
|
|
|