Difference between revisions of "DCS func getCategory"

From DCS World Wiki - Hoggitworld.com
Line 13: Line 13:
 
|par4= [[DCS_Class_Airbase|Airbase]]
 
|par4= [[DCS_Class_Airbase|Airbase]]
  
|desc= Return an enumerator of the category for the specific object. The enumerator returned is dependent on the category of the object.  
+
|desc= 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.  
 
See enumerators Group.Category, Object.Category, and Spot.Category for further reference.  
  
Function also works with [[DCS_Class_Unit|Unit]], [[DCS_Class_Weapon|Weapon]], [[DCS_Class_Static_Object|Static Object]], [[DCS_Class_Scenery_Object|Scenery Object]], [[DCS_Class_Airbase|Airbase]]. When used with any of these objects the category returned is related to the Object.Category.
+
Function also works with [[DCS_Class_Unit|Unit]], [[DCS_Class_Weapon|Weapon]], [[DCS_Class_Static_Object|Static Object]], [[DCS_Class_Scenery_Object|Scenery Object]], [[DCS_Class_Airbase|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.  
 +
 
 +
 
  
 
|rtnType= enum
 
|rtnType= enum
Line 42: Line 50:
 
[[DCS_Class_Spot|'''Spot Functions:''']] {{listofScriptingSpotFuncs}}
 
[[DCS_Class_Spot|'''Spot Functions:''']] {{listofScriptingSpotFuncs}}
  
|examples=  
+
|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)
 +
 
 +
|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.
  
|notes=
 
 
}}
 
}}
 
[[Category:Class Functions|getCategory]]
 
[[Category:Class Functions|getCategory]]
 
[[Category:Game Patch 1.2.0|getCategory]]
 
[[Category:Game Patch 1.2.0|getCategory]]

Revision as of 09:31, 17 November 2023

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.