A new type of animal: How?

So umm,
We’re given cat and dog, but what if we want lots of named snakes or rats? How do we create a new animal class(are they classes?)?
Simple question: expecting it to likely be a complex answer.

(This is my first time offering coding help, so take with a large grain of salt, although I did test out the code below and it worked for me! Also, I’m presuming you’re using TADS3)

LT3 Suggests: “UntakeableActor – An actor (animate object) that’s too large to be picked up (a cow or horse perhaps). For human actors we use Person, a subclass of UntakeableActor.”

I have a few animals in my game. I declare them simply as an UntakeableActor and in some cases add “Fixture.”

But if you want a whole bunch of animals that are of the same type, there’s no reason I can think of to not create a class for them.

For example, if you wanted to create some horses, and wanted a default for smelling them:

class Horse : UntakeableActor
{
    dobjFor(Smell)
    {
        action () {
            "All horses smell alike to you.";
        }
    }
}

blackBeauty: Horse
    name = 'Black Beauty'
    isProperName = true
    vocabWords = 'black beauty/horse*horses'
    location = paddock
;

trigger: Horse 
    name = 'Trigger'
    isProperName = true
    vocabWords = 'silver trigger/horse*horses'
    location = stable
;

Then if you >smell either horse, you’ll get the same response, but you can also add individual code to distinguish how they look and act, et cetera.

Hope this helps,

–Bob

excited laughter

Thank you, this works perfectly and gives me the ability to add all the properties I need to, a thousand salutations!

This works perfectly. The code could be refined a bit. You could use a template format for your code for blackBeauty and trigger:

blackBeauty: Horse 'black beauty/horse*horses' 'Black Beauty' @paddock isProperName = true ;
Also, I’m pretty sure the Smell action can be handled by adding a smellDesc to the class:

class Horse : UntakeableActor smellDesc = "All horses smell alike to you." ;
I haven’t tested this use of smellDesc (not working on a T3 game at the moment), but “Learning T3” seems to indicate that this is one way to do it.

Hi Jim,

You’re certainly right about the templates. But even after all this time, I’m still not used to them, and I find myself modifying the properties a lot anyway. So for me, it’s easier to spell everything out.

But does it actually make a difference to the compiler? I.e., does templated code run any better/faster?

Cheers,

–Bob

Templates are just a syntactic suggar for game author convenience. They are meant to save you from excesive typing when writing your game’s code. Internally compiler replaces templates with their respective properties first and then compile the code as usual so in the end there is absolutelly no difference.