Calling for a NPC

I want to try creating a pet of sorts that comes at the player’s command and fetches items. I have no idea how to do the latter, so I started working on the former. I came up with a modified form of Van Helsing.

[code]Park is a room.

Playground is a room.

House is a room.

Garden is a room.

Dump is a room.

The front door is a door. The front door is west of the House and east of the park.

The playground is north of the park. Dump is west of the playground. Garden is south of the park.

A squeaky toy is in the House.
A bone is in the park.
A magic lamp is in the park.
A swing is in the Playground. The swing is not portable.

A random trash is in the dump.

Fido is a person in the house.

Fido is an action applying to nothing. Understand “call Fido” and “Fido” and “whistle” and “call for Fido” and " whistle for Fido" as Fido.

Carry out Fido:
if the location of Fido is not the location of the player:
let the way be the best route from the location of Fido to the location of the player, using doors;
try Fido going the way;
say “You call for Fido.”;
otherwise:
say “‘Woof. Woof.’ Fido barks.”
[/code]

For some reason, just calling “Fido” and waiting won’t work (Fido never comes). However, spamming Fido does. Why, and is there any way to just “Fido” once and have Fido arrive? And in a more timely manner if there are more rooms?

Thanks for any help.

The Carry out rule is only run on the turn where you actually give the command, not every turn. The path-following in the Van Helsing example takes place in an every-turn rule. One way to do what you want would be like this:

[code]Park is a room.

Playground is a room.

House is a room.

Garden is a room.

Dump is a room.

The front door is a door. The front door is west of the House and east of the park.

The playground is north of the park. Dump is west of the playground. Garden is south of the park.

A squeaky toy is in the House.
A bone is in the park.
A magic lamp is in the park.
A swing is in the Playground. The swing is not portable.

A random trash is in the dump. The indefinite article of the trash is “some”.

Fido is a person in the house.

Fido can be stationary or called-for. Fido is stationary.

Every turn:
if Fido is called-for:
if the location of Fido is not the location of the player:
let the way be the best route from the location of Fido to the location of the player, using doors;
try Fido going the way;
if the location of Fido is the location of the player:
now Fido is stationary.

Fido-calling is an action applying to nothing. Understand “call Fido” and “Fido” and “whistle” and “call for Fido” and " whistle for Fido" as Fido-calling.

Carry out Fido-calling:
if the location of Fido is not the location of the player:
say “You call for Fido.”;
now Fido is called-for;
otherwise:
say “‘Woof. Woof.’ Fido barks.”.[/code]

Thank you. That worked perfectly.