What are my CYOA options in I7?

Hiya!

My friend wants to know what the options are to make a CYOA game in I7.
I’m totally not asking this for myself and it’s absolutely not suspicious at all. Stop looking at me like that.

I know AW Freyr has an extension for it, but are there any others? Or what’s a good way to do it?

This is not a thing I - I mean my friend - can do in Twine or somesuch.

Thank you for your time.

[rant]I did check out Adventure Book but that gives me the following, which I don’t know how to fix.

[/rant]

Re the error: you need to replace “change…to…” with “now…is…” in the new versions of I7. It’s an old deprecated syntax that was finally removed in 6L02.

I think AW Freyr based Hybrid Choices on Adventure Book, the difference being with Hybrid you can switch between CYOA at will along with parser, whereas Adventure Book is intended to stay in CYOA.

Some other potential non Inform or Twine CYOA systems are Squiffy, Quest, Storynexus, Choicescript (CoG), and ChooseYourStory.

That did fix the thing. Sadly, I don’t think this will be able to provide me with what I … my fr-… what I need.

Looks like it. A lot of the “do these things to make it work” things match between the two.

… Why would I want to leave the I7 blanket?

Well, for example, many of these are a little easier than I7, or at least less fiddly when working with CYOA since they are designed for a choice-based narrative. Some have interesting features:

Squiffy allows some neat text replacement and manipulation commands.
Choose Your Story has a built-in inventory system.
Quest allows you to build your game online and I think use the underlying scripting in CYOA.
ChoiceScript offers statistics with progress bars similar to an RPG.
Storynexus gives you a card-drawing deck mechanic and some outrageously flexible “quality” statistics.

The main benefit of using Inform for a CYOA is that you already know the language and world modelling is easy. Quest has world modelling and requires no (or very little) language learning so comes somewhat recommended… however! Inform is the best system out of all systems for text substitution options. So while it’s fiddlier to get off the ground (definitely use an extension), it’ll be easier to do more sophisticated things with the text.

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.

-Wade

2 Likes

Depends what you want to do with text - you cannot replace text that’s already on screen in Inform.
I agree that building random phrases is easiest in Inform.

Despite understanding Inform decently well, I can definitely tell you which language is simplest to quickly be able to make a CYOA in:

Squiffy:

[code]Looking around the room, you can see a [TV], a [book] and a piece of [paper] with some handwriting scribbled on it.

[TV]:
Covered in dust and the plug is missing.

[book]:
It’s a book of magic tricks. Maybe you should [open] it?

[open]:
The cover opens up to reveal the pages all glued together, with an empty key-shaped hole cut out.

[paper]:
“Gone out for a walk. May be a while.”[/code]

Choicescript:

[code]Your majesty, your people are starving in the streets, and threaten revolution.
Our enemies to the west are weak, but they threaten soon to invade. What will you do?

*choice
#Make pre-emptive war on the western lands.
If you can seize their territory, your kingdom will flourish. But your army’s
morale is low and the kingdom’s armory is empty. How will you win the war?
*choice
#Drive the peasants like slaves; if we work hard enough, we’ll win.
Unfortunately, morale doesn’t work like that. Your army soon turns against you
and the kingdom falls to the western barbarians.
*finish
#Appoint charismatic knights and give them land, peasants, and resources.
Your majesty’s people are eminently resourceful. Your knights win the day,
but take care: they may soon demand a convention of parliament.
*finish
#Steal food and weapons from the enemy in the dead of night.
A cunning plan. Soon your army is a match for the westerners; they choose
not to invade for now, but how long can your majesty postpone the inevitable?
*finish
#Beat swords to plowshares and trade food to the westerners for protection.
The westerners have you at the point of a sword. They demand unfair terms
from you.
*choice
#Accept the terms for now.
Eventually, the barbarian westerners conquer you anyway, destroying their
bread basket, and the entire region starves.
*finish
#Threaten to salt our fields if they don’t offer better terms.
They blink. Your majesty gets a fair price for wheat.
*finish
#Abdicate the throne. I have clearly mismanaged this kingdom!
The kingdom descends into chaos, but you manage to escape with your own hide.
Perhaps in time you can return to restore order to this fair land.
*finish[/code]

I7, Hybrid choices

[code]P1 is a page.
“You have just slain the Troll of Bigness, and are ready to make your way into the Temple of Fear. It’s just over the bridge to the north.”

P2 is a page.
"[first time]You cross the bridge and find yourself in a huge forest. [only]The door to the Temple of Fear is north. There is a path through the forest to your left."
The cdesc is "Cross the bridge." It is for p1.

A page-toggle rule for p2:
	now the cdesc of p2 is "Head back to the Temple of Fear."

p3 is a page.
It is flipped to by p2.

p4 is for p3.
"You check the door, but it appears to have a lock or something. Damn."
The cdesc is "Check the door.". It is a dead-end.

A page-switch rule for p4:
	if the player is carrying the bronze key:
		now the current page is p12.

p5 is for p3. It is one-off.
"You travel through the forest and eventually encounter a troll."
The cdesc is "Go to the forest.".

A choice-switch rule for p5:
	if the player carries the bronze key:
		rule fails.

p6 is for p5.
"You slay the troll and lose 4 stamina in the process as it clubs you."
The cdesc is "Kill the troll by stabbing it.".

[/code]

That said, I think Hybrid Choices is amazing and think people should use it. But if you’re making a straightforward choice narrative, it may not be the quickest option to learn.

I have an experimental extension, Unified Glulx Input, which lets you take the all-keypress approach in a less hacky way.

github.com/erkyrath/i7-exts/blo … 0Input.i7x

See the “Maze of Keys 2” example.

Thanks Zarf, this looks great.

So for onlookers, something you could do with this extension is restrict all input to keypresses WITHOUT dispensing with the world model. I’d need to experiment with it before I said anymore.

-Wade

Who told you of my plan?

Unfortunately for Zarf (or at least, for early testing of his extension), I’ve already realised I still don’t want the world model.

I did test the Unification extension while working this out, though, and I think there is some conflict between the extension and Basic Screen Effects,and/or the Unicode extension(s). Because on compile, the compilation kept failing on a error I’d look up in the report and find was ‘VM_GetChar is unsupported/doesn’t exist’. (Sorry for imprecision, that was 2 hours ago and now I’ve had a BBQ and several glasses of wine.)

The upshot is, I saw that in the new Basic Screen Effects that Em Short commented just before defining GetChar that it was no longer supported - but she put it in that she was keeping it ‘just in case.’

Once I had BSE plus the Maze2 demo going together in the one project, it would always crash on compile, complaining about GetChar. The crash only went away when I separated Screen Effects from Maze2 or vice versa.

-Wade

Yes, UGI conflicts with everything because it’s a complete redesign of the low-level input loop.

Yeah, I realised that as soon as I woke up and had no alcohol in my system, and rued the memory of my post. :unamused:

-Wade

I know this is a super old post, but this is basically exactly what I’m trying to do with my game-in-progress and I have no idea where to begin. It seems like it should be pretty simple, but I have no experience in Inform so I’d love to see any code/examples!

In case it’s useful to know, I’m actually trying to make a game in three parts: there are sections in a bedroom you can explore in depth using typical parser commands, then a conversation with numbered dialog options to choose from, then sections where you just forward text by pressing any key.

Definitely check out the “Hybrid Choices” extension (mentioned above). It allows you to switch between parser mode and choice mode at any time.

The current version is neither in the official nor semi-official repositories, but you can download it from here:

2 Likes

Thanks!!

I received AW Freyr’s blessing and committed version 7 of Hybrid Choices to the Friends of I7 Extensions repo.

6 Likes