SetName(object, string)

From NWN Lexicon
Revision as of 14:22, 11 March 2021 by Jasperre (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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 (but not a player), placeable, item, door or area.


Remarks

This will not work on player objects.

If you change an areas name it might not refresh in a DMs pallet, but it is useful to do to have comments in the toolset but not in game. If you change an area name when players are in, they should get the new name (eg; when mousing over their portrait). OnModuleLoad may not set it fast enough for the first player loading the starting area however.

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 and other special strings.


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