I'm trying to have it pick a random coordinate between two different ranges... but instead it always moves to the top left, am I typing this wrong? Like I'm pretty sure I made this and or statement.
Maybe. Usually you use that operator as a condition. If you want to set position to two possible values then use a condition to give two options like if A else B then set the position.
...but I want this to be caused by a whole 1 thing... I'm 100% certain there's a way of typing it. I just think I used the wrong symbol or the wrong function.
You proably did, but I'm no master coder so...
As noted in the manual, the | operator is logical OR. An expression of the form A | B will only ever return 1 or 0 (for true or false). This isn't very good for setting a position! I'm not sure what your actual intent is, but you are probably thinking the operator is doing something it doesn't.
|
A | B
Yeah as Ashley noted you are misunderstanding what the OR operator does. Here's a solution that (I think) should do what you intend it to do.
Player.X+random(64,150)*choose(-1,1)
EDIT: I should add that technically my solution isn't the "best" one since it requires a multiplication. I'd go with the one XHXIAIEIN posted:
Player.X + choose(random(-150, -64), random(64, 150))
Develop games in your browser. Powerful, performant & highly capable.
There are a few ways to do it:
1. expression choose()
choose()
2. ternary operator condition ? True : False
condition ? True : False
Player.X + random(1) > 0.5 ? random(-150, -64) : random(64, 150)
and Use this method by WackyToaster better
Player.X + random(64,150) * choose(-1,1)