Initial commit

This commit is contained in:
Christian Franz
2022-01-19 20:55:23 +01:00
commit 929a188497
57 changed files with 17951 additions and 0 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,97 @@
dmlMain = {}
--
-- DML-based mission skeleton with event loop
--
dmlMain.ups = 1 -- 1 update per second
-- minimal libraries required
dmlMain.requiredLibs = {
"dcsCommon", -- minimal module for all
"cfxZones", -- Zones, of course
"cfxPlayer", -- player events
}
dmlMain.config = {} -- for reading config zones
--
-- world event handling
--
function dmlMain.wPreProc(event)
return true -- true means invoke worldEventHanlder()
-- filter here and return false if the event is to be ignored
end
function dmlMain.worldEventHandler(event)
-- now analyse table <event> and do stuff
trigger.action.outText("DCS World Event " .. event.id .. " (" .. dcsCommon.event2text(event.id) .. ") received", 30)
end
--
-- player event handling
--
function dmlMain.playerEventHandler (evType, description, info, data)
trigger.action.outText("DML Player Event " .. evType .. " received", 30)
end
--
-- update loop
--
function dmlMain.update()
-- schedule myself in 1/ups seconds
timer.scheduleFunction(dmlMain.update, {}, timer.getTime() + 1/dmlMain.ups)
-- perform any regular checks here in your main loop
end
--
-- read configuration from zone 'dmlMainConfig'
--
function dmlMain.readConfiguration()
local theZone = cfxZones.getZoneByName("dmlMainConfig")
if not theZone then return end
dmlMain.config = cfxZones.getAllZoneProperties(theZone)
-- demo: dump all name/value pairs returned
trigger.action.outText("DML config read from config zone:", 30)
for name, value in pairs(dmlMain.config) do
trigger.action.outText(name .. ":" .. value, 30)
end
trigger.action.outText("---- (end of list)", 30)
end
--
-- start
--
function dmlMain.start()
-- ensure that all modules have loaded
if not dcsCommon.libCheck("DML Main",
dmlMain.requiredLibs) then
return false
end
-- read any configuration values placed in a config zone on the map
dmlMain.readConfiguration()
-- subscribe to world events
dcsCommon.addEventHandler(dmlMain.worldEventHandler,
dmlMain.wPreProc) -- no post nor rejected
-- subscribe to player events
cfxPlayer.addMonitor(dmlMain.playerEventHandler)
-- start the event loop. it will sustain itself
dmlMain.update()
-- say hi!
trigger.action.outText("DML Main mission running!", 30)
return true
end
-- start main
if not dmlMain.start() then
trigger.action.outText("Main mission failed to run", 30)
dmlMain = nil
end

View File

@@ -0,0 +1,104 @@
ldgCtr = {}
--
-- DML-based mission that counts the number of
-- successful missions for all players. MP-capable
--
ldgCtr.ups = 1 -- 1 update per second
-- minimal libraries required
ldgCtr.requiredLibs = {
"dcsCommon", -- minimal module for all
"cfxZones", -- Zones, of course
"cfxPlayer", -- player events
}
ldgCtr.config = {} -- for reading config zones
ldgCtr.landings = {} -- set all landings to 0
--
-- world event handling
--
function ldgCtr.wPreProc(event)
return event.id == 4 -- look for 'landing event'
end
function ldgCtr.worldEventHandler(event)
-- wPreProc filters all events EXCEPT landing
local theUnit = event.initiator
local uName = theUnit:getName()
local playerName = theUnit:getPlayerName()
trigger.action.outText(uName .. " has landed.", 30)
if playerName then
-- if a player landed, count their landing
local numLandings = ldgCtr.landings[playerName]
if not numLandings then numLandings = 0 end
numLandings = numLandings + 1
ldgCtr.landings[playerName] = numLandings
trigger.action.outText("Player " .. playerName .. " completed ".. numLandings .." landings.", 30)
end
end
--
-- player event handling
--
function ldgCtr.playerEventHandler (evType, description, info, data)
-- not needed
end
--
-- update loop
--
function ldgCtr.update()
-- schedule myself in 1/ups seconds
timer.scheduleFunction(ldgCtr.update, {}, timer.getTime() + 1/ldgCtr.ups)
-- no regular checks needed
end
--
-- read configuration from zone 'ldgCtrConfig'
--
function ldgCtr.readConfiguration()
local theZone = cfxZones.getZoneByName("ldgCtrConfig")
if not theZone then return end
ldgCtr.config = cfxZones.getAllZoneProperties(theZone)
end
--
-- start
--
function ldgCtr.start()
-- ensure that all modules have loaded
if not dcsCommon.libCheck("Landing Counter",
ldgCtr.requiredLibs) then
return false
end
-- read any configuration values placed in a config zone on the map
ldgCtr.readConfiguration()
-- init variables & state
ldgCtr.landings = {}
-- subscribe to world events
dcsCommon.addEventHandler(ldgCtr.worldEventHandler,
ldgCtr.wPreProc) -- no post nor rejected
-- subscribe to player events
cfxPlayer.addMonitor(ldgCtr.playerEventHandler)
-- start the event loop. it will sustain itself
ldgCtr.update()
-- say hi!
trigger.action.outText("Landing Counter mission running!", 30)
return true
end
-- start main
if not ldgCtr.start() then
trigger.action.outText("Landing Counter failed to run", 30)
ldgCtr = nil
end