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
Dyron
Apprentice


Joined: 08 Apr 2004
Posts: 103
Location: USA

PostPosted: Wed Oct 08, 2008 3:58 am   

Contact/String Variables question
 
Okay here's my code.
Code:

  afflictions=%concat( @afflictions, "|", @pendafflictions)
  Cures=%concat( @Cures, "|", @pendCures)
  pendafflictions=""
  pendCures=""


I've got two problems I'm currently seeing..
First, if pendafflictions is empty every time it concats.. it adds a blank line to the afflictions variable.
Second, if there is something to concat, it will keep adding the same affliction.
Example:


    blank line
    blank line
    burning
    blank line
    burning
    blank line
    blank line
    blank line
    burning
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Wed Oct 08, 2008 4:33 am   
 
Use #IF to check if the @pendaffliction is empty or null

Code:
 #IF (!%null(@pendafflictions)) { afflictions=%concat( @afflictions, "|", @pendafflictions)  }


For you second it's best to loop through @pendafflictions (assuming it's a string list) and use #ADDITEM to add them to cures.

Something like the following should do the trick.

Code:
#FORALL @pendafflictions {#ADDITEM @Cures %i}


Actually that second bit of code should take care of both problems.
_________________
Asati di tempari!
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Wed Oct 08, 2008 8:06 am   
 
Though you don't need the double negative !%null... just doing #if (@pendafflictions) will do.

But yes, the #forall and #additem is a better way to go about it.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Wed Oct 08, 2008 5:04 pm   
 
You could also maybe use %additem/#additem to add the entire @pendafflictions list to the afflictions list. This, of course, will cause parentheses to be placed around this sublist, but two %replace() functions will handle that pretty effectively.
_________________
EDIT: I didn't like my old signature
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