Discuss Scratch

ZeroDeathYTL
New Scratcher
2 posts

increase number of clones by one every 5 broadcasts

I made a project (https://scratch.mit.edu/projects/554003830/editor/) and i want to make clones increase once every 5 enemy deaths (5 broadcasts)…Can someone please help me?

Note:please dont blame my bad quality project i am new to scratch and i made this in 30 mins
heres the code i used
when I receive [dead v]
go to [random position v]
change [citizens v] by (1)
create clone of [myself v]
if <[citizens] > [30]> then
change [citizens v] by (1)
delete this clone

end

Last edited by ZeroDeathYTL (July 18, 2021 18:48:13)

Thingied
Scratcher
1000+ posts

increase number of clones by one every 5 broadcasts

Variables needed:
  • clone? (local/for this sprite only)
  • counter (doesn't matter)
Steps:
  1. Setting it up
    Reset the two new variables when the green flag is clicked. If you don't reset them some things might get messed up. Also, you only need one of the hat blocks to reset everything. Having two just makes things more confusing


  2. Clones
    After receiving the “dead” message, the sprite should go to a random position and clone itself. The thing is that we only want the parent (the main sprite) to clone, not the children (the clones). The best way that I know of is to set a variable to be something, and if that variable is not that, do something.

    Going to perform two checks to see if it should run the clone script. The first one checks to see if the amount citizens has reached the cap and the next one is to check to see if it's the parent that's receiving the message.

    Next we have to add the actual thing that's going to clone. Create a new custom block that's like this

    and put this script under it:

    Lastly, put the custom block under the clone? = 0 if statement and put a 5 in the white blank.

    (change the 5 to be something different if you don't want a clone every 5 deaths. Number = 6 = New citizen every 6 deaths)
Basically, we're using the () mod () block to determine if counter is a multiple of 5 and if it is create a clone.

Last edited by Thingied (July 18, 2021 19:09:44)

The_Imaginarium
Scratcher
1000+ posts

increase number of clones by one every 5 broadcasts

To make a clone every 5 broadcasts modify the following code to fit your need:
when green flag clicked
set [variable v] to [0]

when I receive [Broadcast v]
change [variable v] by (1)
if <((variable) mod (5)) = [0]> then // if variable is divisible by 5
create clone of [myself v]
end
ZeroDeathYTL
New Scratcher
2 posts

increase number of clones by one every 5 broadcasts

Thank you good people for the help!

Powered by DjangoBB