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
talith
Novice


Joined: 03 Mar 2005
Posts: 31

PostPosted: Sun Sep 11, 2011 9:47 am   

Checking a number range?
 
I'm attempting to check a number against a range, and if true return a value. In python it would look like:
Code:
if auraNumber == 1:
      return 'one'
   elif auraNumber in range(398,458):
      return 'two'
   elif auraNumber in range(458,524):
      return 'three'
   elif auraNumber in range(524,596):
      return 'four'


I just can't figure out a zmud equivalent method to do the above. Is this possible?
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Sun Sep 11, 2011 2:32 pm   
 
There's no built in in range function, you'd need to do something like
Code:
#IF (@auraNumber >= 398 and @auraNumber <= 458)

You could also make your own user-defined function:
Code:
#VAR inrange {%if(%1 >= %2 and %1 <= %3,1,0)}
then call it like this:
Code:
#IF @inrange(@auraNumber, 398, 458)
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sun Sep 11, 2011 5:36 pm   
 
There is no equivalent to the elif, either. Nest if commands.
_________________
EDIT: I didn't like my old signature
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