Is there a special syntax for dropping something in a conditional?

The three stages of an action itself are Check, Carry Out, and Report. But you can, if you wish, also intervene Before, Instead, and After.

Before rules intervene before any other rules at all have been considered. So you could use a Before rule, and it would work even in darkness, for example.

Instead rules are general purpose rules: they’re run before check rules, so they can be particularly handy for intervening when you want to affect several rules.

Instead of examining, searching, or looking under the bed:
say “'Aha! There’s my hockey stick!”
now the hockey stick is in the location;

But this usefulness comes at a price: all Instead rules are put into a single rulebook (called, not surprisingly, “the Instead rulebook”), so if you use Instead rules a lot, you can end up with the game slowing down because it has to churn its way through the Instead rulebook for every single action.

If you use a Check rule though, the game only has to check the rules for that particular action, in this case the “Check taking” rulebook. In a larger game this can amount to a significant efficiency saving. It’s perfectly okay to include logic in a check rule, but if you want the check to actually prevent the action from occurring, you have to end the rule with either the phrase “stop the action;” or the keyword “instead;”

So an alternative to the hockey stick “instead rule” above might be–

Check searching the bed:
	try looking under the bed instead;
	
Check examining the bed:
	try looking under the bed instead;

Carry out looking under the bed:
        if the hockey stick is nowhere:
	     now the hockey stick is in the location;
	
Report looking under the bed:
	say "'There's my old hockey stick!' you exclaim.";
	stop the action;
	

Obviously that’s more typing (not to mention the possibility of then accidentally diverting looking under and ending up with a loop!) but hey, you pays your money and you takes your choice.

Carry out rules shouldn’t print any text - this is so that they can be tried “silently” by the library.

Report rules are intended to amplify the standard library message. So –

Report taking the hockey stick:
say “‘Yippee!’ you say, groping eagerly under the bed.”;

Will result in

take hockey stick
“Yippee!” you say, groping eagerly under the bed.
Taken.

That’s why the Report looking under the bed rule had “stop the action;” as its second statement. Without it, you’d get:

search bed
“There’s my old hockey stick!” you exclaim.
You find nothing of interest.

After rules come after the action has happened, but they supersede the default library message, so –

After taking the hockey stick:
say “‘Yippee!’ you say, groping eagerly under the bed.”;

Will print only that message, there’s no need to suppress the standard library message.

I know that having both “After” and “Report” rulebooks seems redundant, but it comes in handy when you’re animating NPCs and want them to react to what the player’s just done. (of course if you want them to interfere before, you’d use a Check rule.)

"The bedsit" by "Testa"


The grubby bedsit is a room. "Nothing much to see here, apart from the usual detritus of life."

A lumpy bed is in the grubby bedsit. "A lumpy bed is pushed up against one wall."

Your old hockey stick is nowhere. "The handle of your old hockey stick protrudes from under the bed."
[ "is nowhere" is optional, simply leaving the initial location unstated would also work, but it tells me, later, that I intended it to begin the game off-stage, and didn't simply forget.]

After taking your old hockey stick:
	if the player can see harriet:
		say "Harriet gives the hockey stick a disdainful glance.";
	continue the action;

[instead rules can be handy for grouping rules together, to ensure the same code is run despite the player trying a variety of approaches.]
Instead of searching or looking under the lumpy bed:
	say "'Ah! There it is!' you cry. 'My old hockey stick!'"; 
	now your old hockey stick is in the grubby bedsit;
	
Harriet is a woman in the grubby bedsit. "Harriet leans against the wall, looking bored."

An umbrella is in the grubby bedsit.

Instead of opening the umbrella when the player can see harriet, say "Harriet glares at you. 'Don't you shake that wet thing over me!' she exclaims."

Check opening the umbrella:
	say "You flap the umbrella repeatedly open and shut to rid it of the last of the rain." instead. [instead rule intervenes before this rule is reached.][n.b. note that you'd have to make the umbrella "openable" if you wanted to actually carry out the action. ]
	
Report taking the umbrella:
	say "You pick up the umbrella and shake the rain off it.";
	stop the action;
	
After taking the umbrella:
	if the player can see harriet:
		say "Harriet raises her eyebrows. 'Can't think what you want that wet old thing for,' she says.";
	continue the action;
	

The hallway is south of the grubby bedsit. "A narrow hallway with a threadbare carpet."


Test me with "take umbrella / open it / s / open it".
2 Likes