Difference between revisions of "DCS func getCountry"

From DCS World Wiki - Hoggitworld.com
m (1 revision imported)
 
Line 33: Line 33:
 
|optType2=
 
|optType2=
  
|examples=  
+
|examples= The following will print the name of the country to dcs.log for a unit with the name of "Tanya"
 +
   
 +
    local countryId = Unit.getByName('Tanya'):getCountry()
 +
    local contryName = country.name[countryId]
 +
    env.info(countryName)
  
 +
    > USA
 
|related= '''[[DCS_Class_Object| Object Class Functions:]]''' {{listofScriptingObjectFuncs}}
 
|related= '''[[DCS_Class_Object| Object Class Functions:]]''' {{listofScriptingObjectFuncs}}
 
'''[[DCS_Class_Coalition_Object| Coalition Object Class Functions:]]''' {{listofScriptingCoaObjectFuncs}}
 
'''[[DCS_Class_Coalition_Object| Coalition Object Class Functions:]]''' {{listofScriptingCoaObjectFuncs}}

Revision as of 21:11, 28 February 2020

Scripting Root

Envrioment: Mission Scripting
Function: getCountry Added with: 1.2.0
Member Of: Object, Coalition Object
Syntax: enum country.id Object.getCountry(Class Self )
Description: Returns an enumerator that defines the country that an object currently belongs to.

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


Return Value: enum country.id
Return Example: See country enums for full listing of countries.
Examples: The following will print the name of the country to dcs.log for a unit with the name of "Tanya"
   local countryId = Unit.getByName('Tanya'):getCountry()
   local contryName = country.name[countryId]
   env.info(countryName) 
   > USA
Related Functions: Object Class Functions: isExist, destroy, getCategory, getTypeName, getDesc, hasAttribute, getName, getPoint, getPosition, getVelocity, inAir

Coalition Object Class Functions: getCoalition, getCountry

Notes: