EOS If clause question

Webteases are great, but what if you're in the mood for a slightly more immersive experience? Chat about Tease AI and other offline tease software.

Moderator: 1885

Post Reply
sirveillance
Explorer
Explorer
Posts: 17
Joined: Mon Oct 31, 2011 1:25 pm

EOS If clause question

Post by sirveillance »

Hello EOS Developers.

I want to show an image from a gallery, with different galleries to chose from. the shall have different propabilites to be chosen.

so i generate a random number between 1 and 10 in an eval:

Code: Select all

n = Math.floor((Math.random() * 10) + 1)
then i have a switch for that in an eval:

Code: Select all

switch(n) {   
case 1: 
case 2: 
case 3: str = 10; strokes = strokes + 10; break;
case 4: str = 15; strokes = strokes + 15; break;
case 5:
case 6:
case 7: str = 20; strokes = strokes + 20; break;
case 8:
case 9:  str = 25; strokes = strokes + 25; break;
case 10: str = 50; strokes = strokes + 50; break; 
default: str = 1; strokes = strokes + 1;
} 
which basically sets str to a number for a category and adds to the stroke counter.
up to here everything works well.

Next, i use the IF Clause in EOS.

IF:

Code: Select all

str = 50
Actions:
Show a random image from gallery number 50
Goto next page

IF

Code: Select all

str = 25
Actions:
Show a random image from gallery number 25
goto next page

.... and so on.

The variables work as they should. But the images don't.

I have 5 IF clauses on the page but always the last image from the last clause is shown, even if variable STR is not matching the IF sentence.

Image

Any Ideas what i do wrong?
Roblsforbobls
Explorer At Heart
Explorer At Heart
Posts: 264
Joined: Tue May 21, 2019 2:27 am
Gender: Male
Sexual Orientation: Asexual
I am a: Switch

Re: EOS If clause question

Post by Roblsforbobls »

Most of your other code went over my head since I am very new to java. However, from past experience I've found that when using If statements you need to use 3 equals signs (maybe 2 works as well). If you use 1 equals sign, the if statement will act as an eval and change your variable. Try it out for yourself:

EVAL:

Code: Select all

A = 0
SAY: A = <A>
(says "A = 0")

IF:

Code: Select all

A = 1
ACTION: GOTO page 1
(goes to page 1)

SAY: A = <A>
(says "A = 1")

The second SAY will show that the variable A has been changed by the IF statement from 0 to 1. However, if the IF statement was:

Code: Select all

A === 1
the variable will remain 0 and your code will work as intended. Hopefully this makes sense/helps!
sirveillance
Explorer
Explorer
Posts: 17
Joined: Mon Oct 31, 2011 1:25 pm

Re: EOS If clause question

Post by sirveillance »

aw. you are right. i have no experience with javascript, so that caught me offguard.

for the record:

equal to is ==
euqal to and same type is ===
not equal to is !=
not equal to and not the same type is !==
Roblsforbobls
Explorer At Heart
Explorer At Heart
Posts: 264
Joined: Tue May 21, 2019 2:27 am
Gender: Male
Sexual Orientation: Asexual
I am a: Switch

Re: EOS If clause question

Post by Roblsforbobls »

Interesting, thanks for the info! Does a regular = mean anything special?
sirveillance
Explorer
Explorer
Posts: 17
Joined: Mon Oct 31, 2011 1:25 pm

Re: EOS If clause question

Post by sirveillance »

it is used to set a value, as in
variable = 1 // which sets variable to one.
sirveillance
Explorer
Explorer
Posts: 17
Joined: Mon Oct 31, 2011 1:25 pm

Re: EOS If clause question

Post by sirveillance »

i have another question about the notification module here: viewtopic.php?f=4&p=265524#p265524
Post Reply

Who is online

Users browsing this forum: No registered users and 47 guests