|
PrestoPimp Apprentice
Joined: 18 Sep 2001 Posts: 175 Location: USA
|
Posted: Sun Jan 26, 2003 3:46 am
#MATH problem (I think) |
Hi.. I want a trigger that gets a gold variable and subtracts it from the old amount.. this is what I have but the #MATH doesnt add correctly. Why is this?
pattern: (%w) gives you (%n) coins.
command:
#VAR currentchar %1
#VAR oldgold @currentgold
worth
#MATH goldsum (@currentgold - @oldgold)
say @currentchar gave me @goldsum coins.
and It keeps saying that goldsum=0 I've tried #MATH w/o () w/{} and stuff.. didn't work.
Someone help plz.
-Presto
For tomarrow is another day, and other days come but 6 times a week. |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Sun Jan 26, 2003 5:34 am |
What did you expect it to do?
#VAR currentchar %1
#VAR oldgold @currentgold (@oldgold now equals @currentgold)
worth
#MATH goldsum (@currentgold - @oldgold) (since @oldgold = @currentgold, this will of course always be 0)
say @currentchar gave me @goldsum coins
And now zMUD is ready to process the commands from the next trigger (probably to update @currentgold from the "worth" command)
LightBulb
Senior Member |
|
|
|
AzCowboy Adept
Joined: 09 Nov 2000 Posts: 222 Location: USA
|
Posted: Sun Jan 26, 2003 5:50 am |
see the "worth" command in there?
He's setting the oldgold to be the same as current, then calling the mud's worth command to get an update for current gold
The problem with this is, the trigger doesn't know to wait for the new value before it continues.....
He just needs to rethink this a bit.... |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Sun Jan 26, 2003 5:59 am |
I believe that was my point, Az.
LightBulb
Senior Member |
|
|
|
PrestoPimp Apprentice
Joined: 18 Sep 2001 Posts: 175 Location: USA
|
Posted: Sun Jan 26, 2003 6:01 am |
Doh! I didnt realize it didnt fetch the new currentgold amount before doing the math. Thanks guys.
For tomarrow is another day, and other days come but 6 times a week. |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Sun Jan 26, 2003 6:07 am |
Okay, now that we've seen why it doesn't work what can be done that will work? One method is to move the calculation to the worth trigger. Since you won't necessarily want to do this every time you check your worth, you should make a separate trigger and put it in a subclass.
pattern: (%w) gives you (%n) coins.
command:
#VAR currentchar %1
#VAR oldgold @currentgold
#T+ CheckGold
worth
Class: CheckGold (should be disabled at connection)
Pattern: You have (%d) gold (whatever matches the output from your worth command)
command:
#VAR currentgold %1
#MATH goldsum (@currentgold - @oldgold)
say @currentchar gave me @goldsum coins.
#T- CheckGold
LightBulb
Senior Member |
|
|
|
|
|