Difference between revisions of "DCS func getAirbases"

From DCS World Wiki - Hoggitworld.com
m (1 revision imported)
 
 
(One intermediate revision by the same user not shown)
Line 41: Line 41:
 
|optType2=
 
|optType2=
  
|examples=  
+
|examples= The following iterates the returned airbases via world.getAirbases() and stores callsign, id, and other useful information in another table.
 +
     
 +
    local base = world.getAirbases()
 +
    local myBaseTbl = {}
 +
    for i = 1, #base do
 +
        local info = {}
 +
        info.desc = Airbase.getDesc(base[i])
 +
        info.callsign = Airbase.getCallsign(base[i])
 +
        info.id = Airbase.getID(base[i])
 +
        info.cat = Airbase.getCategory(base[i])
 +
        info.point = Airbase.getPoint(base[i])
 +
        if Airbase.getUnit(base[i]) then
 +
            info.unitId = Airbase.getUnit(base[i]):getID()
 +
        end
 +
       
 +
        myBaseTbl[info.callsign] = info
 +
    end
  
  
Line 53: Line 69:
 
}}
 
}}
 
[[Category:Singleton Functions|getAirbases]]
 
[[Category:Singleton Functions|getAirbases]]
 +
[[Category:Game Patch 1.2.4|getAirbases]]

Latest revision as of 07:13, 17 March 2022

Scripting Root

Envrioment: Mission Scripting
Function: getAirbases Added with: 1.2.4
Member Of: coalition, world
Syntax: table coalition.getAirbases(enum coalitionId )
Description: Returns a table of airbase objects belonging to the specified coalition. Objects can be ships, static objects(FARP), or airbases on the map.

When the function is run as world.getAirbases() no input values required, and the function returns all airbases, ships, and farps on the map.


Return Value: table
Return Example:
Examples: The following iterates the returned airbases via world.getAirbases() and stores callsign, id, and other useful information in another table.
   local base = world.getAirbases()
   local myBaseTbl = {}
   for i = 1, #base do
       local info = {}
       info.desc = Airbase.getDesc(base[i])
       info.callsign = Airbase.getCallsign(base[i])
       info.id = Airbase.getID(base[i])
       info.cat = Airbase.getCategory(base[i])
       info.point = Airbase.getPoint(base[i])
       if Airbase.getUnit(base[i]) then
           info.unitId = Airbase.getUnit(base[i]):getID()
       end
       
       myBaseTbl[info.callsign] = info
   end
Related Functions: Coalition Functions: addGroup, addStaticObject, getGroups, getStaticObjects, getAirbases. getPlayers, getServiceProviders, addRefPoint, getRefPoints, getMainRefPoint, getCountryCoalition

World functions: addEventHandler, removeEventHandler, getPlayer, getAirbases, searchObjects, getMarkPanels, removeJunk

Notes: