Difference between revisions of "DeleteLocalObject"

From NWN Lexicon
Jump to: navigation, search
(Created page with " =DeleteLocalObject(object, string)= Deletes oObject's object variable sVarName void  DeleteLocalObject(      object  oObject, ...")
 
Line 7: Line 7:
 
Deletes oObject's object variable sVarName
 
Deletes oObject's object variable sVarName
  
 +
<nwscript>
 
  [[void | void ]] DeleteLocalObject(
 
  [[void | void ]] DeleteLocalObject(
 
      [[object | object ]] oObject,
 
      [[object | object ]] oObject,
 
      [[string | string ]] sVarName
 
      [[string | string ]] sVarName
 
  );
 
  );
 +
</nwscript>
  
 
====Parameters====
 
====Parameters====
Line 42: Line 44:
 
====Example====
 
====Example====
  
<font color="#007f00">// We delete the object stored on the PC under "WEAPON" when they pull a lever.
+
<nwscript>
  </font><font color="#0000ff">void</font> main()
+
// We delete the object stored on the PC under "WEAPON" when they pull a lever.
 +
  void main()
 
  {
 
  {
     <font color="#007f00">// Declare the PC object
+
     // Declare the PC object
</font>    <font color="#0000ff">object</font> oPC = GetClickingObject();
+
    object oPC = GetClickingObject();
     <font color="#007f00">// Delete the local object
+
     // Delete the local object
</font>    DeleteLocalObject(oPC, <font color="#00007f">"WEAPON"</font>);
+
    DeleteLocalObject(oPC, "WEAPON");
 
  }
 
  }
 +
</nwscript>
  
 
====See Also====
 
====See Also====

Revision as of 20:32, 25 August 2012



DeleteLocalObject(object, string)

Deletes oObject's object variable sVarName

 [[void | void ]] DeleteLocalObject(
     [[object | object ]] oObject,
     [[string | string ]] sVarName
 );

Parameters

oObject

The object storing the variable.

sVarName

Variable name to delete.


Description

Use this function to delete an object's entry for the object defined by sVarName. If sVarName doesn't exsist, nothing happens.



Remarks

As with all deletions, once removed, GetLocalObject returns OBJECT_INVALID. Cleaning up old variables can help CPU performance if many are stored on one object (especially if the module has many unused values on it) and good for deleting the new persistant variables which can be put on a PC's inventory item, which will hinder performance if there are many unused values.

Local objects also do not store the object as such that it finds it each time, but rather its "code" in the object list, which is probably a smaller value then any string you will store upon objects.


Version

1.22

Example

 // We delete the object stored on the PC under "WEAPON" when they pull a lever.
 void main()
 {
     // Declare the PC object
     object oPC = GetClickingObject();
     // Delete the local object
     DeleteLocalObject(oPC, "WEAPON");
 }

See Also



 author: Michael Nork, editor: Jasperre, additional contributor(s): Jasperre