My way of making a CYOA in Inform 7 is avoiding the parser and world model completely.
You can consider this a major hack approach to Inform 7, because I’m really ignoring 95% of its capabilities. I’m just using it to:
- Collect keypresses
- Sometimes change internal variables
- Print things out depending on the keypresses and the internal variables
I could do this in Applesoft BASIC except that if I do it in Inform, it’s more portable, is in context and has a bigger audience.
The way I see it, leaving the parser running in Inform 7 while you’re trying to collect discrete choices and answers is an incredible pain in the butt. You have to keep screening for different kinds of answers while screening out everything else in the world. On a personal note, as a user, I always groan when a game wants me to type an answer in and press return just to choose a discrete option. I wish it would just let me tap Y, or N, or 1 or 2 or 3, etc.
So my way of avoiding the parser is to immediately ask the user for a keypress (no RETURN required) ‘When play begins’… and then never, ever stop asking for keypresses.
A regular ‘turn’ never passes because the parser doesn’t even turn on once. There’s only one room, and that’s only there to allow the game to compile. I don’t use the room in the game.
The program loop then becomes: I wait for a keypress, see what it was, then run another routine based on that keypress. The new routine, in turn, prints some info, then asks for a keypress, then responds. Repeat until outcome or game over. The parser stays in its cage.
To program like this, you need to create the routine that collects the keypress, and at each appropriate moment you feed it a possible set of responses (EG you tell it ‘ok, this turn, accept 1-6, or this turn, accept only the letters Y N or M’.)
Otherwise, it’s just a bunch of routines which print text, and each one has a different logical name. You do any variable manipulation yourself.
That’s the approach. I hope that mostly makes sense, but I can return with some specific code / examples later if you’re interested.
I think it’s easy to program a CYOA this way in Inform. I think the reason other people don’t do it is just because they’re (understandably) trying to program from Inform 7’s parser-driven perspective, and that perspective is all dead weight for a CYOA.