Module Database
Core -- DATABASE manages the database of mission objects.
Author: FlightControl
Contributions:
Global(s)
DATABASE |
DATABASE class, extends Base#BASEMission designers can use the DATABASE class to refer to:
On top, for internal MOOSE administration purposes, the DATBASE administers the Unit and Group TEMPLATES as defined within the Mission Editor. |
Type DATABASE
DATABASE:AccountDestroys(Event) |
Account the destroys. |
DATABASE:AccountHits(Event) |
Account the Hits of the Players. |
DATABASE:AddAirbase(AirbaseName) |
Adds a Airbase based on the Airbase Name in the DATABASE. |
DATABASE:AddCargo(CargoName, Cargo) |
Adds a Cargo based on the Cargo Name in the DATABASE. |
DATABASE:AddClient(ClientName) |
Adds a CLIENT based on the ClientName in the DATABASE. |
DATABASE:AddGroup(GroupName) |
Adds a GROUP based on the GroupName in the DATABASE. |
DATABASE:AddPlayer(UnitName, PlayerName) |
Adds a player based on the Player Name in the DATABASE. |
DATABASE:AddStatic(DCSStaticName) |
Adds a Static based on the Static Name in the DATABASE. |
DATABASE:AddUnit(DCSUnitName) |
Adds a Unit based on the Unit Name in the DATABASE. |
DATABASE:AddZone(ZoneName, Zone) |
Adds a Zone based on the zone name in the DATABASE. |
DATABASE:DeleteAirbase(AirbaseName) |
Deletes a Airbase from the DATABASE based on the Airbase Name. |
DATABASE:DeleteCargo(CargoName) |
Deletes a Cargo from the DATABASE based on the Cargo Name. |
DATABASE:DeletePlayer(UnitName, PlayerName) |
Deletes a player from the DATABASE based on the Player Name. |
DATABASE:DeleteStatic(DCSStaticName) |
Deletes a Static from the DATABASE based on the Static Name. |
DATABASE:DeleteUnit(DCSUnitName) |
Deletes a Unit from the DATABASE based on the Unit Name. |
DATABASE:DeleteZone(ZoneName) |
Deletes a Zone from the DATABASE based on the zone name. |
DATABASE:FindAirbase(AirbaseName) |
Finds a AIRBASE based on the AirbaseName. |
DATABASE:FindCargo(CargoName) |
Finds an CARGO based on the CargoName. |
DATABASE:FindClient(ClientName) |
Finds a CLIENT based on the ClientName. |
DATABASE:FindGroup(GroupName) |
Finds a GROUP based on the GroupName. |
DATABASE:FindStatic(StaticName) |
Finds a STATIC based on the StaticName. |
DATABASE:FindUnit(UnitName) |
Finds a Unit based on the Unit Name. |
DATABASE:FindZone(ZoneName) |
Finds a Zone based on the zone name. |
DATABASE:ForEach(IteratorFunction, FinalizeFunction, arg, Set) |
Iterate the DATABASE and call an iterator function for the given set, providing the Object for each element within the set and optional parameters. |
DATABASE:ForEachCargo(IteratorFunction, ...) |
Iterate the DATABASE and call an iterator function for each CARGO, providing the CARGO object to the function and optional parameters. |
DATABASE:ForEachClient(IteratorFunction, ...) |
Iterate the DATABASE and call an iterator function for each CLIENT, providing the CLIENT to the function and optional parameters. |
DATABASE:ForEachGroup(IteratorFunction, FinalizeFunction, ...) |
Iterate the DATABASE and call an iterator function for each alive GROUP, providing the GROUP and optional parameters. |
DATABASE:ForEachPlayer(IteratorFunction, FinalizeFunction, ...) |
Iterate the DATABASE and call an iterator function for each ALIVE player, providing the player name and optional parameters. |
DATABASE:ForEachPlayerJoined(IteratorFunction, FinalizeFunction, ...) |
Iterate the DATABASE and call an iterator function for each player who has joined the mission, providing the Unit of the player and optional parameters. |
DATABASE:ForEachPlayerUnit(IteratorFunction, FinalizeFunction, ...) |
Iterate the DATABASE and call an iterator function for each ALIVE player UNIT, providing the player UNIT and optional parameters. |
DATABASE:ForEachStatic(IteratorFunction, FinalizeFunction, ...) |
Iterate the DATABASE and call an iterator function for each alive STATIC, providing the STATIC and optional parameters. |
DATABASE:ForEachUnit(IteratorFunction, FinalizeFunction, ...) |
Iterate the DATABASE and call an iterator function for each alive UNIT, providing the UNIT and optional parameters. |
DATABASE:GetCategoryFromAirbase(AirbaseName) | |
DATABASE:GetCategoryFromClientTemplate(ClientName) | |
DATABASE:GetCoalitionFromAirbase(AirbaseName) | |
DATABASE:GetCoalitionFromClientTemplate(ClientName) | |
DATABASE:GetCountryFromClientTemplate(ClientName) | |
DATABASE:GetGroupNameFromUnitName(UnitName) | |
DATABASE:GetGroupTemplate(GroupName) | |
DATABASE:GetGroupTemplateFromUnitName(UnitName) | |
DATABASE:GetPlayerSettings(PlayerName) |
Gets the player settings |
DATABASE:GetPlayerUnits() |
Get the player table from the DATABASE, which contains all UNIT objects. |
DATABASE:GetPlayers() |
Get the player table from the DATABASE. |
DATABASE:GetPlayersJoined() |
Get the player table from the DATABASE which have joined in the mission historically. |
DATABASE:GetStaticUnitTemplate(StaticName) | |
DATABASE:GetStatusGroup(GroupName) |
Get a status to a Group within the Database, this to check crossing events for example. |
DATABASE:IsCargo(TemplateName) |
Checks if the Template name has a ~CARGO tag. |
DATABASE.Navpoints | |
DATABASE:New() |
Creates a new DATABASE object, building a set of units belonging to a coalitions, categories, countries, types or with defined prefix names. |
DATABASE:OnEventDeleteCargo(EventData) |
Handles the OnEventDeleteCargo. |
DATABASE:OnEventDeleteZone(EventData) |
Handles the OnEventDeleteZone. |
DATABASE:OnEventNewCargo(EventData) |
Handles the OnEventNewCargo event. |
DATABASE:OnEventNewZone(EventData) |
Handles the OnEventNewZone event. |
DATABASE:SetPlayerSettings(PlayerName, Settings) |
Sets the player settings |
DATABASE:SetStatusGroup(GroupName, Status) |
Set a status to a Group within the Database, this to check crossing events for example. |
DATABASE:Spawn(SpawnTemplate) |
Instantiate new Groups within the DCSRTE. |
DATABASE.UNITS | |
DATABASE.UNITS_Position | |
DATABASE:_EventOnBirth(Event) |
Handles the OnBirth event for the alive units set. |
DATABASE:_EventOnDeadOrCrash(Event) |
Handles the OnDead or OnCrash event for alive units set. |
DATABASE:_EventOnPlayerEnterUnit(Event) |
Handles the OnPlayerEnterUnit event to fill the active players table (with the unit filter applied). |
DATABASE:_EventOnPlayerLeaveUnit(Event) |
Handles the OnPlayerLeaveUnit event to clean the active players table. |
DATABASE:_RegisterAirbases() | |
DATABASE:_RegisterCargos() |
Private method that registers new Static Templates within the DATABASE Object. |
DATABASE:_RegisterClients() |
Private method that registers all Units of skill Client or Player within in the mission. |
DATABASE:_RegisterGroupTemplate(GroupTemplate, CoalitionSide, CategoryID, CountryID, GroupName) |
Private method that registers new Group Templates within the DATABASE Object. |
DATABASE:_RegisterGroupsAndUnits() |
Private method that registers all Groups and Units within in the mission. |
DATABASE:_RegisterPlayers() |
Private method that registers all alive players in the mission. |
DATABASE:_RegisterStaticTemplate(GroupTemplate, StaticTemplate, CoalitionID, CategoryID, CountryID) |
Private method that registers new Static Templates within the DATABASE Object. |
DATABASE:_RegisterStatics() | |
DATABASE:_RegisterTemplates() | |
DATABASE:_RegisterZones() |
Private method that registers new ZONE_BASE derived objects within the DATABASE Object. |
Global(s)
- #DATABASE DATABASE
-
DATABASE class, extends Base#BASE
Mission designers can use the DATABASE class to refer to:
- STATICS
- UNITS
- GROUPS
- CLIENTS
- AIRBASES
- PLAYERSJOINED
- PLAYERS
- CARGOS
On top, for internal MOOSE administration purposes, the DATBASE administers the Unit and Group TEMPLATES as defined within the Mission Editor.
The singleton object _DATABASE is automatically created by MOOSE, that administers all objects within the mission. Moose refers to _DATABASE within the framework extensively, but you can also refer to the _DATABASE object within your missions if required.
Type Database
Type DATABASE
Field(s)
- DATABASE:AccountDestroys(Event)
-
Account the destroys.
Parameter
-
Core.Event#EVENTDATA Event
:
-
- DATABASE:AccountHits(Event)
-
Account the Hits of the Players.
Parameter
-
Core.Event#EVENTDATA Event
:
-
- DATABASE:AddAirbase(AirbaseName)
-
Adds a Airbase based on the Airbase Name in the DATABASE.
Parameter
-
#string AirbaseName
: The name of the airbase
-
- DATABASE:AddCargo(CargoName, Cargo)
-
Adds a Cargo based on the Cargo Name in the DATABASE.
Parameters
-
#string CargoName
: The name of the airbase -
Cargo
:
-
- DATABASE:AddClient(ClientName)
-
Adds a CLIENT based on the ClientName in the DATABASE.
Parameter
-
ClientName
:
-
- DATABASE:AddGroup(GroupName)
-
Adds a GROUP based on the GroupName in the DATABASE.
Parameter
-
GroupName
:
-
- DATABASE:AddPlayer(UnitName, PlayerName)
-
Adds a player based on the Player Name in the DATABASE.
Parameters
-
UnitName
: -
PlayerName
:
-
- DATABASE:AddStatic(DCSStaticName)
-
Adds a Static based on the Static Name in the DATABASE.
Parameter
-
DCSStaticName
:
-
- DATABASE:AddUnit(DCSUnitName)
-
Adds a Unit based on the Unit Name in the DATABASE.
Parameter
-
DCSUnitName
:
-
- DATABASE:AddZone(ZoneName, Zone)
-
Adds a Zone based on the zone name in the DATABASE.
Parameters
-
#string ZoneName
: The name of the zone. -
Core.Zone#ZONE_BASE Zone
: The zone.
-
- DATABASE:DeleteAirbase(AirbaseName)
-
Deletes a Airbase from the DATABASE based on the Airbase Name.
Parameter
-
#string AirbaseName
: The name of the airbase
-
- DATABASE:DeleteCargo(CargoName)
-
Deletes a Cargo from the DATABASE based on the Cargo Name.
Parameter
-
#string CargoName
: The name of the airbase
-
- DATABASE:DeletePlayer(UnitName, PlayerName)
-
Deletes a player from the DATABASE based on the Player Name.
Parameters
-
UnitName
: -
PlayerName
:
-
- DATABASE:DeleteStatic(DCSStaticName)
-
Deletes a Static from the DATABASE based on the Static Name.
Parameter
-
DCSStaticName
:
-
- DATABASE:DeleteUnit(DCSUnitName)
-
Deletes a Unit from the DATABASE based on the Unit Name.
Parameter
-
DCSUnitName
:
-
- DATABASE:DeleteZone(ZoneName)
-
Deletes a Zone from the DATABASE based on the zone name.
Parameter
-
#string ZoneName
: The name of the zone.
-
- DATABASE:FindAirbase(AirbaseName)
-
Finds a AIRBASE based on the AirbaseName.
Parameter
-
#string AirbaseName
:
Return value
Wrapper.Airbase#AIRBASE: The found AIRBASE.
-
- DATABASE:FindCargo(CargoName)
-
Finds an CARGO based on the CargoName.
Parameter
-
#string CargoName
:
Return value
Wrapper.Cargo#CARGO: The found CARGO.
-
- DATABASE:FindClient(ClientName)
-
Finds a CLIENT based on the ClientName.
Parameter
-
#string ClientName
:
Return value
Wrapper.Client#CLIENT: The found CLIENT.
-
- DATABASE:FindGroup(GroupName)
-
Finds a GROUP based on the GroupName.
Parameter
-
#string GroupName
:
Return value
Wrapper.Group#GROUP: The found GROUP.
-
- DATABASE:FindStatic(StaticName)
-
Finds a STATIC based on the StaticName.
Parameter
-
#string StaticName
:
Return value
Wrapper.Static#STATIC: The found STATIC.
-
- DATABASE:FindUnit(UnitName)
-
Finds a Unit based on the Unit Name.
Parameter
-
#string UnitName
:
Return value
Wrapper.Unit#UNIT: The found Unit.
-
- DATABASE:FindZone(ZoneName)
-
Finds a Zone based on the zone name.
Parameter
-
#string ZoneName
: The name of the zone.
Return value
Core.Zone#ZONE_BASE: The found ZONE.
-
- DATABASE:ForEach(IteratorFunction, FinalizeFunction, arg, Set)
-
Iterate the DATABASE and call an iterator function for the given set, providing the Object for each element within the set and optional parameters.
Parameters
-
#function IteratorFunction
: The function that will be called when there is an alive player in the database. -
FinalizeFunction
: -
arg
: -
Set
:
Return value
#DATABASE: self
-
- DATABASE:ForEachCargo(IteratorFunction, ...)
-
Iterate the DATABASE and call an iterator function for each CARGO, providing the CARGO object to the function and optional parameters.
Parameters
-
#function IteratorFunction
: The function that will be called for each object in the database. The function needs to accept a CLIENT parameter. -
...
:
Return value
#DATABASE: self
-
- DATABASE:ForEachClient(IteratorFunction, ...)
-
Iterate the DATABASE and call an iterator function for each CLIENT, providing the CLIENT to the function and optional parameters.
Parameters
-
#function IteratorFunction
: The function that will be called object in the database. The function needs to accept a CLIENT parameter. -
...
:
Return value
#DATABASE: self
-
- DATABASE:ForEachGroup(IteratorFunction, FinalizeFunction, ...)
-
Iterate the DATABASE and call an iterator function for each alive GROUP, providing the GROUP and optional parameters.
Parameters
-
#function IteratorFunction
: The function that will be called for each object in the database. The function needs to accept a GROUP parameter. -
FinalizeFunction
: -
...
:
Return value
#DATABASE: self
-
- DATABASE:ForEachPlayer(IteratorFunction, FinalizeFunction, ...)
-
Iterate the DATABASE and call an iterator function for each ALIVE player, providing the player name and optional parameters.
Parameters
-
#function IteratorFunction
: The function that will be called for each object in the database. The function needs to accept the player name. -
FinalizeFunction
: -
...
:
Return value
#DATABASE: self
-
- DATABASE:ForEachPlayerJoined(IteratorFunction, FinalizeFunction, ...)
-
Iterate the DATABASE and call an iterator function for each player who has joined the mission, providing the Unit of the player and optional parameters.
Parameters
-
#function IteratorFunction
: The function that will be called for each object in the database. The function needs to accept a UNIT parameter. -
FinalizeFunction
: -
...
:
Return value
#DATABASE: self
-
- DATABASE:ForEachPlayerUnit(IteratorFunction, FinalizeFunction, ...)
-
Iterate the DATABASE and call an iterator function for each ALIVE player UNIT, providing the player UNIT and optional parameters.
Parameters
-
#function IteratorFunction
: The function that will be called for each object in the database. The function needs to accept the player name. -
FinalizeFunction
: -
...
:
Return value
#DATABASE: self
-
- DATABASE:ForEachStatic(IteratorFunction, FinalizeFunction, ...)
-
Iterate the DATABASE and call an iterator function for each alive STATIC, providing the STATIC and optional parameters.
Parameters
-
#function IteratorFunction
: The function that will be called for each object in the database. The function needs to accept a STATIC parameter. -
FinalizeFunction
: -
...
:
Return value
#DATABASE: self
-
- DATABASE:ForEachUnit(IteratorFunction, FinalizeFunction, ...)
-
Iterate the DATABASE and call an iterator function for each alive UNIT, providing the UNIT and optional parameters.
Parameters
-
#function IteratorFunction
: The function that will be called for each object in the database. The function needs to accept a UNIT parameter. -
FinalizeFunction
: -
...
:
Return value
#DATABASE: self
-
- DATABASE:GetCategoryFromAirbase(AirbaseName)
-
Parameter
-
AirbaseName
:
-
- DATABASE:GetCategoryFromClientTemplate(ClientName)
-
Parameter
-
ClientName
:
-
- DATABASE:GetCoalitionFromAirbase(AirbaseName)
-
Parameter
-
AirbaseName
:
-
- DATABASE:GetCoalitionFromClientTemplate(ClientName)
-
Parameter
-
ClientName
:
-
- DATABASE:GetCountryFromClientTemplate(ClientName)
-
Parameter
-
ClientName
:
-
- DATABASE:GetGroupNameFromUnitName(UnitName)
-
Parameter
-
UnitName
:
-
- DATABASE:GetGroupTemplate(GroupName)
-
Parameter
-
GroupName
:
-
- DATABASE:GetGroupTemplateFromUnitName(UnitName)
-
Parameter
-
UnitName
:
-
- DATABASE:GetPlayerSettings(PlayerName)
-
Gets the player settings
Parameter
-
#string PlayerName
:
Return value
-
- DATABASE:GetPlayerUnits()
-
Get the player table from the DATABASE, which contains all UNIT objects.
The player table contains all UNIT objects of the player with the key the name of the player (PlayerName).
Usage:
local PlayerUnits = _DATABASE:GetPlayerUnits() for PlayerName, PlayerUnit in pairs( PlayerUnits ) do .. end
- DATABASE:GetPlayers()
-
Get the player table from the DATABASE.
The player table contains all unit names with the key the name of the player (PlayerName).
Usage:
local Players = _DATABASE:GetPlayers() for PlayerName, UnitName in pairs( Players ) do .. end
- DATABASE:GetPlayersJoined()
-
Get the player table from the DATABASE which have joined in the mission historically.
The player table contains all UNIT objects with the key the name of the player (PlayerName).
Usage:
local PlayersJoined = _DATABASE:GetPlayersJoined() for PlayerName, PlayerUnit in pairs( PlayersJoined ) do .. end
- DATABASE:GetStaticUnitTemplate(StaticName)
-
Parameter
-
StaticName
:
-
- DATABASE:GetStatusGroup(GroupName)
-
Get a status to a Group within the Database, this to check crossing events for example.
Parameter
-
GroupName
:
-
- DATABASE:IsCargo(TemplateName)
-
Checks if the Template name has a ~CARGO tag.
If yes, the group is a cargo.
Parameter
-
#string TemplateName
:
Return value
#boolean:
-
- DATABASE:New()
-
Creates a new DATABASE object, building a set of units belonging to a coalitions, categories, countries, types or with defined prefix names.
Return value
Usage:
-- Define a new DATABASE Object. This DBObject will contain a reference to all Group and Unit Templates defined within the ME and the DCSRTE. DBObject = DATABASE:New()
- DATABASE:OnEventDeleteCargo(EventData)
-
Handles the OnEventDeleteCargo.
Parameter
-
Core.Event#EVENTDATA EventData
:
-
- DATABASE:OnEventDeleteZone(EventData)
-
Handles the OnEventDeleteZone.
Parameter
-
Core.Event#EVENTDATA EventData
:
-
- DATABASE:OnEventNewCargo(EventData)
-
Handles the OnEventNewCargo event.
Parameter
-
Core.Event#EVENTDATA EventData
:
-
- DATABASE:OnEventNewZone(EventData)
-
Handles the OnEventNewZone event.
Parameter
-
Core.Event#EVENTDATA EventData
:
-
- DATABASE:SetPlayerSettings(PlayerName, Settings)
-
Sets the player settings
Parameters
-
#string PlayerName
: -
Core.Settings#SETTINGS Settings
:
Return value
-
- DATABASE:SetStatusGroup(GroupName, Status)
-
Set a status to a Group within the Database, this to check crossing events for example.
Parameters
-
GroupName
: -
Status
:
-
- DATABASE:Spawn(SpawnTemplate)
-
Instantiate new Groups within the DCSRTE.
This method expects EXACTLY the same structure as a structure within the ME, and needs 2 additional fields defined: SpawnCountryID, SpawnCategoryID This method is used by the SPAWN class.
Parameter
-
#table SpawnTemplate
:
Return value
#DATABASE: self
-
- #number DATABASE.UNITS_Position
- DATABASE:_EventOnBirth(Event)
-
Handles the OnBirth event for the alive units set.
Parameter
-
Core.Event#EVENTDATA Event
:
-
- DATABASE:_EventOnDeadOrCrash(Event)
-
Handles the OnDead or OnCrash event for alive units set.
Parameter
-
Core.Event#EVENTDATA Event
:
-
- DATABASE:_EventOnPlayerEnterUnit(Event)
-
Handles the OnPlayerEnterUnit event to fill the active players table (with the unit filter applied).
Parameter
-
Core.Event#EVENTDATA Event
:
-
- DATABASE:_EventOnPlayerLeaveUnit(Event)
-
Handles the OnPlayerLeaveUnit event to clean the active players table.
Parameter
-
Core.Event#EVENTDATA Event
:
-
- DATABASE:_RegisterCargos()
-
Private method that registers new Static Templates within the DATABASE Object.
Return value
#DATABASE: self
- DATABASE:_RegisterClients()
-
Private method that registers all Units of skill Client or Player within in the mission.
Return value
#DATABASE: self
- DATABASE:_RegisterGroupTemplate(GroupTemplate, CoalitionSide, CategoryID, CountryID, GroupName)
-
Private method that registers new Group Templates within the DATABASE Object.
Parameters
-
#table GroupTemplate
: -
Dcs.DCScoalition#coalition.side CoalitionSide
: The coalition.side of the object. -
Dcs.DCSObject#Object.Category CategoryID
: The Object.category of the object. -
Dcs.DCScountry#country.id CountryID
: the country.id of the object -
GroupName
:
Return value
#DATABASE: self
-
- DATABASE:_RegisterGroupsAndUnits()
-
Private method that registers all Groups and Units within in the mission.
Return value
#DATABASE: self
- DATABASE:_RegisterPlayers()
-
Private method that registers all alive players in the mission.
Return value
#DATABASE: self
- DATABASE:_RegisterStaticTemplate(GroupTemplate, StaticTemplate, CoalitionID, CategoryID, CountryID)
-
Private method that registers new Static Templates within the DATABASE Object.
Parameters
-
#table GroupTemplate
: -
StaticTemplate
: -
CoalitionID
: -
CategoryID
: -
CountryID
:
Return value
#DATABASE: self
-
- DATABASE:_RegisterZones()
-
Private method that registers new ZONE_BASE derived objects within the DATABASE Object.
Return value
#DATABASE: self