How do use a function

Posted by AquaBrother on Wed 01 Jun 2011 01:42 AM — 5 posts, 22,244 views.

Brazil #0
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
Australia Forum Administrator #1
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.

Brazil #2
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
Amended on Wed 01 Jun 2011 03:30 PM by AquaBrother
Australia Forum Administrator #3
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.
Brazil #4
thx Nick, you were awesome, as always...

Best Regards