Discuss Scratch

ghtrefg
Scratcher
59 posts

How to get position of clone that can be deleted?

I need some way to get the position of a clone so I can point to it. The clone can be deleted.
ded_PC
Scratcher
100+ posts

How to get position of clone that can be deleted?

ghtrefg wrote:

I need some way to get the position of a clone so I can point to it. The clone can be deleted.
x position y position give the clone's position so set the global variables to them to get the clone's position when shooting. e.g when I start as a clone… set newbulletx to x position have to be global variables set newbullety to y position create clone of bullet
ghtrefg
Scratcher
59 posts

How to get position of clone that can be deleted?

It's NOT a shooting game. There are multiple clones at once, each with their own x's and y's.

Last edited by ghtrefg (Jan. 25, 2023 18:56:51)

TKTK1234567
Scratcher
1000+ posts

How to get position of clone that can be deleted?

Make this code to get all the clones x pos and y pos:
when I start as a clone
add (x position) to [Clone X v]
add (y position) to [Clone Y v]
set [Clone # v] to (length of [Clone X v] :: list)
forever
replace item (Clone #) of [Clone X v] with (x position)
replace item (Clone #) of [Clone Y v] with (y position)
end
when green flag clicked
delete all of [Clone X v] :: list
delete all of [Clone Y v] :: list
ghtrefg
Scratcher
59 posts

How to get position of clone that can be deleted?

But what do I do when a clone is deleted?

Last edited by ghtrefg (Jan. 25, 2023 22:05:10)

TKTK1234567
Scratcher
1000+ posts

How to get position of clone that can be deleted?

ghtrefg wrote:

But what do I do when a clone is deleted?
In the code that deletes the clone add these blocks:
delete (Clone #) of [Clone X v]
delete (Clone #) of [Clone Y v]

Last edited by TKTK1234567 (Jan. 26, 2023 00:22:05)

ghtrefg
Scratcher
59 posts

How to get position of clone that can be deleted?

Ok, how do I access these values?
medians
Scratcher
1000+ posts

How to get position of clone that can be deleted?

ghtrefg wrote:

Ok, how do I access these values?
Use the item number of list block.
ghtrefg
Scratcher
59 posts

How to get position of clone that can be deleted?

That would imply I already had the data, therefor making the block useless.
ghtrefg
Scratcher
59 posts

How to get position of clone that can be deleted?

That doesn't help.
medians
Scratcher
1000+ posts

How to get position of clone that can be deleted?

ghtrefg wrote:

That would imply I already had the data, therefor making the block useless.

I don't mean the block that does the same thing as this:

Last edited by medians (Jan. 26, 2023 02:40:49)

ghtrefg
Scratcher
59 posts

How to get position of clone that can be deleted?

Oh, that one. I thought you meant the item # of (thing) in (list) block.

Last edited by ghtrefg (Jan. 26, 2023 02:41:41)

deck26
Scratcher
1000+ posts

How to get position of clone that can be deleted?

I'd recommend not deleting the list items since all the clones which refer to values later in the lists will now be pointing to the wrong item!

What do you mean by pointing to a clone - how does a clone know it is the one to be deleted? More information on what you're tryig to do would make it easier to focus the help correctly.
ghtrefg
Scratcher
59 posts

How to get position of clone that can be deleted?

So, the clones are actually food - the food can get eaten, so when it's touching a cell it will be eaten.
deck26
Scratcher
1000+ posts

How to get position of clone that can be deleted?

ghtrefg wrote:

So, the clones are actually food - the food can get eaten, so when it's touching a cell it will be eaten.
So if the clone detects it is being eaten it can just delete itself, no need for a list of positions.
ghtrefg
Scratcher
59 posts

How to get position of clone that can be deleted?

The list is so that the cells go to the food.

Last edited by ghtrefg (Jan. 26, 2023 16:26:58)

deck26
Scratcher
1000+ posts

How to get position of clone that can be deleted?

So you probably do want the clones to remove their data but not by deleting the items so it doesn't mess up. Perhaps replace x with 9999 when a clone is eaten so the cells can differentiate between clones that are there and those that have been eaten.
ghtrefg
Scratcher
59 posts

How to get position of clone that can be deleted?

I've already tried that. It's very laggy - and besides, it wouldn't work anyway since the clones scroll.
ghtrefg
Scratcher
59 posts

How to get position of clone that can be deleted?

Bump!
deck26
Scratcher
1000+ posts

How to get position of clone that can be deleted?

ghtrefg wrote:

I've already tried that. It's very laggy - and besides, it wouldn't work anyway since the clones scroll.
Why wouldn't it work because the clones scroll? A clone that is deleted is not going to be updating its list item any more so its saved x value wouldn't change. If 999 is a valid value you use something bigger like 9999 or 99999 or just use text like ‘dead’ so you know to ignore that clone.

Note this also allows clone numbers to be reused so you don't end up with lots of dead slots. Get each dying clone to add its item number to a separate list and when you want to create a new clone you can just grab the item number from the first item in the list.

If clones are being deleted and recreated quickly though you might be better reusing them rather than deleting them. You can modify the above method to identify a clone for reuse in the same way, just make sure dead clones don't update their positions. That may help lag.

If you actually have something like this in place and it lags let people here see the project so they can help. Sharing a project is a much better way to get help that is relevant.

Powered by DjangoBB