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
laitamandrake
Newbie


Joined: 30 Nov 2007
Posts: 2

PostPosted: Fri Nov 30, 2007 11:31 pm   

Problems with #ADD and #RESET..
 
#ADD g 50
#ADD p 1

Ok, this is the code that I'm trying to use. I have a variable set up for each. "g" is for gold and "p" is for the number of things I kill. The point is that everytime it tries to "add" the number 50 or 1, it shows in my status as 505050 or 11111. I can't get it to correctly add the numbers together. And reset does not bring the value of the variable back to 0. Am I doing something wrong?
Reply with quote
Zugg
MASTER


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

PostPosted: Fri Nov 30, 2007 11:38 pm   
 
That is because you have initialized the variables to a blank string instead of to zero. When you "add" a value to a string, it gets concated to the end of the string. So initialize your variables with

#VAR g 0
#VAR p 0

before starting and then it should add correctly.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Fri Nov 30, 2007 11:38 pm   
 
Set the type for your variables to Integer. The problem with #RESET is fixed for the next public version. Also there are some other fixes for how default values get handled, and I can't recall whether or not they were broken in 1.34.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
laitamandrake
Newbie


Joined: 30 Nov 2007
Posts: 2

PostPosted: Sat Dec 01, 2007 4:17 am   
 
How else can I bring the value of "g" and "p" back to 0? #SET doesn't work either...
Reply with quote
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Sat Dec 01, 2007 1:23 pm   
 
#VAR g 0
#VAR p 0

... or use #RESET (classname for both variables, assuming they're in the same class folder)

... or install 2.14 and use #RESET
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