This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2009-10-13 17:55:57

Lucario621
Community Moderator
Registered: 2007-10-03
Posts: 1000+

Tips to saving time when scripting in massive lag/scripts

Most of us advanced scratchers know, that once you start making big scripts with long and I mean LONG forever loops, there is lots of lag for the computer to update the screen with the new blocks or numbers or words you entered. Well I just wanted to share my tips to saving time, so you don't have to spend as much time on waiting for the computer to refresh the screen just because you typed in some number or phrase.

1. Don't code while having the game still playing. When you finish coding, you'll test it, then click the stop sign, then fix the mistake, or continue your coding. This will make it a bit slower, so its just not reccomended. There are some places where you have to do this, just so you don't have to waste time reclicking the green flag and waiting for the intro and menu animations to finish. But you should rarely have to do that.

2. Type or script it first, then put it into the loop. For those who don't know, when you get long scripts, and you try to enter a number into a textbox, you will type it in, and then you will have to wait anywhere from 2-6 seconds for it to refresh the screen. I reccomend getting the block with the textbox, put it onto the main script area, type it in, and then insert it into the large script. Same goes for groups of blocks, if you have maybe a set of code maybe 4 blocks, inside an if statement, then do that first, then insert it into the script. Doing this will help a lot, the only problem is that you can't use this in every situation. That leads us to our next tip...

3. Substitute large amounts of the same text box, for a variable. Ok I'll say thats a bit difficult to word out, so let me explain it. When you have something, for example x velocity for some character, instead of writing 'change x velocity by (1.5)' all the time in different places, say 'change x velocity by (playerspeed)', in which player speed is a variable which equals 1.5. Whats also great about this is that when you want to increase the speed because the game is getting a bit slow, where you have at the beggining of the script where you reset the variables, you can just change it there, and then it changes it in all of the other place. Credit to archmage, as I learned the technique from his SSBB games :).

The-Whiz wrote:

Save often. Once I made a huge one-sprite one-script game, and tried to add more blocks, and it froze on me. After about half an hour,it was still frozen. I lost all the progress since my last save.

The-Whiz has a great point. Although for this, because I've never experienced this, I'll say that it depends on your computer, and it depends on what project your making. Although I will say that I reccomend saving because of the Dissapearing Text Glitch. For those of you who haven't heard of it -- This is a glitch where after you type lots and lots of text on the screen, perhaps even if a lot of them are just spaces, they all suddenly dissapear. It says the text is still there, but its hidden. And because this can happen unexpectedly, its reccomend you safe often, whether or not your in risk of this or not.

In conclusion, just like coolstuff says, you should just generally not make big scripts. I half agree with that honestly though. With massive forever loops, it can help, but as I've mentioned before it depends on the situation. If your not sure if it'll work, just test it out. Its possible that it will speed your game up, just it will cause some glitches due to timing and such. In that case, you should look carefully and figure out the problems and fix them.

If you have any ideas, just mention. Hope this helps!

Last edited by Lucario621 (2009-10-14 15:45:07)


http://i.imgur.com/WBkM2QQ.png

Offline

 

#2 2009-10-13 18:20:43

The-Whiz
Scratcher
Registered: 2007-07-09
Posts: 1000+

Re: Tips to saving time when scripting in massive lag/scripts

Save often. Once I made a huge one-sprite one-script game, and tried to add more blocks, and it froze on me. After about half an hour,it was still frozen. i lost all the progress since my last save.

Offline

 

#3 2009-10-13 19:13:53

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: Tips to saving time when scripting in massive lag/scripts

Great tips! I'd also like to suggest avoiding longer scripts altogether, it's a lot easier to program. When you start noticing extreme lag (a few seconds) it might be time for a new script using the broadcast function! Once, I had an ultralong script which my computer couldn't really handle and it took at least 10 seconds to load.

Offline

 

#4 2009-10-14 19:58:22

Lucario621
Community Moderator
Registered: 2007-10-03
Posts: 1000+

Re: Tips to saving time when scripting in massive lag/scripts

bump


http://i.imgur.com/WBkM2QQ.png

Offline

 

#5 2009-10-15 19:40:13

samurai768
Scratcher
Registered: 2009-07-21
Posts: 1000+

Re: Tips to saving time when scripting in massive lag/scripts

Lucario621 wrote:

Choose Lucario621 for TBG mod. I have experience (registered Oct. 3 2007), I'm dedicated (went to Scratch Day and Scratch Meetup both at MIT), I'm active, I have good grammer, and I can solve problems without hurting any feelings = )

LOL ironically bad in spelling grammAR

Offline

 

#6 2009-10-15 22:32:33

Lucario621
Community Moderator
Registered: 2007-10-03
Posts: 1000+

Re: Tips to saving time when scripting in massive lag/scripts

samurai768 wrote:

Lucario621 wrote:

Choose Lucario621 for TBG mod. I have experience (registered Oct. 3 2007), I'm dedicated (went to Scratch Day and Scratch Meetup both at MIT), I'm active, I have good grammer, and I can solve problems without hurting any feelings = )

LOL ironically bad in spelling grammAR

OH MY GOODNESSSSSSSSSS!!!!!!!!!!!!!!!!!!!
Already 2 people have noticed grammar mistakes in my post. Now YOUUU!?????????
lol i really didn't expect this >.<


http://i.imgur.com/WBkM2QQ.png

Offline

 

#7 2009-11-01 12:08:45

scratch_yoshi
Scratcher
Registered: 2009-06-12
Posts: 1000+

Re: Tips to saving time when scripting in massive lag/scripts

The-Whiz wrote:

Save often. Once I made a huge one-sprite one-script game, and tried to add more blocks, and it froze on me. After about half an hour,it was still frozen. i lost all the progress since my last save.

My computer shut down on me while I was working hard on a recolored sprite and I had to recolor it! So good point The-Whiz

Last edited by scratch_yoshi (2009-11-28 08:48:12)


Retired from Scratch, but just the language itself. Not the forums.

Offline

 

#8 2010-02-26 23:12:09

ThePCKid
Scratcher
Registered: 2009-09-16
Posts: 1000+

Re: Tips to saving time when scripting in massive lag/scripts

Shorten your scripts. Try to turn those very long scripts into short scripts. It will speed up Scratch and if the project is going to be uploaded, it will also work faster.

Offline

 

#9 2010-02-27 00:45:22

Jonathanpb
Scratcher
Registered: 2008-07-25
Posts: 1000+

Re: Tips to saving time when scripting in massive lag/scripts

Thanks for bumping this up! It's great.  smile

Hey, I was going to suggest for this to be added to Scratch Programming Tutorials, but it was already in there.  tongue


"Human beings... must have action; and they will make it if they cannot find it.
-Charlotte Brontë

Offline

 

#10 2010-02-27 00:52:06

Chrischb
Scratcher
Registered: 2008-07-24
Posts: 1000+

Re: Tips to saving time when scripting in massive lag/scripts

Nice topic!  smile

I wish I had something like that a few days ago. Dx
....................................
I have a suggestion:

Be patient. If you drag a block out of a long script, wait - if you get impatient and try dragging it again, things will only get worse. The same applies to construction issues and such.

That's happened to be several times... it's so irritating.
Fortunately, I've learned.  smile


I fall: It's a tragedy. You fall: It's comedy.
Hmph enjoy your fall - I get a lovely spring... without pans of new leaves.

Offline

 

#11 2010-02-27 05:38:33

RHY3756547
Scratcher
Registered: 2009-08-15
Posts: 1000+

Re: Tips to saving time when scripting in massive lag/scripts

None of this can help me. My latest games crash because of sheer graphical strain and complexity on all sprites. :'(

Offline

 

#12 2010-02-27 19:16:36

Lucario621
Community Moderator
Registered: 2007-10-03
Posts: 1000+

Re: Tips to saving time when scripting in massive lag/scripts

RHY3756547 wrote:

None of this can help me. My latest games crash because of sheer graphical strain and complexity on all sprites. :'(

RHY is too awesome for scratch D:


http://i.imgur.com/WBkM2QQ.png

Offline

 

#13 2010-02-27 19:23:08

Jonathanpb
Scratcher
Registered: 2008-07-25
Posts: 1000+

Re: Tips to saving time when scripting in massive lag/scripts

Lucario621 wrote:

RHY3756547 wrote:

None of this can help me. My latest games crash because of sheer graphical strain and complexity on all sprites. :'(

RHY is too awesome for scratch D:

How true.  yikes


"Human beings... must have action; and they will make it if they cannot find it.
-Charlotte Brontë

Offline

 

#14 2010-02-27 19:45:42

Chrischb
Scratcher
Registered: 2008-07-24
Posts: 1000+

Re: Tips to saving time when scripting in massive lag/scripts

You didn't add my tip...  hmm


I fall: It's a tragedy. You fall: It's comedy.
Hmph enjoy your fall - I get a lovely spring... without pans of new leaves.

Offline

 

#15 2010-02-27 20:11:27

Lucario621
Community Moderator
Registered: 2007-10-03
Posts: 1000+

Re: Tips to saving time when scripting in massive lag/scripts

Chrischb wrote:

You didn't add my tip...  hmm

I didn't add anybody's tip...


http://i.imgur.com/WBkM2QQ.png

Offline

 

#16 2010-04-04 09:41:37

tianabannana
Scratcher
Registered: 2009-10-21
Posts: 3

Re: Tips to saving time when scripting in massive lag/scripts

i wanna make a menu 4 my game but duna how HELP ME!!!!!

Offline

 

#17 2010-04-04 19:00:00

Chrischb
Scratcher
Registered: 2008-07-24
Posts: 1000+

Re: Tips to saving time when scripting in massive lag/scripts

tianabannana, it's best to post a new topic rather than to bump an old unrelated one.  wink

As for your question: Is it a button menu?


I fall: It's a tragedy. You fall: It's comedy.
Hmph enjoy your fall - I get a lovely spring... without pans of new leaves.

Offline

 

#18 2010-04-04 19:03:11

littletonkslover
Scratcher
Registered: 2008-12-12
Posts: 1000+

Re: Tips to saving time when scripting in massive lag/scripts

Chrischb wrote:

tianabannana, it's best to post a new topic rather than to bump an old unrelated one.  wink

As for your question: Is it a button menu?

It's not that old......


http://www.coxlab.org/images/rat_banner.jpg
That's the dark nature of capitalism. ~ Wonder Showzen

Offline

 

#19 2010-04-05 21:46:02

Karra
Scratcher
Registered: 2009-01-14
Posts: 100+

Re: Tips to saving time when scripting in massive lag/scripts

littletonkslover wrote:

Chrischb wrote:

tianabannana, it's best to post a new topic rather than to bump an old unrelated one.  wink

As for your question: Is it a button menu?

It's not that old......

It's not that old now, but it was when the last post was made at the end of February.
If anything, people should add whatever tips they may have left (if there are tips left) and the mods should shut this baby down. It would serve a better purpose that way. -wink-


http://i305.photobucket.com/albums/nn229/myrkalyk/kar.png

Offline

 

#20 2010-04-06 08:09:03

Llamalover
Scratcher
Registered: 2007-05-18
Posts: 100+

Re: Tips to saving time when scripting in massive lag/scripts

One thing I find useful is to try and split up any long blocks of code using the broadcast fonctions. It really helps, especially if you want the script to run quickly.
You can either use one main command script, calling to different snippets of scripts, or you can use different chunks of scripts, each starting when another has finished, and calling for the next when it's finished.

Example (we'll pretend that the few blocks for each action are actually more and more complicated):
[blocks]
<when green flag clicked>
<turn cw( 90 )degrees>
<turn cw( -90 )degrees>
<say[ I don't see anything up there]>
<turn cw( -90 )degrees>
<turn cw( 90 )degrees>
<say[ I don't see anything down there]>
<point in direction( right)>
<move( 10 )steps>
<point in direction( left)>
<move( 10 )steps>
<say[ I don't see anything over there]>
<point in direction(left)>
<move( 10 )steps>
<point in direction( right)>
<move( 10 )steps>
<say[ I don't see anything over there]>
[/blocks]
could be changed into this:
[blocks]
<when green flag clicked>
<broadcast[ look up ]and wait c>
<broadcast[ look down ]and wait c>
<broadcast[ look right ]and wait c>
<broadcast[ look left ]and wait c>

<when I receive[ look up]>
<turn cw( 90 )degrees>
<turn cw( -90 )degrees>
<say[ I don't see anything up there]>
[/blocks]
etc...

or:
[blocks]
<when green flag clicked>
<turn cw( 90 )degrees>
<turn cw( -90 )degrees>
<say[ I don't see anything up there]>
<broadcast[ look down ]>

<when I receive[ look down ]>
<say[ I don't see anything up there]>
<turn cw( -90 )degrees>
<turn cw( 90 )degrees>
<broadcast[ look right ]>
[/blocks]
etc...


Be nice, I'm an old lady  wink

Offline

 

#21 2010-04-06 08:24:41

juststickman
Scratcher
Registered: 2009-05-31
Posts: 1000+

Re: Tips to saving time when scripting in massive lag/scripts

Llamalover wrote:

One thing I find useful is to try and split up any long blocks of code using the broadcast fonctions. It really helps, especially if you want the script to run quickly.
You can either use one main command script, calling to different snippets of scripts, or you can use different chunks of scripts, each starting when another has finished, and calling for the next when it's finished.

Example (we'll pretend that the few blocks for each action are actually more and more complicated):
[blocks]
<when green flag clicked>
<turn cw( 90 )degrees>
<turn cw( -90 )degrees>
<say[ I don't see anything up there]>
<turn cw( -90 )degrees>
<turn cw( 90 )degrees>
<say[ I don't see anything down there]>
<point in direction( right)>
<move( 10 )steps>
<point in direction( left)>
<move( 10 )steps>
<say[ I don't see anything over there]>
<point in direction(left)>
<move( 10 )steps>
<point in direction( right)>
<move( 10 )steps>
<say[ I don't see anything over there]>
[/blocks]
could be changed into this:
[blocks]
<when green flag clicked>
<broadcast[ look up ]and wait c>
<broadcast[ look down ]and wait c>
<broadcast[ look right ]and wait c>
<broadcast[ look left ]and wait c>

<when I receive[ look up]>
<turn cw( 90 )degrees>
<turn cw( -90 )degrees>
<say[ I don't see anything up there]>
[/blocks]
etc...

or:
[blocks]
<when green flag clicked>
<turn cw( 90 )degrees>
<turn cw( -90 )degrees>
<say[ I don't see anything up there]>
<broadcast[ look down ]>

<when I receive[ look down ]>
<say[ I don't see anything up there]>
<turn cw( -90 )degrees>
<turn cw( 90 )degrees>
<broadcast[ look right ]>
[/blocks]
etc...

There is one huge problem with that though.

BROADCASTS LAG LIKE [removed]!!!!!!!!!!!!!!!!!!!!!

Last edited by juststickman (2010-04-06 08:25:02)


http://is.gd/iBQi2 Add grob to your sig and help with world dominiation!http://is.gd/iBQ9Q                                                             Hey guys, we're seriously naming our team bob?

Offline

 

Board footer