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
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Thu Mar 18, 2010 4:04 pm   

Determining the Best Setupt to Use
 
Hey guys, it's been awhile!

Haven't had much time to dink around with my CMUD settings as of late, so I've just used what I had. But I recently got a request to make a script that I'd been intending to make for some time, but hadn't gotten around to. And that would be a "Clan Highlighter" script. Much of the script is already worked out in my head as a general plan. However, I'm trying to determine what the best storage method would be. Currently, I'm looking for a storage method that can easily store multiple, associated entries. Here's an example of what I'd like to store:

Name: Chamenas Clan: Shalonesti Level: 51 Rank: Sha'falas Leader: 0
...

Those need to be associated, and I need to be able to reference them as an association with functions so that when, in a specific situation, Chamenas' name comes up, I can either highlight his name in accordance with his clan, and/or show the other pertinent information related to him.

My initial thoughts were that a database variable would be my best bet? But I know next to nothing about them. I managed to find a list of Commands and Function in association with databases, but I was unable to find any tutorials or guides on how to set them up or, most importantly, whether or not they can store an index of records with multiple associations.

Any help in this matter would be appreciated.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Thu Mar 18, 2010 5:17 pm   
 
How many people are you wanting to recordize? If it's really small, you can get away with using a single datarecord (@clanned_players) that uses the character name (@clanned_players.Chamenas) as the key field and stores the other data as the value. The value can be a stringlist (Shalonesti|51|Sha'falas|0) with the data in a specific order, or it can be a string like your example above (Clan: Shalonesti Level: 51 Rank: Sha'falas Leader: 0)--either way, because of how datarecords are stored internally it won't be so easy to directly refer to it.

The trick to all of that is to assign the value to a local or otherwise non-datarecord variable. So assigned, you're no longer constrained by any limitations of datarecord variables. Thus, if you choose to make the value a stringlist you can simply assign it to a local variable and then directly work on that stringlist using stringlist commands and functions:

Code:

NOTE: for the example, the database is storing key-value pairs in the form of name = clan|level|rank|leader

#trigger {({@clanned_players})} {
  #local $clannie $color
  #if (%iskey(@clanned_players,%1)) {
    $clannie = %db(@clanned_players,%1)
    [b]code goes here to determine the value of $color[/b]
    #PSUB %format("<send 'Clan: &s Level: &0.0f Rank: &s Leader: &s'><color &s>&s</color></send>",%item($clannie,1),%item($clannie,2),%item($clannie,3),%item($clannie,4),$color,%1) %x1
  }
}


Unfortunately, there's a giant immovable object that prevents this from working at the moment. #PSUB and #SUB currently suffer from an inability to process either the <send> tag or all MXP tags entirely, so unless this bug is limited to the beta version the #PSUB will print the text of the tags instead of the processed result. You can perhaps get around this using more specific trigger patterns, some sort of gagging command, and #PRINT to display the new version of the line. Doing so is not guaranteed to maintain line order, however, so your #PRINT might appear in the place of the gagged line or it might appear a few lines later.
_________________
EDIT: I didn't like my old signature
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Thu Mar 18, 2010 5:33 pm   
 
Yeah, I'm not actually planning on using sub for the output! In any case, the code will automatically update entries from the who list. And we're easily talking over a hundred, possibly over two hundred entries. And since it will all be updated automatically, I won't be referencing anything in the code directly by name. Like I said though, I have a vague idea of how I want to run it, and I may run into problems with various parts later, but, right now, my biggest issue is finding the proper method of storage.

A stringlist has occurred to me as far as the individual records. However, the big thing is that I don't intend to make a new stringlist variable for each entry, so I'm sort of hoping that there is something (database variables?) which will allow me to have one variable which can store the hundred of records, and have each record be a stringlist which will contain all of the relevant information.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Fri Mar 19, 2010 12:07 pm   
 
By the way, is it possible to access stringlist records by number? If for some reason the database variables do not work as I had hoped, I could simply use multiple stringlists.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Martaigne
Wanderer


Joined: 05 Jan 2002
Posts: 88
Location: Atlanta, GA

PostPosted: Fri Mar 19, 2010 2:06 pm   
 
%item works for that.
_________________
Unwritten Legends
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