Startup Precomputation by Dannii Willis


There are a few Inform stories which do so much in their "when play begins" rules that the interpreter pauses for a few seconds on the fastest computers. On slow computers it can take much longer. This extension provides a system for the results of the startup code to be saved and loaded the next time the story file is run. It is also possible to embed that precomputation data inside the blorb so that those who download your story don't even need to run the startup code once!

This extension adds two rules: the attempt to load a precomputation data file rule in the after starting the virtual machine rules, and the finalise startup precomputation rule in the when play begins rules. You must ensure that all of your slow startup rules run before the finalise startup precomputation rule, by using "listed before" statements as described in section 19.4 of the manual.

To embed the precomputation data inside the blorb, compile a release version of your story and run it once to produce the data file. Then use a blorb editing program to add the data file as a new blorb chunk. I recommend Andrew Plotkin's blorbtool.py (available at https://github.com/erkyrath/glk-dev/blob/master/blorbtool.py). This command will embed Story-startup-data.glkdata inside Story.gblorb:

python blorbtool.py Story.gblorb import Data 9998 IFZS Story-startup-data.glkdata

This extension will by default use a blorb resource number of 9998. If for some reason you need to change it, you can use this command to set another (higher) number:

Use startup precomputation blorb chunk number of at least 10000.

This extension is released under the Creative Commons Attribution licence. Bug reports, feature requests or questions should be made at <https://github.com/i7/extensions/issues>.