NOBODY PANIC; I HAVE FIGURED IT OUT!
Behold, the new set of compiler options:
## Makefile for an adv3Lite library game template
-I liblite
-D LANGUAGE=english
-Fy obj
-Fo obj
-FI /usr/local/share/frobtads/tads3/include
-FL /usr/local/share/frobtads/tads3/lib
-we
-v
-d
-pre
##sources
-lib system
-lib adv3Lite/adv3Lite
-source gameMain.t
-res
GameInfo.txt
I needed to include -pre
if I was using -d
, which means “use pre-initialization in a debug build, and this is a debug build”.
The reason why my project was taking so long to load was because, by default, debug builds (-d
) skip pre-initialization, and instead perform it when the game normally loads, within the interpreter of your choice. This means that I was right in suspecting that pre-init was happening during the testing phase.
The reason for this is because you are able to log debug output during pre-init, as long as you do not include the -pre
option. If you do include the -pre
option, then pre-init does happen for your debug build, during compile. This means you effectively forfeit your opportunity to get logs during pre-init, as the compiler does not let you hear your program scream during this stage.
So, I am now able to confirm that I am correctly utilizing pre-init, and the data loads just fine! I also have some other funny observations:
- Transience does not matter during pre-init. If your data is
transient
, it’s welcome to come along for the ride; it’s just not allowed in save files, specifically. If you instantiatetransient
object
s, they are saved into the pre-init result, just like everything else. - It seems that @johnnywz00 was quite correct: If you do not want something saved during pre-init, just set it to
nil
when you’re done. Thank you, John!
Also, thanks again to @jnelson and @jbg for all the pointers so far!
Only one question remains:
Do I need to manually perform garbage collection with t3RunGC()
before the end of execute()
in a PreinitObject
, or is garbage collection performed automatically before writing to the final gameMain.t3
file, after pre-init?
I just don’t want to accidentally save garbage memory to a game file during pre-init.
In software engineering, they say that the rubber duck method works wonders.
Clearly, it does.
However, I seem to have made the whole forum into a giant, collective, rubber duck, at least for a moment there. Hopefully, making myself a public mess in a manic state was informative, if not slightly entertaining. Thanks to everyone for allowing me space to do so, lol.