Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » anyone know a workaround for a 'go to <colour> block'?
- Woody00060
- Scratcher
21 posts
anyone know a workaround for a 'go to <colour> block'?
i am trying to make a sort of limbs kinda thing but i have absolutely no idea how get my second clone to got to my first's top. so i added a darker colour at the top of the second clone but the script i have now:
anyone know a workaround for
repeat until <<touching color [#816212] ?> and <not <touching color [#816212] ?>>>doesnt really work.
go to [random position v]
end
anyone know a workaround for
go to [ <colour>]
- The_Imaginarium
- Scratcher
1000+ posts
anyone know a workaround for a 'go to <colour> block'?
There is no block for that.
You could do what you did, just put it in a function and run it without screen refresh.
You could do what you did, just put it in a function and run it without screen refresh.
define go to color
//run without screen refresh
repeat until <touching color(color :: #969696) ?>
go to [random position v]
end
- Woody00060
- Scratcher
21 posts
anyone know a workaround for a 'go to <colour> block'?
thx
tysm that worked rlly good!
There is no block for that.
You could do what you did, just put it in a function and run it without screen refresh.define go to color
//run without screen refresh
repeat until <touching color(color :: #969696) ?>
go to [random position v]
end
tysm that worked rlly good!
- CST1229
- Scratcher
1000+ posts
anyone know a workaround for a 'go to <colour> block'?
If you want it to go to the first occurrence thxand be efficient, do this with a 1 pixel costume with a transparent shape around it to make it go offscreen:snip
tysm that worked rlly good!
define go to color (color)note: untested
go to x: (-240) y: (180)
repeat until <touching color (color)?>
change x by (1)
if <(x position) > (240)> then
change y by (-1)
set x to (-240)
end
if <(y position) < (-180)> then // failsafe
go to x: (0) y: (0)
stop [this script v]
end
end
This is a signature. It's a piece of text that appears below every post I write. Click here to learn more, including how to make your own.
RIP assets image hosting. 2013?-2023
RIP assets image hosting. 2013?-2023
- TheWarhawk2005
- Scratcher
100+ posts
anyone know a workaround for a 'go to <colour> block'?
There is no block for that.
You could do what you did, just put it in a function and run it without screen refresh.define go to color
//run without screen refresh
repeat until <touching color(color :: #969696) ?>
go to [random position v]
end
Like @The_Imaginarium said, there's no good way of doing this. This script will work in theory, but depending on the size of your color splotch, the sprite could go pretty much anywhere on the stage, as long as it was touching the color. Also, I wouldn't use this in a big game; depending on how you use it a No Screen Refresh repeating constantly like that could wreak havoc on your game's playability due to lag.
I'd suggest using lists or variables to store data. <color> blocks are hard to work with at best, and buggy at worst (different OSs show colors differently).
If I helped you at all, please consider following me and checking out my projects!
- TheWarhawk2005
- Scratcher
100+ posts
anyone know a workaround for a 'go to <colour> block'?
Looking closer at your problem, I'd suggest a different approach. The fix to about EVERY kind of clone problem is to just give each clone it's own ID.
Give clones IDs by doing this:
That lets you move each clone to it's own position and do it's own stuff.
Give clones IDs by doing this:
when green flag clicked
set [cloneID v] to [0]//for this sprite only
repeat [10]//number of clones here
change [cloneID v] by (1)
create clone of [myself v]
...
end
when I start as a clone
if <(cloneID) = [1]> then
go to x[] y[]
end
if <(cloneID) = [2]> then//you could use "else" blocks, but just "if" is easier to read and edit.
go to x[] y[]
end
...
That lets you move each clone to it's own position and do it's own stuff.
If I helped you at all, please consider following me and checking out my projects!
- Discussion Forums
- » Help with Scripts
- » anyone know a workaround for a 'go to <colour> block'?