From NWN Lexicon
Revision as of 18:13, 19 September 2022 by Jasperre (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

OBJECT_SELF is the engine constant for the object running the current script. eg:

void main()
    object oSelf = OBJECT_SELF;

    // Send message to first PC of our object name (some objects will have a blank name, eg; Area of Effect objects)
    SendMessageToPC(GetFirstPC(), "I am running a script! I am named: " + GetName(oSelf));

The OBJECT_SELF parameter will always be valid since a script must run against an object. If a object is destroyed any future scripts running on it (eg; via DelayCommand or ExecuteScript) will simply fail to invoke.

It essentially does a special function call to go "Get the Object Running this script".

In some cases it is useful to recast it, making it cleaner to read, and for some scripts like a Spell Script it is useful to recognise there is no singular "caster" but it could be many types of object.