Ticket to ride

The player is trying to buy a ticket, but Inform isn’t cooperating:

[code]A ticket is a thing in Counter.

Understand “buy [something]” as buying.

The description of the ticket is “A little yellow stub with [’]Welcome[’] printed on it.”

The description of Counter is “[first time]This is where you get the tickets.[only]”

The description of the clerk is “A seedy-looking guy, but what else to you get for minimum wage? He probably just works here for the prestige.”

Check going south when player is in Counter:
if player carries ticket:
continue the action;
say “You need to buy a ticket first.”

Check buying ticket:
if the player carries money:
say “You hand some money to the clerk. He hands you a ticket.”;
now player carries ticket;
now money is off-stage.[/code]

Here’s what Inform reports:

buy ticket
[buying the ticket]
Nothing is on sale.
[buying the ticket - failed the block buying rule]

A quick check of the Actions tab in the Index shows Inform 7 already has a Buying action, so you’ve no need to define a new one and a new Check rule is not the right way to do what you want. Try making it an Instead rule, that’ll bypass the standard rules around buying things.

Didn’t work.

Instead of buying ticket: if the player carries money: say "You hand some money to the clerk. He hands you a ticket."; now player carries ticket; now money is off-stage.


buy ticket
[buying the ticket]
[buying the ticket - failed]

I rewrote the code in accordance with the Recipe Book, then tried buying the ticket again.
Inform reported a failure in buying the ticket, but when I inventoried, I had the ticket in my possession.
I wonder why Inform reported a failure?

“Failed” is kind of jargony in Inform – it doesn’t necessarily mean a failure from the author’s or player’s point of view; rather, it means that the action only got through a certain subset of the rulebooks. I’m attaching an image I’ve made of the basic rulebooks and where the line is drawn between “success” and “failure.” As you see, if an action terminates after an “instead” rule, unless you’ve explicitly told Inform to “continue the action,” (in which case it will proceed through Check, and Carry Out, and Report), it counts as “failure.”

To address why that last bit of code you posted is buggy, try thinking about this: what happens when the player tries to buy a ticket without any money?


Excellent chart Tove, copied that to my machine :slight_smile: