Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Only look at this if you have a LOTT of time on your hands and want something complex. Kinda...
- Qman09180
-
Scratcher
55 posts
Only look at this if you have a LOTT of time on your hands and want something complex. Kinda...
Soooo… I'm making an Upgrade tree. And as of right now I have almost 2 upgrade trees (the research tree isn't quite finished yet) and Im working on my 3rd tree. and Im starting to experience LAG… So that means I have to start going through and trying to make my code simpler and better in order to make it less laggy and I tried to do it the simplest way I could but you guys might find flaws. The main things I need are a Buy Max system and just a bunch of code in the Main tree upgrades to be simplified. If you can find anything please let me know and TYSM for the help!!! (I will give credit!) 
https://scratch.mit.edu/projects/1274714134/

https://scratch.mit.edu/projects/1274714134/
- DanglyLegs
-
Scratcher
100+ posts
Only look at this if you have a LOTT of time on your hands and want something complex. Kinda...
Without having looked too in-depth at your project, I'd suggest switching to one main sprite that creates clones for each of the branches, instead of each one being a different sprite.
The basic clone scripts I use are as follows:
I hope this is useful.
The basic clone scripts I use are as follows:
Create clone [whatever you want] :: custom // use this to generate a new clone with a specific clone id.
define Create clone (id)
set [tmp id v] to (id :: variables) // both of these variables are for this sprite only
set [id v] to (id)
create clone of [myself v]
set [id v] to (tmp id)
when I start as a clone // this same script can be duplicated for when I receive an event
if <(id)=[whatever you want]> then
...
else
if <(id)=[some other phrase]> then
...
else
and so on... :: #bfbfbf
end
end
I hope this is useful.
- Qman09180
-
Scratcher
55 posts
Only look at this if you have a LOTT of time on your hands and want something complex. Kinda...
Without having looked too in-depth at your project, I'd suggest switching to one main sprite that creates clones for each of the branches, instead of each one being a different sprite.tysm!! but heres the problem. i would have to put down all of the costs in a seperate list so thats like 30 lists not even including alll of the variables they all use. plus the fact that this one sprite would now have over 300+ costumes alltogether.
The basic clone scripts I use are as follows:Create clone [whatever you want] :: custom // use this to generate a new clone with a specific clone id.
define Create clone (id)
set [tmp id v] to (id :: variables) // both of these variables are for this sprite only
set [id v] to (id)
create clone of [myself v]
set [id v] to (tmp id)
when I start as a clone // this same script can be duplicated for when I receive an event
if <(id)=[whatever you want]> then
...
else
if <(id)=[some other phrase]> then
...
else
and so on... :: #bfbfbf
end
end
I hope this is useful.
- DanglyLegs
-
Scratcher
100+ posts
Only look at this if you have a LOTT of time on your hands and want something complex. Kinda...
Could I suggest using a text engine to write the text instead of creating an individual costume for each button?
- Qman09180
-
Scratcher
55 posts
Only look at this if you have a LOTT of time on your hands and want something complex. Kinda...
Could I suggest using a text engine to write the text instead of creating an individual costume for each button?That's true and kinda what I thought of doing but idrk how to make one.
- THEIMPORTANT
-
Scratcher
100+ posts
Only look at this if you have a LOTT of time on your hands and want something complex. Kinda...
create costumes for all letters a-z, then. Repeatedly clone/stamp the letters to create a sentence letter by letter to form a sentence! Try someone elses text Engine if its too time consuming or hard to understand brieflyCould I suggest using a text engine to write the text instead of creating an individual costume for each button?That's true and kinda what I thought of doing but idrk how to make one.
Last edited by THEIMPORTANT (March 12, 2026 16:29:57)
- Qman09180
-
Scratcher
55 posts
Only look at this if you have a LOTT of time on your hands and want something complex. Kinda...
that sounds PAINFULLLL… Do you think it would be worth the time in the long run? Like what would the pros and cons be? out of curiosity.create costumes for all letters a-z, then. Repeatedly clone/stamp the letters to create a sentence letter by letter to form a sentence! Try someone elses text Engine if its too time consuming or hard to understand brieflyCould I suggest using a text engine to write the text instead of creating an individual costume for each button?That's true and kinda what I thought of doing but idrk how to make one.
Last edited by Qman09180 (March 13, 2026 15:12:47)
- jmb1293634
-
Scratcher
1000+ posts
Only look at this if you have a LOTT of time on your hands and want something complex. Kinda...
pros:that sounds PAINFULLLL… Do you think it would be worth the time in the long run? Like what would the pros and cons be? out of curiosity.create costumes for all letters a-z, then. Repeatedly clone/stamp the letters to create a sentence letter by letter to form a sentence! Try someone elses text Engine if its too time consuming or hard to understand brieflyCould I suggest using a text engine to write the text instead of creating an individual costume for each button?That's true and kinda what I thought of doing but idrk how to make one.
- means you don't have to have a load of costumes for each upgrade
- quicker to add more upgrades later - just type in the text you want and go
- could help stop lag especially if stamping is used
- limits your art for each upgrade
- severe character limitations if you use clones (max 300)
- looks pretty horrible if you stamp
- g6g6g66g6g
-
Scratcher
100+ posts
Only look at this if you have a LOTT of time on your hands and want something complex. Kinda...
#7that sounds PAINFULLLL… Do you think it would be worth the time in the long run? Like what would the pros and cons be? out of curiosity.
It is almost certainly not worth it. It will look worse, you will very quickly reach the 300 clone limit, since the scripts would be pasting each letter it would add to the lag, not lessen it. Editing button text will be a nightmare because you lose the benefit of seeing the results directly in the costume editor.
Is there any specific point where the game starts to lag or does it happen right from the start?
- Qman09180
-
Scratcher
55 posts
Only look at this if you have a LOTT of time on your hands and want something complex. Kinda...
It happens right at the start most likely due to other things running that need to be if called on. I'm also on a VERY low end device :p#7that sounds PAINFULLLL… Do you think it would be worth the time in the long run? Like what would the pros and cons be? out of curiosity.
It is almost certainly not worth it. It will look worse, you will very quickly reach the 300 clone limit, since the scripts would be pasting each letter it would add to the lag, not lessen it. Editing button text will be a nightmare because you lose the benefit of seeing the results directly in the costume editor.
Is there any specific point where the game starts to lag or does it happen right from the start?
- Discussion Forums
- » Help with Scripts
-
» Only look at this if you have a LOTT of time on your hands and want something complex. Kinda...