Gammon Forum
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 (22,973 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.
12,854 views.
It is now over 60 days since the last post. This thread is closed.
  Refresh page
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.