[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vr / w / wg] [i / ic] [r9k / s4s / vip / qa] [cm / hm / lgbt / y] [3 / aco / adv / an / asp / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / qst / sci / soc / sp / tg / toy / trv / tv / vp / wsg / wsr / x] [Settings] [Search] [Home]
Settings Home
/wsr/ - Worksafe Requests

Thread archived.
You cannot reply anymore.

File: Screenshot (2).png (227 KB, 1920x1080)
227 KB
227 KB PNG
>Backstory: 18 in HS taking my first CompSci class. Currently working in a website called Code.org where we get really nice hands-on training with simple JS coding.
So i've got this code where the built in turtle moves, and the icon is constantly moving with it. However i want to make it so that it will stop when the mouse moves over it. I've tried a For Loop solution, but that didn't work. So now I've got this:
var x;

x = 0;
//Fast Movement Until Mouse Touches Icon
function MoveFast(){
while (x <1){

//if ("image1", "mouseover") x = 2; DOESN'T WORKK FUUUUU
if ("image1", "mouseover") x =2;
The issue is that the turtle (and icon) will only move once, then the program ends as if it's completed.
I'm fairly certain it's a syntax thing with if ("image1", "mouseover") x =2;
And so my guess is that i messed that up and so it always thinks that x =2 when it reaches that line and isn't listening for the condition.
Any ideas?
A non-empty string is a truthy value, so "image1" == true, and "mouseover" == true as well. Your if statement just reads `if (true, true)`, so x will always be set to 2.

You have onEvent with the same strings at the bottom of your screenshot, so that's probably confusing you. I don't really know how you want either of these two to work, so I can't give more explanation there.

You should be using `if (valueOne or valueTwo)` instead of a comma if you're trying to check two values. Are you trying to run that event with that if statement? I don't know the syntax for python events, but it doesn't look like you're even returning a value from that event. If you are trying to trigger the event, that doesn't look like the right way to do it; there's another method you need to use to trigger it.
I though you mentioned python, not javascript, my bad. The if should be `valueOne || valueTwo`
Thanks. I'm at work right now, so I'll give it a go when I get home.

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.