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


Joined: 15 Nov 2001
Posts: 4

PostPosted: Thu Nov 15, 2001 5:06 pm   

If statements
 
Is it possible to have an if command turn off a class? I get a sytnax error when using the following: %if( @conc<"10", #class combat 0)

Also is it possible to perform two commands when an if statement is true? For example: %if( @conc<"1", @leavedir and heal)
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Thu Nov 15, 2001 6:58 pm   
 
What you are using is the IF function (%IF), which requires that all arguments be present. You get a syntax error because you left out the false response argument. You're also trying to use a "less than" operator with a string value ("10") instead of a numerical value (10), I'm not sure what the result will be.

The simplest solution would be to switch to the IF command (#IF), where the false response is optional and multiple commands are easily done.

#IF (@conc < 10) {#CLASS combat 0}
#IF (@conc < 1) {@leavedir;heal}

LightBulb
Reply with quote
Castaway
GURU


Joined: 10 Oct 2000
Posts: 793
Location: Swindon, England

PostPosted: Fri Nov 16, 2001 9:29 am   
 
Turning off a class is done with #T- combat (and turning on with #T+ combat)

Lady C.
Reply with quote
decantor
Apprentice


Joined: 14 Nov 2001
Posts: 100

PostPosted: Fri Nov 16, 2001 3:14 pm   
 
You are probably running into problems simply because 1 is also less than 10. Unless the @leavedir;heal trigger(as well as the leavedir variable) is in a different class than 'combat', once the @conc variable is less than 10, your <1 trigger will no longer fire.


#IF (@conc < 10)&&(@conc > 1) {#t- combat}#IF (@conc < 1){[@leavedir;heal] #abort}
Reply with quote
Junker23
Newbie


Joined: 15 Nov 2001
Posts: 4

PostPosted: Fri Nov 16, 2001 5:06 pm   
 
Is there a way to differntiate between 10 and 1?
Reply with quote
Junker23
Newbie


Joined: 15 Nov 2001
Posts: 4

PostPosted: Fri Nov 16, 2001 5:10 pm   
 
Let me explain some more. I have a trigger set up in the default (no)class. The trigger is as follows: #IF (@conc<1) {off;he;@leavedir} The trigger kicks on everytime @conc is less than 10. Is there anyway to fix this problem?
Reply with quote
decantor
Apprentice


Joined: 14 Nov 2001
Posts: 100

PostPosted: Fri Nov 16, 2001 5:24 pm   
 
define what it should do when @conc is less than 10 but greater than one using:

#IF (@conc > 1)&&(@conc < 10) {whatever_you_want_to_do}
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Nov 16, 2001 6:01 pm   
 
What is the value of @conc? That is, what is the script that creates/updates it? Are you sure it's a number and not a string? As I already pointed out, string comparisons don't work the same as numerical comparisons and it's only a numerical comparison if both sides are numerical.

Note to Lady C: I thought about pointing out the #T+/#T- commands, but reading through the helpfile for #CLASS it appears to be a proper, if unusual, method of controlling the class.

LightBulb
Reply with quote
Junker23
Newbie


Joined: 15 Nov 2001
Posts: 4

PostPosted: Sat Nov 17, 2001 12:08 am   
 
Well the trigger I am using to store the variable is C: &conc Is there a way to make sure that this is stored as a number?
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sat Nov 17, 2001 8:08 am   
 
quote:

Well the trigger I am using to store the variable is C: &conc Is there a way to make sure that this is stored as a number?



Yep. You can modify your trigger pattern from 'C: &conc' to 'C: (%d)'. The pattern will ensure the trigger ONLY fires when a number appears where (%d) is. Then in the Value section of the trigger you'd assign %1 to @conc (ie, @conc = %1 or #VAR conc %1).

EDIT: technically, all variables are stored as strings. I haven't a clue if the mathematical functions actually validate the data given to it, though.

li'l shmoe of Dragon's Gate MUD
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