Two or more people exit a car - Inform 7

I have a car with two occupants.
I can exit one of the occupants but how do both or all occupants exit the car?

note: I set the stage where the player plays the driver of the car and uses the extension Modified Exit by Emily Short.

Mind posting your code? If you’re able to get one out it should be relatively straightforward to get the others out too, but since there are a couple different ways to go about this it would be good to match how you’re already handling it. Most basically you’ll probably want some variation of “Try NCP1 exiting the car” (I think that’s how Modified Exit works?)

Thanks, it will be very difficult to put a specific piece of code about leaving the car.

What I can show is when a vehicle arrives at a location, I use this code:

After going from 1st Street to the 5th Street:
	say "You arrive in 5th Street.[line break]7th Street is to the south.[line break]1st Street is to the north.[line break]3rd Street is to the west.";
	now the car is in the 5th Street;
	continue the action.

To exit the car i just type “Exit car”.

I don’t know how else to explain it with code.

Definition: a person is other if it is not the player.

After exiting from a vehicle that contains an other person:
    repeat with the passenger running through other people contained by the container exited from:
        try the passenger exiting;
    continue the action. [Make sure the report rules still run]

You just want passengers to exit the car when the player does? That should be simple:

After getting off the car:
	Repeat with foo running through people in the car:
		Try foo getting off the car;
	Continue the action.

EDIT: ninja’d!


Ah, but your answer was better, because I mixed up exiting (applies to nothing) and getting off (applies to one thing)! Lemme fix that.

Oh, that makes me feel better! I wasn’t sure whether that syntax was something the extension allowed so just defaulted to get off instead of doing any additional work :slight_smile:

The getting off action is what exiting is converted to when the actor is on a supporter (or what you get directly with the commands “get off [thing]” or “get down [thing]”). So maybe…

Previous-holder is an object that varies.
Before doing anything, now previous-holder is the holder of the player.

After exiting when the previous-holder is the car:
  repeat with p running through people in the car begin;
    try p exiting;
  end repeat;
  continue the action.

Welp, time to actually pull up I7 and make sure my code works this time.

Looks like the default rules don’t have any “applying to one thing” action to leave a container. There’s just “exiting”. Rideable Vehicles adds disembarking but I don’t know if you’re using that.

But, exiting has an action variable for “the container exited from”, which is set to the holder of the actor by default. So I modified my code to be “after exiting from a vehicle”. That appears to work in my installation.

Thanks for everyone’s quick response but this one of Mike is working fine.

Draconis, I think you should change “other people contained by the noun” to “other people contained by the container exited from”. (If the player’s command is EXIT, there is no noun.)

One small issue I have with these solutions is that you get the feedback

This bugs me a little. It was my decision to get out, not the NPC’s, so I want the player’s action to be reported first. For that reason I’d be inclined to use a Last Report rule instead of an After rule.

You are correct; got that changed.

The difficulty with using a Last Report rule is that it won’t run if the action is silent for whatever reason. In general authors can assume that trying an action silently won’t cause any huge changes in its functionality (only in how it’s presented), and breaking that assumption is dangerous.

One solution is to just narrate what’s happening in the After rule. Describe the player and everyone else exiting, then have the actual exiting happen silently.

Yes, that is a better scheme.

The next problem on this car journey is as follows:

Now that I can get everyone out of the car, the car can drive by itself (empty) to other locations.

How can I prevent that from happening?

You’ll really need to post your code for this, since there’s nothing built into the standard rules that moves vehicles around on their own!

If you’re having a hard time isolating the code that’s causing the problem, one thing that can be useful is to start a new, empty project in Inform, then start copying and pasting the relevant code from your main project until you get something that reproduces the bug. Then you can post that for folks to look at and help with.


It is very difficult to post the actual code where this is happening.
(If you check all my other posts, you will see that I do put my code in)

Like in my previous posts I posted the code where a car stops in a street (does not matter which street) and that is where I type “Exit car”.

Now everybody gets out of the car but when you say go south the empty car will go there without anyone driving it.

This code is similar to all other street locations so this is the only viable code I can post in terms of what I am trying to do.

After going from 1st Street to the 5th Street:
	say "You arrive in 5th Street.[line break]7th Street is to the south.[line break]1st Street is to the north.[line break]3rd Street is to the west.";
	now the car is in the 5th Street;
	continue the action.

I am using the extension Modified Exit by Emily Short if that will help.

Yeah, I hear you about the challenge of isolating the bug, but it’s really helpful to be able to post code that reproduces the buggy behavior, if you can. Like, from what you’ve got here I’m guessing the issue is that the player can go from First Street to Fifth Street without being in the car, in which case the “now the car is in fifth street” line will teleport it. But without seeing more, I can’t tell whether the issue is that you don’t have a rule preventing movement outside a car, or you do but it’s not working, or there should be separate rules governing travel in vs not in a vehicle…

Anyway I hope this helps narrow it down!

1 Like

Thanks, I do not try to be difficult not posting more code, I just do not know which code is the culprit as I have lots of code already.

I also think the line

now the car is in fifth street

could be the culprit but I am not sure how to prevent the teleportation if that is the case.

My code and problem put aside for a moment, how would one prevent teleportation of say an object, player, NPC or whatever can be teleported.

I just want an idea what I might be looking for and it might narrow down my search.

To put it simply, the car is moving to Fifth Street because you’re putting it there!

The rule you posted says that when the player goes from 1st Street to 5th Street, the car should teleport there. Remove that rule and the car will stop doing that.

Inform doesn’t generally move things around on its own—it only moves them as a result of the player’s actions (if you drive the car north it’ll move north) or as a result of the rules you’ve written. So the best way to prevent teleportation is just not to tell Inform to teleport things. :stuck_out_tongue:


Yeah, just to expand on this – the issue isn’t moving the car as such, since presumably that’s behavior you sometimes! But the “sometimes” is the rub, since it’s now moving sometimes when you don’t want it to. So the place to look is your rules about getting into the car and moving/driving when the player is in it (and walking from place to place when not in the car, if you have any relevant rules for that).

The testing commands RULES and ACTIONS can be very helpful for this, since they’ll have Inform print out exactly how it’s understanding the commands you type, and then list out the rules it’s following in order. So I might try to turn those on, then try to reproduce the behavior you don’t want and see if that helps narrow down what’s going on.