Identifying the other person that a person is related to.

I have a relation called “leading.”

[code]Leading relates one person to another. The verb to lead means the leading relation.

Definition: a person is being led if someone is leading them.

Definition: a person is leading if someone is led by the person.[/code]

I have one rule about leading that works so far.

Instead of going somewhere while being led: say "You cannot move, you are being guided. That'd be rude.".

However, I need a rule that automatically places the person being led into the location of the leader. This is my best attempt:

After going somewhere while leading: let the subject be the person who is led by the person asked; let the way be the location of the person asked; move the subject to the way.

This fails to compile, stating that “the person who is led by the person asked” could apply to multiple people, therefore rendering the description invalid. How could I be going about this better?

You could specify “a random person who is led by the person asked”. That solves the problem with the description potentially applying to many people.

Another way would be to give a name to the person led:

Leading relates one person to another (called the follower). 

Now (after your definitions) you can write

After going somewhere while leading:
	let the subject be the follower of the person asked;
	let the way be the location of the person asked;
	move the subject to the way.

You also need to change your second definition, since Inform won’t accept “the person” as a description. You can do this in several ways:
these should all work (because Inform knows how to conjugate the verb “to lead” without being told).

Definition: a person is leading if they are leading someone.

or

Definition: a person is leading if they lead someone.

or

Definition: a person is leading if someone is led by them.

Or you can give a name to the person in your definition in order to refer to them in the body of the definition. (This can be useful for more complicated cases.)

Definition: a person (called Guy) is leading if Guy leads someone.

Thanks, but it looks like we’re not quite done here. If I say “now (person) is leading the player,” I get strange results if I “try (person) going west” for example. My code for this so far is:

[code]Leading relates one person to another (called the follower). The verb to lead means the leading relation.

Definition: a person is being led if someone is leading them.

Definition: a person is leading if someone is led by them.

Instead of going somewhere while being led:
if the person leading the person asked is in the location:
continue the action;
say “You cannot move, you are being guided. That’d be rude.”.

After going somewhere while leading:
let the subject be the follower of the person asked;
let the way be the location of the person asked;
try the subject going the way;
try the subject looking.[/code]

What happens is once the CPU character is leading the player and then tries going west, that character will go west but nothing happens to the player. The player still cannot move in this state. Deleting the rule about not being able to move does not solve the problem of the player not moving with the CPU character.

To make a rule apply when an NPC tries the action, as well as the player, you need to start with “After an actor going […]”.

Also, “going the way” requires “the way” to be a direction, not a place. You can set it to “the best route from [X] to [Y], using doors”, or just replace “the way” with “the noun” there (since the noun in a going action is the direction).

After adding those suggestions and making some other modifications, I’m getting really close.

[code]Leading relates various people to one person (called the follower). The verb to lead means the leading relation.

Definition: a person is being led if someone is leading them.

Definition: a person is leading if they are leading someone.

Before an actor going somewhere while being led:
say “You cannot move, you are being guided. That’d be rude.”;
stop the action.

After an actor going somewhere while leading:
let the subject be the follower of the person asked;
let the way be the best route from the location of the subject to the location of the person asked;
now the person asked is not leading the subject;
try the subject going the way;
now the person asked is leading the subject.[/code]
I couldn’t figure out how to let the follower move under specific conditions while being led, so I just destroy the leading relation and then recreate it after the leader’s rule is done. So, now when the leading actor moves, the player character does try to move through the route automatically, but it gets stuck at “You can’t reach into (adjacent location)”, and then the move fails. Attempting to move after that results in the “cannot move” line. I’ve never seen this type of command rejection before.

The posted code works for me, so there must be something elsewhere in your code which is interfering. Can you post enough to exhibit the problem?

Have you tried testing it with the ACTIONS and RULES debugging commands? They will probably give you a clue to where the problem is.

I did get the code to work in one instance. Here’s my map:

I have an NPC in the room in the center of the image. If the player performs a certain action with that NPC, I want the NPC to start leading the player to an adjacent room. Scripting the NPC to go east of that center room (through the door) works, but going west does not work. And of course the direction that I need to work is the one that doesn’t. :cry:

Here’s some sample output. The only difference between these two images is one game has the line “try Modthryth going west”, while the other one has that replaced with east.
[rant]Number 1:

Number 2:
[/rant]

Odd. Can you try out the same code (the version that doesn’t work). But this time, before you show the badge to Modfryth, turn on actions and rules reports, like this:

(I don’t know whether you’re familiar with these very useful commands.) Then we should see exactly what goes wrong when Modfryth tries to lead you west.

I identified the issue finally. I had some leftover code that dealt with automatically sending the Modthryth character to talk to the player when attempting to go west from the Bar. It was badly configured and I hadn’t changed it since I first wrote it. After removing certain checks that were blocking the player from moving in that direction (and without giving a reason), everything is working as intended. Now I can actually finish making the intro sequence! Hooray!