Inform 7 Bicycle

I’m taking a first few baby steps into Inform 7, trying to implement a few things that I’ve done successfully in Adventuron. I’m finding it a steep learning curve and am struggling with some basics. One of the things I’m trying to create is a bicycle but I’ve run into a couple of issues:

  1. DISMOUNT BICYCLE produces = ‘I only understood you as far as wanting to dismount.’ GET OFF BICYCLE works though. I think that’s because dismounting is defined as an action applying to nothing? How do I modify it to accept DISMOUNT [noun] as well as just DISMOUNT?

  2. I want the player to be able to mount the bicycle if they are carrying it and drop it (dismounting first) if they’re riding it. I’ve managed to do the first bit with a before rule (avoiding the ‘You can only get into something free-standing’ response) but I can’t work out how to do the second bit and avoid the ‘You haven’t got that’ response. Trying to make the bicycle carried prior to dropping, if the player is riding it, produces the error: [** Programming error: tried to “move” bicycle to yourself, which would make a loop: bicycle in yourself in bicycle **]. I’ve tried ‘now the player is dismounted’ or ‘now the player is not on the bicycle’ but that doesn’t work either. How can I achieve this?

Here’s the code:

Include Rideable Vehicles by Graham Nelson. 

The place is a room.

The bicycle is a portable rideable vehicle in the place. Understand "bike" as the bicycle.

Before mounting:
	if the player is carrying the noun:
		now the noun is in the location.
		
Before dropping:
	if the player is on the noun:
		now the noun is carried by the player.
1 Like

You could do this for point 1:

Understand "dismount [something]" as getting off.

And for 2, one possibility would be like this:

Instead of dropping the bicycle when the player is on the bicycle:
	try dismounting;
	rule succeeds.

You don’t strictly need the “rule succeeds”, but it will let Inform count the action as successful, so if it ever becomes necessary to test for “if we have dropped the bicycle” somewhere else in your code, it will count.

4 Likes

Thanks! That works.