|
Blacky Newbie
Joined: 04 Sep 2008 Posts: 1
|
Posted: Thu Sep 04, 2008 5:42 am
Trigger with variable assignment problem |
Hey,
I'm having some problems with the following trigger. It doesn't seem to be changing my variable, and both if statements are equating to true. I've changed a lot of things around to see if they work, but here's the most recent version of it.
#IF (@practicemode = "1") {
#IF (@currentspell = "0") {
cenchant platinum coin
currentspell = 1
}
#IF (@currentspell = "1") {
cfear all
currentspell = 0
}
}
What is wrong with my syntax? Also, I would like to convert this into a case statement if I can. Does Zmud script support that?
Thanks! |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4715 Location: Pensacola, FL, USA
|
Posted: Thu Sep 04, 2008 5:59 am |
by putting the number in quotes you might be confusing int into comparing string vs integer... try removing them
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
Rappy Wanderer
Joined: 15 Jul 2005 Posts: 96
|
Posted: Thu Sep 04, 2008 4:11 pm |
If the only options for @practicemode and @currentspell are 1 and 0, you can shorten your code a little as well. Also 0 fails an IF so you can do this
Code: |
#IF (@practicemode) {
#IF (@currentspell) {
cfear all
currentspell = 0
} {
cenchant platinum coin
currentspell = 1
}
}
|
-Rappy |
|
_________________ Windows 11 Pro,
cMUD 3.34 |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Thu Sep 04, 2008 10:58 pm |
Quote: |
Also, I would like to convert this into a case statement if I can. Does Zmud script support that?
|
check out #CASE and %case. |
|
_________________ EDIT: I didn't like my old signature |
|
|
|
Rappy Wanderer
Joined: 15 Jul 2005 Posts: 96
|
Posted: Fri Sep 05, 2008 12:01 am |
That's true, #CASE would shorten it even more =p (missed the question at the end about #CASE)
Code: |
#IF (@practicemode) {
#CASE @currentspell {cfear all} {cenchant platinum coin}
#ADD currentspell 1
}
|
Make sure you set @currentspell correctly when you set @practicemode and this should work fine. This assumes @currentspell will be 1 to begin with, if not, swap the cfear and cenchant.
-Rappy |
|
_________________ Windows 11 Pro,
cMUD 3.34 |
|
|
|
|
|