Version 0.995

Watchflags
This commit is contained in:
Christian Franz 2022-03-24 17:42:24 +01:00
parent 95e809b85c
commit 6d1e992037
22 changed files with 474 additions and 73 deletions

Binary file not shown.

Binary file not shown.

View File

@ -1,5 +1,5 @@
rndFlags = {} rndFlags = {}
rndFlags.version = "1.1.0" rndFlags.version = "1.2.0"
rndFlags.verbose = false rndFlags.verbose = false
rndFlags.requiredLibs = { rndFlags.requiredLibs = {
"dcsCommon", -- always "dcsCommon", -- always
@ -22,6 +22,7 @@ rndFlags.requiredLibs = {
getFlagValue in update getFlagValue in update
some code clean-up some code clean-up
rndMethod synonym rndMethod synonym
1.2.0 - Watchflag integration
--]] --]]
rndFlags.rndGen = {} rndFlags.rndGen = {}
@ -104,6 +105,14 @@ function rndFlags.createRNDWithZone(theZone)
theZone.remove = cfxZones.getBoolFromZoneProperty(theZone, "remove", false) theZone.remove = cfxZones.getBoolFromZoneProperty(theZone, "remove", false)
-- watchflag:
-- triggerMethod
theZone.rndTriggerMethod = cfxZones.getStringFromZoneProperty(theZone, "triggerMethod", "change")
if cfxZones.hasProperty(theZone, "rndTriggerMethod") then
theZone.rndTriggerMethod = cfxZones.getStringFromZoneProperty(theZone, "rndTriggerMethod", "change")
end
-- trigger flag -- trigger flag
if cfxZones.hasProperty(theZone, "f?") then if cfxZones.hasProperty(theZone, "f?") then
theZone.triggerFlag = cfxZones.getStringFromZoneProperty(theZone, "f?", "none") theZone.triggerFlag = cfxZones.getStringFromZoneProperty(theZone, "f?", "none")
@ -117,6 +126,7 @@ function rndFlags.createRNDWithZone(theZone)
theZone.triggerFlag = cfxZones.getStringFromZoneProperty(theZone, "rndPoll?", "none") theZone.triggerFlag = cfxZones.getStringFromZoneProperty(theZone, "rndPoll?", "none")
end end
if theZone.triggerFlag then if theZone.triggerFlag then
theZone.lastTriggerValue = cfxZones.getFlagValue(theZone.triggerFlag, theZone) --trigger.misc.getUserFlag(theZone.triggerFlag) -- save last value theZone.lastTriggerValue = cfxZones.getFlagValue(theZone.triggerFlag, theZone) --trigger.misc.getUserFlag(theZone.triggerFlag) -- save last value
end end
@ -223,6 +233,13 @@ function rndFlags.update()
timer.scheduleFunction(rndFlags.update, {}, timer.getTime() + 1) timer.scheduleFunction(rndFlags.update, {}, timer.getTime() + 1)
for idx, aZone in pairs(rndFlags.rndGen) do for idx, aZone in pairs(rndFlags.rndGen) do
if cfxZones.testZoneFlag(aZone, aZone.triggerFlag, aZone.rndTriggerMethod, "lastTriggerValue") then
if rndFlags.verbose then
trigger.action.outText("+++RND: triggering " .. aZone.name, 30)
end
rndFlags.fire(aZone)
end
--[[-- old code pre watchflag
if aZone.triggerFlag then if aZone.triggerFlag then
local currTriggerVal = cfxZones.getFlagValue(aZone.triggerFlag, aZone) -- trigger.misc.getUserFlag(aZone.triggerFlag) local currTriggerVal = cfxZones.getFlagValue(aZone.triggerFlag, aZone) -- trigger.misc.getUserFlag(aZone.triggerFlag)
if currTriggerVal ~= aZone.lastTriggerValue if currTriggerVal ~= aZone.lastTriggerValue
@ -235,6 +252,7 @@ function rndFlags.update()
end end
end end
--]]--
end end
end end

View File

@ -1,7 +1,12 @@
cfxArtilleryDemon = {} cfxArtilleryDemon = {}
cfxArtilleryDemon.version = "1.0.2" cfxArtilleryDemon.version = "1.0.3"
-- based on cfx stage demon v 1.0.2 -- based on cfx stage demon v 1.0.2
--[[--
Version History
1.0.2 - taken from stageDemon
1.0.3 - corrected 'messageOut' bug
--]]--
cfxArtilleryDemon.messageToAll = true -- set to false if messages should be sent only to the group that set the mark cfxArtilleryDemon.messageToAll = true -- set to false if messages should be sent only to the group that set the mark
cfxArtilleryDemon.messageTime = 30 -- how long a message stays on the sceeen cfxArtilleryDemon.messageTime = 30 -- how long a message stays on the sceeen
@ -181,7 +186,7 @@ function cfxArtilleryDemon:onEvent(theEvent)
local theGroup = cfxArtilleryDemon.retrieveGroupFromEvent(theEvent) local theGroup = cfxArtilleryDemon.retrieveGroupFromEvent(theEvent)
if not theGroup then if not theGroup then
args.toAll = true args.toAll = true
trigger.action.messageOut("*** WARNING: cfxArtilleryDemon can't find group for command", 30) trigger.action.outText("*** WARNING: cfxArtilleryDemon can't find group for command", 30)
else else
args.group = theGroup args.group = theGroup
end end

View File

@ -1,5 +1,5 @@
cfxArtilleryZones = {} cfxArtilleryZones = {}
cfxArtilleryZones.version = "2.0.2" cfxArtilleryZones.version = "2.2.0"
cfxArtilleryZones.requiredLibs = { cfxArtilleryZones.requiredLibs = {
"dcsCommon", -- always "dcsCommon", -- always
"cfxZones", -- Zones, of course "cfxZones", -- Zones, of course
@ -28,6 +28,7 @@ cfxArtilleryZones.verbose = false
2.0.2 - boom?, arty? synonyms 2.0.2 - boom?, arty? synonyms
2.1.0 - DML Flag Support 2.1.0 - DML Flag Support
- code cleanup - code cleanup
2.2.0 - DML Watchflag integration
Artillery Target Zones *** EXTENDS ZONES *** Artillery Target Zones *** EXTENDS ZONES ***
Target Zones for artillery. Can determine which zones are in range and visible and then handle artillery barrage to this zone Target Zones for artillery. Can determine which zones are in range and visible and then handle artillery barrage to this zone
@ -123,6 +124,15 @@ function cfxArtilleryZones.processArtilleryZone(aZone)
aZone.transitionTime = cfxZones.getNumberFromZoneProperty(aZone, "transitionTime", 20) -- average time of travel for projectiles aZone.transitionTime = cfxZones.getNumberFromZoneProperty(aZone, "transitionTime", 20) -- average time of travel for projectiles
aZone.addMark = cfxZones.getBoolFromZoneProperty(aZone, "addMark", true) -- note: defaults to true aZone.addMark = cfxZones.getBoolFromZoneProperty(aZone, "addMark", true) -- note: defaults to true
aZone.shellVariance = cfxZones.getNumberFromZoneProperty(aZone, "shellVariance", 0.2) -- strength of explosion can vary by +/- this amount aZone.shellVariance = cfxZones.getNumberFromZoneProperty(aZone, "shellVariance", 0.2) -- strength of explosion can vary by +/- this amount
-- watchflag:
-- triggerMethod
aZone.artyTriggerMethod = cfxZones.getStringFromZoneProperty(aZone, "artyTriggerMethod", "change")
if cfxZones.hasProperty(aZone, "triggerMethod") then
aZone.artyTriggerMethod = cfxZones.getStringFromZoneProperty(aZone, "triggerMethod", "change")
end
if cfxZones.hasProperty(aZone, "f?") then if cfxZones.hasProperty(aZone, "f?") then
aZone.artyTriggerFlag = cfxZones.getStringFromZoneProperty(aZone, "f?", "none") aZone.artyTriggerFlag = cfxZones.getStringFromZoneProperty(aZone, "f?", "none")
end end
@ -134,6 +144,10 @@ function cfxArtilleryZones.processArtilleryZone(aZone)
if cfxZones.hasProperty(aZone, "artillery?") then if cfxZones.hasProperty(aZone, "artillery?") then
aZone.artyTriggerFlag = cfxZones.getStringFromZoneProperty(aZone, "artillery?", "none") aZone.artyTriggerFlag = cfxZones.getStringFromZoneProperty(aZone, "artillery?", "none")
end end
if cfxZones.hasProperty(aZone, "in?") then
aZone.artyTriggerFlag = cfxZones.getStringFromZoneProperty(aZone, "in?", "none")
end
if aZone.artyTriggerFlag then if aZone.artyTriggerFlag then
aZone.lastTriggerValue = trigger.misc.getUserFlag(aZone.artyTriggerFlag) -- save last value aZone.lastTriggerValue = trigger.misc.getUserFlag(aZone.artyTriggerFlag) -- save last value
end end
@ -357,6 +371,17 @@ function cfxArtilleryZones.update()
-- iterate all zones to see if a trigger has changed -- iterate all zones to see if a trigger has changed
for idx, aZone in pairs(cfxArtilleryZones.artilleryZones) do for idx, aZone in pairs(cfxArtilleryZones.artilleryZones) do
if cfxZones.testZoneFlag(aZone, aZone.artyTriggerFlag, aZone.artyTriggerMethod, "lastTriggerValue") then
-- a triggered release!
cfxArtilleryZones.doFireAt(aZone) -- all from zone vars!
if cfxArtilleryZones.verbose then
local addInfo = " with var = " .. aZone.baseAccuracy .. " pB=" .. aZone.shellStrength
trigger.action.outText("Artillery T-Firing on ".. aZone.name .. addInfo, 30)
end
end
-- old code
if aZone.artyTriggerFlag then if aZone.artyTriggerFlag then
local currTriggerVal = cfxZones.getFlagValue(aZone.artyTriggerFlag, aZone) -- trigger.misc.getUserFlag(aZone.artyTriggerFlag) local currTriggerVal = cfxZones.getFlagValue(aZone.artyTriggerFlag, aZone) -- trigger.misc.getUserFlag(aZone.artyTriggerFlag)
if currTriggerVal ~= aZone.lastTriggerValue if currTriggerVal ~= aZone.lastTriggerValue

View File

@ -1,5 +1,5 @@
cfxCargoReceiver = {} cfxCargoReceiver = {}
cfxCargoReceiver.version = "1.2.0" cfxCargoReceiver.version = "1.2.1"
cfxCargoReceiver.ups = 1 -- once a second cfxCargoReceiver.ups = 1 -- once a second
cfxCargoReceiver.maxDirectionRange = 500 -- in m. distance when cargo manager starts talking to pilots who are carrying that cargo cfxCargoReceiver.maxDirectionRange = 500 -- in m. distance when cargo manager starts talking to pilots who are carrying that cargo
cfxCargoReceiver.requiredLibs = { cfxCargoReceiver.requiredLibs = {
@ -16,6 +16,7 @@ cfxCargoReceiver.requiredLibs = {
silent attribute silent attribute
- 1.2.0 method - 1.2.0 method
f!, cargoReceived! f!, cargoReceived!
- 1.2.1 cargoMethod
CargoReceiver is a zone enhancement you use to be automatically CargoReceiver is a zone enhancement you use to be automatically
@ -71,13 +72,17 @@ function cfxCargoReceiver.processReceiverZone(aZone) -- process attribute and ad
end end
-- new method support -- new method support
aZone.method = cfxZones.getStringFromZoneProperty(aZone, "method", "inc") aZone.cargoMethod = cfxZones.getStringFromZoneProperty(aZone, "method", "inc")
if cfxZones.hasProperty(aZone, "cargoMethod") then
aZone.cargoMethod = cfxZones.getStringFromZoneProperty(aZone, "cargoMethod", "inc")
end
if cfxZones.hasProperty(aZone, "f!") then if cfxZones.hasProperty(aZone, "f!") then
aZone.outReceiveFlag = cfxZones.getNumberFromZoneProperty(aZone, "f!", -1) aZone.outReceiveFlag = cfxZones.getStringFromZoneProperty(aZone, "f!", "*<none>")
end end
if cfxZones.hasProperty(aZone, "cargoReceived!") then
aZone.outReceiveFlag = cfxZones.getNumberFromZoneProperty(aZone, "cargoReceived!", -1) if cfxZones.hasProperty(aZone, "cargoReceived!") then
aZone.outReceiveFlag = cfxZones.getStringFromZoneProperty(aZone, "cargoReceived!", "*<none>")
end end
end end
@ -146,7 +151,7 @@ function cfxCargoReceiver.cargoEvent(event, object, name)
end end
if aZone.outReceiveFlag then if aZone.outReceiveFlag then
cfxZones.pollFlag(aZone.outReceiveFlag, aZone.method) cfxZones.pollFlag(aZone.outReceiveFlag, aZone.cargoMethod)
end end
--trigger.action.outText("+++rcv: " .. name .. " delivered in zone " .. aZone.name, 30) --trigger.action.outText("+++rcv: " .. name .. " delivered in zone " .. aZone.name, 30)

View File

@ -1,5 +1,5 @@
cfxObjectSpawnZones = {} cfxObjectSpawnZones = {}
cfxObjectSpawnZones.version = "1.2.0" cfxObjectSpawnZones.version = "1.2.1"
cfxObjectSpawnZones.requiredLibs = { cfxObjectSpawnZones.requiredLibs = {
"dcsCommon", -- common is of course needed for everything "dcsCommon", -- common is of course needed for everything
-- pretty stupid to check for this since we -- pretty stupid to check for this since we
@ -7,7 +7,7 @@ cfxObjectSpawnZones.requiredLibs = {
"cfxZones", -- Zones, of course. MUST HAVE RUN "cfxZones", -- Zones, of course. MUST HAVE RUN
} }
cfxObjectSpawnZones.ups = 1 cfxObjectSpawnZones.ups = 1
cfxObjectSpawnZones.verbose = false
-- --
-- Zones that conform with this requirements spawn toops automatically -- Zones that conform with this requirements spawn toops automatically
-- *** DOES NOT EXTEND ZONES *** -- *** DOES NOT EXTEND ZONES ***
@ -25,6 +25,8 @@ cfxObjectSpawnZones.ups = 1
-- 1.1.4 - activate?, pause? attributes -- 1.1.4 - activate?, pause? attributes
-- 1.1.5 - spawn?, spawnObjects? synonyms -- 1.1.5 - spawn?, spawnObjects? synonyms
-- 1.2.0 - DML flag upgrade -- 1.2.0 - DML flag upgrade
-- 1.2.1 - config zone
-- - autoLink bug (zone instead of spaneer accessed)
-- respawn currently happens after theSpawns is deleted and cooldown seconds have passed -- respawn currently happens after theSpawns is deleted and cooldown seconds have passed
cfxObjectSpawnZones.allSpawners = {} cfxObjectSpawnZones.allSpawners = {}
@ -191,6 +193,20 @@ function cfxObjectSpawnZones.verifySpawnOwnership(spawner)
end end
function cfxObjectSpawnZones.spawnObjectNTimes(aSpawner, theType, n, container) function cfxObjectSpawnZones.spawnObjectNTimes(aSpawner, theType, n, container)
if cfxObjectSpawnZones.verbose then
trigger.action.outText("+++oSpwn: enter spawnNT for " .. theType .. " with spawner " .. aSpawner.name .. " for zone " .. aSpawner.zone.name , 30)
if aSpawner.zone.linkedUnit then
trigger.action.outText("linked to unit " .. aSpawner.zone.linkedUnit:getName(), 30)
if aSpawner.autoLink then
trigger.action.outText("autolink", 30)
else
trigger.action.outText("UNAUTO", 30)
end
else
trigger.action.outText("Unlinked", 30)
end
end
if not aSpawner then return end if not aSpawner then return end
if not container then container = {} end if not container then container = {} end
if not n then n = 1 end if not n then n = 1 end
@ -220,7 +236,11 @@ function cfxObjectSpawnZones.spawnObjectNTimes(aSpawner, theType, n, container)
-- if linked, relative-link instead to ship -- if linked, relative-link instead to ship
-- NOTE: it is possible that we have to re-calc heading -- NOTE: it is possible that we have to re-calc heading
-- if ship turns relative to original designation position. -- if ship turns relative to original designation position.
if aZone.linkedUnit and aZone.autoLink then if aZone.linkedUnit and aSpawner.autoLink then
-- remember there is identical code for when more than 1 item!!!!
if cfxObjectSpawnZones.verbose then
trigger.action.outText("+++oSpwn: linking <" .. aZone.name .. ">'s objects to unit " .. aZone.linkedUnit:getName(), 30)
end
dcsCommon.linkStaticDataToUnit( dcsCommon.linkStaticDataToUnit(
theStaticData, theStaticData,
aZone.linkedUnit, aZone.linkedUnit,
@ -269,7 +289,7 @@ function cfxObjectSpawnZones.spawnObjectNTimes(aSpawner, theType, n, container)
aSpawner.count = aSpawner.count + 1 aSpawner.count = aSpawner.count + 1
dcsCommon.moveStaticDataTo(theStaticData, ox, oy) dcsCommon.moveStaticDataTo(theStaticData, ox, oy)
if aZone.linkedUnit and aZone.autoLink then if aZone.linkedUnit and aSpawner.autoLink then
dcsCommon.linkStaticDataToUnit(theStaticData, aZone.linkedUnit, aSpawner.dx + rx, aSpawner.dy + ry, aSpawner.origHeading) dcsCommon.linkStaticDataToUnit(theStaticData, aZone.linkedUnit, aSpawner.dx + rx, aSpawner.dy + ry, aSpawner.origHeading)
end end
@ -430,12 +450,33 @@ function cfxObjectSpawnZones.update()
end end
end end
function cfxObjectSpawnZones.readConfigZone()
local theZone = cfxZones.getZoneByName("objectSpawnZonesConfig")
if not theZone then
if cfxObjectSpawnZones.verbose then
trigger.action.outText("+++oSpwn: NO config zone!", 30)
end
return
end
cfxObjectSpawnZones.verbose = cfxZones.getBoolFromZoneProperty(theZone, "verbose", false)
cfxObjectSpawnZones.ups = cfxZones.getNumberFromZoneProperty(theZone, "ups", 1)
if cfxObjectSpawnZones.verbose then
trigger.action.outText("+++oSpwn: read config", 30)
end
end
function cfxObjectSpawnZones.start() function cfxObjectSpawnZones.start()
if not dcsCommon.libCheck("cfx Object Spawn Zones", if not dcsCommon.libCheck("cfx Object Spawn Zones",
cfxObjectSpawnZones.requiredLibs) then cfxObjectSpawnZones.requiredLibs) then
return false return false
end end
-- read config
cfxObjectSpawnZones.readConfigZone()
-- collect all spawn zones -- collect all spawn zones
local attrZones = cfxZones.getZonesWithAttributeNamed("objectSpawner") local attrZones = cfxZones.getZonesWithAttributeNamed("objectSpawner")

View File

@ -1,5 +1,5 @@
cfxPlayerScore = {} cfxPlayerScore = {}
cfxPlayerScore.version = "1.3.0" cfxPlayerScore.version = "1.3.1"
cfxPlayerScore.badSound = "Death BRASS.wav" cfxPlayerScore.badSound = "Death BRASS.wav"
cfxPlayerScore.scoreSound = "Quest Snare 3.wav" cfxPlayerScore.scoreSound = "Quest Snare 3.wav"
cfxPlayerScore.announcer = true cfxPlayerScore.announcer = true
@ -22,6 +22,7 @@ cfxPlayerScore.announcer = true
- scenery objects are now supported. use the - scenery objects are now supported. use the
number that is given under OBJECT ID when number that is given under OBJECT ID when
using assign as... using assign as...
1.3.1 - isStaticObject() to better detect buildings after Match 22 patch
--]]-- --]]--
@ -233,6 +234,13 @@ function cfxPlayerScore.postProcessor(theEvent)
-- don't do anything -- don't do anything
end end
function cfxPlayerScore.isStaticObject(theUnit)
if not theUnit.getGroup then return true end
local aGroup = theUnit:getGroup()
if aGroup then return false end
return true
end
function cfxPlayerScore.killDetected(theEvent) function cfxPlayerScore.killDetected(theEvent)
-- we are only getting called when and if -- we are only getting called when and if
-- a kill occured and killer was a player -- a kill occured and killer was a player
@ -270,7 +278,9 @@ function cfxPlayerScore.killDetected(theEvent)
-- see what kind of unit (category) we killed -- see what kind of unit (category) we killed
-- and look up base score -- and look up base score
if not victim.getGroup then local isStO = cfxPlayerScore.isStaticObject(victim)
--if not victim.getGroup then
if isStO then
-- static objects have no group -- static objects have no group
local staticName = victim:getName() -- on statics, this returns local staticName = victim:getName() -- on statics, this returns
@ -279,7 +289,7 @@ function cfxPlayerScore.killDetected(theEvent)
if staticScore > 0 then if staticScore > 0 then
-- this was a named static, return the score - unless our own -- this was a named static, return the score - unless our own
if fraternicide then if fraternicide then
scoreMod = -2 * scoreMod scoreMod = -1 * scoreMod -- blue on blue static kills award negative
trigger.action.outSoundForCoalition(killSide, cfxPlayerScore.badSound) trigger.action.outSoundForCoalition(killSide, cfxPlayerScore.badSound)
else else
trigger.action.outSoundForCoalition(killSide, cfxPlayerScore.scoreSound) trigger.action.outSoundForCoalition(killSide, cfxPlayerScore.scoreSound)
@ -294,7 +304,15 @@ function cfxPlayerScore.killDetected(theEvent)
end end
local vicGroup = victim:getGroup() local vicGroup = victim:getGroup()
if not vicGroup then
trigger.action.outText("+++scr: strange stuff:group, outta here", 30)
return
end
local vicCat = vicGroup:getCategory() local vicCat = vicGroup:getCategory()
if not vicCat then
trigger.action.outText("+++scr: strange stuff:cat, outta here", 30)
return
end
local unitScore = cfxPlayerScore.unit2score(victim) local unitScore = cfxPlayerScore.unit2score(victim)
-- see which weapon was used. gun kills score 2x -- see which weapon was used. gun kills score 2x
@ -308,9 +326,7 @@ function cfxPlayerScore.killDetected(theEvent)
else else
local kWeapon = killWeap:getTypeName() local kWeapon = killWeap:getTypeName()
killMeth = " with " .. kWeapon killMeth = " with " .. kWeapon
end end
else
end end
if pk then if pk then

View File

@ -6,7 +6,7 @@
-- --
cfxZones = {} cfxZones = {}
cfxZones.version = "2.5.8" cfxZones.version = "2.6.1"
--[[-- VERSION HISTORY --[[-- VERSION HISTORY
- 2.2.4 - getCoalitionFromZoneProperty - 2.2.4 - getCoalitionFromZoneProperty
- getStringFromZoneProperty - getStringFromZoneProperty
@ -57,6 +57,10 @@ cfxZones.version = "2.5.8"
- 2.5.7 - pollFlag supports dml flags - 2.5.7 - pollFlag supports dml flags
- 2.5.8 - flagArrayFromString - 2.5.8 - flagArrayFromString
- getFlagNumber invokes tonumber() before returning result - getFlagNumber invokes tonumber() before returning result
- 2.5.9 - removed pass-back flag in getPoint()
- 2.6.0 - testZoneFlag() method based flag testing
- 2.6.1 - Watchflag parsing of zone condition for number-named flags
- case insensitive
--]]-- --]]--
cfxZones.verbose = false cfxZones.verbose = false
@ -884,6 +888,7 @@ end
-- from center to rim, with 100% being entirely in center, 0 = outside -- from center to rim, with 100% being entirely in center, 0 = outside
-- the third value returned is the distance to center -- the third value returned is the distance to center
function cfxZones.pointInZone(thePoint, theZone) function cfxZones.pointInZone(thePoint, theZone)
if not (theZone) then return false, 0, 0 end if not (theZone) then return false, 0, 0 end
local pflat = {x = thePoint.x, y = 0, z = thePoint.z} local pflat = {x = thePoint.x, y = 0, z = thePoint.z}
@ -1177,6 +1182,146 @@ function cfxZones.isMEFlag(inFlag)
-- return dcsCommon.stringIsPositiveNumber(inFlag) -- return dcsCommon.stringIsPositiveNumber(inFlag)
end end
-- method-based flag testing
function cfxZones.testFlagByMethodForZone(currVal, lastVal, theMethod, theZone)
-- return true/false based on theMethod's contraints
-- simple constraints
-- ONLY RETURN TRUE IF CHANGE AND CONSTRAINT MET
local lMethod = string.lower(theMethod)
if lMethod == "#" or lMethod == "change" then
-- check if currVal different from lastVal
return currVal ~= lastVal
end
if lMethod == "0" or lMethod == "no" or lMethod == "false"
or lMethod == "off" then
-- WARNING: ONLY RETURNS TRUE IF FALSE AND lastval not zero!
return currVal == 0 and currVal ~= lastVal
end
if lMethod == "1" or lMethod == "yes" or lMethod == "true"
or lMethod == "on" then
-- WARNING: only returns true if lastval was false!!!!
return (currVal ~= 0 and lastVal == 0)
end
if lMethod == "inc" or lMethod == "+1" then
return currVal == lastVal+1
end
if lMethod == "dec" or lMethod == "-1" then
return currVal == lastVal-1
end
-- number constraints
-- or flag constraints
-- ONLY RETURN TRUE IF CHANGE AND CONSTRAINT MET
local op = string.sub(theMethod, 1, 1)
local remainder = string.sub(theMethod, 2)
remainder = dcsCommon.trim(remainder) -- remove all leading and trailing spaces
local rNum = tonumber(remainder)
if not rNum then
-- we use remainder as name for flag
-- PROCESS ESCAPE SEQUENCES
local esc = string.sub(remainder, 1, 1)
local last = string.sub(remainder, -1)
if esc == "@" then
remainder = string.sub(remainder, 2)
remainder = dcsCommon.trim(remainder)
end
if esc == "(" and last == ")" and string.len(remainder) > 2 then
-- note: iisues with startswith("(") ???
remainder = string.sub(remainder, 2, -2)
remainder = dcsCommon.trim(remainder)
end
if esc == "\"" and last == "\"" and string.len(remainder) > 2 then
remainder = string.sub(remainder, 2, -2)
remainder = dcsCommon.trim(remainder)
end
if cfxZones.verbose then
trigger.action.outText("+++zne: accessing flag <" .. remainder .. ">", 30)
end
rNum = cfxZones.getFlagValue(remainder, theZone)
end
if rNum then
-- we have a comparison = ">", "=", "<" followed by a number
-- THEY TRIGGER EACH TIME lastVal <> currVal AND condition IS MET
if op == "=" then
return currVal == rNum and lastVal ~= currVal
end
if op == "#" or op == "~" then
return currVal ~= rNum and lastVal ~= currVal
end
if op == "<" then
return currVal < rNum and lastVal ~= currVal
end
if op == ">" then
return currVal > rNum and lastVal ~= currVal
end
end
-- if we get here, we have an error
local zoneName = "<NIL>"
if theZone then zoneName = theZone.name end
trigger.action.outText("+++Zne: illegal method constraints |" .. theMethod .. "| for zone " .. zoneName, 30 )
return false
end
function cfxZones.testZoneFlag(theZone, theFlagName, theMethod, latchName)
-- returns true if method contraints are met for flag theFlagName
-- as defined by theMethod
if not theMethod then
theMethod = "change"
end
-- will read and update theZone[latchName] as appropriate
if not theZone then
trigger.action.outText("+++Zne: no zone for testZoneFlag", 30)
return
end
if not theFlagName then
-- this is common, no error, only on verbose
if cfxZones.verbose then
trigger.action.outText("+++Zne: no flagName for zone " .. theZone.name .. " for testZoneFlag", 30)
end
return
end
if not latchName then
trigger.action.outText("+++Zne: no latchName for zone " .. theZone.name .. " for testZoneFlag", 30)
return
end
-- get current value
local currVal = cfxZones.getFlagValue(theFlagName, theZone)
-- get last value from latch
local lastVal = theZone[latchName]
if not lastVal then
trigger.action.outText("+++Zne: latch <" .. latchName .. "> not valid for zone " .. theZone.name, 30)
return
end
-- now, test by method
-- we should only test if currVal <> lastVal
if currVal == lastVal then
return false
end
--trigger.action.outText("+++Zne: about to test: c = " .. currVal .. ", l = " .. lastVal, 30)
local testResult = cfxZones.testFlagByMethodForZone(currVal, lastVal, theMethod, theZone)
-- update latch by method
theZone[latchName] = currVal
-- return result
return testResult
end
function cfxZones.flagArrayFromString(inString) function cfxZones.flagArrayFromString(inString)
-- original code from RND flag -- original code from RND flag
if string.len(inString) < 1 then if string.len(inString) < 1 then
@ -1500,8 +1645,13 @@ function cfxZones.getPoint(aZone) -- always works, even linked, point can be reu
thePos.x = aZone.point.x thePos.x = aZone.point.x
thePos.y = 0 -- aZone.y thePos.y = 0 -- aZone.y
thePos.z = aZone.point.z thePos.z = aZone.point.z
-- since we are at it, update the zone as well -- update the zone as well -- that's stupid!
aZone.point = thePos --[[-- aZone.point = thePos
local retPoint = {} -- create new copy to pass back
retPoint.x = thePos.x
retPoint.y = 0
retPoint.z = thePos.z
--]]--
return thePos return thePos
end end

View File

@ -1,5 +1,5 @@
cloneZones = {} cloneZones = {}
cloneZones.version = "1.3.1" cloneZones.version = "1.4.0"
cloneZones.verbose = false cloneZones.verbose = false
cloneZones.requiredLibs = { cloneZones.requiredLibs = {
"dcsCommon", -- always "dcsCommon", -- always
@ -36,6 +36,7 @@ cloneZones.uniqueCounter = 9200000 -- we start group numbering here
1.3.0 - DML flag upgrade 1.3.0 - DML flag upgrade
1.3.1 - groupTracker interface 1.3.1 - groupTracker interface
- trackWith: attribute - trackWith: attribute
1.4.0 - Watchflags
--]]-- --]]--
@ -184,6 +185,14 @@ function cloneZones.createClonerWithZone(theZone) -- has "Cloner"
end end
end end
-- watchflag:
-- triggerMethod
theZone.cloneTriggerMethod = cfxZones.getStringFromZoneProperty(theZone, "triggerMethod", "change")
if cfxZones.hasProperty(theZone, "cloneTriggerMethod") then
theZone.cloneTriggerMethod = cfxZones.getStringFromZoneProperty(theZone, "cloneTriggerMethod", "change")
end
-- f? and spawn? and other synonyms map to the same -- f? and spawn? and other synonyms map to the same
if cfxZones.hasProperty(theZone, "f?") then if cfxZones.hasProperty(theZone, "f?") then
theZone.spawnFlag = cfxZones.getStringFromZoneProperty(theZone, "f?", "none") theZone.spawnFlag = cfxZones.getStringFromZoneProperty(theZone, "f?", "none")
@ -870,6 +879,14 @@ function cloneZones.update()
end end
-- see if we got spawn? command -- see if we got spawn? command
if cfxZones.testZoneFlag(aZone, aZone.spawnFlag, aZone.cloneTriggerMethod, "lastSpawnValue") then
if cloneZones.verbose then
trigger.action.outText("+++clnZ: spawn triggered for <" .. aZone.name .. ">", 30)
end
cloneZones.spawnWithCloner(aZone)
end
-- old code
--[[--
if aZone.spawnFlag then if aZone.spawnFlag then
local currTriggerVal = cfxZones.getFlagValue(aZone.spawnFlag, aZone) -- trigger.misc.getUserFlag(aZone.spawnFlag) local currTriggerVal = cfxZones.getFlagValue(aZone.spawnFlag, aZone) -- trigger.misc.getUserFlag(aZone.spawnFlag)
if currTriggerVal ~= aZone.lastSpawnValue if currTriggerVal ~= aZone.lastSpawnValue
@ -881,6 +898,7 @@ function cloneZones.update()
aZone.lastSpawnValue = currTriggerVal aZone.lastSpawnValue = currTriggerVal
end end
end end
--]]--
-- empty handling -- empty handling
local isEmpty = cloneZones.countLiveUnits(aZone) < 1 and aZone.hasClones local isEmpty = cloneZones.countLiveUnits(aZone) < 1 and aZone.hasClones

View File

@ -1,5 +1,5 @@
countDown = {} countDown = {}
countDown.version = "1.2.0" countDown.version = "1.3.0"
countDown.verbose = true countDown.verbose = true
countDown.ups = 1 countDown.ups = 1
countDown.requiredLibs = { countDown.requiredLibs = {
@ -21,6 +21,9 @@ countDown.requiredLibs = {
- counterOut! - counterOut!
- ups config - ups config
1.2.1 - disableCounter? 1.2.1 - disableCounter?
1.3.0 - DML & Watchflags upgrade
- method --> ctdwnMethod
--]]-- --]]--
@ -85,8 +88,18 @@ function countDown.createCountDownWithZone(theZone)
-- extend after zero -- extend after zero
theZone.belowZero = cfxZones.getBoolFromZoneProperty(theZone, "belowZero", false) theZone.belowZero = cfxZones.getBoolFromZoneProperty(theZone, "belowZero", false)
-- method -- out method
theZone.method = cfxZones.getStringFromZoneProperty(theZone, "method", "flip") theZone.ctdwnMethod = cfxZones.getStringFromZoneProperty(theZone, "method", "flip")
if cfxZones.hasProperty(theZone, "ctdwnMethod") then
theZone.ctdwnMethod = cfxZones.getStringFromZoneProperty(theZone, "ctdwnMethod", "flip")
end
-- triggerMethod
theZone.ctdwnTriggerMethod = cfxZones.getStringFromZoneProperty(theZone, "triggerMethod", "change")
if cfxZones.hasProperty(theZone, "ctdwnTriggerMethod") then
theZone.ctdwnTriggerMethod = cfxZones.getStringFromZoneProperty(theZone, "ctdwnTriggerMethod", "change")
end
-- trigger flag "count" / "start?" -- trigger flag "count" / "start?"
if cfxZones.hasProperty(theZone, "count?") then if cfxZones.hasProperty(theZone, "count?") then
@ -155,7 +168,7 @@ function countDown.isTriggered(theZone)
if countDown.verbose then if countDown.verbose then
trigger.action.outText("+++cntD: TMINUTS", 30) trigger.action.outText("+++cntD: TMINUTS", 30)
end end
cfxZones.pollFlag(theZone.tMinusFlag, theZone.method, theZone) cfxZones.pollFlag(theZone.tMinusFlag, theZone.ctdwnMethod, theZone)
end end
elseif val == 0 then elseif val == 0 then
@ -165,7 +178,7 @@ function countDown.isTriggered(theZone)
if countDown.verbose then if countDown.verbose then
trigger.action.outText("+++cntD: ZERO", 30) trigger.action.outText("+++cntD: ZERO", 30)
end end
cfxZones.pollFlag(theZone.zeroFlag, theZone.method, theZone) cfxZones.pollFlag(theZone.zeroFlag, theZone.ctdwnMethod, theZone)
end end
if theZone.loop then if theZone.loop then
@ -184,7 +197,7 @@ function countDown.isTriggered(theZone)
if countDown.verbose then if countDown.verbose then
trigger.action.outText("+++cntD: Below Zero", 30) trigger.action.outText("+++cntD: Below Zero", 30)
end end
cfxZones.pollFlag(theZone.zeroFlag, theZone.method, theZone) cfxZones.pollFlag(theZone.zeroFlag, theZone.ctdwnMethod, theZone)
end end
end end
@ -203,6 +216,16 @@ function countDown.update()
for idx, aZone in pairs(countDown.counters) do for idx, aZone in pairs(countDown.counters) do
-- make sure to re-start before reading time limit -- make sure to re-start before reading time limit
if (not aZone.counterDisabled) and cfxZones.testZoneFlag(aZone, aZone.triggerCountFlag, aZone.ctdwnTriggerMethod, "lastCountTriggerValue")
then
if countDown.verbose then
trigger.action.outText("+++cntD: triggered on in?", 30)
end
countDown.isTriggered(aZone)
end
-- old colde
--[[--
if aZone.triggerCountFlag and not aZone.counterDisabled then if aZone.triggerCountFlag and not aZone.counterDisabled then
local currTriggerVal = cfxZones.getFlagValue(aZone.triggerCountFlag, aZone) -- trigger.misc.getUserFlag(aZone.triggerCountFlag) local currTriggerVal = cfxZones.getFlagValue(aZone.triggerCountFlag, aZone) -- trigger.misc.getUserFlag(aZone.triggerCountFlag)
if currTriggerVal ~= aZone.lastCountTriggerValue if currTriggerVal ~= aZone.lastCountTriggerValue
@ -214,7 +237,16 @@ function countDown.update()
aZone.lastCountTriggerValue = cfxZones.getFlagValue(aZone.triggerCountFlag, aZone) -- trigger.misc.getUserFlag(aZone.triggerCountFlag) -- save last value aZone.lastCountTriggerValue = cfxZones.getFlagValue(aZone.triggerCountFlag, aZone) -- trigger.misc.getUserFlag(aZone.triggerCountFlag) -- save last value
end end
end end
--]]--
if cfxZones.testZoneFlag(aZone, aZone.disableCounterFlag, aZone.ctdwnTriggerMethod, "disableCounterFlagVal") then
if countDown.verbose then
trigger.action.outText("+++cntD: disabling counter " .. aZone.name, 30)
end
aZone.counterDisabled = true
end
-- old code
--[[--
if aZone.disableCounterFlag then if aZone.disableCounterFlag then
local currVal = cfxZones.getFlagValue(aZone.disableCounterFlag, aZone) local currVal = cfxZones.getFlagValue(aZone.disableCounterFlag, aZone)
if currVal ~= aZone.disableCounterFlagVal then if currVal ~= aZone.disableCounterFlagVal then
@ -224,6 +256,7 @@ function countDown.update()
aZone.counterDisabled = true aZone.counterDisabled = true
end end
end end
--]]--
end end
end end

View File

@ -1,5 +1,5 @@
dcsCommon = {} dcsCommon = {}
dcsCommon.version = "2.5.6" dcsCommon.version = "2.5.7"
--[[-- VERSION HISTORY --[[-- VERSION HISTORY
2.2.6 - compassPositionOfARelativeToB 2.2.6 - compassPositionOfARelativeToB
- clockPositionOfARelativeToB - clockPositionOfARelativeToB
@ -66,6 +66,7 @@ dcsCommon.version = "2.5.6"
- stringStartsWithLetter() - stringStartsWithLetter()
- stringIsPositiveNumber() - stringIsPositiveNumber()
2.5.6 - corrected stringEndsWith() bug with str 2.5.6 - corrected stringEndsWith() bug with str
2.5.7 - point2text(p)
--]]-- --]]--
@ -1772,6 +1773,15 @@ dcsCommon.version = "2.5.6"
return "no" return "no"
end end
function dcsCommon.point2text(p)
if not p then return "<!NIL!>" end
local t = "[x="
if p.x then t = t .. p.x .. ", " else t = t .. "<nil>, " end
if p.y then t = t .. p.y .. ", " else t = t .. "<nil>, " end
if p.z then t = t .. p.z .. "]" else t = t .. "<nil>]" end
return t
end
-- recursively show the contents of a variable -- recursively show the contents of a variable
function dcsCommon.dumpVar(key, value, prefix, inrecursion) function dcsCommon.dumpVar(key, value, prefix, inrecursion)
if not inrecursion then if not inrecursion then

View File

@ -1,5 +1,5 @@
delayFlag = {} delayFlag = {}
delayFlag.version = "1.1.0" delayFlag.version = "1.2.0"
delayFlag.verbose = false delayFlag.verbose = false
delayFlag.requiredLibs = { delayFlag.requiredLibs = {
"dcsCommon", -- always "dcsCommon", -- always
@ -28,6 +28,7 @@ delayFlag.flags = {}
- delayDone! synonym - delayDone! synonym
- pauseDelay? - pauseDelay?
- unpauseDelay? - unpauseDelay?
1.2.0 - Watchflags
--]]-- --]]--
@ -58,7 +59,14 @@ function delayFlag.createTimerWithZone(theZone)
if delayFlag.verbose then if delayFlag.verbose then
trigger.action.outText("+++dlyF: time delay is <" .. theZone.delayMin .. ", " .. theZone.delayMax .. "> seconds", 30) trigger.action.outText("+++dlyF: time delay is <" .. theZone.delayMin .. ", " .. theZone.delayMax .. "> seconds", 30)
end end
-- watchflags:
-- triggerMethod
theZone.delayTriggerMethod = cfxZones.getStringFromZoneProperty(theZone, "triggerMethod", "change")
if cfxZones.hasProperty(theZone, "delayTriggerMethod") then
theZone.delayTriggerMethod = cfxZones.getStringFromZoneProperty(theZone, "delayTriggerMethod", "change")
end
-- trigger flag -- trigger flag
if cfxZones.hasProperty(theZone, "f?") then if cfxZones.hasProperty(theZone, "f?") then
@ -142,6 +150,14 @@ function delayFlag.update()
for idx, aZone in pairs(delayFlag.flags) do for idx, aZone in pairs(delayFlag.flags) do
-- see if we need to stop -- see if we need to stop
if cfxZones.testZoneFlag(aZone, aZone.triggerStopDelay, aZone.delayTriggerMethod, "lastTriggerStopValue") then
aZone.delayRunning = false -- simply stop.
if delayFlag.verbose then
trigger.action.outText("+++dlyF: stopped delay " .. aZone.name, 30)
end
end
-- old code
--[[--
if aZone.triggerStopDelay then if aZone.triggerStopDelay then
local currTriggerVal = cfxZones.getFlagValue(aZone.triggerStopDelay, aZone) local currTriggerVal = cfxZones.getFlagValue(aZone.triggerStopDelay, aZone)
if currTriggerVal ~= lastTriggerStopValue then if currTriggerVal ~= lastTriggerStopValue then
@ -151,7 +167,20 @@ function delayFlag.update()
end end
end end
end end
--]]--
if cfxZones.testZoneFlag(aZone, aZone.triggerDelayFlag, aZone.delayTriggerMethod, "lastDelayTriggerValue") then
if delayFlag.verbose then
if aZone.delayRunning then
trigger.action.outText("+++dlyF: re-starting timer " .. aZone.name, 30)
else
trigger.action.outText("+++dlyF: init timer for " .. aZone.name, 30)
end
end
delayFlag.startDelay(aZone) -- we restart even if running
end
-- old code
--[[--
-- make sure to re-start before reading time limit -- make sure to re-start before reading time limit
if aZone.triggerDelayFlag then if aZone.triggerDelayFlag then
local currTriggerVal = cfxZones.getFlagValue(aZone.triggerDelayFlag, aZone) -- trigger.misc.getUserFlag(aZone.triggerDelayFlag) local currTriggerVal = cfxZones.getFlagValue(aZone.triggerDelayFlag, aZone) -- trigger.misc.getUserFlag(aZone.triggerDelayFlag)
@ -168,6 +197,7 @@ function delayFlag.update()
aZone.lastDelayTriggerValue = currTriggerVal aZone.lastDelayTriggerValue = currTriggerVal
end end
end end
--]]--
if aZone.delayRunning then if aZone.delayRunning then
-- check expiry -- check expiry

View File

@ -1,5 +1,5 @@
messenger = {} messenger = {}
messenger.version = "1.1.1" messenger.version = "1.2.0"
messenger.verbose = false messenger.verbose = false
messenger.requiredLibs = { messenger.requiredLibs = {
"dcsCommon", -- always "dcsCommon", -- always
@ -18,6 +18,8 @@ messenger.messengers = {}
1.1.1 - firewalled coalition to msgCoalition 1.1.1 - firewalled coalition to msgCoalition
- messageOn? - messageOn?
- messageOff? - messageOff?
1.2.0 - triggerMethod (original Watchflag integration)
--]]-- --]]--
function messenger.addMessenger(theZone) function messenger.addMessenger(theZone)
@ -53,6 +55,9 @@ function messenger.createMessengerWithZone(theZone)
theZone.duration = cfxZones.getNumberFromZoneProperty(theZone, "duration", 30) theZone.duration = cfxZones.getNumberFromZoneProperty(theZone, "duration", 30)
-- triggerMethod
theZone.triggerMethod = cfxZones.getStringFromZoneProperty(theZone, "triggerMethod", "change")
-- trigger flag f? in? messageOut? -- trigger flag f? in? messageOut?
if cfxZones.hasProperty(theZone, "f?") then if cfxZones.hasProperty(theZone, "f?") then
theZone.triggerMessagerFlag = cfxZones.getStringFromZoneProperty(theZone, "f?", "none") theZone.triggerMessagerFlag = cfxZones.getStringFromZoneProperty(theZone, "f?", "none")
@ -157,37 +162,26 @@ function messenger.update()
for idx, aZone in pairs(messenger.messengers) do for idx, aZone in pairs(messenger.messengers) do
-- make sure to re-start before reading time limit -- make sure to re-start before reading time limit
if aZone.triggerMessagerFlag then -- new trigger code
local currTriggerVal = cfxZones.getFlagValue(aZone.triggerMessagerFlag, aZone) -- trigger.misc.getUserFlag(aZone.triggerMessagerFlag) if cfxZones.testZoneFlag(aZone, aZone.triggerMessagerFlag, aZone.triggerMethod, "lastMessageTriggerValue") then
if currTriggerVal ~= aZone.lastMessageTriggerValue if messenger.verbose then
then
if messenger.verbose then
trigger.action.outText("+++msgr: triggered on in? for <".. aZone.name ..">", 30) trigger.action.outText("+++msgr: triggered on in? for <".. aZone.name ..">", 30)
end end
messenger.isTriggered(aZone) messenger.isTriggered(aZone)
aZone.lastMessageTriggerValue = cfxZones.getFlagValue(aZone.triggerMessagerFlag, aZone) -- trigger.misc.getUserFlag(aZone.triggerMessagerFlag) -- save last value end
end
-- old trigger code
if cfxZones.testZoneFlag(aZone, aZone.messageOffFlag, "change", "lastMessageOff") then
aZone.messageOff = true
if messenger.verbose then
trigger.action.outText("+++msg: messenger <" .. aZone.name .. "> turned ***OFF***", 30)
end
end end
if aZone.messageOffFlag then if cfxZones.testZoneFlag(aZone, aZone.messageOnFlag, "change", "lastMessageOn") then
local currVal = cfxZones.getFlagValue(aZone.messageOffFlag, aZone) aZone.messageOff = false
if currVal ~= aZone.lastMessageOff then if messenger.verbose then
aZone.messageOff = true trigger.action.outText("+++msg: messenger <" .. aZone.name .. "> turned ON", 30)
aZone.lastMessageOff = currVal
if messenger.verbose then
trigger.action.outText("+++msg: messenger <" .. aZone.name .. "> turned ***OFF***", 30)
end
end
end
if aZone.messageOnFlag then
local currVal = cfxZones.getFlagValue(aZone.messageOnFlag, aZone)
if currVal ~= aZone.lastMessageOn then
aZone.messageOff = false
aZone.lastMessageOn = currVal
if messenger.verbose then
trigger.action.outText("+++msg: messenger <" .. aZone.name .. "> turned ON", 30)
end
end end
end end
end end

View File

@ -1,5 +1,5 @@
pulseFlags = {} pulseFlags = {}
pulseFlags.version = "1.1.0" pulseFlags.version = "1.2.0"
pulseFlags.verbose = false pulseFlags.verbose = false
pulseFlags.requiredLibs = { pulseFlags.requiredLibs = {
"dcsCommon", -- always "dcsCommon", -- always
@ -27,6 +27,8 @@ pulseFlags.requiredLibs = {
pulseMethod synonym pulseMethod synonym
startPulse? synonym startPulse? synonym
pulseStopped synonym pulseStopped synonym
- 1.2.0 DML Watchflag integration
corrected bug in loading last pulse value for paused
--]]-- --]]--
@ -57,7 +59,15 @@ function pulseFlags.createPulseWithZone(theZone)
theZone.pulses = cfxZones.getNumberFromZoneProperty(theZone, "pulses", -1) theZone.pulses = cfxZones.getNumberFromZoneProperty(theZone, "pulses", -1)
theZone.pulsesLeft = 0 -- will start new cycle theZone.pulsesLeft = 0 -- will start new cycle
-- watchflag:
-- triggerMethod
theZone.pulseTriggerMethod = cfxZones.getStringFromZoneProperty(theZone, "triggerMethod", "change")
if cfxZones.hasProperty(theZone, "pulseTriggerMethod") then
theZone.pulseTriggerMethod = cfxZones.getStringFromZoneProperty(theZone, "pulseTriggerMethod", "change")
end
-- trigger flags -- trigger flags
if cfxZones.hasProperty(theZone, "activate?") then if cfxZones.hasProperty(theZone, "activate?") then
theZone.activatePulseFlag = cfxZones.getStringFromZoneProperty(theZone, "activate?", "none") theZone.activatePulseFlag = cfxZones.getStringFromZoneProperty(theZone, "activate?", "none")
@ -71,12 +81,12 @@ function pulseFlags.createPulseWithZone(theZone)
if cfxZones.hasProperty(theZone, "pause?") then if cfxZones.hasProperty(theZone, "pause?") then
theZone.pausePulseFlag = cfxZones.getStringFromZoneProperty(theZone, "pause?", "*none") theZone.pausePulseFlag = cfxZones.getStringFromZoneProperty(theZone, "pause?", "*none")
theZone.lastPauseValue = cfxZones.getFlagValue(theZone.lastPauseValue, theZone)-- trigger.misc.getUserFlag(theZone.pausePulseFlag) -- save last value theZone.lastPauseValue = cfxZones.getFlagValue(theZone.pausePulseFlag, theZone)-- trigger.misc.getUserFlag(theZone.pausePulseFlag) -- save last value
end end
if cfxZones.hasProperty(theZone, "pausePulse?") then if cfxZones.hasProperty(theZone, "pausePulse?") then
theZone.pausePulseFlag = cfxZones.getStringFromZoneProperty(theZone, "pausePulse?", "*none") theZone.pausePulseFlag = cfxZones.getStringFromZoneProperty(theZone, "pausePulse?", "*none")
theZone.lastPauseValue = cfxZones.getFlagValue(theZone.lastPauseValue, theZone)-- trigger.misc.getUserFlag(theZone.pausePulseFlag) -- save last value theZone.lastPauseValue = cfxZones.getFlagValue(theZone.pausePulseFlag, theZone)-- trigger.misc.getUserFlag(theZone.pausePulseFlag) -- save last value
end end
theZone.pulsePaused = cfxZones.getBoolFromZoneProperty(theZone, "paused", false) theZone.pulsePaused = cfxZones.getBoolFromZoneProperty(theZone, "paused", false)
@ -85,10 +95,10 @@ function pulseFlags.createPulseWithZone(theZone)
theZone.pulsePaused = cfxZones.getBoolFromZoneProperty(theZone, "pulseStopped", false) theZone.pulsePaused = cfxZones.getBoolFromZoneProperty(theZone, "pulseStopped", false)
end end
theZone.method = cfxZones.getStringFromZoneProperty(theZone, "method", "flip") theZone.pulseMethod = cfxZones.getStringFromZoneProperty(theZone, "method", "flip")
if cfxZones.hasProperty(theZone, "pulseMethod") then if cfxZones.hasProperty(theZone, "pulseMethod") then
theZone.method = cfxZones.getStringFromZoneProperty(theZone, "pulseMethod", "flip") theZone.pulseMethod = cfxZones.getStringFromZoneProperty(theZone, "pulseMethod", "flip")
end end
-- done flag -- done flag
if cfxZones.hasProperty(theZone, "done+1") then if cfxZones.hasProperty(theZone, "done+1") then
@ -127,7 +137,7 @@ function pulseFlags.doPulse(args)
trigger.action.outText("+++pulF: will bang " .. theZone.pulseFlag, 30); trigger.action.outText("+++pulF: will bang " .. theZone.pulseFlag, 30);
end end
cfxZones.pollFlag(theZone.pulseFlag, theZone.method, theZone) cfxZones.pollFlag(theZone.pulseFlag, theZone.pulseMethod, theZone)
-- decrease count -- decrease count
if theZone.pulses > 0 then if theZone.pulses > 0 then
@ -202,6 +212,15 @@ function pulseFlags.update()
end end
-- see if we got a pause or activate command -- see if we got a pause or activate command
-- activatePulseFlag
if cfxZones.testZoneFlag(aZone, aZone.activatePulseFlag, aZone.pulseTriggerMethod, "lastActivateValue") then
if pulseFlags.verbose then
trigger.action.outText("+++PulF: activating <" .. aZone.name .. ">", 30)
end
aZone.pulsePaused = false -- will start anew
end
--[[-- -- old code
if aZone.activatePulseFlag then if aZone.activatePulseFlag then
local currTriggerVal = cfxZones.getFlagValue(aZone.activatePulseFlag, aZone) -- trigger.misc.getUserFlag(aZone.activatePulseFlag) local currTriggerVal = cfxZones.getFlagValue(aZone.activatePulseFlag, aZone) -- trigger.misc.getUserFlag(aZone.activatePulseFlag)
if currTriggerVal ~= aZone.lastActivateValue if currTriggerVal ~= aZone.lastActivateValue
@ -214,7 +233,20 @@ function pulseFlags.update()
end end
end end
--]]--
-- pausePulseFlag
if cfxZones.testZoneFlag(aZone, aZone.pausePulseFlag, aZone.pulseTriggerMethod, "lastPauseValue") then
if pulseFlags.verbose then
trigger.action.outText("+++PulF: pausing <" .. aZone.name .. ">", 30)
end
aZone.pulsePaused = true -- prevents new start
if aZone.timerID then
timer.removeFunction(aZone.timerID)
aZone.timerID = nil
end
end
--[[--
-- old colde
if aZone.pausePulseFlag then if aZone.pausePulseFlag then
local currTriggerVal = cfxZones.getFlagValue(aZone.pausePulseFlag, aZone)-- trigger.misc.getUserFlag(aZone.pausePulseFlag) local currTriggerVal = cfxZones.getFlagValue(aZone.pausePulseFlag, aZone)-- trigger.misc.getUserFlag(aZone.pausePulseFlag)
if currTriggerVal ~= aZone.lastPauseValue if currTriggerVal ~= aZone.lastPauseValue
@ -230,6 +262,7 @@ function pulseFlags.update()
end end
end end
end end
--]]--
end end
end end

View File

@ -1,5 +1,5 @@
raiseFlag = {} raiseFlag = {}
raiseFlag.version = "1.0.1" raiseFlag.version = "1.2.0"
raiseFlag.verbose = false raiseFlag.verbose = false
raiseFlag.requiredLibs = { raiseFlag.requiredLibs = {
"dcsCommon", -- always "dcsCommon", -- always
@ -12,6 +12,8 @@ raiseFlag.flags = {}
Version History Version History
1.0.0 - initial release 1.0.0 - initial release
1.0.1 - synonym "raiseFlag!" 1.0.1 - synonym "raiseFlag!"
1.1.0 - DML update
1.2.0 - Watchflag update
--]]-- --]]--
function raiseFlag.addRaiseFlag(theZone) function raiseFlag.addRaiseFlag(theZone)
@ -44,6 +46,14 @@ function raiseFlag.createRaiseFlagWithZone(theZone)
theZone.minAfterTime, theZone.maxAfterTime = cfxZones.getPositiveRangeFromZoneProperty(theZone, "afterTime", -1) theZone.minAfterTime, theZone.maxAfterTime = cfxZones.getPositiveRangeFromZoneProperty(theZone, "afterTime", -1)
-- method for triggering
-- watchflag:
-- triggerMethod
theZone.raiseTriggerMethod = cfxZones.getStringFromZoneProperty(theZone, "triggerMethod", "change")
if cfxZones.hasProperty(theZone, "raiseTriggerMethod") then
theZone.raiseTriggerMethod = cfxZones.getStringFromZoneProperty(theZone, "raiseTriggerMethod", "change")
end
if cfxZones.hasProperty(theZone, "stopFlag?") then if cfxZones.hasProperty(theZone, "stopFlag?") then
theZone.triggerStopFlag = cfxZones.getStringFromZoneProperty(theZone, "stopFlag?", "none") theZone.triggerStopFlag = cfxZones.getStringFromZoneProperty(theZone, "stopFlag?", "none")
theZone.lastTriggerStopValue = cfxZones.getFlagValue(theZone.triggerStopFlag, theZone) -- save last value theZone.lastTriggerStopValue = cfxZones.getFlagValue(theZone.triggerStopFlag, theZone) -- save last value
@ -79,6 +89,12 @@ function raiseFlag.update()
for idx, aZone in pairs(raiseFlag.flags) do for idx, aZone in pairs(raiseFlag.flags) do
-- make sure to re-start before reading time limit -- make sure to re-start before reading time limit
if cfxZones.testZoneFlag(aZone, aZone.triggerStopFlag, aZone.raiseTriggerMethod, "lastTriggerStopValue") then
theZone.raiseStopped = true -- we are done, no flag!
end
-- old code
--[[--
if aZone.triggerStopFlag then if aZone.triggerStopFlag then
local currTriggerVal = cfxZones.getFlagValue(aZone.triggerStopFlag, theZone) local currTriggerVal = cfxZones.getFlagValue(aZone.triggerStopFlag, theZone)
if currTriggerVal ~= aZone.lastTriggerStopValue if currTriggerVal ~= aZone.lastTriggerStopValue
@ -86,6 +102,7 @@ function raiseFlag.update()
theZone.raiseStopped = true -- we are done, no flag! theZone.raiseStopped = true -- we are done, no flag!
end end
end end
--]]--
end end
end end

View File

@ -1,5 +1,5 @@
xFlags = {} xFlags = {}
xFlags.version = "1.0.0" xFlags.version = "1.0.1"
xFlags.verbose = false xFlags.verbose = false
xFlags.ups = 1 -- overwritten in get config! xFlags.ups = 1 -- overwritten in get config!
xFlags.requiredLibs = { xFlags.requiredLibs = {
@ -11,6 +11,8 @@ xFlags.requiredLibs = {
Version History Version History
1.0.0 - Initial version 1.0.0 - Initial version
1.0.1 - allow flags names for ops as well
modelled on cfxZones.testFlagByMethodForZone()
--]]-- --]]--
xFlags.xFlagZones = {} xFlags.xFlagZones = {}
@ -99,7 +101,6 @@ function xFlags.evaluateFlags(theZone)
-- we must preserve the order of the array -- we must preserve the order of the array
local flagName = theZone.flagNames[i] local flagName = theZone.flagNames[i]
currVals[i] = cfxZones.getFlagValue(flagName, theZone) currVals[i] = cfxZones.getFlagValue(flagName, theZone)
end end
-- now perform comparison flag by flag -- now perform comparison flag by flag
@ -109,6 +110,11 @@ function xFlags.evaluateFlags(theZone)
local firstChar = string.sub(op, 1, 1) local firstChar = string.sub(op, 1, 1)
local remainder = string.sub(op, 2) local remainder = string.sub(op, 2)
local rNum = tonumber(remainder) local rNum = tonumber(remainder)
if not rNum then
-- interpret remainder as flag name
-- so we can say >*killMax
rNum = cfxZones.getFlagValue(remainder, theZone)
end
for i = 1, #theZone.flagNames do for i = 1, #theZone.flagNames do
local lastHits = hits local lastHits = hits

Binary file not shown.