Topic Information

WHAT IS UP WITH FRACTALS[scratchblocks] by griefercube in Help With Scripts

Posts: 4

1: griefercube wrote at 3:38:36 AM 7/9/20204397220
I made a fractal generator but it crashed! Would anyone tell me the reason?
no screen refresh
define fractal(input)
set [numba v] to [0]
repeat until <(numba) = (input)>
point in direction (([360] / (input)) * (numba))
end
2: qrcool wrote at 3:59:23 AM 7/9/20204397250

griefercube wrote:

I made a fractal generator but it crashed! Would anyone tell me the reason?
no screen refresh
when flag clicked
fractal [input]

define fractal(input)
set [numba v] to [0]
repeat until <(numba) = (input)>
point in direction (([360] / (input)) * (numba))
move (size) steps
create clone of [myself v]
move (join (-) (size)) steps
end
stamp
hide
delete this clone

when I start as a clone
if <not<(size) < (5)>> then
fractal [input]

end
Fractals go on forever. Scratch can't handle that.
3: griefercube wrote at 4:01:11 AM 7/9/20204397254

qrcool wrote:

griefercube wrote:

I made a fractal generator but it crashed! Would anyone tell me the reason?
no screen refresh
when flag clicked
fractal [input]

define fractal(input)
set [numba v] to [0]
repeat until <(numba) = (input)>
point in direction (([360] / (input)) * (numba))
move (size) steps
create clone of [myself v]
move (join (-) (size)) steps
end
stamp
hide
delete this clone

when I start as a clone
if <not<(size) < (5)>> then
fractal [input]

end
Fractals go on forever. Scratch can't handle that.
I made sure that once it hits size = 5, it stops
4: deck26 wrote at 9:35:27 AM 7/9/20204397657
You never change numba so the repeat loop is creating clones endlessly. If you're going to code recursively you have to be absolutely sure to include a stopping system that will work!