Difference between revisions of "GetIsObjectValid"

From NWN Lexicon
Jump to: navigation, search
(Created page with " =GetIsObjectValid(object)= Determines whether an object is valid. int  GetIsObjectValid(      object  oObject ); ====Paramete...")
 
Line 7: Line 7:
 
Determines whether an object is valid.
 
Determines whether an object is valid.
  
 +
<nwscript>
 
  [[int | int ]] GetIsObjectValid(
 
  [[int | int ]] GetIsObjectValid(
 
      [[object | object ]] oObject
 
      [[object | object ]] oObject
 
  );
 
  );
 +
</nwscript>
  
 
====Parameters====
 
====Parameters====
Line 37: Line 39:
 
====Example====
 
====Example====
  
<font color="#0000ff">void</font> main()
+
<nwscript>
 +
void main()
 
  {
 
  {
  <font color="#007f00">//Loop through all PC's in a module:
+
  //Loop through all PC's in a module:
  </font><font color="#0000ff">object</font> oPC=GetFirstPC();
+
  object oPC=GetFirstPC();
 
   
 
   
  <font color="#0000ff">while</font> (GetIsObjectValid(oPC))
+
  while (GetIsObjectValid(oPC))
 
     {
 
     {
     SendMessageToPC(oPC, <font color="#00007f">"You're a player, aren't you? ;-)"</font>);
+
     SendMessageToPC(oPC, "You're a player, aren't you? ;-)");
 
     oPC=GetNextPC();
 
     oPC=GetNextPC();
 
     }
 
     }
 
  }
 
  }
 +
</nwscript>
  
 
====See Also====
 
====See Also====

Revision as of 20:41, 25 August 2012



GetIsObjectValid(object)

Determines whether an object is valid.

 [[int | int ]] GetIsObjectValid(
     [[object | object ]] oObject
 );

Parameters

oObject

The object to check the validity of.


Description

Returns TRUE if oObject is a valid object, otherwise FALSE.



Remarks

This function is a widely used utility function to check the return values for functions that return objects. While looping through objects NWN functions usually return invalid objects to signify that there are no more objects left. This function can be used to test that condition.

Most of the time, this will be the same as comparing oObject to OBJECT_INVALID. There may be times where it isn't though, so it is generally recommended that you use this function.


Version

1.61

Example

 void main()
 {
 //Loop through all PC's in a module:
 object oPC=GetFirstPC();
 
 while (GetIsObjectValid(oPC))
    {
    SendMessageToPC(oPC, "You're a player, aren't you? ;-)");
    oPC=GetNextPC();
    }
 }

See Also



 author: Tom Cassiotis, editor: Lilac Soul