Module Database
This module contains the DATABASE class, managing the database of mission objects.
1) #DATABASE class, extends Base#BASE
Mission designers can use the DATABASE class to refer to:
- UNITS
- GROUPS
- CLIENTS
- AIRPORTS
- PLAYERSJOINED
- PLAYERS
On top, for internal MOOSE administration purposes, the DATBASE administers the Unit and Group TEMPLATES as defined within the Mission Editor.
Moose will automatically create one instance of the DATABASE class into the global object _DATABASE. Moose refers to _DATABASE within the framework extensively, but you can also refer to the _DATABASE object within your missions if required.
1.1) DATABASE iterators
You can iterate the database with the available iterator methods. The iterator methods will walk the DATABASE set, and call for each element within the set a function that you provide. The following iterator methods are currently available within the DATABASE:
- DATABASE.ForEachUnit: Calls a function for each UNIT it finds within the DATABASE.
- DATABASE.ForEachGroup: Calls a function for each GROUP it finds within the DATABASE.
- DATABASE.ForEachPlayer: Calls a function for each alive player it finds within the DATABASE.
- DATABASE.ForEachPlayerJoined: Calls a function for each joined player it finds within the DATABASE.
- DATABASE.ForEachClient: Calls a function for each CLIENT it finds within the DATABASE.
- DATABASE.ForEachClientAlive: Calls a function for each alive CLIENT it finds within the DATABASE.
Global(s)
| DATABASE |
Type DATABASE
| DATABASE.AIRBASES | |
| DATABASE:AddAirbase(DCSAirbaseName) |
Adds a Airbase based on the Airbase 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.CLIENTS | |
| DATABASE.COUNTRY_ID | |
| DATABASE.COUNTRY_NAME | |
| DATABASE.ClassName | |
| DATABASE:DeleteAirbase(DCSAirbaseName) |
Deletes a Airbase from the DATABASE based on the Airbase Name. |
| DATABASE:DeletePlayer(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:FindAirbase(AirbaseName) |
Finds a AIRBASE based on the AirbaseName. |
| 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: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: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, ...) |
Iterate the DATABASE and call an iterator function for each alive GROUP, providing the GROUP and optional parameters. |
| DATABASE:ForEachPlayer(IteratorFunction, ...) |
Iterate the DATABASE and call an iterator function for each ALIVE player, providing the player name and optional parameters. |
| DATABASE:ForEachPlayerJoined(IteratorFunction, ...) |
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:ForEachUnit(IteratorFunction, FinalizeFunction, ...) |
Iterate the DATABASE and call an iterator function for each alive UNIT, providing the UNIT and optional parameters. |
| DATABASE.GROUPS | |
| 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:GetStatusGroup(GroupName) |
Get a status to a Group within the Database, this to check crossing events for example. |
| 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.PLAYERS | |
| DATABASE.PLAYERSJOINED | |
| DATABASE.STATICS | |
| 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.Templates | |
| DATABASE.UNITS | |
| 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:_RegisterClients() |
Private method that registers all Units of skill Client or Player within in the mission. |
| 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:_RegisterStatics() | |
| DATABASE:_RegisterTemplate(GroupTemplate, CoalitionID, CategoryID, CountryID) |
Private method that registers new Group Templates within the DATABASE Object. |
| DATABASE:_RegisterTemplates() |
Global(s)
Type Database
Type DATABASE
DATABASE class
Field(s)
- DATABASE:AddAirbase(DCSAirbaseName)
-
Adds a Airbase based on the Airbase Name in the DATABASE.
Parameter
-
DCSAirbaseName:
-
- 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:
-
- #string DATABASE.ClassName
- DATABASE:DeleteAirbase(DCSAirbaseName)
-
Deletes a Airbase from the DATABASE based on the Airbase Name.
Parameter
-
DCSAirbaseName:
-
- DATABASE:DeletePlayer(PlayerName)
-
Deletes a player from the DATABASE based on the Player Name.
Parameter
-
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:FindAirbase(AirbaseName)
-
Finds a AIRBASE based on the AirbaseName.
Parameter
-
#string AirbaseName:
Return value
Wrapper.Airbase#AIRBASE: The found AIRBASE.
-
- 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: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: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 when there is an alive player in the database. The function needs to accept a CLIENT parameter. -
...:
Return value
#DATABASE: self
-
- DATABASE:ForEachGroup(IteratorFunction, ...)
-
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 when there is an alive GROUP in the database. The function needs to accept a GROUP parameter. -
...:
Return value
#DATABASE: self
-
- DATABASE:ForEachPlayer(IteratorFunction, ...)
-
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 when there is an player in the database. The function needs to accept the player name. -
...:
Return value
#DATABASE: self
-
- DATABASE:ForEachPlayerJoined(IteratorFunction, ...)
-
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 when there is was a player in the database. The function needs to accept a UNIT parameter. -
...:
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 when there is an alive UNIT 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:GetStatusGroup(GroupName)
-
Get a status to a Group within the Database, this to check crossing events for example.
Parameter
-
GroupName:
-
- 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: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
-
- 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:_RegisterClients()
-
Private method that registers all Units of skill Client or Player within in the mission.
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:_RegisterTemplate(GroupTemplate, CoalitionID, CategoryID, CountryID)
-
Private method that registers new Group Templates within the DATABASE Object.
Parameters
-
#table GroupTemplate: -
CoalitionID: -
CategoryID: -
CountryID:
Return value
#DATABASE: self
-