Readthrough mode for adv3Lite!

If you just read my post about readthrough mode for adv3, I apologize, but for newcomers/searchers I’m going to repeat the information describing the mode. But the bottom line is, I’m including code below to add readthrough mode to any existing adv3Lite games!

Readthrough mode is intended for two main purposes.
One: if you are bringing in new testers and you only need them to test later parts of the game, this mode will help them get briefed on the rest of your story in the process of whisking them to the point where you need the work.
Two: bringing players in to your (finished) game who might otherwise never try it because of its length, its puzzle difficulty, their puzzle disinterestedness, or general parserphobia.
The mode seems to me to be a particularly favorable parser introduction to those who are leery of or daunted by parser games, because not only can they see the game play out its commands without effort on their part, they can also dabble freely with entering their own commands with no risk, since the next time they enter a blank command the readthrough takes over again.

I have posted about this previously, but for those who missed it, this is a mode where a player can launch the game, and simply hit the Enter key (with a blank command line) to watch the game play the next step. They can proceed all the way through the game in this manner. However, the game allows the player to enter their own commands as well, with the understanding that the next time a blank command is entered, their autonomous actions will all be undone and the readthrough will proceed from where it left off. They can, however, exit the mode entirely at any point in the readthrough sequence, in which case they can play autonomously from the state that the game was left in. This could be particularly helpful for testers.

It should be able to be incorporated into any existing adv3Lite game. All the author needs to do is supply a list of command strings (which is probably most easily accomplished by using the RECORD feature built into TADS… the code can load the strings from a RECORD file) and perhaps determine how they want to present the option of launching the game in readthrough mode versus normal mode.
If you have randomization in your game, and you need to forcibly move characters or set other data, you can include anonymous functions in your step list, which will be executed directly before the following command.

// in a RECORD file: a string that will be compiled by DynamicFunc
function { igor.moveIntoForTravel(igorsLair); }
>ask igor about himself

// OR steps explicitly typed: can use an actual function pointer

function { igor.moveIntoForTravel(igorsLair); },
'ask igor about himself' ]

The code will be posted below, but I’ll give an overview of what the code is made of in order to make it work.

We create a readthru object, to store various data pertaining to the mode. Most of the principal mechanics occur in a modification of Parser.parse. Undo causes lots of weird situations so we need to modify Undo. libGlobal needs a couple of mods, and we need some verbs for starting the mode, and also for leaving it if the player chooses to continue autonomously from a given point. We also need to add one change to Command.exec to have control over whether the library calls savepoint() or not, and we need to alter processOptions if the author wants to include PC deaths in the readthrough.

[ The website is telling me the post is too long if I paste the code here. I’ll paste it in a separate topic…]
[Readthrough for adv3Lite: the actual code]