|
MisterDwooD Novice
Joined: 04 Feb 2014 Posts: 42
|
Posted: Thu Feb 04, 2016 12:05 am
Map Room Evaluate Question |
I have a question to see if it's possibly using zMud.
I play a mud where I'm told that someone is in "blah" room, and I was wondering if there was a command to evaluate how many rooms away that room is from my current room.
Using the assumption that there is only 1 room with that name, and that all rooms as accessible.
So, It'd be like:
I'm in the room On a Hill.
Eagle tells me: George was spotted In a Riverbed.
I want to be able run a check and see if there is a room within 50 rooms of my current room.
Using either the roomname or roomnum.
Maybe something like. {%evaluate numrooms{travel, %roomvnum 2342, %roomvnum 1508)}
Anyways. Is that possible? If you want me to specify any further, please let me know!
Thanks! |
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Thu Feb 04, 2016 6:40 am |
You will also want to look at the help for %mapquery.
|
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
MisterDwooD Novice
Joined: 04 Feb 2014 Posts: 42
|
Posted: Sat Feb 06, 2016 4:05 am |
Thanks Guys!
So.. right now, I have a script:
#ALIAS room {#VAR searchforthis {%-1};#MAPQUERY {[Name] LIKE '%@searchforthis%'};#SAY {Searched For: @searchforthis}} "Scripts|Misc"
If I type "room Hills"
That will pull up the "find" window on the map and will locate all rooms with that name.
Is it possible to somehow only list rooms that are within X amount of rooms from me?
Like.. %forall (matched names) %numitems(%pathexpand(%pathfrom(from_vnum, to_vnum)))
show all rooms where %numitems<50 ?
I know that's probably some INSANE stuff.. But, just curious how people would go about doing it . And if anyone wants to try and help me do it. :)
Any variation of it would be nice.
The main reason is that there are lots of rooms with the same name, so I want to find any rooms close to me with that name once I get a report from the eagle.
Thanks! |
|
|
|
MisterDwooD Novice
Joined: 04 Feb 2014 Posts: 42
|
Posted: Sat Feb 06, 2016 8:50 am |
Thanks for responding man! Sorry it was in the other thread. My computer was blinding them altogether. But... This is what you gave me:
#ALIAS room {
#VAR searchforthis {%-1}
#SAY {Searched For: @searchforthis}
#FORALL %mapquery(%concat("[Name] LIKE '%", @searchforthis, "%'") {
#IF (%numitems(%pathexpand(%walk(%i))) < 50) {
#SAY {Room %i - %roomname(%i)}
}
}
} "Scripts|Misc"
In red is what i'm having an issue with. I am using zMUD. so if that's written for cMUD, that might be the issue. This is what it looks like in zmud: (I added the "1s" so as to not overwrite my other script.)
#ALIAS room1 {
#VAR searchforthis1 {%-1}
#SAY {Searched For: @searchforthis1}
#FORALL %mapquery(%concat("[Name] LIKE '%", @searchforthis, "%'") {
#IF (%numitems(%pathexpand(%walk(%i))) < 50) {
#SAY {Room %i - %roomname(%i)}
}
}} "Scripts|Misc"
It doesn't like the bracket after the #forall statement. I tried not having it, or changing things, and I can't get it to shape up. Can you look into why it's not having it?
Thanks! |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Sat Feb 06, 2016 12:46 pm |
There is a missing ) before that {.
|
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
MisterDwooD Novice
Joined: 04 Feb 2014 Posts: 42
|
Posted: Sat Feb 06, 2016 6:31 pm |
Thanks!
That definitely fixed it.. However, In trying to adapt it to what I need, I'm "surprisingly" running into difficulties. :)
That script is outputting the closest rooms within my parameter and giving me a vnum for them and their name, which is great. However, I'm not able to search for that on the map In a quick manner.
With that vnum, I tried doing something like:
#MAPQUERY {[Num] LIKE '%@searchedforroomnum%'}
But the SQL doesn't like Num, or Number, or VNUM.
I'd like to be able to find on my map really quick where that room is, since in this mud there's like 100k rooms, quite a few have the same name, I'd like to find the one closest to me with that name.
But I can't seem to get it to search the vnum. I could do it for the zone I'm in, but if I'm 1 room from the border, it'll never pick up the room just 1 room away.
Is there anyway to:
Hear from Eagle
Search RoomName within X amount of rooms.
Have that roomname searched on my map.
Be able to searchmap for that 1 room found
Possibly walk to that room if it's a saferoom for me
Right now, the problem that I'm having is that when it reports all rooms within X rooms of me. It just shoots em out as a Say Command, but I still have no idea where they are. Or, even if it's just 1. I have to copy the vnum and then go into the map and do a manual search. Which, I was trying to avoid the manual search. Narrowing it down does help TEMENDOUSLY though! Thanks!
I thought I could adapt it with what you provided into looking for just that 1 closest room on the map. But so far, I haven't been able to.
Thanks again for your help. And if it's not possible, just let me know. |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Sat Feb 06, 2016 7:34 pm |
Code: |
#ALIAS room {
#VAR searchforthis {%-1}
#SAY {Searched For: @searchforthis}
#VAR bestfound {51}
#FORALL %mapquery(%concat("[Name] LIKE '%", @searchforthis, "%'") {
searchforthis=%walk(%i)
foundthis=%numitems(%pathexpand(@searchforthis)
#IF (@foundthis) < %item(@bestfound,1)) {
bestfound=%concat(@foundthis,"|",%i,"|",@searchforthis)
}
}
foundthis=%item(@bestfound,2)
#SAY {Room @foundthis - %item(@bestfound,1) : %roomname(@foundthis) }
#PATHHIGH %item(@bestfound,3)
} "Scripts|Misc" |
|
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
MisterDwooD Novice
Joined: 04 Feb 2014 Posts: 42
|
Posted: Sat Feb 06, 2016 8:26 pm |
Holy cow man.. That found looks so "sexy"! I'll have to play around to understand it so I can know which variables to change, but hot dang! Looks good.
I'll let you know when I find things I don't understand... after I've tested it for a while. :)
Seriously, cool dude! |
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Sat Feb 06, 2016 10:33 pm |
Fixed up Viji's code a little (one of the missing parentheses was mine from earlier, sorry about that).
Code: |
#ALIAS room {
#VAR searchforthis {%-1}
#SAY {Searched For: @searchforthis}
#VAR bestfound {51}
#FORALL %mapquery(%concat("[Name] LIKE '%", @searchforthis, "%'")) {
searchforthis=%walk(%i)
foundthis=%numitems(%pathexpand(@searchforthis))
#IF (@foundthis < %item(@bestfound,1)) {
bestfound=%concat(@foundthis,"|",%i,"|",@searchforthis)
}
}
foundthis=%item(@bestfound,2)
#SAY {Room @foundthis - %item(@bestfound,1) : %roomname(@foundthis) }
#PATHHIGH %item(@bestfound,3)
} "Scripts|Misc" |
|
|
|
|
MisterDwooD Novice
Joined: 04 Feb 2014 Posts: 42
|
Posted: Sat Feb 06, 2016 11:09 pm |
Well, unfortunately, when putting that in zMUD, it has several syntax errors and I'm not able to do much with it. :( So far, I have this:
#alias room2 {
#VAR searchforthis {%-1}
#SAY {Searched For: @searchforthis}
#VAR bestfound {51}
#FORALL %mapquery(%concat("[Name] LIKE '%", @searchforthis, "%'")) {
searchforthis=%walk(%i)
foundthis=%numitems(%pathexpand(@searchforthis) syntax error
#IF (@foundthis) < %item(@bestfound,1)) {
bestfound=%concat(@foundthis,"|",%i,"|",@searchforthis)
}
}
foundthis=%item(@bestfound,2)
#SAY {Room @foundthis - %item( @bestfound, 1) : %roomname( @foundthis)}
#PATHHIGH %item( @bestfound, 3)
} "Scripts|Misc"
I wasn't able to get it put in so it worked ever.. Everything looks fine except for all the stuff in the FORALL command.. which is pretty intense. I get an error where it says syntax error, and on the "<". I can sorta see what it's going to do but I couldn't get it to work.
Maybe I just don't know how to put it into zMUD. But I tried 2 ways. First, just copy past the whole thing in the command line. Second, Created a new alias, and dumped everything between the brackets into the Value Box. Neither worked.
Thanks for your help! |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Sun Feb 07, 2016 1:38 am |
Thanks Daern. I always hated typing these things out on the forum off the top of my head. Those mismatched parenthesis are always such an easy mistake to make.
|
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
MisterDwooD Novice
Joined: 04 Feb 2014 Posts: 42
|
Posted: Sun Feb 07, 2016 2:09 am |
I must have not seen your response from before. Let me try that out again and I'll report back! :)
Thanks |
|
|
|
MisterDwooD Novice
Joined: 04 Feb 2014 Posts: 42
|
Posted: Sat Feb 13, 2016 2:41 am |
So that was pretty slick. It works well most the time. I haven't narrowed down what causes it to find a room very far away from me sometimes.
However, I did find something interesting that maybe you can help with.
Right now, if you run the script, this is the output:
Input:
room A Dark Column
Output:
Searched For: a dark column
Room 25 - 25 : Path Near the Plains
What it's doing is searching for "A Dark Column". It is finding that that room is 25 rooms from my current room. But then instead of showing me the room name again, it's showing me the roomname of the room that is number 25 in my database, which is a completely different room that's like 15 zones away. It still finds the right room on my map, and tells me the right (x) number of rooms away the room is, but it's showing me the roomname of the room that is number (x) in my database.
Anyway we can fix this besides just taking out that "#say"?
Right now I'm using the code:
Code: |
#ALIAS room {
#VAR searchforthis {%-1}
#SAY {Searched For: @searchforthis}
#VAR bestfound {51}
#FORALL %mapquery(%concat("[Name] LIKE '%", @searchforthis, "%'")) {
searchforthis=%walk(%i)
foundthis=%numitems(%pathexpand(@searchforthis))
#IF (@foundthis < %item(@bestfound,1)) {
bestfound=%concat(@foundthis,"|",%i,"|",@searchforthis)
}
}
foundthis=%item(@bestfound,2)
#SAY {Room @foundthis - %item(@bestfound,1) : %roomname(@foundthis) }
#PATHHIGH %item(@bestfound,3)
} "Scripts|Misc" |
Thanks! |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
MisterDwooD Novice
Joined: 04 Feb 2014 Posts: 42
|
Posted: Sat Feb 13, 2016 10:46 pm |
Unfortunately, I have no idea how to implement the fix you suggested. I don't see how that would fix it or where you're applying it that it would fix it.
Also, how is it choosing "Best found"? is it that it's the closest one to my current location on the map?
Thanks! |
|
|
|
MisterDwooD Novice
Joined: 04 Feb 2014 Posts: 42
|
Posted: Sat Feb 13, 2016 11:00 pm |
Hmm..
I think I figured it out. I put it in as:
#SAY {Found room: ~"%roomname( %item( @bestfound, 2))~" ~(%item( @bestfound, 2)~) and it's ~"@foundthis~" rooms away.}
I'm definitely learning as I do this, so thank you! |
|
|
|
|
|