Page 1 of 1
EOS Help
Posted: Mon Apr 13, 2020 11:27 am
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

Re: EOS Help
Posted: Mon Apr 13, 2020 11:39 am
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.
Re: EOS Help
Posted: Tue Apr 14, 2020 5:03 am
by subm13
I am doing a lot of coin tosses, but I think I might have to roll with that
Thanks sm

Re: EOS Help
Posted: Tue Apr 14, 2020 9:47 am
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
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!

Re: EOS Help
Posted: Tue Apr 14, 2020 11:05 am
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:
Re: EOS Help
Posted: Wed Apr 15, 2020 12:56 am
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.

Re: EOS Help
Posted: Wed Apr 15, 2020 12:57 am
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:
Thanks sm, honestly the more compact and simple the better for me. I might try this as well.