Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Blacky
Newbie


Joined: 04 Sep 2008
Posts: 1

PostPosted: 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!
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4715
Location: Pensacola, FL, USA

PostPosted: 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
Reply with quote
Rappy
Wanderer


Joined: 15 Jul 2005
Posts: 96

PostPosted: 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
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: 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
Reply with quote
Rappy
Wanderer


Joined: 15 Jul 2005
Posts: 96

PostPosted: 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
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net