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
Private
Adept


Joined: 10 Jan 2002
Posts: 264
Location: USA

PostPosted: Wed Apr 07, 2010 3:58 pm   

%ismember and (X|x) case sensitivity
 
trying yet again to give cmud a go, having a problem it seems %ismember is no longer case sensitive...

CMUD:
Code:

tcolors = black|Blue|blue|Cyan|cyan|Green|green|Magenta|magenta|Red|red|White|white|Yellow|yellow
#SORT tcolors 1
#SHOW %ismember(cyan,@tcolors)  --> 4


ZMUD:
Code:

tcolors = black|Blue|blue|Cyan|cyan|Green|green|Magenta|magenta|Red|red|White|white|Yellow|yellow
#SHOW %ismember(cyan,@tcolors)  --> 5


the bit of code i need this for is:
Code:

tcolor1_mud = %case( %ismember( %1, @tcolors), D, B, b, C, c, G, g, M, m, R, r, W, w, Y, y)
tcolor1_mxp = %case( %ismember( %1, @tcolors), ~~~$505050, ~~~$3296ff, ~~~$4b4bff, ~~~$00aaaa, ~~~$44ffff, ~~~$00aa00, ~~~$00ff00, ~~~$960096, ~~~$C800C8, ~~~$ff0000, ~~~$aa0000, ~~~$aaaaaa, ~~~$ffffff, ~~~$ffff00, ~~~$aaaa00)
tcolor1 = %case( %ismember( %1, @tcolors), high%char( 44)black, high%char( 44)blue, blue, cyan, high%char( 44)cyan, green, high%char( 44)green, magenta, high%char( 44)magenta, high%char( 44)red, red, white, high%char( 44)white, high%char( 44)yellow, yellow)


the last 2 vars aint in proper order, getting tired of sorting em until i can get ismember to be CaSe SeNsItIvE :P

tried all diff versions of vars, and with or without sort on "String List" or #SORT tcolors 1/0 same results, no case sensitivity

even tried a DBVAR, but it wont let me add Blue & blue, it accepts it, saves in editor, but click some other setting and return, the dbvar only has one entry.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Wed Apr 07, 2010 5:22 pm   
 
Yes, unfortunately CMUD is case insensitive since it switched to it's internal hashing algorithm for string lists and database variables.

What you might try to do is something like this:
Code:
mud_colors = "DBbCcGgMmRrWwYy"
color_index = %pos( %1, @mud_colors);
tcolors = black|Blue|blue|Cyan|cyan|Green|green|Magenta|magenta|Red|red|White|white|Yellow|yellow
mycolor = %item(@tcolors,@color_index)

In other words, instead of using %ismember, use %item to retrieve a specific value in the string list and use the %pos to determine the position of your %1 character within the string.
Reply with quote
Private
Adept


Joined: 10 Jan 2002
Posts: 264
Location: USA

PostPosted: Wed Apr 07, 2010 5:32 pm   
 
found another workaround... will have to see which is faster on bigger scripts

Code:

tcolors = 1=black|2=red|3=green|4=blue|5=cyan|6=magenta|7=yellow|8=white|9=Red|10=Green|11=Blue|12=Cyan|13=Magenta|14=Yellow|15=White


the above is a Data Record Var...

Alias testdb...
Code:

#LOOPDB @tcolors {#IF (%val = %1) {#SHOW theme_color1_mud = %case( %key, D, r, g, b, c, m, y, w, R, G, B, C, M, Y, W)}}
#LOOPDB @tcolors {#IF (%val = %2) {#SHOW theme_color2_mud = %case( %key, D, r, g, b, c, m, y, w, R, G, B, C, M, Y, W)}}


# testdb white White
theme_color1_mud = w
theme_color2_mud = W

#testdb Green yellow
theme_color1_mud = G
theme_color2_mud = y

#testdb Blue black
theme_color1_mud = B
theme_color2_mud = D


guess either way will suffice... but BLEH :P
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