How to make clones do something? SOLVED

#1

(Sorry for making this, idk much about clones though)

So I’m making this project, and I’m trying to make the editor super compact, so I want to use clones for this.
But some clones will have to do stuff, so how do I make a clone do something like set a value to __, when, say, it’s tapped or something like that?

@ codehelp

11 Likes
How do you make an animated pixel art/moving trail art
#2

I know a lot about clones, so just give me a problem you need to solve and I could help.

3 Likes
#3

Ok thanks so much!!

2 Likes
#4

Could you be more specific?
gtg see you tomorrow

2 Likes
#5

Ok bye.

Anyways I need to make a clone set a value to 4, when the clone is tapped.

3 Likes
#6

I think someone could help you with that while I’m gone. Bye!

2 Likes
#7

Hi @tankt2016 I can help u

1 Like
#8

There is a Hopscotch Academy lesson on Clone ID I made, I will quickly get the link

1 Like
#9

Here is the link:

1 Like
#10

Clone Index allows you to control a clone individually. To use it just use
(Check once if (Clone Index) = (2 (for example)))
Whatever you want the clone to do.
);

1 Like
#11

BTW the original object is clone #1, the first clone is clone Index #2

2 Likes
#12

Thanks so much @TheDeliciousOrange, @HopscotchRemixer! Although how would I have the clone know when it’s been tapped, and do something?

1 Like
#13

(When (Self) (Is tapped)
(Check once if ((self) Clone Index = 2) (or whatever)
Insert Code here

1 Like
#14

Thanks so much! (You’re getting credit btw)

1 Like
#15

Oh thanks Tankt.

1 Like
#16


Why isn’t this working?
I know I did something wrong somewhere.
(The clones are supposed to be the options for the text colors, in the settings app. The original one is light gray.)

#17

You tried to use a created variable for clone index. While this is an option, the way you tried to use it does not work.
When clones were first added, it would result in the original object ID being 3, and all the clones being 1. Now, it results in the original object being 3, and the clones being 0.
This is because the clones no longer do the code after the block which creates them in the rule which creates them. So even if you correctly set up the ID in that way, it would no longer work.


Do you see why it wouldn’t have worked even if the clones were doing the set variable blocks?


While you could leave this rule as it is, and simply have the clones set their own value based off of the original object’s, that would not be the best way and would make bugs easier to create.
Hopscotch automatically counts the clones, in the clone index property. I’d recommend using that. So the new code would be three create a clone blocks, and replace all clone ID variables with clone index.


An important thing to remember is that clone ID starts at 1, so the original object has a clone ID of 1.


Another good use of clone ID would allow you to have only one set position block in the when object is cloned rule, outside of the check once ifs. Can you see what it is?

4 Likes
#18

Just do ‘When (Self) is tapped’ set (Value) to (4). Or, you can use clone index if that isn’t what you meant. Feel free to tag me anytime!

2 Likes
#19

I´m pretty sure that your first solution solves what @tankt2016 was looking for. I´m also here to help, so if anything else is needed, just tag me! :slight_smile:

#20

Use the clone index variable! You can search it on the forum for help with it.

1 Like