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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Mon Nov 12, 2007 4:27 am   

Since #SUB is a topic of late... here's mine!
 
Don't know if this is possible without a whole bunch of code, but it's worth asking about.

On Aardwolf, the columns for pretty much everything is formatted to a set length. This can be a bit troublesome for some of my scripts. One of my scripts allows for clickable links that act as speedwalks. It looks for the full name, and if it matches, I can click it to walk to an area. Overall, it works pretty good. But that's only about 95% of the time. What I'm hoping I can do is have it match (and therefore complete) the line if only part of it is showing.

For instance, here is a line from the MUD.

Code:
the blasted corpse of Chiriri is in At the top of the stairs in area The Island of Stardo


The area name should be "The Island of Stardock" but due to length restrictions, it cuts it off. Is there a way to not only match "The Island of Stardock" but to match any shortened versions of it as well (such as the above example)? Any help would be appreciated. Thanks!

Charneus
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Mon Nov 12, 2007 6:27 am   
 
It's late and I'm about to head for bed but I do have a suggestion.

If you are making clickable lings from lines like the above then I am guessing that you are using the mapper database and %query

Provided that this is true then you could use the LIKE operator on your query.

Here is a gem from one of my aliases. It is using the predefined variable %selected but you could easily use %-1 instead.

It is using local variables from Cmud but you could change them back to ordinary variables, the original code was from Zmud.
Code:
#class Find
CurrentRoom=%roomkey
$lostroom = %selected
$lostroom=%subchar($lostroom,"'!","%%")
$sqlquery = %concat( ~", "Name Like ", "'", $lostroom, "%", "'", ~")
#noop %roommode( 1)
$FindQuery = %mapquery( $sqlquery)
$OtherMatches = %null
$OtherResults = %null
#FORALL $FindQuery
 {
    $OtherResults = %addItem( %i, $OtherResults)
    $OtherMatches = %addItem( %concat( "  ", %roomname( %i), " ", %numitems( $OtherResults), "^   ", "^   ",), $OtherMatches)
}
$OtherMatches = %sort( $OtherMatches)
$OtherMatches = %push( %concat( %ansi( cyan), "Other Matches ", %numitems( $OtherResults)), $OtherMatches)
OtherResults=$OtherResults
#noop %roommode( 0)
#if (%numItems( $OtherMatches) > 1) {#forall $OtherMatches {#show %replace( %i, "^", %cr)};#cr} {#show No matches found.}
#class 0

Because you are matching PART of a line rather than all of a line you could possibly get multiple results even if your mud does not allow multiple rooms of the same name.

Note $FindQuery = %mapquery( $sqlquery)

That line places a string list of rooms matching the query into the $FindQuery variable. Everything below that point is preparation for display to the screen and use outside of the alias.

Someone else here should be able to answer questions of how or why if you need help.
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Mon Nov 12, 2007 7:14 am   
 
Actually, even though I have maps, I'm not using it for one reason: it'll take the shortest path, and sometimes, the shortest path goes through some high level areas that wind up getting me instakilled. Therefore, I just use <send "speedwalk"> when clicking on it. So for instance:

Code:
#TRIGGER {Adventurer's Guild} {#SUB {<send "home;run esu">Adventurer's Guild</send>}}


But your code also looks interesting. I may take that into account on one of my next scripts. :D

Charneus
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Mon Nov 12, 2007 12:37 pm   
 
If you're creating your own speedwalker for this, you could incorporate the %begins function to see if the string that the trigger matches begins any of your area names.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Mon Nov 12, 2007 1:36 pm   
 
I think you misunderstand. This code does NOT speedwalk. It finds room numbers that I might choose to speedwalk to.

Still if you are storing your information in some form other than the map Fang's suggestion and a loop of some kind probably would be best.
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Tue Nov 13, 2007 2:14 am   
 
Hmmm... I was afraid of that. If I interpret %begins correctly, then I have a lot of work cut out for me. I guess what I can do is find the shortest form that is unique to each area and trigger off that way. I don't want to use something like

Code:
#TRIGGER {(*)} {#IF %begins("Island of Stardock",%1) {#SUB {<send "home;run e23s8e4sed">Island of Stardock</send>}};#IF %begins("Adventurer's Guild",%1) {#SUB {<send "home;run esu">Adventurer's Guild</send>}}


because it'll analyze every line of output. I could make it trigger off a set of opening variables (such as {is in the area|can be found in}), but that also seems a bit troublesome. Well, I'll work with what I have for now, unless anyone else can come up with a much better solution.

Arminas, you're right - I did assume that it would take me to the room, however, the premise is still the same: it finds the shortest path, and sometimes the shortest path is not always the safest. I realize that I could make the rooms I don't want to enter into a "Do not enter" room for the time being, but I'd have to figure out how to trigger that off my level so that once I reach a certain level, the map updates itself to allow access to those rooms. Any ideas on that one? I appreciate any help anyone gives on this subject. :)

Charneus
Reply with quote
chris-74269
Magician


Joined: 23 Nov 2004
Posts: 364

PostPosted: Tue Nov 13, 2007 6:25 am   
 
make a database of the roomnumbers and the level you want to be in order to enter it, then make an alias/event to update all roomcosts in regards to that information? I use something similar for parties where some portals are only accesible to me,


'partyon' alias:
Code:

maplock=%maplocked
#call %maplocked(0)
#call %roomcost( 1361, 9999)
#call %roomcost( 5860, 9999)
#call %roomcost( 137, 9999)
#call %roomcost( 1081, 9999)
#call %roomcost( 588, 9999)
#call %maplocked(@maplock)


i'm imagine you could use a forall to run through your database to compare to your current level and set the corresponding values
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Tue Nov 13, 2007 11:22 am   
 
Charneus: You're right that doing that for every line of text would suck bigtime, but do you really need to run it on every line? There're probably a limited number of times when the MUD will send area names.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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