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.
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] endbut 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 endI hope you get what I mean. I want to see what you think about my idea before I rescript the entire project. Thanks
Offline
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.
Offline
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
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.
Offline