Adding Variables

Posted by Zeppy on Tue 24 Apr 2001 06:28 PM — 3 posts, 21,004 views.

USA #0
Please excuse my ignorance if this seems to obvious a question...

I am in the process of creating a stat roller for a MUD. I have created the needed triggers and have all the variables set up as needed within the script. I am attempting to add the totals for the stats. As it stands now, I have variables for each stat (i.e. Str, Wis, Int, etc...). The problem is that when I attempt to add them, the variables are concatenated instead of summed.

The command I use is a simple - total = str + wis + int

I assume this is because the script thinks that the variables are strings and not integers. How would I modify this?

BTW...I tried to change the trigger so that I was using a regular expression. After some trial and error, I managed to get the trigger to send only the numbers to the variables. This time though instead of concatenating or adding them in the script, I simply get an invalid class error. (That's not the exact error, but I think you will catch my drift.)
Australia Forum Administrator #1
Just convert them to integers, like this:



total = cint (str) + cint (wis) + cint (int)


As for the invalid class error, it sounds like a bug in the script. Post your script (the part with the error) and also, you can copy and paste the exact error message from the error screen.
USA #2
So it was a rocket science issue!

Sheesh...you'd think I'd read a book or something!?

Anyhow, thanks for the help. As far as the code that caused the error, it's really a waste. Now that I see how to properly add the variables I will have no need for that particular script. Thanks though...