Multiple conditions in an if/then

Post all technical issues and questions here. We'll gladly help you wherever we can.
Post Reply
User avatar
ritewriter
Explorer At Heart
Explorer At Heart
Posts: 325
Joined: Sun Jan 02, 2022 6:51 am
Gender: Male
Sexual Orientation: Open to new ideas!
I am a: Switch
Contact:

Multiple conditions in an if/then

Post by ritewriter »

Is there anyway to create an 'or' type statement in an if/then?

I currently have a lot of if/then that check a random number against a variable called will then checks if rand>will, but I'd also like to have the same statements work if rand==10.

Is there a way to do:

IF rand>will OR rand==10
THEN Condition A
ELSE Condition B

Currently the only way I could figure out was...

IF rand==10
THEN Condition A
ELSE IF rand>will
THEN Condition A
ELSE Condition B

But that's messy and it requires extensively rewriting every will check. It would be much easier if I could just rewrite the actual IF line. Any suggestions?
User avatar
computergeek
Explorer At Heart
Explorer At Heart
Posts: 133
Joined: Sat Jul 14, 2012 11:59 am
Gender: Male
Sexual Orientation: Straight
I am a: Master
Contact:

Re: Multiple conditions in an if/then

Post by computergeek »

A lot of times if needed I will forgo the else for a chain of if statements:

x = rnd * 100

if x < 10 then ...
if x < 20 then ...
if x < 30 then ...
if x < 40 then ...
if x < 50 then ...
if x < 60 then ...
if x < 70 then ...
if x < 80 then ...
if x < 90 then ...

Most languages will default to the closest fit, just a little slow on the clock ticks. Otherwise you need to put maximums in the statements such as

if x < 10 && x > 19 then ...
if x < 20 && x > 29 then ...
if x < 30 && x > 39 then ...
if x < 40 && x > 49 then ...
if x < 50 && x > 59 then ...
if x < 60 && x > 69 then ...
if x < 70 && x > 79 then ...
if x < 80 && x > 89 then ...
if x < 90 && x > 100 then ...
Thamrill
Explorer At Heart
Explorer At Heart
Posts: 265
Joined: Thu Jan 03, 2013 4:55 pm
Gender: Male
Sexual Orientation: Straight
I am a: Submissive

Re: Multiple conditions in an if/then

Post by Thamrill »

ritewriter wrote: Wed Sep 28, 2022 11:58 pm Is there anyway to create an 'or' type statement in an if/then?

I currently have a lot of if/then that check a random number against a variable called will then checks if rand>will, but I'd also like to have the same statements work if rand==10.

Is there a way to do:

IF rand>will OR rand==10
THEN Condition A
ELSE Condition B

Currently the only way I could figure out was...

IF rand==10
THEN Condition A
ELSE IF rand>will
THEN Condition A
ELSE Condition B

But that's messy and it requires extensively rewriting every will check. It would be much easier if I could just rewrite the actual IF line. Any suggestions?
I *think*

IF (rand==10)||(rand>will)

should do the trick
Image

Image

Image
User avatar
ritewriter
Explorer At Heart
Explorer At Heart
Posts: 325
Joined: Sun Jan 02, 2022 6:51 am
Gender: Male
Sexual Orientation: Open to new ideas!
I am a: Switch
Contact:

Re: Multiple conditions in an if/then

Post by ritewriter »

Thamrill wrote: Thu Sep 29, 2022 4:53 am
I *think*

IF (rand==10)||(rand>will)

should do the trick
Thank you! I’ll give that a try.

UPDATE: Works great!
Post Reply

Who is online

Users browsing this forum: No registered users and 18 guests