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

#1 2012-05-16 14:26:57

PhirripSyrrip
Scratcher
Registered: 2012-02-11
Posts: 100+

Ran out of space- lists problem

I'm making a game involving lots of lists and stuff like that. It's gonna have LOADS of

add [item 1] to [results v]
However, when I was 20% of my way through making it, i suddenly got this red message saying that squeak is running out of memory. I'll admit that that was kinda expected as I had 2 sprites loaded with those scripts mentioned above.

However, I had a thought. My game basically relies on this format:
if <<[factors v] contains [factor 1]> and <[factors v] contains [factor 2]>>
add [result 1] to [results v]
end
if <<[factors v] contains [factor 2]> and <[factors v] contains [factor 5]>>
add [result 2] to [results v]
end
if <<[factors v] contains [factor 1]> and <<[factors v] contains [factor 2]> and <[factors v] contains [factor 6]>>>
add [result 3] to [results v]
end
but then I thought, what if I make "factor 1" a variable that never changes? That way, scratch will treat is as 1 figure rather than 100 seperate figures. It would look something like this:
when gf clicked
set [factor 1 v] to [factor 1]
set [factor 2 v] to [factor 2]
set [factor 3 v] to [factor 3]
set [factor 4 v] to [factor 4]
set [factor 5 v] to [factor 5]
set [factor 6 v] to [factor 6]
when gf clicked
forever
if <<[factors v] contains (factor 1)> and <[factors v] contains (factor 2)>>
add [result 1] to [results v]
end
if <<[factors v] contains (factor 2)> and <[factors v] contains (factor 5)>>
add [result 2] to [results v]
end
if <<[factors v] contains (factor 1)> and <<[factors v] contains (factor 2)> and <[factors v] contains (factor 6)>>>
add [result 3] to [results v]
end
end
I hope you get what I mean. I want to see what you think about my idea before I rescript the entire project. Thanks  tongue


http://i46.tinypic.com/ao03lk.png

Offline

 

#2 2012-05-16 15:27:59

sonicfan12p
Scratcher
Registered: 2011-11-16
Posts: 1000+

Re: Ran out of space- lists problem

If you are reluctant about rescripting the whole thing, try rescripting it, and then using save as instead of save, and save it as something different. That way you can test this theory. I don't work with lists much, so I'm not sure right off the bat. If you just really don't want to rescript yet though, tell me and I can test it myself.


Why are the secret organizations getting all the attention?  mad

Offline

 

#3 2012-05-17 22:27:48

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Ran out of space- lists problem

The "Squeak is running out of memory" error message is not in response to the lists, but in response to your scripts.  Having a single very long script is hard on Squeak.  Try breaking up your code into "broadcast and wait" and "when I receive."  That'll also make it easier to read, since code will be organized in sections that go together.

Offline

 

#4 2012-05-18 12:58:53

mythbusteranimator
Scratcher
Registered: 2012-02-28
Posts: 1000+

Re: Ran out of space- lists problem

I cannot tell you HOW many times I downloaded a large, 1s1s project and have Scratch crash on me due to low space. However, when there is a huge game with 1000s of scripts, it works fine. Like ambercu said, you probably want to break the script up.


http://www.foxtrot.com/comics/2012-04-01-fdb37077.gif
clicky

Offline

 

#5 2012-05-18 13:00:34

PhirripSyrrip
Scratcher
Registered: 2012-02-11
Posts: 100+

Re: Ran out of space- lists problem

thanks everyone, I'll try that  smile


http://i46.tinypic.com/ao03lk.png

Offline

 

Board footer