DCS func getCategory

From DCS World Wiki - Hoggitworld.com
Revision as of 09:31, 17 November 2023 by Grimes (talk | contribs)

Scripting Root

Envrioment: Mission Scripting
Function: getCategory Added with: 1.2.0
Member Of: Object, Group, Spot, Airbase
Syntax: enum Object.getCategory(Class Self )
Description: Returns an enumerator of the category for the specific object. The enumerator returned is dependent on the category of the object and how the function is called.

See enumerators Group.Category, Object.Category, and Spot.Category for further reference.

Function also works with Unit, Weapon, Static Object, Scenery Object, Airbase.

Object.getCategory(obj) will always return the Object category.

Unit.getCategory(obj) will return the unit category.

obj:getCategory() will return the unit category.


Return Value: enum
Return Example: number
Examples: The following is run on a ship unit named CVN75.
  local unit = Unit.getByName("CVN75")
  env.info(unit:getCategory() -> 3  (unit category for a ship)
  env.info(Object.getCategory(unit) - > 1 (object category for a unit)
  env.info(Airbase.getCategory(unit) -> 2 (airbase category for a ship)
Related Functions: Object Functions: isExist, destroy, getCategory, getTypeName, getDesc, hasAttribute, getName, getPoint, getPosition, getVelocity, inAir

Group Functions: isExist, activate, destroy, getCategory, getCoalition, getName, getID, getUnit, getUnits, getSize, getInitialSize, getController, enableEmission

Spot Functions: createLaser. createInfraRed, destroy, getCategory, getPoint, setPoint, getCode, setCode

Notes: From DCS 1.5.7 and DCS 2.1.1 (Nov 2017) this function was broken. It has been fixed in DCS 2.9.1 (Nov 2023). In this timeframe it would always return the result of Object.getCategory() no matter how the function was called. Users were required to use getDesc().category to get the correct category value within its subclass.