CLEO Help [HELP] A way to set non random float ranges on variables?

CLEO related
Status
Not open for further replies.

MaryKate

Active member
Joined
Feb 7, 2014
Messages
28
Reaction score
0
I'm making a cleo and I've added a speed up and slow down button that basically add + or - 1.0 to a variable when a key is pressed like so
Code:
wait 0
if 
key_pressed 1
jf @thread_whatever
1@ += 1.0

and it works fine but i want to set a limit, Is there a way i can set it so a variable has a range and it doesn't go higher or lower than certain numbers for example no lower than 1.0 or higher than 10.0, the only opcode i've seen makes the variable a random number between a range of your choosing which isn't useful.

ive tried

Code:
wait 0
if 
1@ == 10.0
jump @Thread_whatever
if 
key_pressed 1
jf @thread_whatever
1@ += 1.0

in hopes it will jump past the speed up command once the variable reaches 10.0 but when i add that it makes the function not work all together

any help will be appreciated
 

T3KTONIT

Well-known member
Joined
Sep 2, 2013
Messages
308
Reaction score
5
if you want a random number between 1.0 and 10.0 then :
Code:
0208: 2@ = random_float_in_ranges 1.0 10.0   //between 0.0 and 9.0 ==> 0.0 < 2@ < 9.0
there you go... 2@ is now a number between 1 and 10.0

if you want to check if 2@ doesn't go over 10.0 or below 1.0 (variable range limit as you called it...)

Code:
if
2@ == 1.0 // i suppose you're adding 1.0 and decreasing 1.0 everytime you press the button
 jump @whaev
if
2@ == 10.0 
 jump @whaev

//code here for your speed thing...

:whatev
message("out of range !")
nop
jump @originalthread
 
Status
Not open for further replies.
Top