Incrementing variable

Posted by SR388 on Fri 23 Nov 2007 08:51 AM — 4 posts, 19,745 views.

#0
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?
#1
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
#2
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))
Australia Forum Administrator #3
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.