dcsext.env.Mission

Represents a mission table.

Contents

  1. Description
  2. Methods
    1. mission:loadfile(zfile)
    2. mission:groupTable(grp, countryID, dcscategory)
    3. mission:processCategory(grplist, cattbl, cntryid, dcscategory, logger)
    4. mission:processCoalition(coatbl, logger)
    5. mission:noFilter()
    6. mission:isPlayerUnit(unit)
    7. mission:isPlayerGroup(grp)
    8. mission:addZone(zonetbl)
    9. mission:getZones()
    10. mission:addGroup(grp, countryID, dcscategory)
    11. mission:getGroups()
    12. mission:iterateGroups(filter)
    13. mission:iterateUnits(filter)
  3. Metamethods
    1. mission:__init(miztbl, logger)
  4. Tables
    1. mission.categorymap

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 loadfile or the DCS env.mission table
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[] keys.

Parameters

[HELICOPTER]
[SHIP]
[VEHICLE]
[PLANE]
[STATIC]