I’m modularising my game into chapters so I can compile it with just one chapter active at a time. This mostly means the main source cannot refer to specific things in chapters. Each chapter has its own extension. In some cases, these extensions drop chapter-specific rules into rulebooks when they’re included.
I’m having trouble with this drop-in system and a particular programming approach. I’ve reduced it to a coding example here.
Summary: I have these backdrops, which here we’ll call feature-props.
The idea is, 90% of actions tried on a feature-prop fall through to a fob line of ‘That doesn’t make sense’ via an ‘Instead of doing anything but examining to a feature-prop:’ rule. But first some actions are checked and allowed to continue, others are redirected, and others get a custom fob message.
The process is:
- Action tried on a feature-prop enters instead rule.
- A series of rules dropped in by specific chapters are run (abided by). They could stop things, redirect, or allow the action to continue Right Away.
- If the action wasn’t dealt with somehow, it reaches the bottom and says ‘That doesn’t make sense.’
I need to abide by the chapter-specific rules if I want their ‘instead’ clauses to stop things. But I can’t work out how to make an allowed action continue Right Away. Using ‘continue the action’ simply keeps all the rules flowing, whether I use abide or follow. It doesn’t exit and run the action.
This system worked when I had one mega-rule to do the whole thing, because then ‘continue the action’ exited the main rule and did indeed continue the action. But now I need it modularised and can’t work out the best way to do it.
In the example code, if you type LOOK UNDER CARRIER, the desired behaviour is that that action is allowed as per the chapter 1 rule and says ‘You find nothing of interest’. What actually happens is ‘continue the action’ does nothing, all the rules run, and then the fallthrough is reached and printed: “That doesn’t make sense.”
Summary
A feature-prop is a kind of backdrop.
current chapter is initially 1.
underwater is a room.[chapter 1]
a carrier is a feature-prop in underwater.
atrium is a room.[chapter 2]
a marble pool is a feature-prop in atrium.
pool water is a feature-prop in atrium.
Instead of doing anything other than examining to a feature-prop:
abide by the chapter-specific feature-prop rules;
say "That doesn't make sense.";[fallthrough line]
The chapter-specific feature-prop rules is a rulebook.
A chapter-specific feature-prop rule (this is the chapter 1 rule):
if current chapter is 1:
if noun is the carrier:
if searching:
instead try looking under carrier;
if looking under:
continue the action;
if eating:
instead say "Don't be ridiculous.";
A chapter-specific feature-prop rule (this is the chapter 2 rule):
if current chapter is 2:
if noun is pool water:
if looking under:
instead try searching marble pool;
if drinking or entering or searching or tasting or touching:[a general redirect]
now the noun is marble pool;
continue the action;
The example’s more illustrative than practical. You’d have to change the start location, and the current chapter value to 2, to try the second rule, but there’s no need to. You can see what’s going on with the chapter 1 rule.
-Wade