subtracting triggers

Posted by Lightzout on Mon 04 Jun 2007 07:22 PM — 3 posts, 14,142 views.

#0
Hi, I just registered and hope if you guys can help me. I'm having problems subtracting using Vbscripting, here's an example.

Trigger Line: You have gained (.*?) experience points.

Send: setvariable "experience",getvariable ("experience")-%1


normally this would work but with 4 digits or more, say, '5,000' then it'll cause the script to error, I suspect that the comma is the problem but the game doesn't have the option to remove it so I'm stuck here, anyone can help me?
USA #1
Hi Lightzout,

First as a general note this should probably be in the MUSHclient VBscript section, not Programming General.

Now to solve your problem, you can remove the comma yourself in VBscript:

SetVariable "experience", GetVariable ("experience") - Replace(%1, ",", "")

That should work. You might need to wrap the replace call in a CInt call to convert to number first, but IIRC VB takes care of that kind of thing for you.

The modified version would be:
SetVariable "experience", CInt(GetVariable ("experience")) - CInt(Replace(%1, ",", ""))
#2
Oh, sorry! And thanks for the help. Thought this falls under programming section.