Object#
Object is the base class for everything with a physical body, a unique name, and
a category/type: units, weapons, static objects, scenery objects, and airbases. It is
a non-final class, scripts never obtain a bare Object instance, only instances
of one of its subclasses, but every subclass inherits the member functions
documented here.
- class Object#
- isExist()#
Returns whether the object still exists in the simulation (e.g. has not been destroyed or despawned).
- Returns:
Whether the object exists.
- Return type:
boolean
- destroy()#
Immediately removes the object from the simulation.
- getCategory()#
Returns the object’s top-level category (see Object.Category). This is the object category, not the more specific unit/weapon/etc. category – for that, use
object:getDesc().category.- Returns:
The object’s category.
- Return type:
number
- getTypeName()#
Returns the internal type name string of the object, e.g.
"Su-27".- Returns:
Type name.
- Return type:
string
- getDesc()#
Returns a description table for the object, with fields dependent on the object’s actual (sub)type. Common fields include
life(initial hit points) andbox(bounding box).- Returns:
Description table.
- Return type:
table
- hasAttribute(attribute)#
Returns whether the object’s type has the given attribute (see the attributes enumerator on the Hoggit wiki for the full list, e.g.
"Ships","Fighters").- Parameters:
attribute (
string) – Attribute name to check.- Returns:
Whether the object has the attribute.
- Return type:
boolean
- getName()#
Returns the object’s Mission Editor name.
- Returns:
Object name.
- Return type:
string
- getPoint()#
Returns the object’s current position as a
{x, y, z}point, without orientation.- Returns:
Position.
- Return type:
table
- getPosition()#
Returns the object’s current position and orientation, as a table with
p(position) andx/y/zorientation unit vectors.- Returns:
Position/orientation table.
- Return type:
table
- getVelocity()#
Returns the object’s current velocity vector, in meters/second.
- Returns:
Velocity vector.
- Return type:
table
- inAir()#
Returns whether the object is currently airborne.
- Returns:
Whether the object is in the air.
- Return type:
boolean
Enumerators#
Object.Category identifies the top-level object category returned by
Object.getCategory():
Value |
Meaning |
|---|---|
|
Unit ( |
|
Weapon ( |
|
Static object ( |
|
Airbase ( |
|
Scenery object ( |
|
Cargo ( |
Footnotes#
Objectis inherited by CoalitionObject, SceneryObject, and (transitively, viaCoalitionObject) Unit, Weapon, StaticObject, and Airbase.