|
laitamandrake Newbie
Joined: 30 Nov 2007 Posts: 2
|
Posted: 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? |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: 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. |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: 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 |
|
|
|
laitamandrake Newbie
Joined: 30 Nov 2007 Posts: 2
|
Posted: 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...
|
|
|
|
Larkin Wizard
Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: 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 |
|
|
|
|
|