Adding to variables.

Posted by Scarn on Tue 26 Jul 2005 01:08 PM — 4 posts, 19,550 views.

#0
Hi,

I have a varible for the amount of gold I am carrying that shows in the info bar...

this is the string i use to get that variable:

Gold: (.*) Encumbrance: (.*)

setvariable "Gold", "%1"
setvariable "Weight", "%2"
infoclear
world.InfoFont "Courier", 10, 1
world.infocolour "red"
info "Health: " & getvariable("Health") & " Energy: " & getvariable("Energy") & " Gold: " & getvariable("Gold") & " Weight: " & getvariable("Weight")


i want to be able to add to this figure as i get more gold .... rather than having to check my nventory to update it, here is the emote for getting gold.

You put * gold in your pockets.


could some help me by telling me the script to add * to the "Gold" variable?

Thanks,
-Scarn
USA #1
You'll obviously need a trigger to match, and you can use this script to update the variable:

setvariable "Gold", getvariable("Gold") + %1

(you'll then have to update your info bar).
Since you'll be doing that, you might want to do something like this:

dim gold
gold = getvariable("Gold") + %1
setvariable "Gold", gold
[and then you can use 'gold' to set your infobar line, which removes the need to use another getvariable, which will perform better]
#2
it doesnt work...heres the trigger:

<triggers>
<trigger
enabled="y"
expand_variables="y"
match="You put * gold in your pockets."
regexp="y"
send_to="12"
sequence="100"
>
<send>dim gold
gold = getvariable("Gold") + %1
setvariable "Gold", gold</send>
</trigger>
</triggers>
USA #3
What doesn't work about it? Are you sure you're matching? (turn on trace, or color the line)
Is it instead appending the number to the original value? What isn't working?