|
Iceclaw Apprentice
Joined: 11 Sep 2005 Posts: 124
|
Posted: Sat Nov 03, 2007 1:19 am
Performing a %mapquery on other Fields in the ObjectTbl Table |
Is this possible for all fields in the table (Including Desc, etc)
I'm looking to do a query which returns all rooms of a given color in a specified zone? I can figure out how to do the %mapquery(Color=%romcol(,red)) bit, or the %mapquery(Zoneid=%zonenum()), but not a query which checks both.
Eventually i'd want to be able to preform the query on the Cost field in this query as well. |
|
|
|
Seb Wizard
Joined: 14 Aug 2004 Posts: 1269
|
Posted: Sat Nov 03, 2007 3:42 am |
Just but AND between each part of the query. (You can also use OR.)
e.g.
#show %mapquery(Zoneid=%zonenum() AND Name='The West Road')
#show %mapquery(Zoneid=%zonenum() OR Name='The West Road')
Combinations of both are also possible using parentheses for grouping. You can also use NOT:
#show %mapquery(Zoneid=%zonenum() AND NOT Name='The West Road')
It's basically the WHERE clause of an SQL query. |
|
|
|
Iceclaw Apprentice
Joined: 11 Sep 2005 Posts: 124
|
Posted: Sat Nov 03, 2007 4:29 am |
When I try "#sh %mapquery(Color=255 AND Zoneid=%zonenum()) I get no results.
If I run the querys seperated ie %mapquery(Color=255) or %mapquery(%zonenum()) It works, so I'm trying to figure out what my problem is. |
|
|
|
Seb Wizard
Joined: 14 Aug 2004 Posts: 1269
|
Posted: Sat Nov 03, 2007 3:49 pm |
Maybe there are no rooms with colour 255 in the current zone? I did test the examples I posted in zMUD (although retesting in CMUD, I realise I need to replace the single quotes with double quotes). Actually there do appear to be some parsing problems in CMUD.
Code: |
#show %mapquery(Zoneid=%zonenum() AND Name="The West Road")
Compiles to:
0000 STR 'Zoneid='
0016 FUNCREF zonenum (0)
0028 CONCAT
0032 STR 'ANDName="The West Road"'
0064 CONCAT
0068 FUNCREF mapquery (1)
0080 CMD show (1)
Notice there is no space between AND and Name.
#show %mapquery(Zoneid=%zonenum() {AND Name="The West Road"})
Does not compile, with error "unmatched parenthesis".
This one works:
#show %mapquery(Zoneid=%zonenum() "AND "Name="The West Road") |
The problem is that %mapquery currently removes whitespace (and that is also why the single quotes for the Name does not work. I'll post a separate bug report. |
|
|
|
Iceclaw Apprentice
Joined: 11 Sep 2005 Posts: 124
|
Posted: Sat Nov 03, 2007 6:19 pm |
Definately rooms with Color=255 in the current zone, I suspect it's due to the removal of the whitespace (this was done in [2.10])
|
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sat Nov 03, 2007 6:24 pm |
Zugg wrote: |
CMUD is just pickier about string values. Outside of quotes (or {}) spaces are stripped. Because %mapquery is still an old mapper function ported from zMUD, it isn't taking an "expression" as the argument, it's still just taking a string value. [src] |
What this means (I think) is that you need to build a string that'll then be sent to the %mapquery function, rather than have it do the concatenation itself. Something like
%mapquery(%concat("Color=",%roomcol(,red)," AND Zoneid=",%zonenum()))
should hopefully work. Remember, however, that a call %roomcol(,red) is going to set the colour of the room and then return the new colour. Might not be what you wanted. If you can verify that this method is working, I'll update the help files. |
|
|
|
Iceclaw Apprentice
Joined: 11 Sep 2005 Posts: 124
|
Posted: Sat Nov 03, 2007 6:56 pm |
The implicit concat does work for what it's sending and returning.
In my testing I found a problem with my method of implimentation though..
#sh %roomcol(,[AnyColorhere]) will return the color of the current room, rather then the color you give it. Is there another function I can use to get the html color for a given color name? :) |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sat Nov 03, 2007 7:07 pm |
What do you mean by "html colour"? %color returns a numeric value based on a name, but it might not be the value you're after. I'm not sure how the mapper numbers its colours. %roomcol with no arguments will return the colour of the current room, though, and you can probably use that.
|
|
|
|
|
|