Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How do you create a sensor using grid coordinates?
- I305Evan
- Scratcher
16 posts
How do you create a sensor using grid coordinates?
As you can see with my my Drop Tower simulator on my page (which still isn't complete) I use a ton of characters that act like a “sensor.” When the ride vehicle reaches it, it will then begin slowing down/ come to a stop.
Well that process is very nit-picky because each sensor is roughly 1px in size and when I need to adjust where it is placed, I can't really do so. So I'm wondering it you can use grid coordinates to act as an “invisible sensor” to say. I have a new script set up, but when my ride vehicle reaches that point, it just continues going instead of stopping. Here is the script I'm using:
This script is used to raise the ‘catch car’
Now when I'm holding the down arrow, it goes down but doesn't stop when it reaches y: -177 and the same when it goes up. I press and hold the up arrow, but it doesn't stop when it reaches y: 84.
Well that process is very nit-picky because each sensor is roughly 1px in size and when I need to adjust where it is placed, I can't really do so. So I'm wondering it you can use grid coordinates to act as an “invisible sensor” to say. I have a new script set up, but when my ride vehicle reaches that point, it just continues going instead of stopping. Here is the script I'm using:
This script is used to raise the ‘catch car’
when [up arrow] key pressedAnd this one is to lower it
repeat until <(y position) = [84]>
if <key [up arrow] pressed?>
change y by (.3)
when [down arrow] key pressed
repeat until <(y position) = [-177]>
if <key [down arrow] pressed?>
change y by (-.3)
Now when I'm holding the down arrow, it goes down but doesn't stop when it reaches y: -177 and the same when it goes up. I press and hold the up arrow, but it doesn't stop when it reaches y: 84.
- karmanhof
- Scratcher
41 posts
How do you create a sensor using grid coordinates?
The problem could be that because you change the y value with 0.3 y will not become exact 84 (or-177). You might try a range (between 84 and 85) in the repeat statement.
- turkey3_test
- Scratcher
1000+ posts
How do you create a sensor using grid coordinates?
See Snap to Grid and Implementing Grids for any possible help.
- scubajerry
- Scratcher
1000+ posts
How do you create a sensor using grid coordinates?
Karmanhof is correct. The other choice is to round xposition before comparing.
As you can see with my my Drop Tower simulator on my page (which still isn't complete) I use a ton of characters that act like a “sensor.” When the ride vehicle reaches it, it will then begin slowing down/ come to a stop.
Well that process is very nit-picky because each sensor is roughly 1px in size and when I need to adjust where it is placed, I can't really do so. So I'm wondering it you can use grid coordinates to act as an “invisible sensor” to say. I have a new script set up, but when my ride vehicle reaches that point, it just continues going instead of stopping. Here is the script I'm using:
This script is used to raise the ‘catch car’when [up arrow] key pressedAnd this one is to lower it
repeat until <(y position) = [84]>
if <key [up arrow] pressed?>
change y by (.3)when [down arrow] key pressed
repeat until <(round(y position)) = [-177]>
if <key [down arrow] pressed?>
change y by (-.3)
Now when I'm holding the down arrow, it goes down but doesn't stop when it reaches y: -177 and the same when it goes up. I press and hold the up arrow, but it doesn't stop when it reaches y: 84.
Last edited by scubajerry (Dec. 18, 2013 05:59:09)
- Discussion Forums
- » Help with Scripts
- » How do you create a sensor using grid coordinates?