Register forum user name Search FAQ

Gammon Forum

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 ➜ Tips and tricks ➜ How do use a function

How do use a function

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


Posted by AquaBrother   Brazil  (19 posts)  Bio
Date Wed 01 Jun 2011 01:42 AM (UTC)
Message
Hi, i'd like to add a value to a variable, like, i have a variable called @number, this variable has a value, i'd like to add to another trigger a function that would sum a number to that variable, like @number + 1, or @number + @numer2, i know it might be simple but i tried a few things and nothing worked... =(...

Sorry to bother...

Best regards
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #1 on Wed 01 Jun 2011 05:51 AM (UTC)
Message
The @number syntax is read-only. This alias will add a number to the variable "number":


<aliases>
  <alias
   match="^add (\d+)$"
   enabled="y"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>

SetVariable ("number", tonumber (GetVariable ("number")) + %1)

</send>
  </alias>
</aliases>


Template:pasting For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by AquaBrother   Brazil  (19 posts)  Bio
Date Reply #2 on Wed 01 Jun 2011 03:28 PM (UTC)

Amended on Wed 01 Jun 2011 03:30 PM (UTC) by AquaBrother

Message
thx Nick, but lets say that i already have a global variable and i want so sum the number variable to that variable instead of %1...

would it be something like that?:

SetVariable ("number", tonumber (GetVariable ("number")) + tonumber (GetVariable ("number2")))

Thx for your time... really appreciate it...

i navigated though all the help files and coudnt find something to help me sum variables... i must have missed something...

Best regards

Aquabrother
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #3 on Wed 01 Jun 2011 10:06 PM (UTC)
Message
Yes, sure that should work. Why not try and see?

The help files don't specifically say how to add variables. But they tell you how to get and set them, and after that it is basically how you do arithmetic in a script.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by AquaBrother   Brazil  (19 posts)  Bio
Date Reply #4 on Wed 01 Jun 2011 10:59 PM (UTC)
Message
thx Nick, you were awesome, as always...

Best Regards
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.


19,987 views.

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

Go to topic:           Search the forum


[Go to top] top

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