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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Incrementing variable

Incrementing variable

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


Posted by SR388   (4 posts)  [Biography] 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?
[Go to top] top

Posted by Shadoweave   (42 posts)  [Biography] 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
[Go to top] top

Posted by SR388   (4 posts)  [Biography] 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))
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] 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
[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.


12,854 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 HostDash]