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
Telos
Newbie


Joined: 18 Mar 2004
Posts: 9
Location: USA

PostPosted: Thu Apr 15, 2004 2:50 am   

If statement problem
 
Have a fairly simple if statement, which looks like it should be working but isn't. Just want to check if I already have an instrument equipped, and if I don't get it out and equip it... otherwise just start singing. Here's the code:

#if ( @currLyre != @currentInstrument ) {
rem bp
rem @currentInstrument
put @currentInstrument bp
get @currLyre bp
hold @currLyre
@currentInstrument = lyre
wear bp
}
sing 'song of regeneration'

Tested it with a few values, but right now testing it with currLyre set to "lyre" and currentInstrument set to "nothing".

Err... not set to a string, just lyre and nothing... just used quotes to show the value they are set to.

Anyway, the stuff inside the if block is _never_ happening. I even tried testing them equal to each other and setting them to the same thing and it wouldn't execute...

Thoughts?
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Thu Apr 15, 2004 3:23 am   
 
@currentInstrument = lyre
remove the @
currentinstrument=lyre

I think I am reading this right but am tired and its late
And your using this inside a #TRIGGER or #ALIAS right
Reply with quote
jessew
Apprentice


Joined: 03 Mar 2003
Posts: 141

PostPosted: Thu Apr 15, 2004 3:24 am   
 
Don't see a problem with it as written, tried it myself and it worked fine, so if the alias that uses that
#if statement has more then just that could you post it. And post where those variables are being defined, if there done through alias as well. Could be something else.

Jesse
Reply with quote
Telos
Newbie


Joined: 18 Mar 2004
Posts: 9
Location: USA

PostPosted: Thu Apr 15, 2004 3:47 am   
 
Yes, it is an alias.

That's actually the entire thing too... there will be several triggers, each of which will set currentInstrument to the proper instrument. The idea is thta when I want to switch songs the triggers will switch the instrument for me. Here's another one for reference/example:

#if ( @currHarp != @currentInstrument ) {
rem bp
rem @currentInstrument
put @currentInstrument bp
get @currHarp bp
hold @currHarp
@currentInstrument = @currHarp
wear bp
}
sing 'song of protection'


It was working fine until I added in the if statement. The only problem is it was spammy, since if I needed to restart the same song it would remove the instrument, put it in bp and then take it out and hold it again. :(

currLyre and such are set manually by me in zmud, but originally they were just the names of the instruments themsleves and it didn't work with the if statement.

It worked fine for you though, that may indicate some setting somewhere. Or a different version, I've got 7.05.
Reply with quote
jessew
Apprentice


Joined: 03 Mar 2003
Posts: 141

PostPosted: Thu Apr 15, 2004 4:35 am   
 
Ok its the extra space your putting in your #if statement i think? this time i cut and pasted yours (last time i rewrote it) ..and it didnt work, i noticed the space and deleted it.. and it worked :p
Maybe thats your problem, not sure though :)

#if (@currHarp != @currentInstrument) {
rem bp
rem @currentInstrument
put @currentInstrument bp
get @currHarp bp
hold @currHarp
@currentInstrument = @currHarp
wear bp
}
sing 'song of protection'

Jesse
Reply with quote
Telos
Newbie


Joined: 18 Mar 2004
Posts: 9
Location: USA

PostPosted: Thu Apr 15, 2004 5:03 am   
 
Yep, that got it. :groan: Thanks for the help... can't believe it was something like that...
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