Player carries

Hi, I’ve just started with inform 7 and for some reason player carries won’t work. Here is the code that is messing me up:

After entering Kitchen: The player carries Toast.

Simple code but I don’t know what to do.

1 Like

Welcome to the forum! :slightly_smiling_face:

Try this:

After going to the kitchen:
	now the player carries toast;
	continue the action.

The continue the action is required, otherwise the description of the kitchen will not be printed after entering it. Another solution would be to use Carry out going to the kitchen instead of After going to the kitchen. Then continue the action is not needed.

2 Likes

Inform 7 has two ways of describing the world. The declarative form describes the world. It happens out in the source text. Notice that it doesn’t tell you when something happens, just that something is.

Home is a room. John is a man.

The imperative form is encapsulated in rules and phrases. It describes an event or change to the world.

When play begins:
    now the ruddy dog is in the location of the player.

The two paradigms don’t mix. You can’t use declarative syntax from within a rule or phrase, because those things can’t contain world facts.

To change your statement from declarative to imperative, use the now keyword.

1 Like

Hmmm… I’ve tried Carry out going to the kitchen:, continue the action and adding now but they still don’t seem to be working.

I wonder if it’s to do with that there isn’t a Toast object before then?

Yes, it’s a good idea to create the important things, first.

Living Room is a room.  "This is your modest living room.[paragraph break]To the west is your modest kitchen."

Kitchen is west of Living Room.  "This is your even more modest kitchen.[paragraph break]You can go east back to the living room."

Some toast is here.  It is edible.  "Lying inexplicably on the floor is a piece of toast."  The description is "Brown.  It looks edible."  Understand "piece/-- of/-- brown/-- toast" as the toast.
After eating the toast:
    say "You chew on the toast, licking your fingers.  It wasn't buttered, but it was sufficient for just one piece of toast."

You don’t need a ‘Carry out’ rule for ‘going’ as that is an action built into Inform7. Writing Carry out rules for built-in actions is generally discouraged–you’ll want to do this only for new actions that you create. If you want a built-in action (such as ‘going’, etc) to have additional results, it’s probably best to use an ‘After’ rule, such as Bjorn advises above (and you will want to add a sentence telling the player that the toast has been taken by the player–a ‘now’ statement will give the player the toast without telling)–

After going to Kitchen:
    say "Seeing the toast on the floor, and having no other food option, you pick it up, presumably with the intention of eating it.";
    now the toast is carried by the player;
    continue the action.

Of course, you don’t have to say it all my way, be creative with quoted text. I always say ‘a [name of the object] is here.’, then list its properties, then write a sentence or two for its initial appearance (for take-able objects–it’s what the player reads in the room description before he takes the object), then its full description (the other quoted text), then an Understand phrase (the /-- indicates optional words), for synonyms that the player can refer to it with.

I admit that this is a little too much at first, but the bare-bones is that it is good to create your objects first, then write the rules. ‘After’ is probably the best for defining additional results of built-in actions, and do a ‘continue the action’ at the end of the rule if it is a ‘going’ action–because ‘going’ is always followed automatically by a ‘looking’ action, but an After rule will short-circuit the looking if you don’t allow it to continue, resulting in no room description.

Strange. I’ve tried that and it still isn’t working.

Could you post your current code? If it’s too big, you could either cut it down in size or post it on bitbucket.

I should have added another line like so–

After going to Kitchen:
    if the toast is not handled:
        say "Seeing the toast on the floor, and having no other food option, you pick it up, presumably with the intention of eating it.";
        now the toast is carried by the player;
    continue the action.

‘if the toast is not handled’ insures that the player gets the toast only the first time that he enters the kitchen.

Now I’ll let you post your code.

Adding the if seems to break it even more. So does continue the action;

I do think it would help to post your code! It’s hard to tell how things are broken if we don’t know what you’re trying to compile.

To spell out what EpicIFer said about creating objects first–“now the player carries toast” will not create a toast object. In fact it’s basically impossible to create objects while the game is running.* You have to create the objects with those declarative form statements Björn was talking about. Then you can move them around with the rules and phrases.

If you don’t want the toast to be present anywhere at the beginning, that’s OK: you can write

Some toast is a thing.

This will create a “toast” thing that isn’t in any room at the start of play. Then when you write:

After going to the kitchen:
	now the player carries toast;
	continue the action.

going to the kitchen will move the toast into the player’s inventory.

*There is an extension to allow this, but you really don’t want to get into that.

2 Likes

Thanks! It must have been that Toast wasn’t a thing before that.

And don’t forget to tell the player that he has taken the toast!