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
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Mon Apr 21, 2008 8:04 pm   

DB Var's value look-up and String List.
 
I'll try to explain the issue to best of my abilities.

DB var with key-value pairs.

key is %roomvnum.

value is String List that consists of %roomexit data for the same key in the pair.

Separate String List is Exits data taken from MUD and parsed into the same string list output (n|s|d etc)

I want to make a look-up to compare the String List values through each keys "values" and if its an exact match, #teleport myself to that %key on Map.

Everything is peachy until I realized that I can't do simple

Code:


#loopdb @db {#if (@room_exits_from_mud=%db(@db,%key)) {#te %key}}



Because the output of %roomexit on Map DB and actually on MUD isn't exact same match.

Directions are the same, but order is different.

From MUD I can parse exits data as n|w|s|d but it won't match the room I want because %roomexit for that %roomvnum gives w|s|n|d instead.


I hope I made at least some sense so that someone could point me towards a pleasing solution... Confused


Thanks,

Prog
Reply with quote
Dharkael
Enchanter


Joined: 05 Mar 2003
Posts: 593
Location: Canada

PostPosted: Mon Apr 21, 2008 8:16 pm   
 
Maybe something like:
Code:
#loopdb @db {#if (%sort(@room_exits_from_mud)=%sort(%db(@db,%key))) {#te %key}}
_________________
-Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style."
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Mon Apr 21, 2008 8:38 pm   
 
I wish I'd have an eye for obvious Shocked

Its right-on to the whole concept so I think it will work. Honestly I already tried it, too but ran into a new problem which maybe can't be solved at all without manually changing some secondary data about those rooms.

Basically, a situation where I'd have a match of mud's current exits vs one from %db(@db,%key) but there are *several* matches like that in %db. And how would it know where exactly to #teleport when even Room names are exactly the same.

The premise behind all this code bit is really simple. When speedwalk'ing around, agressive mobiles can get me off-guard and hence, screw up the mapper location because it will still point to the destination room. So I have to reset my location on map. Its easy when I get stuck in a uniquely named room, but if I don't... well, then I need all this I'm writing about above.

%roomexit was the best next thing that hit me when I wondered about finding something that is unique for each room even if room names aren't.

But apparently in some cases, even roomexit part overlaps Neutral

I'm open for ideas.

The code bit you suggested Dharkael is awesome and in most cases I believe it will help me out. But heh, I can never be in peace when I notice that something won't be 100% solid.

Thanks again,

Prog
Reply with quote
Dharkael
Enchanter


Joined: 05 Mar 2003
Posts: 593
Location: Canada

PostPosted: Mon Apr 21, 2008 8:52 pm   
 
This question has Vijilante all over it.
I know he's written something that relates to this, His Walk Location System there are both ZMUD and
CMUD versions.
I would start by looking through those posts and see what you can take from them.
Once that's done if you have any problems adapting his ideas then post some questions here and no doubt he'll assist.
_________________
-Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style."
Reply with quote
meyn
Beginner


Joined: 06 Mar 2008
Posts: 27

PostPosted: Mon Apr 21, 2008 9:25 pm   
 
here's the one i wrote it triggers off the room title on my mud, svaes room title, room exit and first line of description.

checks to see if mud and map matches if not checks roomname, if only 1 teleports, otherwise checks name matches for exit matches, if only 1 teleports otherwise checks room description, if first line matches adds to list if only 1 teleports otherwise displays matches on screen, at which point if i've still not got a match i move one room and repeat.


Code:
#CLASS {CheckRoom}
#VAR roomonmap {}
#VAR roomonmud {}
#TRIGGER {%e[36m(*)} {
  #VAR exactnamematches {}
  #VAR exactexitmatches {}
  #VAR exactdescmatches {}
  #VAR getroom %array( %1)
  #WA 200
  #VAR roomonmap %roomname( )
  #VAR roomonmud {%arrget( getroom, 0)}
  #VAR roomonmud %stripansi( @roomonmud)
  #IF (@roomonmap=@roomonmud) {
    #OK
    #VAR slowstopped 1
  } {
    #Var roomlost 1
    #VAR pathneedscheckin 1
    letsfindroom=%concat( "[Name] LIKE '%", @roomonmud, "%'")
    #VAR Path %mapquery( @letsfindroom)
    #IF (%numitems( @path)=1) {
      #TE @path
      #Var roomlost 0
    } {
      #FORALL @Path {
        #IF (%roomname( %i) = @roomonmud) {
          #VAR exactnamematches %addItem( %i, @exactnamematches)
        }
      }
      #VAR exactnamematches %dups( @exactnamematches)
      #IF (%numitems( @exactnamematches)=1) {
        #TE @exactnamematches
        #Var roomlost 0
      } {
        #FORALL @exactnamematches {
          #IF (%roomexit( %i)=@exitsinroom) {
            #VAR exactexitmatches %addItem( %i, @exactexitmatches)
          }
        }
        #IF (%numitems( @exactexitmatches)=1) {
          #TE @exactexitmatches
          #Var roomlost 0
        } {
          #FORALL @exactexitmatches {
            #IF (%begins( @roomview, %roomdesc( %i))) {
              #VAR exactdescmatches %addItem( %i, @exactdescmatches)
            }
          }
          #IF (%numitems( @exactdescmatches)=1) {#TE @exactdescmatches} {
            #FORALL @exactdescmatches {
              #SHOW %roomname( %i)
              #SHOW %roomdesc( %i)
              #SHOW %roomexit( %i)
            }
          }
        }
      }
    }
  }
} "" {color}
#COND {^&roomview$} {}
#TRIGGER {^~[ obvious exits: &exitsinroom ~]$} {
  #VAR exitsinroom %replace( @exitsinroom, " ", "|")
  #VAR exitsinroom %lower( @exitsinroom)
}
#CLASS 0[\code]
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Mon Apr 21, 2008 9:51 pm   
 
Nods, manipulating with %roomdesc was actually my next idea after I had finished writing my last reply.

Not all my maps over the time have been made with descriptions however, so it could still end up being hit and miss sort of deal.

At the very least, I might now have an actual use of mapping stuff with descriptions included Twisted Evil

Thanks Meyn for the concept, btw.

If I come up with something cool eventually, I'll let you guys know.

Appreciated.

Prog
_________________
The Proud new owner of CMud.

--------------------------------
Intel Core i5-650 3,2GHz
4 DD3 RAM
GTX 460 768MB
Win 7 Home Premium 64x
--------------------------------
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Mon Apr 21, 2008 9:57 pm   
 
Keeping a database of your rooms is a pretty pants way to do this - it's just duplicating data that's stored in another database, so you've got to keep them both synced, got to deal with not having enough data, and so on.

We go to quite some length in those threads Dharkael linked discussing various ways of detecting which room you're currently in. If you're in combat and can't move (which you are) then the best way would be to look for the same combination of room name and exits. If that doesn't return a single room, just return a list of them and you can choose which one you're in. You could even write some code to compare where they are in the zone, if you feel that way (the mapper's database contains their xyz coordinates on the zone map).

As an aside, if you can move, we reckoned it'd be pretty cool if you could keep a map of the rooms you've visited since you'd gotten lost - a sort of sub-map that's kept in memory, kind of like how you've got your database set up at the moment - that you try to superimpose onto the main map every time you move into a new room and add more data to it. The more complex your sub-map gets, the fewer positions in your map it'll match, until there's only one. For all but the maziest of mazes, it won't take more than a couple of moves to find a unique spot.

So, yeah, how do you get to this juicy mine of map data? Take a look at Viji's code - he uses COM to open the map database directly, allowing you to write your own SQL queries. And with that, you can do pretty much anything you like with the data.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Thu Jun 19, 2008 9:04 pm   
 
I keep revisiting old issues now that I have more time over the summer.

Basically I'm working on the same type of script that Meyn has pasted above. Depends completely on ansi trigger that captures the room name.

However, I keep loosing the ansi option checked all the time. I make the trigger, check the ansi, save. Then after a while come back to
the trigger to see that ansi option is unchecked again.

I even tried with his script by pasting the class into cmd line and by doing so creating the folder within my own settings. But once I checked the ansi trigger, the ansi option was already unchecked even though it has {color} above.

I wrote a thread about this issue few months ago, too but didn't get any feedback.

Maybe I'll have more luck here, or if not, maybe someone can suggest how to work around this problem aiming for the same outcome without using ansi trigger at all.

Thanks,

Prog
_________________
The Proud new owner of CMud.

--------------------------------
Intel Core i5-650 3,2GHz
4 DD3 RAM
GTX 460 768MB
Win 7 Home Premium 64x
--------------------------------
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Thu Jun 19, 2008 10:03 pm   
 
If I remember correctly zMud required that the ansi option be all states or none. It isn't documented anywhere and is a bug that no one ever noticed until well after it was too late. Basically you have to check the ansi option on all the staes in order for it to work consitently on any of them. Then you will have to be prepared to use %stripansi on the captures where you don't actually need that information.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Thu Jun 19, 2008 10:23 pm   
 
Hah, yeah. That sounds a lot as I've seen myself while playing around with it. I'll see how it works out when the primary trigger is ansi and its condition isn't but has ansi checked as well.

So far ansi hasn't gone unchecked itself yet, so maybe I'll be OK from now on.

Thanks a lot for clearing this issue up. Appreciated.


Prog
_________________
The Proud new owner of CMud.

--------------------------------
Intel Core i5-650 3,2GHz
4 DD3 RAM
GTX 460 768MB
Win 7 Home Premium 64x
--------------------------------
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Sat Jun 21, 2008 1:44 pm   
 
Ok... updates.

Code:

REGEX "color_captures" {^\033\[32m(.*)\033\[0m$} {
  roomname_mud=%1
  #say Roomname is: @roomname_mud
  } "" {color}
#COND {^\s+(.*)} {
  desc_line=%stripansi( %1)
  #say Desc line is: @desc_line
  roomname_map=%roomname( )
  #if (!%null( @room_to_find)) {room_to_find=%mapquery( %concat( "Name LIKE '", @roomname_mud, "'"))}
  #if (%numitems( @room_to_find)=1) {#te @room_to_find} {#forall @room_to_find {#if (%begins( @desc_line, %trimleft( %roomdesc( %i)))) {#te %i}}}
  #state 0
  } {color|regex}



This is the bit of code I'm trying to make work but it isn't going very well at all. Although there can be problems within the code itself, its not the reason I'm writing atm. The trouble at this point is that all of a sudden Room name capturing ansi trigger got a life of its own.

Sometimes it captures the room name into the responsive variable, sometimes it doesn't. Within the trigger states tab, I can see that sometimes after I've used "look" to get the data, the primary trigger has the bright green box by it and the menu with right mouse click has "triggered" checked. However the second state has black arrow by it. When I uncheck the triggered by primary and move the black arrow to primary, whole thing works for that one time. Then it doesn't again..

Granted, I haven't messed around with trigger states that much so it may be something I've overlooked. But I've no idea atm how to solve this.

Something weird seems to be going on with ansi triggers :/

Before anyone points those things out... Anchoring etc the ansi line doesn't have any affect as opposed to not to. Problem is the same both ways. Within the code of the condition trigger I ended up using #state 0 to force the trigger to go back to start after executing but that doesn't seem to work either. Again, maybe I'm just making a fool of myself because I haven't really worked much with trigger states...

Thanks,

Prog
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sat Jun 21, 2008 2:31 pm   
 
It would seem that your second state isn't always matching. As you have it the line must start with spaces, and it is probable that there is an ansi code at the start of the line. I would suggest actually using a null pattern.
Code:
REGEX "color_captures" {^\033\[32m(.*)\033\[0m$} {
  roomname_mud=%1
  #say Roomname is: @roomname_mud
  } "" {color}
#COND {} {
  desc_line=%line
  #say Desc line is: @desc_line
  roomname_map=%roomname( )
  #if (!%null( @room_to_find)) {room_to_find=%mapquery( %concat( "Name LIKE '", @roomname_mud, "'"))}
  #if (%numitems( @room_to_find)=1) {#te @room_to_find} {#forall @room_to_find {#if (%begins( @desc_line, %trimleft( %roomdesc( %i)))) {#te %i}}}
  #state 0
  } {color|regex|looplines|param=1}
This eliminates the need to use %stripansi for the description, as its data is gathered from the %line predefined variable which will not contain ansi data. The use of the null pattern ensures that the match occurs with the next line received.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Sat Jun 21, 2008 2:43 pm   
 
It's a good idea but I'm not very sure that'll work.

Specially because actually second condition is *always* matching right now. I haven't seen a single time yet it hasn't.
I really can't say anything else than something very random is going on.

Sometimes the main state matches too, then few tries fail again and then it matches again. I really have no clue, few days back when I didn't had that bit of code within the condition trigger yet, it matched both 100%. Now it does it randomly, even with the most simplistic of code bits.

I'll try it later with the idea you suggested, but I doubt its going to work :/


Thanks,

Prog
_________________
The Proud new owner of CMud.

--------------------------------
Intel Core i5-650 3,2GHz
4 DD3 RAM
GTX 460 768MB
Win 7 Home Premium 64x
--------------------------------
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Sat Jun 21, 2008 6:08 pm   
 
Extremely weird, but now it all appears to work. I even added an additional condition and it still works the way it should looping back to main trigger once everything is done.

Makes you think if it was a simple usage of wrong trigger option that I used for first condition (it was just set to "pattern" in my original code).

Thanks a lot, Vji!


Prog
_________________
The Proud new owner of CMud.

--------------------------------
Intel Core i5-650 3,2GHz
4 DD3 RAM
GTX 460 768MB
Win 7 Home Premium 64x
--------------------------------
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