Discuss Scratch

AntonL1kesPotato
Scratcher
1000+ posts

How can i fix the lag in the editor?

For a few days, my project lags very badly on the editor because of a looooooong line of code in the most important sprite. But i don't know how to fix it. So, i quite don't want to do the proceedings in order to fix the lag:
-Using broadcast blocks
-Using the offline editor
Here's my project: https://scratch.mit.edu/projects/542384369/
Is there a solution for this?
mrcreatorluigi
Scratcher
1000+ posts

How can i fix the lag in the editor?

you can use turbowarp or turbo mode, honestly idk what else
orangetheory
Scratcher
500+ posts

How can i fix the lag in the editor?

spam the flag as much as you can or make a new script like so:

when green flag clicked
if <is compiled?> then
... // this is just a placeholder, it is where you want your code that lags should be.
else
... // this is for the less laggy code
end

define is compiled?
Don't put anything above

Let me explain this: If you write Is compiled? In a costum block Scratch automatically senses it and compiles all the code inside the “is compiled” if-statement to JavaScript to make it run faster. Therefore, your project runs at a faster FPS (frames per second) and your problem is solved.

Or, as post #2 said copy your project's link and go to Turbowarp or Forkhporus and paste your project link in that faint box with a sample URL in there, located below the project. I hope this helped, follow me if it did!
orangetheory
Scratcher
500+ posts

How can i fix the lag in the editor?

Also, this is the link to your project in Forkhporus:
https://forkphorus.github.io/#542384369
and the link to your project on TurboWarp:
https://turbowarp.org/542384369
AntonL1kesPotato
Scratcher
1000+ posts

How can i fix the lag in the editor?

orangetheory wrote:

spam the flag as much as you can or make a new script like so:

when green flag clicked
if <is compiled?> then
... // this is just a placeholder, it is where you want your code that lags should be.
else
... // this is for the less laggy code
end

define is compiled?
Don't put anything above

Let me explain this: If you write Is compiled? In a costum block Scratch automatically senses it and compiles all the code inside the “is compiled” if-statement to JavaScript to make it run faster. Therefore, your project runs at a faster FPS (frames per second) and your problem is solved.

Or, as post #2 said copy your project's link and go to Turbowarp or Forkhporus and paste your project link in that faint box with a sample URL in there, located below the project. I hope this helped, follow me if it did!
Sorry but, the lag happens in the editor, not the project. Thanks for your help though!
awesome-llama
Scratcher
1000+ posts

How can i fix the lag in the editor?

You are going to have to split up the large scripts in order to make the editor stop lagging. There's no way around it if that is your sole source of editor lag. I know you don't want to use broadcasts, so I will give you the alternative: use custom blocks (the pink “more blocks”). You can split the scripts into halves quite easily:



What makes custom blocks better than broadcasts for this is that they will only be seen within the sprite you put them in. In other words, it is “local” to the sprite. Using custom blocks is actually what a lot of advanced projects use. I do this all the time to split up scripts.
orangetheory
Scratcher
500+ posts

How can i fix the lag in the editor?

AntonL1kesPotato wrote:

orangetheory wrote:

spam the flag as much as you can or make a new script like so:

when green flag clicked
if <is compiled?> then
... // this is just a placeholder, it is where you want your code that lags should be.
else
... // this is for the less laggy code
end

define is compiled?
Don't put anything above

Let me explain this: If you write Is compiled? In a costum block Scratch automatically senses it and compiles all the code inside the “is compiled” if-statement to JavaScript to make it run faster. Therefore, your project runs at a faster FPS (frames per second) and your problem is solved.

Or, as post #2 said copy your project's link and go to Turbowarp or Forkhporus and paste your project link in that faint box with a sample URL in there, located below the project. I hope this helped, follow me if it did!
Sorry but, the lag happens in the editor, not the project. Thanks for your help though!

No problem. Lag in the editor happens a lot to me, too, because of the amount of blocks or the server or internet traffic, or maybe Scratch takes up too much RAM (random access memory, part of the CPU), or maybe your computer is too weak. Really, there is no other way to do this except to keep refreshing or download the 2.0 offline editor then export it to the browser version. I hope this helped!

EDIT: YES THERE IS A WAY just forgot as post #6 said, split up the scripts and use custom blocks instead. I also suggest using less clones and less extensions, because that would make both the project AND the editor lag as well. Too much sounds may do the same.

Last edited by orangetheory (July 6, 2021 13:27:35)

AntonL1kesPotato
Scratcher
1000+ posts

How can i fix the lag in the editor?

awesome-llama wrote:

You are going to have to split up the large scripts in order to make the editor stop lagging. There's no way around it if that is your sole source of editor lag. I know you don't want to use broadcasts, so I will give you the alternative: use custom blocks (the pink “more blocks”). You can split the scripts into halves quite easily:



What makes custom blocks better than broadcasts for this is that they will only be seen within the sprite you put them in. In other words, it is “local” to the sprite. Using custom blocks is actually what a lot of advanced projects use. I do this all the time to split up scripts.
Thanks!
orangetheory
Scratcher
500+ posts

How can i fix the lag in the editor?

Should this even be in HWS? I think this should be in QAS, or maybe a little bit of both…
MasterofTheBrick
Scratcher
1000+ posts

How can i fix the lag in the editor?

orangetheory wrote:

Should this even be in HWS? I think this should be in QAS, or maybe a little bit of both…
Since this is a scripting problem it would belong in HWS.

Powered by DjangoBB