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
Panpardus
Beginner


Joined: 27 Feb 2005
Posts: 11

PostPosted: Sat Dec 30, 2006 8:43 am   

stringlist help
 
Question 1

#if (%numitems(@herbaffs) > 3 and !@focusaffs.stupidity and !@focusaffs.confused and !@focusaffs.reckless) {focus}

Thats the script i want to use. @focusaffs is a stringlist and i want to check if it has stupidity and a few other things in it if it doesnt i want it to fire off a comand like focus. The problem is !@focusaffs.stupidity doenst work.

I thought that the syntax !@focusaffs.stupdity was correct so what im asking is there a simple way to do this instead of using

If %ismember( stupidity,@focusaffs) {} {next nested If statement}

Question 2

Is it possible to add more than one thing in additem

eg #additem focusaffs stupidity will add stupidity but what if i want to add 3 things i thought it was #additem focusaffs {stupidity|confusion|reckless}
but this adds stupidity|confusion|reckless as one item

anyhelp on any of the questions would be greatly appreciated
Reply with quote
Ceres
Wanderer


Joined: 25 May 2006
Posts: 88

PostPosted: Sat Dec 30, 2006 9:24 am   
 
This should work but is untested:

Code:
#if (%numitems(@herbaffs) > 3 and %ismember(stupidity,@focusaffs)!=0
   and %ismember(confused,@focusaffs)!=0
   and %ismember(reckless,@focusaffs)!=0) {focus}


Last edited by Ceres on Sat Dec 30, 2006 9:30 am; edited 1 time in total
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Sat Dec 30, 2006 9:29 am   
 
Question 1 works fine as you've done it already

herbaffs = a|b|c|d|e
focusaffs.stupidity = 0
focusaffs.confused = 0
focusaffs.reckless = 0
#if (%numitems(@herbaffs) > 3 and !@focusaffs.stupidity and !@focusaffs.confused and !@focusaffs.reckless) {focus} {}

does fire as expected. I just added an empty else statement to the end to ensure nothing was ambiguous

Question 2, I think #ADDITEM is only for single items. Fairly simple way to do multiple ones with not much more writing is
#FORALL "test1|test2|test3" {#ADDITEM Test %i}
_________________
CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;)
Reply with quote
Panpardus
Beginner


Joined: 27 Feb 2005
Posts: 11

PostPosted: Sat Dec 30, 2006 2:10 pm   
 
focusaffs.stupidiy doesnt work for me at all, does the is the .stupidity part only work for db vars or does it work for stringlists aswell

used this for an example

#additem focusaffs stupid
#if @focusaffs.stupid {ok} {no}

returns no
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Sat Dec 30, 2006 2:53 pm   
 
#additem focusaffs stupid
will add the string "stupid" to the variable 'focusaffs'

@focusaffs.stupid doesn't then query whether the variable 'focusaffs' contains the value "stupid"
it returns the value associated with the key 'stupid', it's shorthand for %db(@focusaffs, stupid)

to see if three things exist in a stringlist you need to use %ismember

No need to use nested #IFs though
Since %ismember returns 0 if it doesn't exist, but the position in the list if it does - any non 0 number equates to TRUE, so you can just do
#if (%numitems(@herbaffs) > 3 && %ismember( stupidity,@focusaffs) && !%ismember( confused,@focusaffs) && !%ismember( reckless,@focusaffs)) {focus} {}

note, I've replaced the and's with && (I think this is supported syntax for CMUD)
_________________
CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;)
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