Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Dark Dreams of Furiae - a new module for NWN:EE! Buy now
Attention, new and old users! Please read the new rules of conduct for the forums, and we hope you enjoy your stay!

ActionExamine OnUsed

Lexicon example:
// This script is placed on a placeable's OnUsed event.
// It causes a PC that uses it to examine the placeable.
void main()
object oPC = GetLastUsedBy();
AssignCommand(oPC, ActionExamine(OBJECT_SELF));
This is causing the PC to examine itself.


  • DazDaz Member Posts: 89
    OBJECT_SELF in an AssignCommand refers to the action subject, which is oPC in this case, the example is wrong.

    This is the right way to do it:

    // A simpler example - examine the thing being used by the PC
    void main()
    // Define oPC AND OBJECT_SELF.
    object oPC = GetLastUsedBy();

    // * Note: Remember, defining OBJECT_SELF means that when
    // we pass oSelf into the AssignCommand()'s
    // ActionExamine, instead of OBJECT_SELF, it WILL examine
    // this sign, not the PC. see the note in Remarks.
    object oSelf = OBJECT_SELF;

    // Assign the action to read oSelf, not OBJECT_SELF, which
    // would be the PC.
    AssignCommand(oPC, ActionExamine(oSelf));

    See AssignCommand's lexicon page for more info

  • RestoRangerRestoRanger Member Posts: 5
    Thanks. I just came across this page as well.

    First, OBJECT_SELF does not have a specific value, unlike OBJECT_INVALID for example. Instead, OBJECT_SELF gets replaced by the value of the current object (is bound to an object) as soon as the game encounters the "constant" while executing a script. The timing of this binding is of particular note when used in conjunction with AssignCommand(), as any parameters to the assigned command are not "encountered" until after control is transferred. That is, if OBJECT_SELF is used in the parameters to the assigned command, it will be bound to the object to which the command was assigned. To have the assigned command refer to the assigner, OBJECT_SELF needs to be assigned to a variable, then that variable can be used as a parameter.

  • ProlericProleric Member Posts: 825
    Just so. If you always do what Daz did - assign OBJECT_SELF to a variable at the outset of every script, then refer only to the variable thereafter - you can avoid this and related pitfalls.

Sign In or Register to comment.