Discuss Scratch

trolley_explodes
Scratcher
100+ posts

Some help with my project please?

Here's the code I have in it so far:
In the scanner sprite:
(INPUTTED CODE) // For all sprites.
(code)
(color)
(frame idx)
(starting in)
(x)
(y)
(@list COLORS:: list) // For all sprites.
(@list Code:: list) // For all sprites.
when gf clicked
Prepare:: custom blocks
say [Click when you're ready to record. Click again to stop the recording. Also, press W to import a code.]
wait until <mouse down?>
repeat (3)
say (starting in)
wait (1) seconds
change [starting in v] by (-1)
end
say []
broadcast (Ok to stop v)
repeat until <mouse down?>
Record Frame:: custom blocks
wait (0) seconds
end
when I receive [Stop v]
stop [other scripts in sprite v]
turn video (off v)
add [Your code is:] to [Code v]
add (code) to [Code v]
add [Triple click to copy.] to [Code v]
define Prepare
delete all of [COLORS v]
delete all of [Code v]
hide list [Code v]
turn video (on v)
set video transparency to (100)
set [frame idx v] to (1)
set [code v] to ()
set [starting in v] to (3)
define Record Frame
set [x v] to (-240)
set [y v] to (180)
go to x: (x) y: (y)
repeat until <not <(y) = (y position)>>
repeat until <not <(x) = (x position)>>
change [x v] by (1)
change x by (1)
Scan Color:: custom blocks
end
set [x v] to (-240)
set x to (-240)
change [y v] by (-1)
change y by (-1)
end
define Scan Color
set [color v] to (0)
repeat (32)
repeat (32)
repeat (16)
if <touching color (color)?> then
add (color) to [COLORS v]
Add to code:: custom blocks
stop [this script v]
end
change [color v] by (16)
end
change [color v] by (1792)
end
change [color v] by (458752)
end
define Add to code
if <(frame idx) = (1)> then
set [code v] to (item (frame idx) of [COLORS v])
else
if <((frame idx) mod (172800)) = (0)> then
set [code v] to (join (code) (join (-) (item (frame idx) of [COLORS v]))
else
set [code v] to (join (code) (join (:) (item (frame idx) of [COLORS v]))
end
end
change [frame idx v] by (1)
In the stage:
when I receive [Ok to stop v]
wait until <mouse down?>
broadcast (Stop v)
I can't figure out the code to break down the save code and I was hoping you guys could help with that.

Last edited by trolley_explodes (Yesterday 22:50:36)

minniesworld
Scratcher
100+ posts

Some help with my project please?

deck26
Scratcher
1000+ posts

Some help with my project please?

It's much easier for you and anyone helping if you share the project rather than duplicate scripts here with limited context and possible differences from your actual code.

Scanning the whole screen pixel by pixel for every colur is very inefficient and the custom block probably won't complete fast enough to allow it to run with the ‘no screen refresh’ option. A useful trick is to initially scan the whole screen using a full-screen size costume and build a list of the colours that are actually present. You can then scan pixel by pixel for that reduced list which is much faster.
minniesworld
Scratcher
100+ posts

Some help with my project please?

deck26 wrote:

It's much easier for you and anyone helping if you share the project rather than duplicate scripts here with limited context and possible differences from your actual code.

Scanning the whole screen pixel by pixel for every colur is very inefficient and the custom block probably won't complete fast enough to allow it to run with the ‘no screen refresh’ option. A useful trick is to initially scan the whole screen using a full-screen size costume and build a list of the colours that are actually present. You can then scan pixel by pixel for that reduced list which is much faster.
Ooh, smart! I will probably use that myself!

Last edited by minniesworld (Today 18:25:29)

Powered by DjangoBB