Discuss Scratch

CT-7569
Scratcher
100+ posts

More Cloning Features

Many games have enemy-to-enemy collisions and other similar things, and they are extremely hard to recreate in Scratch because it doesn't have a few cloning features. This suggestion is for a clone index and counter, and a few more clone-related blocks, to make it easier to make such projects.
  1. Built-In Clone Index and Counter

    A clone index would be a variable local to each clone of a sprite. The actual sprite would have a clone index of 0, and all the clones would have a clone index increasing by 1 depending on the order of creation, i.e. the original sprite would have a clone index of 0, the first clone created would have a clone index of 1, the second a clone index of 2, and so on. It would be in the “Sensing” category, and it would look like this:
    clone index :: control reporter

    A clone counter would report the number of clones created by a particular sprite, so if Sprite A had cloned 8 times, its clone counter variable would report 8, and if Sprite B had cloned twice, its clone counter would report 2. It would look like this:
    clone count :: control reporter

  2. Modify ([…] of [sprite]) block for clones
    This would look like this:
    [... v] of clone index (0) of [sprite v] :: sensing reporter
    This would work as the currently existing block, but it would also include sensing for clones. You can use a clone index of 0 to get information about the original sprite.

  3. Modify the <touching > block for clones
    This would look like this:
    touching clone index (0) of [sprite v] ? :: sensing boolean
    This would function the same as before and would include sensing for clones. As in suggested block #2, using a clone index of 0 would check for the original sprite.

  4. Modify the (distance to [sprite]) block
    This would look like this:
    distance to clone index (0) of [sprite v] :: sensing reporter
    It would function the same , and the modifications work the same way as in block #2 and #3.

  5. Modify these three motion blocks
    Pretty self-explanatory by now.
    point towards clone index (0) of [sprite v] :: motion

    go to clone index (0) of [sprite v] :: motion

    glide (1) secs to clone index (0) of [sprite v] :: motion

If this would be too complicated for New Scratchers, it should probably be an extension, as suggested by @Yellowsheep43.

Please reply with your ideas and suggestions.

Last edited by CT-7569 (Oct. 27, 2022 15:38:38)

Yellowsheep43
Scratcher
1000+ posts

More Cloning Features

I think clone indexes should be added as an extension, since I'm not sure if new scratchers would understand them
qwerty_wasd_gone
Scratcher
1000+ posts

More Cloning Features

Support! This is needed by lots of people!
hi875230163394
Scratcher
1000+ posts

More Cloning Features

Yellowsheep43 wrote:

I think clone indexes should be added as an extension, since I'm not sure if new scratchers would understand them
Alternatively, it could be changed to “clone number”
RED-001-alt
Scratcher
1000+ posts

More Cloning Features

These can all be worked around with variables.

Clone index and counter:
when green flag clicked
set [clone id v] to [0]
repeat (5)
create clone of [myself v]
change [clone id v] by [1]
end
when I start as a clone
forever
if <(clone id) = [1]> then
...
end
...
end

Why would you want to change the clone ID?

I can't think of a simple workaround for the rest of the blocks, I think they should be added. But I mean there wouldn't be a use for them really

Last edited by RED-001-alt (Oct. 14, 2022 19:11:12)

CST1229
Scratcher
1000+ posts

More Cloning Features

I think clone indexes should be an extension of the sprite naming system used in blocks:

// each clone has a unique id associated with it, like Sprite1#1, Sprite1#2, etc...
// Sprite1#0 refers specifically to the original sprite in things like touching blocks,
// unlike Sprite1 which would refer to both Sprite1 and its clones
// the editor would probably block names that end with #[number], like
// it already does with _mouse_, _stage_, _myself_ and _random_

// blocks added:
(clone (1) of [Sprite1 v] :: control) // returns Sprite1#[id of nth clone created that currently exists]
([first v] clone of [Sprite1 v] :: control) // returns Sprite1#[id of first clone created that exists]. options: first, last, random
(number of clones of [Sprite1 v] :: control)

// if the sprite has no clones, the above 2 blocks would return empty strings


// a sprite name with its clone id can be substituted for a sprite name in blocks:

go to (clone (1) of [Sprite1 v] :: control)

create clone of (clone (1) of [Sprite1 v] :: control) // creates a clone with that clone's sprite, position and properties
([x position v] of (clone (1) of [Sprite1 v] :: control))
<touching (clone (1) of [Sprite1 v] :: control)?>

Last edited by CST1229 (Oct. 14, 2022 19:08:18)

CT-7569
Scratcher
100+ posts

More Cloning Features

iBump
-Valtren-
Scratcher
1000+ posts

More Cloning Features

Euglena73
Scratcher
1000+ posts

More Cloning Features

I think it's kinda a duplicate…
TheSecondGilbert
Scratcher
100+ posts

More Cloning Features

Here's a question though:
Given this code on sprite Sprite1:
when green flag clicked
repeat (3)
create clone of [myself v]
end
wait (2) secs
say (join <touching clone index (1) of [Sprite1 v] :: sensing> <touching clone index (3) of [Sprite1 v] :: sensing>)

when I start as a clone
wait (clone index :: sensing reporter) secs
delete this clone
What would the sprite say?
CT-7569
Scratcher
100+ posts

More Cloning Features

TheSecondGilbert wrote:

Here's a question though:
Given this code on sprite Sprite1:
when green flag clicked
repeat (3)
create clone of [myself v]
end
wait (2) secs
say (join <touching clone index (1) of [Sprite1 v] :: sensing> <touching clone index (3) of [Sprite1 v] :: sensing>)

when I start as a clone
wait (clone index :: sensing reporter) secs
delete this clone
What would the sprite say?
It would say “falsetrue”.

-Valtren- wrote:

dupe?

Euglena73 wrote:

I think it's kinda a duplicate…
No, the blocks I suggested are different from the blocks suggested in the linked topic.

Last edited by CT-7569 (Oct. 16, 2022 12:16:00)

TheSecondGilbert
Scratcher
100+ posts

More Cloning Features

CT-7569 wrote:

TheSecondGilbert wrote:

Here's a question though:
Given this code on sprite Sprite1:
when green flag clicked
repeat (3)
create clone of [myself v]
end
wait (2) secs
say (join <touching clone index (1) of [Sprite1 v] :: sensing> <touching clone index (3) of [Sprite1 v] :: sensing>)

when I start as a clone
wait (clone index :: sensing reporter) secs
delete this clone
What would the sprite say?
It would say “falsetrue”.

Do new-created clones use vacant clone slots? For example, when clone #1 is deleted while there's still clone #2 as the most recent clone, if I create a new clone here, will it become the 1st clone or the 3rd clone?
-ErrorPurpl_157
Scratcher
100+ posts

More Cloning Features

CST1229 wrote:

I think clone indexes should be an extension of the sprite naming system used in blocks:

// each clone has a unique id associated with it, like Sprite1#1, Sprite1#2, etc...
// Sprite1#0 refers specifically to the original sprite in things like touching blocks,
// unlike Sprite1 which would refer to both Sprite1 and its clones
// the editor would probably block names that end with #[number], like
// it already does with _mouse_, _stage_, _myself_ and _random_

// blocks added:
(clone (1) of [Sprite1 v] :: control) // returns Sprite1#[id of nth clone created that currently exists]
([first v] clone of [Sprite1 v] :: control) // returns Sprite1#[id of first clone created that exists]. options: first, last, random
(number of clones of [Sprite1 v] :: control)

// if the sprite has no clones, the above 2 blocks would return empty strings


// a sprite name with its clone id can be substituted for a sprite name in blocks:

go to (clone (1) of [Sprite1 v] :: control)

create clone of (clone (1) of [Sprite1 v] :: control) // creates a clone with that clone's sprite, position and properties
([x position v] of (clone (1) of [Sprite1 v] :: control))
<touching (clone (1) of [Sprite1 v] :: control)?>
The second block has a workaround using the first block
CST1229
Scratcher
1000+ posts

More Cloning Features

-ErrorPurpl_157 wrote:

The second block has a workaround using the first block
I was thinking there would be a random and last option too, which specifically choose from existing clones (as opposed to all clone IDs, which might choose a clone ID that no longer exists).
CT-7569
Scratcher
100+ posts

More Cloning Features

TheSecondGilbert wrote:

CT-7569 wrote:

TheSecondGilbert wrote:

Here's a question though:
Given this code on sprite Sprite1:
when green flag clicked
repeat (3)
create clone of [myself v]
end
wait (2) secs
say (join <touching clone index (1) of [Sprite1 v] :: sensing> <touching clone index (3) of [Sprite1 v] :: sensing>)

when I start as a clone
wait (clone index :: sensing reporter) secs
delete this clone
What would the sprite say?
It would say “falsetrue”.

Do new-created clones use vacant clone slots? For example, when clone #1 is deleted while there's still clone #2 as the most recent clone, if I create a new clone here, will it become the 1st clone or the 3rd clone?
It would be the 3rd clone.
Very_Interesting_Bid
Scratcher
500+ posts

More Cloning Features

support.
CT-7569
Scratcher
100+ posts

More Cloning Features

bump
CT-7569
Scratcher
100+ posts

More Cloning Features

bump
CT-7569
Scratcher
100+ posts

More Cloning Features

bump
gem1001
Scratcher
100+ posts

More Cloning Features

support

Powered by DjangoBB