Page 1 of 1
Eos code help
Posted: Wed Jul 24, 2019 11:47 pm
by BopIT
Hey Milovana.
I'm trying to get a prompt Q and A and Eos is not reading the correct answer.
Here is what I have:
Code: Select all
var v = 0;
Prompt
variable: blank
if
blank = "answer";
eval
++v
if
v = 1
say: correct
if
v=0
say: incorrect
As of now the code is not saying correct or incorrect. What did I do wrong?
Re: Eos code help
Posted: Thu Jul 25, 2019 7:07 am
by Roblsforbobls
Ok, as of right now I have it working properly.
Here's your problem:
- When working with if statements (the actions themselves) you have to use two equals signs. If you use one equals sign only (for example, v = 1) the if statement will act like an eval action and change your variable's value (to 1 in this example).
- When using an if statement comparing a variable to zero, you have to use three equals signs for some reason. I'm not knowledgeable about coding so I don't know why, but that's the way it is.
- I never had a problem of it giving neither correct nor incorrect; if you are seeing that, you might have a spelling error, because I followed exactly what you typed in your code here.
So here's how it looks for me:
Code: Select all
var v = 0
Prompt
variable: blank
if
blank == "answer"
eval
++v
if
v == 1
say: correct
if
v === 0
say: incorrect
When you are dealing with situations like this in the future where your page or code is not working and you aren't sure why, I suggest putting "Say" actions after every action. This will help you figure out which action is giving eos a hard time. For example, to figure out why your code wasn't working, I placed a "Say: v = <v>" followed by a number after every eval and at the beginning of every if statement. Depending on which numbers were displayed I was able to figure out what part of it was not working. I hope this helps! I am excited to see your tease when it comes out ~
