Making an NPC (under certain conditions) follow the player

Okay guys, I have another puzzle for you all. The setup looks something like this:

A ferret is an animal.  The ferret can be hungry, thirsty, or happy.  The ferret is hungry.  

What I want is the ferret to follow the player when happy. I figured I could use a simple code like:

If the ferret is happy:
               The location of the ferret is the location of the player.[/code]
Naturally I found out that Inform doesn't like this command but can't figure out the language that it will accept.  

I've added a part of Emily Short's "Simple Followers" code that reads as follows:

[code]Shadowing relates various people to one person (called the goal). The verb to shadow (he shadows, they shadow, he shadowed, he is shadowed, he is shadowing) implies the shadowing relation. 

Every turn: 
	repeat with pursuer running through people who are shadowing someone:
		let starting-space be the location of the pursuer; 
		let ending-space be the location of the goal of the pursuer; 
		if the starting-space is not the ending-space:
			let next-way be the best route from the starting-space to the ending-space, using doors; 
			if next-way is a direction:
				try the pursuer trying going next-way;

When I have that turned on, Inform still won’t accept anything similar to:

If the ferret is happy: now the ferret is shadowing the player

I think the answer is in the code right in front of me but can’t pick it out. Any bright ideas?

You can’t write a free-floating if-statement. It has to be executed at some specific point. Try this:

[code]Before jumping:
now the ferret is happy;
continue the action.

Every turn:
if the ferret is happy:
now the ferret is shadowing the player.[/code]
I like to use ‘jump’ to test changes in object states. With this code, I find that after ‘jump’, the ferret follows the player.


And of course, I added:

Include Simple Followers by Emily Short.

…to my code. That allows “shadowing” to work.

Awesome, thanks! Works like a charm. Knew the answer was right in front of me :confused: