|
adamandkate Wanderer
Joined: 14 Oct 2009 Posts: 57
|
Posted: Sun Nov 29, 2009 11:43 am
Is there a better way to do this %mapquery |
I have a trigger that when i try to find my current location, it takes the room name, querys the map. And teleports my current location to that point.
#var locating {}
#var room2find {}
#var found_rooms {}
#var numberrooms {}
room2find = %replace( %1, ', %)
foundrooms = %mapquery( %concat( "Name LIKE '%", @room2find, "%'"))
currentroom = %item( @foundrooms , 1)
#wait 500
#teleport %item( @foundrooms, 1)
Now in the latest cmud its a LOT LOT LOT faster. (it ROCKS, thanks zugg!) But it does still lagg, so wondered if there was a better way of doing this.
thanks
edit - i know the #wait is bad. i will change that to a waitfor or something |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Sun Nov 29, 2009 6:32 pm |
Use %mapfilter() to cut down on the number of rooms that it searches. The lag is probably happening due to having to search the entire map.
You'll want two calls, like so:
#call %mapfilter(the stuff that limits the query)
...
#call %mapfilter("") |
|
_________________ EDIT: I didn't like my old signature |
|
|
|
adamandkate Wanderer
Joined: 14 Oct 2009 Posts: 57
|
Posted: Wed Dec 02, 2009 12:14 am |
thanks for that. works a lot better!
|
|
|
|
adamandkate Wanderer
Joined: 14 Oct 2009 Posts: 57
|
Posted: Fri Dec 11, 2009 12:01 am |
actually, i know im being stupid.. but is it simply...
#call %mapfilter(ZoneID = 56)
#call %mapfilter("")
i feel like im missing some quotes. but cant work out how to put em
thanks again |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Fri Dec 11, 2009 1:56 pm |
Yes, %mapfilter() requires quotes around the SQL string, just like %mapquery(). So, %mapfilter("ZoneID = 56") would work. If you need to evaluate some variables or functions in the SQL string, you can either do it outside the function:
Code: |
$myfilter = %concat("ZoneID = ",%zonenum())
#call %mapfilter($myfilter)
|
or do it all in one line:
Code: |
#CALL %mapfilter(%concat("ZoneID = ",%zonenum()))
|
|
|
|
|
gamma_ray Magician
Joined: 17 Apr 2005 Posts: 496
|
Posted: Fri Dec 11, 2009 7:54 pm |
I'm missing something--what are you doing that isn't done by #find?
|
|
|
|
|
|