|
Balarik Newbie
Joined: 07 Jul 2007 Posts: 9
|
Posted: Sun Mar 21, 2010 9:36 am
Map database requests with %mapquery |
What i'm trying to do is query the map database to compare a saved room description to the room i'm currently in.
This is to make the mapper auto-find which room i've been kicked to after entering a room with mobs that randomly
kick you off the road.
I've used
Code: |
#SHOW @B_CurrentRoom" <> "%mapquery(%concat("Zoneid=",%zonenum," AND Desc='",%roomdesc,"'")) |
which is almost a copy/paste from the help file, and it outputs this:
2429 <> 2429
It works fine of course, except when the room desc contains funny symbols like ^ or / or # etc.
Then it doesnt find anything and naturally only outputs 2429 <>
The minimap in the room descriptions contains those symbols
Example:
\^^v^vvvb
m\^v^vvvm
mm+^*vvvm
m^|v^vvvv
^m|vvv^^^
In this case the roof symbols are mountains, the \ is road and so on.
What i'm wondering is how to make the %mapquery function look for the description regardless of what the description is.
I'm also wondering how to find the list of exits from a particular room from the map database.
Another problem i've had is that the mapper can't save a description where the first line if the description paragraph begins
with a special symbol, like # for example. I've forced it to capture it by just making triggers like
Code: |
#TRIGGER {^~#*} {#TAG descpara} |
.
It doesn't work very well either cos mostly it will just capture that line alone. The mapper works perfectly in all other senses,
but it doesn't capture special chars when they're at the beginning of a line.
So the third thing i'm wondering is if there's a good way to capture these lines in a sensible manner.
I need a workaround for those special symbols. |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Mon Mar 22, 2010 4:31 pm |
For the first problem, try replacing %roomdesc with %quote(%roomdesc).
To list the exits from a room, use the %roomexit() function.
I'm not sure about the problem with autocapturing room descriptions starting with # or *. That could be a bug. As for making your #TAG trigger work better, have you checked whether your mud has a setting to turn off line wrapping? If it does, you can let Cmud do the linewrapping for you. This will make it a lot easier to capture long lines in other triggers too. |
|
|
|
Balarik Newbie
Joined: 07 Jul 2007 Posts: 9
|
Posted: Mon Mar 22, 2010 7:10 pm |
I tried the %quote() thingy now:
Code: |
#SHOW "name "@B_CurrentRoom" <> "%mapquery(%concat("Zoneid=",%zonenum," AND Name='",%quote(%roomname),"'"))
#SHOW "desc "@B_CurrentRoom" <> "%mapquery(%concat("Zoneid=",%zonenum," AND Desc='",%quote(%roomdesc),"'")) |
but it doesn't seem to help completely. It looks like the failures in the previous tries i made were just a coincidence.
The queries don't work when there is one or more of # ; @ % & anywhere in the name or description.
But it works with : / . ! ~ > and ` anywhere in the desc.
Those are all standard special chars i think? Also i switched the # to ยค and put a # into the desc, and the query worked.
So there's obviously some problem with these chars even though i'm quoting the line.
The odd thing is that i tried a few rooms that has only regular text in the name and description, but it still failed to return a room number.
A few examples here, and i'm using the query lines with %quote.
This one works.
cccc+cccc A stone covered road running from south to north.
cccc|cccc
.ccc*cccc
returns:
name 2769 <> 2769
desc 2769 <> 2769
Name doesn't work cos of the @.
cccc+@cccc A stone covered road running from south to north.
cccc|cccc
.ccc*cccc
returns:
name 2769 <>
desc 2769 <> 2769
Desc doesn't work cos of the #.
cccc+cccc A stone covered road running from south to north.
cccc|#cccc
.ccc*cccc
returns:
name 2769 <> 2769
desc 2769 <>
This one does not work, even though it's just normal text.
It is a rather small room where a table has been firmly attached to the wall
just left of the doorway. There are also two short logs aligned with the table
to sit on. To the right is the iron range which emits a cosy warmth drying the
newly washed clothes hanging above it. All the kitchen belongings are carefully
sorted on the shelves above the kitchen sink which is next to the range. At the
very back of the room is a heavy and rather narrow double bed with deep blue
bedding. There's a window on the northern wall between the bed and the table.
returns:
name 2769 <> 2769
desc 2769 <>
Oh and the room names are the first line in the room desc in each room.
They seem to work more often than the desc when i walk around and check random rooms.
I guess that's just cos it's only one line, less chance to have captured a bad char in there.
I really have no clue what is going on here. |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Mon Mar 22, 2010 8:42 pm |
Hm. I'm not sure offhand what the problem is. But I have a question about your logic. You are doing a %mapquery based on %zonenum and %roomdesc. But those functions will return the value based on the room that the map _thinks_ you are in. If the map did not actually know you moved, %roomdesc will still show the description of the room the map still thinks you are in. So, your search logic won't work for finding your new room. You need to somehow capture the current room description and do the search based on that instead.
Do you actually store the mini-map in your room descriptions? |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Mon Mar 22, 2010 9:22 pm |
He does, and he's probably of the mind to leave them in there instead of editing the entire map. It will be simpler if he removes the minimap, but I fully understand how tedious that can be (I did it 3 or 4 times myself because I thought of new things to add to/fix the map).
|
|
_________________ EDIT: I didn't like my old signature |
|
|
|
Balarik Newbie
Joined: 07 Jul 2007 Posts: 9
|
Posted: Mon Mar 22, 2010 11:14 pm |
This is just a test line, i wouldn't be using that exact one. I'm just trying to find some functions i can use to be able to get what i want.
So far i was thinking that i can "look" after i've been kicked, and match the desc that comes up to any room in the zone i'm in.
That would result in one room (or several if the exact same desc are in many rooms). I could check the exits from that or those rooms,
to see if any of them leads to the room i was in before the kick. I haven't thought this far ahead yet actually, becuase i don't even know
how to begin with identifying the room i've been kicked to. Normally i begin with something and then i go and find a solution.
Yes the mapper normally captures the whole description (except when there are special chars), and the minimap is part of it. So it is
automatically captured. Not all rooms in the mud has this minimap in the desc, but as it is now i've got about 3000 rooms with it.
I don't really feel like editing all those rooms And besides, i don't know if it would be able to match the desc i get when i type "look"
if it's not exactly the same as the one saved in the mapper. |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Tue Mar 23, 2010 5:13 am |
Not "look", "#LOOK". #LOOK replaces the old description with the new description. The trick is in making sure CMud recognizes the proper text so that it doesn't replace old junk with new junk. Since you want to exclude things from the line, this is where #TAG triggers would come into play.
We can help you with the trigger part, so all you need to do is provide the proper examples and whatever code you may have been using. |
|
_________________ EDIT: I didn't like my old signature |
|
|
|
Balarik Newbie
Joined: 07 Jul 2007 Posts: 9
|
Posted: Tue Mar 23, 2010 9:52 am |
Actually i mean "look" I meant to say that i send the "look" command to the mud to "look around in the room" and bring up the desc, exits and any mobs or players. Because that doesn't automatically show up when i get kicked out.
I have already saved to a var the ID of the room i was in before i go kicked, and i can then do something like this:
look -> identify new room with desc -> match rooms to the rooms adjacent to the original room -> determine the correct exit from the original room -> step map into the room i got kicked to
This way i can make the mapper follow to the room i got kicked to. It should always just be in follow mode.
I haven't yet written any code or made any triggers at all for this auto-relocate function, since i haven't even come up with a way to match the descriptions. That's why i'm just using the #show command to print it on the screen.
This is an example room:
It is the text i get from the mud when i give the command look.
Code: |
++tfffffr You are walking in a dark forest.
|fftffffr
|fff*?ffr
f\fffffrm
ff+-+ffrm
There are eight exits: north, northeast, southeast, south, southwest, west, northwest and east. |
For the mapper i only have #tags for the exits line, and the prompt
Code: |
There {are|is} %w exit{|s}~:*
#TAG exit |
I have no roof in the beginning because some rooms have a few spaces in the beginning of the exit line.
But both the prompt and exit tags works fine. The only things that don't work is when the mapper tries to create a room with a description like the one above. Since the first char on the first line is a +, it won't capture anything, and no room is created.
It will capture this room though, even if it contains wierd chars, because the first char on the first line is an f.
Code: |
ff/fffffr You are in a forest. The grass beneath your feet is
++tfffffr coated with frost.
|fft*fffr
|ffft?ffr
f\fffffrm
There are eight exits: north, northeast, east, south, southwest, west, northwest and southeast. |
It wouldn't ahve captured anything at all if there had been for example a # somewhere in the desc.
When i created these particular rooms i had triggers for those special chars, like #TRIGGER {^~+*} {#TAG descpara}
One for each special char. So it only captured the lines beginning with these chars into the room description of the latter room:
as room name and
Code: |
++tfffffr coated with frost. |
as room desc.
I've turned those triggers off though because i don't need them when i'm not mapping.
As for the script im trying to make for the auto-relocate. When i went to the first room in this post i typed
Code: |
#SHOW "name "@B_CurrentRoom" <> "%mapquery(%concat("Zoneid=",%zonenum," AND Name='",%quote(%roomname),"'"))
#SHOW "desc "@B_CurrentRoom" <> "%mapquery(%concat("Zoneid=",%zonenum," AND Desc='",%quote(%roomdesc),"'")) |
And it returned
name 2264 <> 2264
desc 2264 <> 2264
Even though the description for this room is full of special chars. As i explained in my previous post this %mapquery works with some of the special chars, but not with # @ etc.
I think the problem with the %mapquery is quite related to the fact that the mapper doesn't like those special chars. Cos as i run around on the map and enter those query lines it never works when there's a # @ or any of those "bad" special chars. And those bad special chars are only in the room description in the mapper because i forced them to be captured.
But also it sometimes doesn't work even though there is only normal text in the desc. Like the example in my previous post. |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Tue Mar 23, 2010 1:15 pm |
Okay, I think you've described the situation pretty well at this point. Let's see...
I guess you are only using %roomdesc right now for testing? Because you will have to do something else to capture the results of your "look" command for your actual application, as I said above.
For the #TAG descpara triggers, you could rewrite all those different triggers into a single trigger.
Quote: |
As for the script im trying to make for the auto-relocate. When i went to the first room in this post i typed
Code:
#SHOW "name "@B_CurrentRoom" <> "%mapquery(%concat("Zoneid=",%zonenum," AND Name='",%quote(%roomname),"'"))
#SHOW "desc "@B_CurrentRoom" <> "%mapquery(%concat("Zoneid=",%zonenum," AND Desc='",%quote(%roomdesc),"'"))
And it returned
name 2264 <> 2264
desc 2264 <> 2264
|
That looks like it succeeded. I bet that %quote will work unless there is an @ symbol in the description. There appears to be a problem when using %quote on a variable which contains that symbol. It apparently tries to interpret it as a variable name despite the %quote. I will report this in the beta forum, since it seems to work the same way in 3.14. Can you verify that the mapquery with %quote works for all other special characters except the @?
[edit]Ok, weird. I just tried it again, and can't recreate the problem I had with the @ symbol. Both the %quote and %mapquery with %quote are working for me now, after I've reinstalled 3.14 and 2.37 a couple times. I'm positive the @ was not being properly quoted last time, I tried a couple variations. And now, doing exactly the same lines, it's working fine. [shrug] |
|
|
|
Balarik Newbie
Joined: 07 Jul 2007 Posts: 9
|
Posted: Tue Mar 23, 2010 2:27 pm |
Yea i'm just using those two #show lines to see the output. At the moment i'm not really thinking about the rest of the script since it all depends on getting this to work. It really should be a piece of cake to whip up the rest once this coconut is smashed.
I've tested all the special characters in Options>General>Scripting>Special Characters, and the ones that don't work for me are # ; @ % &
The rest works fine. And they're all standard ones i presume, cos i've never changed them.
I just typed in those characters in turn into the description of the room i was currently in, and those 5 characters made the queries fail.
About the #tag triggers, i'd rather avoid using them actually, atleast the way they are now. They only make the mapper capture the lines that begin with those chars, nothing else. Like this:
Code: |
v^vvvbsss The mountains are almost reaching the sky.
v^vvvmbbs
^vvv*mmbs
v^vvvvmdd
vvv^^^^^d |
in that room only
would be captured to the room desc by the mapper. If i turn them off and reconfigure and try to cap it again all of it will be captured correctly, because the first char on the first line is a "v", and not an odd char like ^
So they're really not working either.
I also prefer to get a good config for the mapper and let it do the work.
I don't know how to make the mapper always capture anything that is shown where the desc is supposed to be (above the exits line) |
|
|
|
nexela Wizard
Joined: 15 Jan 2002 Posts: 1644 Location: USA
|
Posted: Wed Mar 24, 2010 5:49 am |
I didnt read to much past the first couple of posts so this the solution to that
Those are possibly special chars in sql for something so the easiest way to get past this would be to use double quotes instead of single quotes when building your query since you are looking for an exact match and don't need any of the fancy SQL shortcuts.
I created a room and teleported into it for testing
ROOMNAME: cccc+@cccc A stone covered road running from south to north.
ROOM DESc: cccc|#cccc
.ccc*cccc
#SHOW ROOM %mapquery(%concat("Zoneid='",%zonenum(),"' AND Name=",%char(34),%roomname,%char(34)))
#SHOW DESC %mapquery(%concat("Zoneid='",%zonenum(),"' AND DESC=",%char(34),%roomdesc,%char(34)))
ROOM 7437
DESC 7437
(Same triggers with the mapquery removed so you can see the query)
Zoneid='69' AND Name="cccc+@cccc A stone covered road running from south to north."
Zoneid='69' AND DESC="cccc|#cccc
.ccc*cccc" |
|
|
|
Balarik Newbie
Joined: 07 Jul 2007 Posts: 9
|
Posted: Wed Mar 24, 2010 9:33 am |
Yes my brother was talking about some SQL stuff too before i posted here, i didn't really listen.
Those lines didn't work for me, i had to change them to:
#SHOW ROOM %mapquery(%concat("Zoneid=",%zonenum," AND Name=",%char(34),%roomname,%char(34)))
#SHOW DESC %mapquery(%concat("Zoneid=",%zonenum," AND DESC=",%char(34),%roomdesc,%char(34)))
Almost the same. i'm gonna play around with it some more and see what more can be done. But atleast now it works in the rooms where it didn't work before.
Now the only thing i'm still wondering about is how to set up the mapper to capture room descriptions with these special chars correctly
But i think i'm gonna move that to a different thread since it doesn't have anything to do with the title.
Thanks everyone for the help! |
|
|
|
nexela Wizard
Joined: 15 Jan 2002 Posts: 1644 Location: USA
|
Posted: Thu Mar 25, 2010 5:44 am |
Yes please use a second thread for the map captures. Also to help us out walk between 4 rooms or so and paste the output between code tags. This will allow us to see exactly how everything is formatted and exactly what happens when you walk between rooms, resulting in fewer frustrations between poster and postee in narrowing it down.
|
|
|
|
|
|
|
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
|
|