Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ General
➜ Incrementing variable
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| SR388
(4 posts) Bio
|
Date
| Fri 23 Nov 2007 08:51 AM (UTC) |
Message
| I'd like to keep track of how many critical hits I get in any given gaming session, so I tried to have a trigger notice a crit and add to a variable. So far all I've been able to figure out, though, is how to change that variable's text. I need to increment the variable by 1 every time the trigger fires.
Ideas? | Top |
|
Posted by
| Shadoweave
(42 posts) Bio
|
Date
| Reply #1 on Fri 23 Nov 2007 12:38 PM (UTC) |
Message
| If it's a mush variable, then:
SetVariable ("crit", tostring(tonumber(GetVariable("crits")) + 1))
Be sure to initialize it with 0, though
For a Lua variable:
crits = crits or 0
crits = crits + 1
| Top |
|
Posted by
| SR388
(4 posts) Bio
|
Date
| Reply #2 on Sat 24 Nov 2007 12:36 AM (UTC) |
Message
| You're going really fast for me. Sorry for being such a nub, but it seems you're using a script of some kind. I tried pasting that text into a .vbs file and running it after creating a "crits" variable and setting it to 0, but I got an error:
Cannot use parentheses when calling a Sub
Line in error:
SetVariable ("crit", tostring(tonumber(GetVariable("crits")) + 1)) | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #3 on Sat 24 Nov 2007 02:37 AM (UTC) |
Message
| See http://www.mushclient.com/faq point 31. That shows doing arithmetic, like incrementing things. I suggest you use Lua as your script language. The example given above was for Lua. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | 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.
14,750 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top