handle (object);
Returns a handle of an engine object. A handle is a unique object number that
can
be assigned to any variable, and identifies that object.
Parameters:
object - ENTITY*, STRING*, BMAP*, VIEW*, PANEL*, TEXT*, FONT*,
SOUND*, or MATERIAL* pointer.
Returns:
Handle of object.
Speed:
Fast
Remarks:
- A handle is similar to a pointer, but is just a number and therefore
can be assigned to any variable or skill.
-
For getting a handle to a lite-C struct that is not an engine object, use the pVars pointer.
- After saving and loading a game, a
handle generated by this instruction is guaranteed to reference
always the same object
- this is not guaranteed for pointers that are just references to memory
areas.
- On a single player system, the entity handle
is valid immediately after entity creation (
(► ent_create). On multiplayer
systems, it can take up to 0.5 seconds until the entity is
created on all connected machines and the handle becomes valid.
During that time the entity handle can not be used.
- For using a handle to get the
referenced object, it can be converted to a pointer through the ptr_for_handle instruction.
- The handle is the first integer of an object. It consists of
a unique index number plus an object type identifier taken
from the following table, and left shifted by
24.
The handle can be used to identify the type of the object.
For converting the handle to a var that contains the index
number, right shift it by
24, then left shift the resulting int by
10.
| INVALID |
-1 |
| ENTITY |
4 (global) |
| ENTITY |
5 (local) |
| ENTITY |
8 (layer) |
| STRING |
10 |
| FONT |
11 |
| BMAP |
12 |
| MATERIAL |
13 |
| SOUND |
14 |
| STREAM |
15 |
| TEXT |
20 |
| PANEL |
21 |
| VIEW |
22 |
Example:
if(entity)
{
my.skill48 = handle(entity); // store entity pointer
}
you = ptr_for_handle(my.skill48); // restore YOU;
See also:
ptr_for_handle,
pVars
► latest
version online