Difference between revisions of "SetName"

From NWN Lexicon
Jump to: navigation, search
(Remarks)
 
Line 22: Line 22:
  
 
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.
 
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]].
  
 
===Version===
 
===Version===

Latest revision as of 00:07, 29 June 2020

Set the name of an object.

void SetName(
    object oObject
    string sNewName    
);

Parameters

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

Description

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

Remarks

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.

Version

1.67

Example

// 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)
        return;
 
    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