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


Joined: 08 Nov 2000
Posts: 44
Location: Australia

PostPosted: Thu May 16, 2002 3:57 am   

dice and if statements
 
Using a dice roll in a variable... say 1 to 100, i want to be able to use if statements to carry out actions based on what number range is rolled.
eg. 26 is rolled, and that falls into a range that i wish to set as from 20 to 30. is there some way to write a if statement like #if (@dice >19 <31) {do whatever}....?
id like to use just the one dice if possible and break it into ranges of numbers, with the ranges or numbers not necessarily being the same size. Maybe theres a simple programming convention that im not aware of cause i cant seem to achieve what seems to me to be a fairly simple objective. I'd appreciate some help, tnx for your time.
Reply with quote
dacheeba
Adept


Joined: 29 Oct 2001
Posts: 250

PostPosted: Thu May 16, 2002 4:33 am   
 
#TR {Dice 1 ~: (%d).} {#IF (%1>0 AND %1<=19) {do stuff if true} {do stuff if false/optional};#IF (%1>=20 AND %1<=30) {do something else};#IF (%1>=31 AND %1<=50) {do something else, yet again};etc....}

Get the idea?
Reply with quote
iljhar
GURU


Joined: 10 Oct 2000
Posts: 1116
Location: USA

PostPosted: Thu May 16, 2002 4:34 am   
 
You can try something like this:



#trigger {You roll a (%d).} {
#if (%1>=90) {#echo between 90 and 100} {
#if (%1>=80) {#echo between 80 and 89} {
#if (%1>=70) {#echo between 70 and 79} {
#if (%1>=60) {#echo between 60 and 69} {
#if (%1>=50) {#echo between 50 and 59} {
#if (%1>=40) {#echo between 40 and 49} {
#if (%1>=30) {#echo between 30 and 39} {
#if (%1>=20) {#echo between 20 and 29} {
#if (%1>=10) {#echo between 10 and 19} {
#echo between 0 and 9
}
}
}
}
}
}
}
}
}
}


Is that what you were looking for?

Iljhar
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