Module Database

Core -- DATABASE manages the database of mission objects.


Author: Sven Van de Velde (FlightControl)

Contributions:


Global(s)

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.

PlayerCheckSchedule

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: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: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: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:GetStaticUnitTemplate(StaticName)
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:OnEventDeleteCargo(EventData)

Handles the OnEventDeleteCargo.

DATABASE:OnEventNewCargo(EventData)

Handles the OnEventNewCargo 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:_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()

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.

PlayerCheckSchedule

Type Database

Type DATABASE

Field(s)

DATABASE:AccountDestroys(Event)

Account the destroys.

Parameter

DATABASE:AccountHits(Event)

Account the Hits of the Players.

Parameter

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: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: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: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

Core.Settings#SETTINGS:

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.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.

Return value

#DATABASE:

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

DATABASE:OnEventNewCargo(EventData)

Handles the OnEventNewCargo event.

Parameter

DATABASE:SetPlayerSettings(PlayerName, Settings)

Sets the player settings

Parameters

Return value

Core.Settings#SETTINGS:

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.UNITS
#number DATABASE.UNITS_Position
DATABASE:_EventOnBirth(Event)

Handles the OnBirth event for the alive units set.

Parameter

DATABASE:_EventOnDeadOrCrash(Event)

Handles the OnDead or OnCrash event for alive units set.

Parameter

DATABASE:_EventOnPlayerEnterUnit(Event)

Handles the OnPlayerEnterUnit event to fill the active players table (with the unit filter applied).

Parameter

DATABASE:_EventOnPlayerLeaveUnit(Event)

Handles the OnPlayerLeaveUnit event to clean the active players table.

Parameter

DATABASE:_RegisterAirbases()
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

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:_RegisterStatics()
DATABASE:_RegisterTemplates()