GetResRef(object)

Returns the ResRef of an object.

string GetResRef(
    object oObject
);

Parameters

oObject

Object to return the ResRef of.


Description

Returns the ResRef (resource reference) of oObject. The ResRef is, more or less, what identifies an object on the palette. For instance, you must use the ResRef, not tag, when creating objects. Thus, you can use GetResRef to create a copy of an object (though you won’t need to, now that we have CopyObject).
Returns an empty string ("") on error.



Remarks

Does not return the ResRef of an area object; returns an empty string ("") instead.

Please note, as it says, it will only return a non-empty string if the resref actually exsists in the module resources (and therefore can be created using this!). If it doesn't, then it will return a blank string.


Known Bugs

In game, if a stacked item is split, only one of the new stacks will have a resref - the resref for the other stack will be an empty string. Also, restacking them will keep the ResRef of the stack being added into, so it is very possible to end up with items without ResRefs when dealing with stackable items.


Version

1.61

Example

//Put this OnDeath of a creature to respawn it at the
//waypoint tagged "wp_respawn". Note that the creature on
//the palette must be identical to the creature dying, as
//the respawning creature is actually a new creature from the
//palette. Lilac Soul.
void main()
{
     string sRes=GetResRef(OBJECT_SELF);
     object oTarget=GetWaypointByTag("wp_respawn");
     location lLoc=GetLocation(oTarget);
     CreateObject(OBJECT_TYPE_CREATURE, sRes, lLoc);
}

See Also

categories: Get Data from Object Functions


 author: Charles Feduke, editor: Jasperre, additional contributor(s): Harald Schuster, Christopher Smith
 Send comments on this topic.