EOS Help

All about the past, current and future webteases and the art of webteasing in general.
---
Post Reply
subm13
Explorer
Explorer
Posts: 20
Joined: Mon Apr 13, 2020 8:05 am

EOS Help

Post by subm13 »

I want to make a coin toss using the IF statement tool on eos. It's not calling variables or functions I make in any evals, and the things I make in the if statement are only outputting a single result. It also doesn't help that I suck at coding java-script/coding in general. If anyone here can help/write up a line of java for me I would really appreciate it :-) .

Also on a side note, this is my first day signed up here, so nice to meet you all :wave:
User avatar
Shattered
Experimentor
Experimentor
Posts: 1391
Joined: Fri Jan 11, 2013 6:41 pm
I am a: Switch
Location: United Kingdom

Re: EOS Help

Post by Shattered »

Maybe an easier way for you with no coding required:

if you put * after a page name on a goto, itll go to a random apge with that name.

so if we made

cointossheads

and

cointosstails

as pages, then went

goto -> cointoss*

it would go to a random cointoss result!

If you want a lot of coin tosses might not be great but thats a simple way.
subm13
Explorer
Explorer
Posts: 20
Joined: Mon Apr 13, 2020 8:05 am

Re: EOS Help

Post by subm13 »

I am doing a lot of coin tosses, but I think I might have to roll with that :-/

Thanks sm :yes:
Roblsforbobls
Explorer At Heart
Explorer At Heart
Posts: 272
Joined: Tue May 21, 2019 2:27 am
Gender: Male
Sexual Orientation: Asexual
I am a: Switch

Re: EOS Help

Post by Roblsforbobls »

subm13 wrote: Tue Apr 14, 2020 5:03 am I am doing a lot of coin tosses, but I think I might have to roll with that :-/

Thanks sm :yes:
Hi subm13,

Anytime I need to generate a random number, I copy-paste this into an eval action:

Code: Select all

var myNumber = Math.floor((Math.random() * 20) + 1);
console.log('The number is %s', myNumber)
This generates a random number from 1 to 20, and stores the number in the variable "myNumber". Feel free to change the variable name or numbers to suit your needs!
For a coin toss I suggest using 1 = heads and 2 = tails.
When using if actions, make sure to use 2 or 3 equals signs (I usually just do 3). Ex:

Code: Select all

if:
myNumber === 1
then:
Say: "Heads!"
If your if statement only has 1 equals sign, instead of checking to see if your variable is 1, for ex, it will just set the variable equal to 1. That's why I think you're only getting one output from your if statements.

One last trick I use all the time:

Code: Select all

CurrentPage = pages.getCurrentPageId();
This sets the ID of the page you are currently on to the variable "CurrentPage". You can use a GoTo action with that variable as the target to return to whatever the variable is set too. Super useful!

Learning Eos takes time and there are a lot of tricks and kinks that you learn through practice and experimenting. The forums have a lot of good QandA bout Eos - that's where a lot of us coding newbies learned some basics. I recommend checking out the eos tutorial and the coding APIs in there too. It'll get easier to use as you go! I hope this helps, and welcome to the community! :-D
undeniable_denial
Explorer At Heart
Explorer At Heart
Posts: 109
Joined: Sat Aug 24, 2019 11:42 am
Gender: Male
Location: Germany

Re: EOS Help

Post by undeniable_denial »

I completely agree with the previous answers, but since you are
subm13 wrote: Tue Apr 14, 2020 5:03 am doing a lot of coin tosses
I thought you might be interested in a compact alternative. Stick this into an if:

Code: Select all

Math.random()<.5
subm13
Explorer
Explorer
Posts: 20
Joined: Mon Apr 13, 2020 8:05 am

Re: EOS Help

Post by subm13 »

If your if statement only has 1 equals sign, instead of checking to see if your variable is 1, for ex, it will just set the variable equal to 1. That's why I think you're only getting one output from your if statements.

Ah that makes a lot of sense, I was making that mistake a lot. I decided to roll with the suggestion made by the other guy, but that you so much for the in-depth response, I'm sure it'll be super helpful with anything I try to make in the future/if I decide to revamp the one I already made. :-D
subm13
Explorer
Explorer
Posts: 20
Joined: Mon Apr 13, 2020 8:05 am

Re: EOS Help

Post by subm13 »

undeniable_denial wrote: Tue Apr 14, 2020 11:05 am I completely agree with the previous answers, but since you are
subm13 wrote: Tue Apr 14, 2020 5:03 am doing a lot of coin tosses
I thought you might be interested in a compact alternative. Stick this into an if:

Code: Select all

Math.random()<.5
Thanks sm, honestly the more compact and simple the better for me. I might try this as well.
Post Reply