User Tools

Site Tools


hpl3:game:scripting:id_handles

Link to this comparison view

Both sides previous revision Previous revision
hpl3:game:scripting:id_handles [2013/07/19 13:05]
nebej
hpl3:game:scripting:id_handles [2015/09/11 10:50] (current)
ian.thomas
Line 1: Line 1:
 ====== ID Handles ====== ====== ID Handles ======
- 
  
 ===== General ===== ===== General =====
  
 +**Storing**
  
-**Storing**  +An ID handle is used to store and retrieve a object. Instead of storing the object handle directly the ID of the object should be stored.
- +
- +
-ID handle is used to store and retrieve a object. Instead of storing the object handle directly the ID of the object should be stored. +
  
 <​code>​ <​code>​
Line 18: Line 14:
 </​code>​ </​code>​
  
- +Storing ​an ID instead of class handle is safer and allows for saving of the handle.
-Storing ​ID instead of class handle is safer and allows for saving of the handle. +
  
 <​code>​ <​code>​
Line 31: Line 25:
 </​code>​ </​code>​
  
 +The ID of a object is returned from the GetID() function or by calling one of the functions that return the ID of an object directly.
  
-The ID of a object is returned from the GetID() function or by calling one of the functions that return the ID of a object directly. +**Accessing**
- +
- +
-**Accessing** ​ +
  
 After storing the ID it can be used to retrieve the object. Retrieving the object is safe and will return a null pointer if it has been deleted. After storing the ID it can be used to retrieve the object. Retrieving the object is safe and will return a null pointer if it has been deleted.
- 
  
 <​code>​ <​code>​
Line 47: Line 37:
 } }
 </​code>​ </​code>​
- 
  
 Even if the body has been deleted elsewhere the code will not crash, since accessing a null pointer only generates a warning. Even if the body has been deleted elsewhere the code will not crash, since accessing a null pointer only generates a warning.
- 
  
 Retrieving the object using the ID handle is very fast and can be used directly. When changing multiple properties of a object it is adviced to retrieve it once and then call all the function from the object itself. Retrieving the object using the ID handle is very fast and can be used directly. When changing multiple properties of a object it is adviced to retrieve it once and then call all the function from the object itself.
- 
  
 <​code>​ <​code>​
Line 68: Line 55:
 </​code>​ </​code>​
  
 +The retrieval functions performs a safe cast. The ID for a Prop can be used to retrieve a Entity, but if you use it to try to retrieve an Area then it will return null.
  
-The retrieval functions perform safe cast. The ID for a Prop can be used to retrieve a Entity, but if you use it to try to retrieve a Area then it will return null. +**Default Value**
- +
- +
-**Default Value** ​ +
  
 The default value of the tID class is tID_Invalid. Calling any retrieval function with that value will cause the function to return null. When a handle is no longer in use it should have its value set to tID_Invalid. The default value of the tID class is tID_Invalid. Calling any retrieval function with that value will cause the function to return null. When a handle is no longer in use it should have its value set to tID_Invalid.
  
- +**Saving and loading**
-**Saving and loading** ​ +
  
 A ID handle can be saved to the save file and it will retrieve the same object after load. The ID will also stay the same when working on the map which means that the save file will stay valid even after a patch on a map. This will also work with the realtime reload of the entity maptrack. A ID handle can be saved to the save file and it will retrieve the same object after load. The ID will also stay the same when working on the map which means that the save file will stay valid even after a patch on a map. This will also work with the realtime reload of the entity maptrack.
  
hpl3/game/scripting/id_handles.txt · Last modified: 2015/09/11 10:50 by ian.thomas