SetName(object, string)

From NWN Lexicon
Revision as of 00:07, 29 June 2020 by Jasperre (talk | contribs) (Remarks)
Jump to: navigation, search

Set the name of an object.

void SetName(
    object oObject
    string sNewName    


The object whose name is to be changed.
The new name to give oObject.


Set the name of oObject to sNewName. oObject can be a creature, placeable, item, or door.


This will not work on player objects.

Setting an object's name to "" will make the object revert back to using the name it had originally had before any SetName() calls were made on the object.

You can change the color of the text shown using StringToRGBString.




// Tag-based script for an intelligent weapon. When the weapon is activated,
// this will create a generic invisible object for the PC to talk to, but will
// rename it to match the weapon that triggered the event.
#include "x2_inc_switches"
void main()
    // Make sure this is the OnAtivateItem event
    if (GetUserDefinedItemEventNumber() != X2_ITEM_EVENT_ACTIVATE)
    object oPC    = GetItemActivator(); // The player character using the item
    object oItem  = GetItemActivated(); // The item being used
    object oInvis = CreateObject(OBJECT_TYPE_PLACEABLE, "x2_plc_intwp", GetLocation(oPC));
    // Set the name of the invisible object to that of the item
    SetName(oInvis, GetName(oItem));
    // Start the conversation
    AssignCommand(oPC, ActionStartConversation(oInvis, GetTag(oItem)));

See Also

functions:  GetName

author: Mistress