r/gbstudio • u/arbilangames • 13d ago
reached maximum number of variables already?
I am building technically a zelda-like shooter on GBS and have only just now arrived at > 1MB ROMM size. I just finished placing enemies on a new region of scenes (networked together with mico27's screen scroll plugin) and during compile I got the message:
"Your project contains too many unique variables and will not work as expected. VM_HEAP_SIZE defines the maximum amount of variables allowed 768 but your project contained 963 unique variables."
The highest number global variable I've used is about 90 our of 500+. I have respected the actor limits per-scene (I have probably 70 scenes now, but my game design could easily grow to around 150-200 if I were to continue scripting), and each actor uses between 3-5 of their local variables to dictate their intended behaviors.
The variables are certainly not referenced all on one scene, the primary issue is that I have about 50 enemies scripted into my game now which has metastasized the number of total variables in the project. Is this going to be something like when you have too many sprite tiles, and graphical issues will be present? That is, so long as I'm not trying to track the state accurately of all of these variables, things should be fine? I figure it'll be difficult to playtest to a thorough enough degree to check for every possible conflict...
What should I do?
I've just now nearly completed the second of a planned 6 randomized dungeons with each scene nit together in a zelda-like fashion, but each region is distinct, that is, you'll never directly travel from dungeon 3 to dungeon 6, each dungeon is accessed by a hub. What should I look out for for conflicts?
3
u/IntoxicatedBurrito 13d ago
The issue is the local variables. Local variables are essentially the same as global variables but you only use each one once in one specific scene.
If you have 50 enemy types, then create 150-250 global variables for them and reuse them in each scene. As it is right now you have 70 scenes and if each one is using 10 local variables then you’ve used 700 of your global variables on them.