About Us
Products
Purchase
Downloads
Support
Forums
Contact Us
Site
 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
Killfile
Novice


Joined: 30 Sep 2002
Posts: 32
Location: USA

PostPosted: Mon Sep 30, 2002 1:49 pm   

Setting Variables wih If
 
I'm trying to create an if statment which will watch a variable and act on that variable when certain conditions are met.

The variable in question is something called "GasLeft" which is an integer value I am decrimenting each time I cast a spell. However, I don't want this value to dip below -25. My current function is

%if(@GasLeft < -25,GasLeft = 8)

The problem is that when the conditional is met instead of seting GasLeft equal to 8 it sends "GasLeft = 8" to the mud, which has no idea what I'm talking about.

How do I get Zmud to evaluate this numeric expression rather than deciding it is an actual command?


--Killfile
Reply with quote
Troubadour
GURU


Joined: 14 Oct 2000
Posts: 556
Location: USA

PostPosted: Mon Sep 30, 2002 4:24 pm   
 
#IF is a command which executes a command.
%if is a function which returns a value.

You can do what you want using either:

#IF (@GasLeft < -25) {Gasleft = 8}

or

#VAR GasLeft %if(@GasLeft < -25, 8, @GasLeft)

Note that you MUST provide a false-value if you use the %if function. In this case I used @GasLeft.

Troubadour
(Win 98, Pentium III, 550 MHz)
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