Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Help with constantly-updating clone property lists
- fishu4
-
Scratcher
100+ posts
Help with constantly-updating clone property lists
Hi. I'm making a more traditional tower defense game, and I need a list to have the properties of clones (and have it constantly update them.) The issue is that my broken method of having the parent delete all of the list and ping the clones via a broadcast to add their properties to a list doesn't work. It seems to be because the clones receiving the broadcast takes one tick, though I'm not usure. Having the clones have IDs and constantly replace their properties in a list doesn't help either as there will be issues with deleting clones. Not using clones and having the sprites just be rendered from a list isn't what I'm going for either. I need help with this!
- Tornadowrath
-
Scratcher
85 posts
Help with constantly-updating clone property lists
Only real way to speed up optimized code is with make-a-blocks so If you can run anything w/o screen refresh, do it.
- dem_bot
-
Scratcher
100+ posts
Help with constantly-updating clone property lists
apparently it's a thing that if you broadcast something, as long as it's the first time that thing is broadcasted within the frame, it's added to the queue of stuff to run that frame. This means that if you
foreveryou can pass the thread between sprites. Just don't use the same broadcast twice. (receive is fine, but send not) Creating clones runs the when i start as a clone script regardless of if it's the first time within the frame, but that does allow you to crash scratch by having each clone create a clone and delete itself.
broadcast [1 v]
end
when I receive [1 v]
broadcast [2 v]
do first thing
when I receive [2 v]
do second thing
broadcast [3 v]
when I receive [3 v]
do third thing
Last edited by dem_bot (Dec. 9, 2025 08:58:34)
- fishu4
-
Scratcher
100+ posts
Help with constantly-updating clone property lists
Would something like this work?
when i receive [start v]
forever
delete all of [properties v]
broadcast [properties v]
end
when i receive [properties v]
if <(clone) = (1)> then
add (stuff) to [properties v]
end
- fishu4
-
Scratcher
100+ posts
Help with constantly-updating clone property lists
apparently it's a thing that if you broadcast something, as long as it's the first time that thing is broadcasted within the frame, it's added to the queue of stuff to run that frame. This means that if youThis is helpful, but it doesn't work for the situation I need. The code I posted above (not this quote) doesn't workforeveryou can pass the thread between sprites. Just don't use the same broadcast twice. (receive is fine, but send not) Creating clones runs the when i start as a clone script regardless of if it's the first time within the frame, but that does allow you to crash scratch by having each clone create a clone and delete itself.
broadcast [1 v]
end
when I receive [1 v]
broadcast [2 v]
do first thing
when I receive [2 v]
do second thing
broadcast [3 v]
when I receive [3 v]
do third thing
- fishu4
-
Scratcher
100+ posts
Help with constantly-updating clone property lists
Update: I modified it at bit, and it now works. Thank you!
forever
broadcast (the stuff v)
end
when i receive (the stuff v)
broadcast (make clones add their properties to list v)
delete all of (list v)
- deck26
-
Scratcher
1000+ posts
Help with constantly-updating clone property lists
But why delete the contents of the list? Just give each clone a unique ID so it can use that as the index for its list value.
- fishu4
-
Scratcher
100+ posts
Help with constantly-updating clone property lists
Yeah but then it might reach the list limit in niche cases or it cold cause bugs with index, and the method by @dem_bot already works
- Discussion Forums
- » Help with Scripts
-
» Help with constantly-updating clone property lists