Trouble with Trying

I’m working on a game with multiple beds the player might want to sleep on, so I wrote some code for an action to sleep on a specific object. It looks like this:

A bed is a kind of supporter. It is usually scenery.
The guest bed is a bed. 

Sleeping on something is action applying to one thing.
Understand "sleep on [something]" as sleeping on something.
Check sleeping on something:
	if the noun is not a bed:
		say "You can't sleep on that." instead.

Carry out sleeping on something:
	say "[Player's forename] climbs into [the noun] and goes to sleep.".

This all works fine. However, I wanted to include an option for the player to just type “sleep” and then sleep on the default bed. Unfortunately, I haven’t been able to get it to work.

Instead of sleeping when the guest bed is visible:
	try sleeping on the guest bed.

When I add that, I get an error:
Problem. You wrote ‘try sleeping on the guest bed’ but this is not an action I recognise, or else is malformed in a way I can’t see how to sort out.

I can’t seem to fix this. Can anyone tell me what is going wrong?

1 Like

You don’t want something in the action name. With these changes, it’ll work.

Sleeping on is an action applying to one thing.
Understand "sleep on [something]" as sleeping on.

These rule preambles are fine as is:

Check sleeping on something: [...]
Carry out sleeping on something: [...]

although the somethings aren’t necessary for this case.

You may want, though:

a bed is  always enterable.

Carry out sleeping on something:
  now the player is on the bed.

Report sleeping on:
	say "[Player's forename] climbs into [the noun] and goes to sleep.".

or, depending on details of what you have in mind and what enter bed should do, maybe:

instead of sleeping on a bed: try entering the noun.

after entering a bed: say "[Player's forename] climbs into [the noun] and goes to sleep.".
2 Likes

Thank you, that was a huge help

1 Like