[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  VBscript
. . -> [Subject]  Adding Variables
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Adding Variables

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Zeppy   USA  (15 posts)  [Biography] bio
Date Tue 24 Apr 2001 06:28 PM (UTC)
Message
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.)
[Go to top] top

Posted by Nick Gammon   Australia  (21,387 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Tue 24 Apr 2001 09:25 PM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Zeppy   USA  (15 posts)  [Biography] bio
Date Reply #2 on Wed 25 Apr 2001 03:10 PM (UTC)
Message
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...

[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


8,251 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]