# Thoughts

The thoughts.t module provides a framework for responding to commands of the form THINK ABOUT WHATEVER. It uses precisely the same TopicEntry mechanism as the Consultable/ConsultTopic classes, and can be used in almost precisely the same way. All you need to do is to define an object of the ThoughtManager class and then populate it with Thought objects, like so:

    myThoughts: ThoughtManager
    ;

    + Thought @george
        "To be honest, you're not really sure what he's doing here. "
    ;

    + Thought @tFire
        "It's a wretched nuiscance. Your nephew's probably to blame for it
        somehow, but the important thing right now is just to escape from it. "
    ;

    + DefaultThought
        "You find your thoughts start to wander; for some reason you can't
        concentrate on that topic right now. "
    ;

Thought inherits from TopicEntry, so you can use all the properties and methods of TopicEntry with it; Thought and DefaultThought work just like ConsultTopic and DefaultConsultTopic.

You can exclude thoughts.t if you don't want to implement a THINK ABOUT command (or you don't want to implement it this way), but if you include thoughts.t you must also include topicentry.t.

## Thoughts with Multiple Player Characters

If the player character changes during the course of your game, you may want to define a different set of Thoughts for each actor who might become a Player Character. To do this you need to define a thoughtManager object for each (potential or actual) player character and set its thinker property to the actor whose Thoughts will be located under it, for example:

    myThoughts: ThoughtManager
       thinker = me
    ;

    + Thought @george
        "To be honest, you're not really sure what he's doing here. "
    ;

    + Thought @tMavis
        "You rather like her. "
    ;

    + Thought @tFire
        "It's a wretched nuiscance. Your nephew's probably to blame for it
        somehow, but the important thing right now is just to escape from it. "
    ;

    + DefaultThought
        "You find your thoughts start to wander; for some reason you can't
        concentrate on that topic right now. "
    ;

    georgeThoughts: ThoughtManager
       thinker = george
    ;

    + Thought @tFire
      "A nasty hazard, in your opinion."
    ;

    + Thought @tMavis
       "You can't stand her. "
    ;

What happens behind the scenes here is that the preinitialization of any ThoughtManager object will set the myThoughtManager property to itself on the Thing defined on its (the ThoughtManager's) thinker property. If thinker is nil it will assume that the owner of the thoughts is the initial player character. The setPlayer() function then changes libGlobal.thoughtManagerObj to the value of the new player character's myThoughtManager property, provided the latter is not nil.

There is no need to do bother with any of this if the player character never changes (if thinker is left undefined on the sole ThoughtManager it will be assumed to belong to the sole player character), and you may prefer not to set up multiple ThoughtManagers for multiple player characters if your Thoughts are intended to model the player's thoughts rather than the player characters'.

adv3Lite Library Manual
Table of Contents | Optional Modules > Thoughts
Prev: Topic Entries Next: Actions