Discuss Scratch
- Discussion Forums
- » Bugs and Glitches
- » About Clone Glitch and Local List
- HarmonyCalcium
-
Scratcher
18 posts
About Clone Glitch and Local List
My browser: / operating system: Windows NT 10.0, Firefox 61.0, Flash 28.0 (release 0)
Clone…
—
My Scratch offline editor is up to date and occasionally clones don't show up when I created it with
(PS: sometimes clones show up in fullscreen and disappear instantly when I quit full screen)
(PS2: I had met this problem various time and in different projects, so I'm quite sure it's not the problem of the script)
Local List…
—
When I create like 200 clones and each of them is doing some operations with its own local list, the project just freezed! Idk why but this is quite annoying… Is there an limit to how many local lists you can operate with?
Clone…
—
My Scratch offline editor is up to date and occasionally clones don't show up when I created it with
create clone of [ a sprite]I made sure that the program hadn't stopped, and my clone had show at the very beginning of its script. Can anyone tell me why this is happening?
(PS: sometimes clones show up in fullscreen and disappear instantly when I quit full screen)
(PS2: I had met this problem various time and in different projects, so I'm quite sure it's not the problem of the script)
Local List…
—
When I create like 200 clones and each of them is doing some operations with its own local list, the project just freezed! Idk why but this is quite annoying… Is there an limit to how many local lists you can operate with?
- Auroura_WoIf
-
Scratcher
1000+ posts
About Clone Glitch and Local List
My browser: / operating system: Windows NT 10.0, Firefox 61.0, Flash 28.0 (release 0)My browser / operating system: Windows 7, Chrome 68.0.3440.106, Flash 30.0 (release 0)
Clone…
—
My Scratch offline editor is up to date and occasionally clones don't show up when I created it withcreate clone of [ a sprite]I made sure that the program hadn't stopped, and my clone had show at the very beginning of its script. Can anyone tell me why this is happening?
(PS: sometimes clones show up in fullscreen and disappear instantly when I quit full screen)
(PS2: I had met this problem various time and in different projects, so I'm quite sure it's not the problem of the script)
Local List…
—
When I create like 200 clones and each of them is doing some operations with its own local list, the project just freezed! Idk why but this is quite annoying… Is there an limit to how many local lists you can operate with?
I don't know what would cause your first issue, although I do recommend updating your Flash player. The second problem is probably due to your computer having too little computational power to let the project run
- TheLogFather
-
Scratcher
1000+ posts
About Clone Glitch and Local List
Clone…I think you would have to share your project so we can take a look at what's going on.
…
Local List…
…
However…
Regarding the clones, it's worth pointing out that there is a limit of 301 clones, in total, for a project (and it's 300 for Scratch 3.0…) If you don't delete them when finished with them (e.g. you just hide), then you can run out of clones, and no more will be created. –Make sure you delete a clone when no longer needed. (Though see my caveat about this in my following post…)
Regarding the local lists, it really depends what and how much work you're doing with them. It's possible you're making those 200 clones do more work than just the list manipulation, and that may be adding to the load. (E.g. if you're switching costume unnecessarily, setting direction unnecessarily, applying effects unnecessarily, etc.)
But it's worth remembering that delete and insert can be expensive list operations, once a list becomes fairly long. (That's because Scratch has to change all the references for items that are above the deleted/inserted one.) If you can keep the operations to only add and replace (and deleting maybe the last one or few, or the whole thing, which is also quick), then that will allow many more list operations before you see significant slowdown.
(Indeed, rather than inserting a bunch of items at the start of a long list, it can be quicker to make a copy of the list, delete the whole list, add the new items, and then re-add the copied items back onto the original. –I would point you to this demo project, except the “timer” bug in the current [v461] Scratch player means all timings end up shown as zero… That bug has affected many of the projects in my speedtests studio…
)Also, if you haven't deleted some clones, but they are just hiding, then it's possible they are still doing work ‘behind the scenes’ that you don't realise.
Hope that helps!
Last edited by TheLogFather (Aug. 28, 2018 20:22:48)
- TheLogFather
-
Scratcher
1000+ posts
About Clone Glitch and Local List
The other thing that comes to mind is if you're creating clones quite frequently…
Clone creation by itself (i.e. without any local lists) is a fairly intensive operation for Scratch (it has to create a whole new copy of the sprite, with all its attributes, and potentially apply the sizing, the rotation, the effects to the costume).
If the clone also has a local list associated with it, and it's not short, then all of those items have to be copied, too. –That will make clone creation even more intensive.
If you are creating and deleting a number of clones per second then it's quite likely this will slow things down.
In that case, I'd recommend you have a think how you might be able to *re-use* existing clones instead. (I.e. when a clone is finished with, don't delete it, but just hide it and shut down its scripts. When you need another clone you can send a broadcast to ‘reactivate’ an old clone, and the first clone that picks up that signal can restart with some new settings, and set a flag that tells any other ‘dead’ clones that receive the signal that it has already been answered.)
OTOH, if you're not creating lots of clones all the time, you can probably ignore all of above (though it may be useful info for someone reading this at some point, I guess…)
Clone creation by itself (i.e. without any local lists) is a fairly intensive operation for Scratch (it has to create a whole new copy of the sprite, with all its attributes, and potentially apply the sizing, the rotation, the effects to the costume).
If the clone also has a local list associated with it, and it's not short, then all of those items have to be copied, too. –That will make clone creation even more intensive.
If you are creating and deleting a number of clones per second then it's quite likely this will slow things down.
In that case, I'd recommend you have a think how you might be able to *re-use* existing clones instead. (I.e. when a clone is finished with, don't delete it, but just hide it and shut down its scripts. When you need another clone you can send a broadcast to ‘reactivate’ an old clone, and the first clone that picks up that signal can restart with some new settings, and set a flag that tells any other ‘dead’ clones that receive the signal that it has already been answered.)
OTOH, if you're not creating lots of clones all the time, you can probably ignore all of above (though it may be useful info for someone reading this at some point, I guess…)
Last edited by TheLogFather (Aug. 28, 2018 20:20:11)
- HarmonyCalcium
-
Scratcher
18 posts
About Clone Glitch and Local List
I think you would have to share your project so we can take a look at what's going on.
I shared the project! It's now here! Can u check the “Tile” sprite? I only created the clone for 256 and it's under a
when green flag clickedblock so I'm sure I didn't created it more times than I should. (they are all created by the parent sprite.)
- HarmonyCalcium
-
Scratcher
18 posts
About Clone Glitch and Local List
Wow that's pretty interesting and I'm really happy to know that. Btw is string operation faster or list operation?(in Scratch)Clone…I think you would have to share your project so we can take a look at what's going on.
…
Local List…
…
However…
Regarding the clones, it's worth pointing out that there is a limit of 301 clones, in total, for a project (and it's 300 for Scratch 3.0…) If you don't delete them when finished with them (e.g. you just hide), then you can run out of clones, and no more will be created. –Make sure you delete a clone when no longer needed. (Though see my caveat about this in my following post…)
Regarding the local lists, it really depends what and how much work you're doing with them. It's possible you're making those 200 clones do more work than just the list manipulation, and that may be adding to the load. (E.g. if you're switching costume unnecessarily, setting direction unnecessarily, applying effects unnecessarily, etc.)
But it's worth remembering that delete and insert can be expensive list operations, once a list becomes fairly long. (That's because Scratch has to change all the references for items that are above the deleted/inserted one.) If you can keep the operations to only add and replace (and deleting maybe the last one or few, or the whole thing, which is also quick), then that will allow many more list operations before you see significant slowdown.
(Indeed, rather than inserting a bunch of items at the start of a long list, it can be quicker to make a copy of the list, delete the whole list, add the new items, and then re-add the copied items back onto the original. –I would point you to this demo project, except the “timer” bug in the current [v461] Scratch player means all timings end up shown as zero… That bug has affected many of the projects in my speedtests studio…)
Also, if you haven't deleted some clones, but they are just hiding, then it's possible they are still doing work ‘behind the scenes’ that you don't realise.
Hope that helps!
- HarmonyCalcium
-
Scratcher
18 posts
About Clone Glitch and Local List
I just met another problem… does
?
(x position)&
(y position)give the position of the clone or the parent if it's under a hat block
when I start as a clone
?- TheLogFather
-
Scratcher
1000+ posts
About Clone Glitch and Local List
I just met another problem… doesThese report the position of whichever object is executing the script. (So for “when I start as a clone” it's definitely the clone.)(x position)&(y position)give the position of the clone or the parent if it's under a hat blockwhen I start as a clone?
Your project has a bug at the moment that means it never gets to create the clones, since it's trying to create 30 mines, looking for list items that contain “null” – but you made them all contain “no” to start with…
Once you fix that, it creates the 256 tiles just fine (though you can't tell which are mines since the “mine” costume is the same as the “clicked” costume that the non-mines have) – but none of the clones are doing anything, so the project just ends after that.
Did you plan to have these clones do some work…?
Last edited by TheLogFather (Aug. 29, 2018 11:28:46)
- HarmonyCalcium
-
Scratcher
18 posts
About Clone Glitch and Local List
Actually I didn't uploaded the full project successfully. I will try that later. And I do found the null bug. TBH I feel like to rewrite the entire script since they are becomming more and more messy. Maybe I can precalculate each tile before I even clone them? :/I just met another problem… doesThese report the position of whichever object is executing the script. (So for “when I start as a clone” it's definitely the clone.)(x position)&(y position)give the position of the clone or the parent if it's under a hat blockwhen I start as a clone?
Your project has a bug at the moment that means it never gets to create the clones, since it's trying to create 30 mines, looking for list items that contain “null” – but you made them all contain “no” to start with…
Once you fix that, it creates the 256 tiles just fine (though you can't tell which are mines since the “mine” costume is the same as the “clicked” costume that the non-mines have) – but none of the clones are doing anything, so the project just ends after that.
Did you plan to have these clones do some work…?
- HarmonyCalcium
-
Scratcher
18 posts
About Clone Glitch and Local List
I rewrite the whole thing and they work pretty nice now! Can anyone check if there is anything I can optimize or any bugs I haven't found?
- Obi_wan_Cannoli
-
Scratcher
1 post
About Clone Glitch and Local List
Wait!….I have to rewrite my hole platformer?


- Discussion Forums
- » Bugs and Glitches
-
» About Clone Glitch and Local List



