§8.3. Animals

Animals exhibit a wide range of behaviour: much of the chapter on Other Characters applies just as well to animals as to human beings, with the exception of the material on conversation. But two examples here, both fairly simple, show how a fairly convincing domestic pet can be achieved simply by reacting to certain events going on nearby: Feline Behavior (a cat) and Today Tomorrow (a dog).

Fido provides a dog which the player can re-name at will.

For animals that we can sit on and ride - a camel or a horse, say - we may want to use the Rideable Vehicles extension by Graham Nelson, which also provides a rideable animal kind.

* See Liveliness for pets that change what they're doing every time the player looks

* See Bags, Bottles, Boxes and Safes for a cat that eats food put in its container


arrow-up.pngStart of Chapter 8: Vehicles, Animals and Furniture
arrow-left.pngBack to §8.2. Ships, Trains and Elevators
arrow-right.pngOnward to §8.4. Furniture

*ExampleFeline Behavior
A cat which reacts to whatever items it has handy, returning the result of a rulebook for further processing.

Suppose we'd like to have a dog which the player is allowed to name himself. We'd like to deal correctly with both

>name the dog fido

and

>name the dog "fido"

so we'll also need to strip quotation marks out of the command. We can do this as follows:

paste.png "Fido"

The Back Yard is a room.

A dog is an animal in Back Yard. The dog has some text called the nickname. The nickname of the dog is "nothing". Understand the nickname property as describing the dog.

Rule for printing the name of the dog when the nickname of the dog is not "nothing":
    say "[nickname of the dog]"

Naming it with is an action applying to one thing and one topic. Understand "name [something] [text]" as naming it with. Check naming it with: say "You can't name that."

Instead of naming the dog with "nothing":
    now the nickname of the dog is "nothing";
    now the dog is improper-named;
    say "You revoke your choice of dog-name."

Instead of naming the dog with something:
    let N be "[the topic understood]";
    replace the text "'" in N with "";
    now the nickname of the dog is "[N]";
    now the dog is proper-named;
    say "The dog is now known as [nickname of the dog]."

Test me with "name the dog Fido / name the dog Lawrence / look / x lawrence / name Lawrence nothing / look / x lawrence".

*ExampleFido
A dog the player can name and un-name at will.

Suppose we'd like to have a dog which the player is allowed to name himself. We'd like to deal correctly with both

>name the dog fido

and

>name the dog "fido"

so we'll also need to strip quotation marks out of the command. We can do this as follows:

paste.png "Fido"

The Back Yard is a room.

A dog is an animal in Back Yard. The dog has some text called the nickname. The nickname of the dog is "nothing". Understand the nickname property as describing the dog.

Rule for printing the name of the dog when the nickname of the dog is not "nothing":
    say "[nickname of the dog]"

Naming it with is an action applying to one thing and one topic. Understand "name [something] [text]" as naming it with. Check naming it with: say "You can't name that."

Instead of naming the dog with "nothing":
    now the nickname of the dog is "nothing";
    now the dog is improper-named;
    say "You revoke your choice of dog-name."

Instead of naming the dog with something:
    let N be "[the topic understood]";
    replace the text "'" in N with "";
    now the nickname of the dog is "[N]";
    now the dog is proper-named;
    say "The dog is now known as [nickname of the dog]."

Test me with "name the dog Fido / name the dog Lawrence / look / x lawrence / name Lawrence nothing / look / x lawrence".

**ExampleToday Tomorrow
A few notes on "In the presence of" and how it interacts with concealed objects.