Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Lennya
Newbie


Joined: 19 Oct 2012
Posts: 7

PostPosted: Fri Oct 19, 2012 8:19 pm   

Long search times in cMUD mapper Find Room command
 
Hi,

I only recently upgraded from zMUD into cMUD. Converting my zmap.mdb into a cmap.dbm went fine, its size shrunk to 25%, and it loads a lot quicker now.

However, if I try to find a room through the Find Room option, it makes the game stall for about 5-10 seconds where in zMUD the result was more or less immediate. Is there something I can do to fix this?

Also, when the spreadsheet view window of the mapper is opened, and I then speed walk from one zone to another, the game tends to stall occasionally as well. Any help there?

Cheers,
Lennya
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Fri Oct 19, 2012 10:22 pm   
 
1)I had other things in the mapper to search for, so I just built my own findroom functionality. In a map with 30,000+ rooms, there's no lag at all. Might be a case of a feature designed for an older functionality (ie, ADO) that wasn't updated when the format switch was made. ADO was super-slow.

2)close the spreadsheet view, always, when you are not busy working in that window. It's definitely not designed to be something you leave open.
_________________
EDIT: I didn't like my old signature
Reply with quote
rozdwojeniejazni
Wanderer


Joined: 13 Aug 2011
Posts: 74

PostPosted: Sun Oct 21, 2012 8:46 pm   
 
MattLofton wrote:
Might be a case of a feature designed for an older functionality (ie, ADO) that wasn't updated when the format switch was made.


I didn't understand a word in this sentence. Are you saying there is a way to omit this long searching time or not?
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Oct 22, 2012 4:00 am   
 
Yeah, don't use the built-in Find Room feature and write a function/alias that does the same thing.
_________________
EDIT: I didn't like my old signature
Reply with quote
Lennya
Newbie


Joined: 19 Oct 2012
Posts: 7

PostPosted: Wed Oct 24, 2012 9:41 pm   
 
Could you point me in the right direction of how to make a findroom function?
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Wed Oct 24, 2012 10:57 pm   
 
First, time to describe the SELECT command in SQL. When you want to return results from an SQL-type database (ADO, MYSQL, SQLite, etc), you always use SELECT. The basic syntax is SELECT fields FROM table WHERE conditions:

fields -- this defines what fields are returned if any results are found. Use * to return all the fields defined for records, or use (field1,field2,fieldN) to return only specific columns.

table -- this is the name of the table to look for results. It can be a real table (use the table name), or it can be a predefined view. A view is just like the (field1,field2,fieldN) syntax, except that you refer to it by name in the form of [viewname]

conditions -- these are the logical comparisons used to determine what results to return. Each condition is in the form of column_name operator value (ie, Cost>7). You can include multiple conditions by using the logical operators AND, OR, XOR, and NOT (ie, Cost>7 and Level=10). You can even include multiple groups of these logical comparisons using parentheses--ie, Cost>7 and (Level > 10 and Level < 20). In addition, you can use the LIKE operator and % as a positional wildcard (ie, Name like '%Hall%' will return results of all records where the word hall appears in the Name field).

There's a whole heck of a lot more stuff to the SELECT statement, but this can get you through almost anything you want to query a database for so we'll stop here.

Next, in the case of the Findroom functionality, the core of the code is going to be the %mapquery() command. This command sets up the SELECT command for you, so all you need to do is specify the conditions for the WHERE part. As a function, you'll want to assign the return results to a variable so you can look at them in later code.

$results = %mapquery("Name like "~""%"%-1"%"~")

I know that looks confusing, so we'll take it apart piece by piece. First, all of the literal text is surrounded in "". What this does is prevent CMud from ever trying to parse this text. In the example, the literal text is colored blue. Next, many times MUDs will use single quotes in the place of double quotes when they want to quote something. This is by design, since in SQL the single and double quotes work interchangeably. What is important to know is that you cannot include the same type of quote character inside a set of that same quote character type (ie, ''' is a syntax error). Thus, by adopting the use of one quote character type we can generally be assured that the other type is safely useable. I colored the quote characters needed by SQL in blue. Finally, the whole point of the function is to send the info the user was looking to search for, which is what the %-1 is for. %-1 specifically refers to everything you sent to the alias or function you're building here and I colored that green.

%mapquery() returns a list of vnums. Numbers aren't very useful or intuitive by themselves, so now we need to lay out the data in human-readable form. How you do this is very much going to be up to you, but #PRINT is a good way to show it since you probably don't want anything accidentally triggering on your output here. %format() will help you with the positioning, and #FORALL or #LOOP will help you to step through each item in the list. You would then use the appropriate %room function to get the specific piece of data you wanted to get.

The below is an example of a very simple findroom alias that only works on room name:
Code:
#alias findroom {
  $results = %mapquery("Name like "~""%"%-1"%"~")
  #forall $results {
    #print %format("&5.0f - &s",%i,%roomname(%i))
  }
  #print %format("&0.0f room names found that  contain '&s'",%numitems($results),%-1)
}
_________________
EDIT: I didn't like my old signature
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Wed Oct 24, 2012 11:33 pm   
 
Here is what I use.

Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <alias name="MapFind" copy="yes">
    <value><![CDATA[#if (%-1 != %null) {
  $room = %lower(%-1)
  $str = %concat("[Name] LIKE '%", $room, "%'")
  $locations = %mapquery($str)
  #call %roommode(1)
  #print ""
  #mxp {<color brown><hr></color>}
  $msg = "<strong><color khaki>VNum" + %repeat(" ",4) + "Destinations" + %repeat(" ",31) + "Zones</color></strong>"
  #print $msg
  #mxp {<color brown><hr></color>}
  #forall $locations {
    $roomNum = %roomnum(%i)
    $roomName = %roomname(%i)
    $roomZone = %zonename(%roomzone(%i))
    $msg = "<color white>[<color gold>" +
      %repeat(" ", 5-(%len($roomNum))) +
      $roomNum + "</color>]</color><color silver> " +
      $roomName%repeat(" ", 40-(%len($roomName))) +
      "</color><color lime>   " + $roomZone + "</color>"
    #print $msg
    }
  #mxp {<color brown><hr></color>}
  #call %roommode(0)
  } {
  #print "<color red>NO ROOM NAME PROVIDED. ENTER THE ROOM NAME OR PART OF THE NAME.</color>"
  }]]></value>
    <notes>Enter MAPFIND "room name or part of room name"</notes>
  </alias>
</cmud>


You need to use a font like Consolas if you want this stuff to view correctly with spacing.
Reply with quote
Lennya
Newbie


Joined: 19 Oct 2012
Posts: 7

PostPosted: Thu Oct 25, 2012 6:51 pm   
 
Thanks for the help guys, that's a huge improvement.

I'm sure there's a way to make the mapper zone in on a certain room if I supply the roomnumber. Any tips here too?
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Thu Oct 25, 2012 7:35 pm   
 
That's what the function %roomname() is for.

Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <alias name="FindNum" copy="yes">
    <value>#print %roomname(%1)</value>
  </alias>
</cmud>
Reply with quote
rozdwojeniejazni
Wanderer


Joined: 13 Aug 2011
Posts: 74

PostPosted: Fri Oct 26, 2012 12:48 pm   
 
No, it's not. Read the question again, please.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Fri Oct 26, 2012 4:44 pm   
 
If you mean something to move the map view to show your room, the only way to do that is via #location
_________________
EDIT: I didn't like my old signature
Reply with quote
Lennya
Newbie


Joined: 19 Oct 2012
Posts: 7

PostPosted: Fri Oct 26, 2012 5:19 pm   
 
Works like a charm with #location!

Much obliged,
Lennya
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Sat Oct 27, 2012 4:13 pm   
 
Sorry I read that as wanting to show a specific roomname by giving a roomnumber. I thought you were talking about those scripts but I see you said mapper. My mistake!
Reply with quote
Latino
Beginner


Joined: 16 Feb 2017
Posts: 12

PostPosted: Thu Feb 16, 2017 11:25 am   
 
oldguy2 wrote:


Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <alias name="MapFind" copy="yes">
    <value><![CDATA[#if (%-1 != %null) {
  $room = %lower(%-1)
  $str = %concat("[Name] LIKE '%", $room, "%'")
  $locations = %mapquery($str)
  #call %roommode(1)
  #print ""
  #mxp {<color brown><hr></color>}
  $msg = "<strong><color khaki>VNum" + %repeat(" ",4) + "Destinations" + %repeat(" ",31) + "Zones</color></strong>"
  #print $msg
  #mxp {<color brown><hr></color>}
  #forall $locations {
    $roomNum = %roomnum(%i)
    $roomName = %roomname(%i)
    $roomZone = %zonename(%roomzone(%i))
    $msg = "<color white>[<color gold>" +
      %repeat(" ", 5-(%len($roomNum))) +
      $roomNum + "</color>]</color><color silver> " +
      $roomName%repeat(" ", 40-(%len($roomName))) +
      "</color><color lime>   " + $roomZone + "</color>"
    #print $msg
    }
  #mxp {<color brown><hr></color>}
  #call %roommode(0)
  } {
  #print "<color red>NO ROOM NAME PROVIDED. ENTER THE ROOM NAME OR PART OF THE NAME.</color>"
  }]]></value>
    <notes>Enter MAPFIND "room name or part of room name"</notes>
  </alias>
</cmud>




How can i make the same version of what you use, but with a specific name search, (not using LIKE, using = instead)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
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

© 2009 Zugg Software. Hosted by Wolfpaw.net