Getting off a rideable vehicle

Hi,

I’m using Rideable Vehicles, and want the player to get off a bike before going into particular zones. My code works to warn the player that they need to do this, but I want to be a bit more helpful and get Inform to actually get off the bike for them. However, I can’t get the command right.

My vehicle is ‘bike’. I have two regions, and I want the player to automatically get off the bike when going from one region to the other. As I said above, the code works up to and including the ‘say’ below - it’s the next line I can’t get right.

before going from bikeplace to nonbikeplace:
if player is on bike:
say “You’ll have to leave the bike behind first. It’s got a big combination lock on the back wheel so should be safe, even here.”;
now player is dismounting the bike;
continue the action.

I’ve tried ‘now player is getting off the bike’, ‘now player is dismounting the bike’, ‘now player is off the bike’…but just get:

Problem. In the sentence ‘now player is dismounting the bike’ , I was expecting to read a condition, but instead found some text that I couldn’t understand - ‘player is dismounting the bike’.

For each version. I’m sure I’m missing something really obvious here…please help. How can I get the code right to get the player off the bike?

Thank you,

Ian

If you want to make an action happen, use “try”, as in “try dismounting the bike”.

2 Likes

I haven’t used the extension, but “try” is the command you use to get the player to (try to) perform an action – see the docs here. So I suspect what you need to do is sub in some line like “try dismounting the bike”

EDIT: ninja’d!

EDIT 2: given that you’re outputting text already, you might actually want “try silently” rather than try (which suppresses the default reporting rules), in case those don’t make sense with the custom stuff you’re writing in the before rule.

1 Like

Thank you. For some reason ‘now’ works when getting on the bike as in:

instead of taking bike:
say “It’s a big old heavy bike. You decide not to pick it up, but instead get on it.”;
now the player is on the bike.

But ‘now’ does not work (as far I as I can see) when getting off the bike.

However, following your helpful suggestion (with a little adaptation):

instead of going from bikeplace to nonbikeplace:
if player is on bike:
say “You’ll have to leave the bike behind first. It’s got a big combination lock on the back wheel so should be safe, even here.”;
try getting off the bike;
continue the action;
else:
continue the action.

Does the job.

Thank you again,

Ian

The difference is that “now” directly changes the state of the world, whereas “try” gets the player to take an action (which in turn will change the state of the world). In most cases it’s possible to take either approach if you work at it – again, I haven’t used the extension, but there’s probably some syntax that will get you there, like “now the player is in the location” – but typically the “try”/action approach is better since it obeys the various other rules you’ve set up, whereas “now” is a blunt approach that might lead to some odd results.

1 Like

I imagine that the problem is that you are writing something like “Now the player is not on the bike”. But you can’t tell Inform to move the player without specifying exactly where.

3 Likes

Yep; “on the bike” is a specific position to move the player to, but “off the bike” or “not on the bike” isn’t. Inform isn’t smart enough to realize that you probably mean “in the holder of the bike” (i.e. whatever directly contains the bike) if you don’t say that explicitly.

“Try dismounting” invokes all the machinery that handles commands like > GET OFF THE BIKE, and that machinery includes code to decide where exactly to put the player.

1 Like

Hi,

Thanks for this. It actually gets weirder (at least to my eyes!).

The code below nearly works.

before going from bikeplace to nonbikeplace:
	if player is on bike:
		say "You'll have to get off the bike first. It's got a big combination lock on the back wheel so should be safe, even here.";
		try the player getting off bike;
		continue the action;
	else:
		continue the action.

What happens here is that the player gets off the bike (good), but the bike ends up in the first ‘nonbikeplace’ location - and the player ends up in the last ‘bikeplace’ location. It’s as if the game has moved the player, got off the bike, then moved the player back again (although that movement isn’t reported in the game).

If I replace the first ‘continue the action’ with ‘stop the action’ , the player and the bike end up in the last ‘bikeplace’ location, but the player then doesn’t move (which is kind of what I’d like to happen). The same thing happens if I replace ‘instead’ with ‘before’.

So I can get half of what I want (the player off the bike), but I can’t get both the player off the bike and then to move…

Thanks again to anyone who has any thoughts on how to fix this (if it is possible to do so).

Best wishes,

Ian

You’re getting some interference from the move player and vehicle rule (part of the Standard Rules), which says:

Carry out an actor going (this is the move player and vehicle rule):
    if the vehicle gone by is nothing,
	    surreptitiously move the actor to the room gone to during going;
    otherwise
	    surreptitiously move the vehicle gone by to the room gone to during going;
    if the location is not the location of the player:
	    now the location is the location of the player.

The vehicle gone by will have been set to the bicycle while setting action variables, which is very early in action processing. Your Before rule doesn’t modify that action variable, so when the above rule is reached in the Carry out rules, the bicycle will be moved. However, due to your Before rule, the player will have already dismounted by that point, so the player stays behind.

See WWI 12.2 How actions are processed for more details.

Here’s a super-short example that seems to work:

"Leave Bike Behind"

Include Rideable Vehicles by Graham Nelson.

Bikezone and Nonbikezone are regions.

Place is a room.

Place is in Bikezone.

Other Place is east of Place.

Other Place is in Nonbikezone.

A rideable vehicle called a bike is in Place.

The player is on the bike.

Before going from Bikezone to Nonbikezone:
    if player is on bike:
	    say “You’ll have to leave the bike behind first. It’s got a big combination lock on the back wheel so should be safe, even here.”;
	    silently try the actor dismounting;
	    now the vehicle gone by is nothing;
	    continue the action.

Test me with "e".
2 Likes

Wow. Thanks. I’m beginning to wonder if Inform 6 might be better suited to me - I appreciate that you can set up a lot really quickly with Inform 7, but when unexpected things happen the squirrel holes you have to go down seem not entirely obvious…

Thank you again.

Ian

I’m beginning to wonder if Inform 6 might be better suited to me - I appreciate that you can set up a lot really quickly with Inform 7, but when unexpected things happen the squirrel holes you have to go down seem not entirely obvious…

Perhaps. Or you might find that Inform 6 has squirrel holes of its own. It has happened several times that I’ve tried doing things in Inform 6 that are straightforward in I7, and simply couldn’t work out how to do it. And vice versa.

1 Like