dcsext.env.Mission
Represents a mission table.
Contents
- Description
- Methods
- mission:loadfile(zfile)
- mission:groupTable(grp, countryID, dcscategory)
- mission:processCategory(grplist, cattbl, cntryid, dcscategory, logger)
- mission:processCoalition(coatbl, logger)
- mission:noFilter()
- mission:isPlayerUnit(unit)
- mission:isPlayerGroup(grp)
- mission:addZone(zonetbl)
- mission:getZones()
- mission:addGroup(grp, countryID, dcscategory)
- mission:getGroups()
- mission:iterateGroups(filter)
- mission:iterateUnits(filter)
- Metamethods
- Tables
Description
Handles loading a mission table and provides some common ways of accessing the data. Also provides a class method to extract the mission table from a zip.
Methods
mission:loadfile(zfile)
Load a .miz file into a lua table. It is assumed the mission is zip compressed.
Parameters
- zfile
- string zip compressed file path
Returns
- a Mission instance otherwise nil and an error string
mission:groupTable(grp, countryID, dcscategory)
Create a group table.
Parameters
- grp
- the group definition
- countryID
- the country the group belongs to, will determine which coalition the group belongs to in game
- dcscategory
- the Unit.Category the group belongs to
Returns
- a group table with data, countryid and category entries
mission:processCategory(grplist, cattbl, cntryid, dcscategory, logger)
Process category table and extract all defined groups.
Parameters
- grplist
- [output] list of groups found, indexed by group name
- cattbl
- category table from a mission.coalition table
- cntryid
- country id
- dcscategory
- category from Unit.Category
- logger
- a Logger instance
mission:processCoalition(coatbl, logger)
Get all groups defined in tbl.mission.coalition.
Parameters
- coatbl
- coalition table, example
env.mission.coalition - logger
- reference to an env.Logger instance
Returns
- table keyed on group names.
mission:noFilter()
A nil filter function.
Returns
- true always
mission:isPlayerUnit(unit)
Test if a mission unit table is player or client controlled.
Parameters
- unit
- unit table from a mission group definition
Returns
- true when the unit skill is CLIENT or PLAYER
mission:isPlayerGroup(grp)
Reads a DCS mission group definition and determines if there are any player/client units defined in the group.
Parameters
- grp
- the mission group table to read.
Returns
- true when any unit of the group is player/client controlled
mission:addZone(zonetbl)
Add a new Zone to the zones table. Duplicate zone names replace the existing zone and log an error.
Parameters
- zonetbl
- the zone definition to process
mission:getZones()
Get the zones defined in the mission.
Returns
- table of Zone objects keyed by zone name
mission:addGroup(grp, countryID, dcscategory)
Add a group definition to the Mission instance.
Parameters
- grp
- the group definition
- countryID
- the country the group belongs to, will determine which coalition the group belongs to in game
- dcscategory
- the Unit.Category the group belongs to
mission:getGroups()
Get the groups defined in the mission.
Returns
- table of group tables keyed by group name
mission:iterateGroups(filter)
Iterate over the groups defined in the mission.
Parameters
- filter
- optional predicate applied to each group table, groups where it returns false or nil are skipped
Returns
- iterator function yielding index and group table pairs
- the groups table used as iterator state
- nil initial index
mission:iterateUnits(filter)
Iterate over every unit of every group defined in the mission. Units are collected from all groups before iterating so units added during iteration are not visited.
Parameters
- filter
- optional predicate applied to each unit table, units where it returns false or nil are skipped
Returns
- iterator function yielding index and unit table pairs
- the collected units list used as iterator state
- nil initial index
Metamethods
mission:__init(miztbl, logger)
Constructor.
Parameters
- miztbl
- mission table as returned by
loadfileor the DCSenv.missiontable - logger
- optional Logger instance, defaults to the shared DCSEXT logger
Tables
mission.categorymap
maps category to the table entry in a mission table. The keys are the mission table entries in lower case and the values map the Unit.Category[
Parameters
- [HELICOPTER]
- [SHIP]
- [VEHICLE]
- [PLANE]
- [STATIC]