|
Death Apprentice
Joined: 25 Jun 2002 Posts: 109 Location: USA
|
Posted: Fri Aug 02, 2002 10:15 pm
variable equation help |
i have triggers set up, so if anyone gives me money i cast some spells on them
well, a few have figured out that emotes work just as well. how can i set up variables and triggers so they can't do that?
on my prompt there is a thing that keeps track of my gold...
--gold_here-->
#tr {--(%d)-->} {#var gold {%1}}
now when i receive money i want it to check that and see if it actually got gold.
#tr {(%w) gives you (%d) gold.} {#var tempgold {%2};#if (@tempgold=(@gold+1000)) {cast spell} {sorry, try again}
i know i'm doing some kind of math wrong in the (@tempgold=(@gold+1000)) part. any help would be very thankful
-Death |
|
|
|
iljhar GURU
Joined: 10 Oct 2000 Posts: 1116 Location: USA
|
Posted: Fri Aug 02, 2002 10:51 pm |
Try this:
#tr {(%w) gives you (%d) gold.} {#math tempgold @gold+1000;#if (@tempgold=%2) {cast spell} {sorry, try again}
Untested, but looks okay.
Iljhar |
|
|
|
Death Apprentice
Joined: 25 Jun 2002 Posts: 109 Location: USA
|
Posted: Sat Aug 03, 2002 3:27 am |
Thanks iljhar!
That worked great, that'll help me alot.
-Death |
|
|
|
Death Apprentice
Joined: 25 Jun 2002 Posts: 109 Location: USA
|
Posted: Mon Aug 05, 2002 2:31 pm |
Ok, what if i wanted to have the same trigger be in charge of getting different amounts of money for different spells. I played with it and got confused because I couldn't get it to work.
#tr {(%w) gives you (%d) gold.} {#math tempgold @gold+%2;#if ((@tempgold=%2) & (%2=1000)) {cast 'protection good' %1};#if ((@tempgold=%2) & (%2=1001)) {c 'protection evil' %1};#if ((@tempgold=%2) & (%2=3000)) {c sanctuary %1;c visegrip %1}
There is more amounts of gold and more spells, but that should be enough hopefully to see what i'm doing wrong. Any help or hints and I will be very thankful.
-Death |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Mon Aug 05, 2002 3:51 pm |
You have the following equation
@tempgold = @gold+%2 (from #math tempgold @gold+%2)
You then do a comparison
#if (@tempgold=%2)
Substituting the value from the equation:
#if (@gold+%2=%2)
Clearly, this will only be true when @gold=0.
Going back to the original problem (how to tell if you received any gold), what's needed is the amount of gold just before and just after someone pays you. At the moment the trigger fires, @gold should still be the amount before you were paid. When the prompt arrives a few microseconds later, @gold should be the amount after payment. I've put in a one-second delay to ensure there's time for the prompt to arrive and @gold to update.
#TR {(%w) gives you (%d) gold.} {#VAR tempgold @gold;#VAR target %1} {#ALA +1 spellcaster}
#AL spellcaster {#IF (@tempgold = @gold) {sorry, try again};#IF (@tempgold + 1000 = @gold) {cast 'protection good' @target};#IF (@tempgold + 1001 = @gold) {cast 'protection evil' @target};#IF (@tempgold + 3000 = @gold) {cast sanctuary @target;cast visegrip @target}}
Like iljhar's, this is untested.
LightBulb
Senior Member |
|
|
|
Death Apprentice
Joined: 25 Jun 2002 Posts: 109 Location: USA
|
Posted: Mon Aug 05, 2002 5:57 pm |
Thank you LightBulb,
Those equations got them working together fine.
-Death |
|
|
|
|
|