Version 1.03

The Debugger
This commit is contained in:
Christian Franz 2022-07-14 08:09:21 +02:00
parent cb3cd4ccd2
commit 780797aba3
13 changed files with 1467 additions and 44 deletions

Binary file not shown.

Binary file not shown.

View File

@ -1,5 +1,5 @@
rndFlags = {} rndFlags = {}
rndFlags.version = "1.3.0" rndFlags.version = "1.3.1"
rndFlags.verbose = false rndFlags.verbose = false
rndFlags.requiredLibs = { rndFlags.requiredLibs = {
"dcsCommon", -- always "dcsCommon", -- always
@ -25,6 +25,10 @@ rndFlags.requiredLibs = {
1.2.0 - Watchflag integration 1.2.0 - Watchflag integration
1.3.0 - DML simplification: RND! 1.3.0 - DML simplification: RND!
zone-local verbosity zone-local verbosity
1.3.1 - 'done+1' --> 'done!', using rndMethod instead of 'inc'
- added zonal verbosity
- added 'rndDone!' flag
- rndMethod defaults to "inc"
--]] --]]
rndFlags.rndGen = {} rndFlags.rndGen = {}
@ -147,12 +151,15 @@ function rndFlags.createRNDWithZone(theZone)
theZone.onStart = cfxZones.getBoolFromZoneProperty(theZone, "onStart", false) theZone.onStart = cfxZones.getBoolFromZoneProperty(theZone, "onStart", false)
if not theZone.onStart and not theZone.triggerFlag then if not theZone.onStart and not theZone.triggerFlag then
theZone.onStart = true -- theZone.onStart = true
if true or theZone.verbose or rndFlags.verbose then
trigger.action.outText("+++RND - WARNING: no triggers and no onStart, RND in <" .. theZone.name .. "> can't be triggered.", 30)
end
end end
theZone.rndMethod = cfxZones.getStringFromZoneProperty(theZone, "method", "on") theZone.rndMethod = cfxZones.getStringFromZoneProperty(theZone, "method", "inc")
if cfxZones.hasProperty(theZone, "rndMethod") then if cfxZones.hasProperty(theZone, "rndMethod") then
theZone.rndMethod = cfxZones.getStringFromZoneProperty(theZone, "rndMethod", "on") theZone.rndMethod = cfxZones.getStringFromZoneProperty(theZone, "rndMethod", "inc")
end end
theZone.reshuffle = cfxZones.getBoolFromZoneProperty(theZone, "reshuffle", false) theZone.reshuffle = cfxZones.getBoolFromZoneProperty(theZone, "reshuffle", false)
@ -161,10 +168,17 @@ function rndFlags.createRNDWithZone(theZone)
theZone.flagStore = dcsCommon.copyArray(theFlags) theZone.flagStore = dcsCommon.copyArray(theFlags)
end end
-- done flag -- done flag OLD, to be deprecated
if cfxZones.hasProperty(theZone, "done+1") then if cfxZones.hasProperty(theZone, "done+1") then
theZone.doneFlag = cfxZones.getStringFromZoneProperty(theZone, "done+1", "none") theZone.doneFlag = cfxZones.getStringFromZoneProperty(theZone, "done+1", "<none>")
-- now NEW replacements
elseif cfxZones.hasProperty(theZone, "done!") then
theZone.doneFlag = cfxZones.getStringFromZoneProperty(theZone, "done!", "<none>")
elseif cfxZones.hasProperty(theZone, "rndDone!") then
theZone.doneFlag = cfxZones.getStringFromZoneProperty(theZone, "rndDone!", "<none>")
end end
end end
function rndFlags.reshuffle(theZone) function rndFlags.reshuffle(theZone)
@ -197,7 +211,7 @@ function rndFlags.fire(theZone)
end end
if theZone.doneFlag then if theZone.doneFlag then
cfxZones.pollFlag(theZone.doneFlag, "inc", theZone) cfxZones.pollFlag(theZone.doneFlag, theZone.rndMethod, theZone)
end end
return return
@ -262,7 +276,7 @@ end
function rndFlags.startCycle() function rndFlags.startCycle()
for idx, theZone in pairs(rndFlags.rndGen) do for idx, theZone in pairs(rndFlags.rndGen) do
if theZone.onStart then if theZone.onStart then
if rndFlags.verbose then if rndFlags.verbose or theZone.verbose then
trigger.action.outText("+++RND: starting " .. theZone.name, 30) trigger.action.outText("+++RND: starting " .. theZone.name, 30)
end end
rndFlags.fire(theZone) rndFlags.fire(theZone)

View File

@ -1,16 +1,20 @@
baseCaptured={} baseCaptured={}
baseCaptured.version = "1.0.0" baseCaptured.version = "1.0.1"
baseCaptured.verbose = false baseCaptured.verbose = false
baseCaptured.ups = 1
baseCaptured.requiredLibs = { baseCaptured.requiredLibs = {
"dcsCommon", -- always "dcsCommon", -- always
"cfxZones", -- Zones, of course "cfxZones", -- Zones, of course
} }
baseCaptured.handleContested = true --
--[[-- --[[--
baseCaptured - Detects when the assigned base has been captured, idea and first implementation by cloose baseCaptured - Detects when the assigned base has been captured, idea and first implementation by cloose
Version History Version History
1.0.0 - Initial version based on cloose's code 1.0.0 - Initial version based on cloose's code
1.0.1 - contested! flag
- update and handleContested
--]]-- --]]--
@ -50,6 +54,10 @@ function baseCaptured.createZone(theZone)
theZone.redCap = cfxZones.getStringFromZoneProperty(theZone, "red!", "*none") theZone.redCap = cfxZones.getStringFromZoneProperty(theZone, "red!", "*none")
end end
if cfxZones.hasProperty(theZone, "contested!") then
theZone.contested = cfxZones.getStringFromZoneProperty(theZone, "contested!", "*none")
end
if cfxZones.hasProperty(theZone, "baseOwner") then if cfxZones.hasProperty(theZone, "baseOwner") then
theZone.baseOwner = cfxZones.getStringFromZoneProperty(theZone, "baseOwner", "*none") theZone.baseOwner = cfxZones.getStringFromZoneProperty(theZone, "baseOwner", "*none")
cfxZones.setFlagValueMult(theZone.baseOwner, theZone.currentOwner, theZone) cfxZones.setFlagValueMult(theZone.baseOwner, theZone.currentOwner, theZone)
@ -79,7 +87,10 @@ function baseCaptured.triggerZone(theZone)
cfxZones.pollFlag(theZone.blueCap, theZone.capturedMethod, theZone) cfxZones.pollFlag(theZone.blueCap, theZone.capturedMethod, theZone)
end end
else else
-- possibly a new side? Neutral doesn't cap -- contested
if theZone.contested then
cfxZones.pollFlag(theZone.contested, theZone.capturedMethod, theZone)
end
end end
if baseCaptured.verbose or theZone.verbose then if baseCaptured.verbose or theZone.verbose then
@ -118,6 +129,31 @@ function baseCaptured:onEvent(event)
end end
end end
function baseCaptured.update()
-- call me in a second to poll triggers
timer.scheduleFunction(baseCaptured.update, {}, timer.getTime() + 1/baseCaptured.ups)
-- look for contested event - it's not covered with capture event!
for idx, aZone in pairs(baseCaptured.zones) do
local newOwner = aZone.theBase:getCoalition()
if (newOwner ~= aZone.currentOwner) and (newOwner == 3) then
if aZone.contested then
cfxZones.pollFlag(aZone.contested, aZone.capturedMethod, aZone)
end
aZone.currentOwner = newOwner
if aZone.verbose or baseCaptured.verbose then
trigger.action.outText("+++bCap: zone <" .. aZone.name .. "> has become contested!", 30)
end
if aZone.baseOwner then
cfxZones.setFlagValueMult(aZone.baseOwner, newOwner, aZone)
end
end
end
end
function baseCaptured.readConfigZone() function baseCaptured.readConfigZone()
-- search for configuration zone -- search for configuration zone
local theZone = cfxZones.getZoneByName("baseCapturedConfig") local theZone = cfxZones.getZoneByName("baseCapturedConfig")
@ -127,6 +163,8 @@ function baseCaptured.readConfigZone()
baseCaptured.verbose = cfxZones.getBoolFromZoneProperty(theZone, "verbose", false) baseCaptured.verbose = cfxZones.getBoolFromZoneProperty(theZone, "verbose", false)
baseCaptured.handleContested = cfxZones.getBoolFromZoneProperty(theZone, "handleContested", true)
if baseCaptured.verbose then if baseCaptured.verbose then
trigger.action.outText("+++bCap: read configuration from zone", 30) trigger.action.outText("+++bCap: read configuration from zone", 30)
end end
@ -155,6 +193,11 @@ function baseCaptured.start()
-- listen for events -- listen for events
world.addEventHandler(baseCaptured) world.addEventHandler(baseCaptured)
-- start update to look for contested
if baseCaptured.handleContested then
baseCaptured.update()
end
trigger.action.outText("baseCaptured v" .. baseCaptured.version .. " started.", 30) trigger.action.outText("baseCaptured v" .. baseCaptured.version .. " started.", 30)
return true return true
end end

View File

@ -1,11 +1,13 @@
cfxZones = {}
cfxZones.version = "2.8.3"
-- cf/x zone management module -- cf/x zone management module
-- reads dcs zones and makes them accessible and mutable -- reads dcs zones and makes them accessible and mutable
-- by scripting. -- by scripting.
-- --
-- Copyright (c) 2021, 2022 by Christian Franz and cf/x AG -- Copyright (c) 2021, 2022 by Christian Franz and cf/x AG
-- --
cfxZones = {}
cfxZones.version = "2.8.1"
--[[-- VERSION HISTORY --[[-- VERSION HISTORY
- 2.2.4 - getCoalitionFromZoneProperty - 2.2.4 - getCoalitionFromZoneProperty
- getStringFromZoneProperty - getStringFromZoneProperty
@ -82,6 +84,10 @@ cfxZones.version = "2.8.1"
- setFlagValue QoL for <none> - setFlagValue QoL for <none>
- 2.8.0 - new allGroupNamesInZone() - 2.8.0 - new allGroupNamesInZone()
- 2.8.1 - new zonesLinkedToUnit() - 2.8.1 - new zonesLinkedToUnit()
- 2.8.2 - flagArrayFromString trims elements before range check
- 2.8.3 - new verifyMethod()
- changed extractPropertyFromDCS() to also match attributes with blanks like "the Attr" to "theAttr"
- new expandFlagName()
--]]-- --]]--
cfxZones.verbose = false cfxZones.verbose = false
@ -1222,6 +1228,32 @@ function cfxZones.pollFlag(theFlag, method, theZone)
end end
function cfxZones.expandFlagName(theFlag, theZone)
if not theFlag then return "!NIL" end
local zoneName = "<dummy>"
if theZone then
zoneName = theZone.name -- for flag wildcards
end
if type(theFlag) == "number" then
-- straight number, return
return theFlag
end
-- we assume it's a string now
theFlag = dcsCommon.trim(theFlag) -- clear leading/trailing spaces
local nFlag = tonumber(theFlag)
if nFlag then -- a number, legal
return theFlag
end
-- now do wildcard processing. we have alphanumeric
if dcsCommon.stringStartsWith(theFlag, "*") then
theFlag = zoneName .. theFlag
end
return theFlag
end
function cfxZones.setFlagValueMult(theFlag, theValue, theZone) function cfxZones.setFlagValueMult(theFlag, theValue, theZone)
local allFlags = {} local allFlags = {}
if dcsCommon.containsString(theFlag, ",") then if dcsCommon.containsString(theFlag, ",") then
@ -1297,7 +1329,7 @@ function cfxZones.getFlagValue(theFlag, theZone)
-- some QoL: detect "<none>" -- some QoL: detect "<none>"
if dcsCommon.containsString(theFlag, "<none>") then if dcsCommon.containsString(theFlag, "<none>") then
trigger.action.outText("+++Zone: warning - getFlag has '<none>' flag name in zone <" .. zoneName .. ">", 30) trigger.action.outText("+++Zone: warning - getFlag has '<none>' flag name in zone <" .. zoneName .. ">", 30) -- break here
end end
-- now do wildcard processing. we have alphanumeric -- now do wildcard processing. we have alphanumeric
@ -1316,6 +1348,68 @@ function cfxZones.isMEFlag(inFlag)
-- return dcsCommon.stringIsPositiveNumber(inFlag) -- return dcsCommon.stringIsPositiveNumber(inFlag)
end end
function cfxZones.verifyMethod(theMethod, theZone)
local lMethod = string.lower(theMethod)
if lMethod == "#" or lMethod == "change" then
return true
end
if lMethod == "0" or lMethod == "no" or lMethod == "false"
or lMethod == "off" then
return true
end
if lMethod == "1" or lMethod == "yes" or lMethod == "true"
or lMethod == "on" then
return true
end
if lMethod == "inc" or lMethod == "+1" then
return true
end
if lMethod == "dec" or lMethod == "-1" then
return true
end
if lMethod == "lohi" or lMethod == "pulse" then
return true
end
if lMethod == "hilo" then
return true
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 true then
-- we have a comparison = ">", "=", "<" followed by a number
-- THEY TRIGGER EACH TIME lastVal <> currVal AND condition IS MET
if op == "=" then
return true
end
if op == "#" or op == "~" then
return true
end
if op == "<" then
return true
end
if op == ">" then
return true
end
end
return false
end
-- method-based flag testing -- method-based flag testing
function cfxZones.evalFlagMethodImmediate(currVal, theMethod, theZone) function cfxZones.evalFlagMethodImmediate(currVal, theMethod, theZone)
-- immediate eval - does not look at last val. -- immediate eval - does not look at last val.
@ -1569,7 +1663,8 @@ function cfxZones.flagArrayFromString(inString)
local rawElements = dcsCommon.splitString(inString, ",") local rawElements = dcsCommon.splitString(inString, ",")
-- go over all elements -- go over all elements
for idx, anElement in pairs(rawElements) do for idx, anElement in pairs(rawElements) do
if dcsCommon.stringStartsWithDigit(anElement) and dcsCommon.containsString(anElement, "-") then anElement = dcsCommon.trim(anElement)
if dcsCommon.stringStartsWithDigit(anElement) and dcsCommon.containsString(anElement, "-") then
-- interpret this as a range -- interpret this as a range
local theRange = dcsCommon.splitString(anElement, "-") local theRange = dcsCommon.splitString(anElement, "-")
local lowerBound = theRange[1] local lowerBound = theRange[1]
@ -1649,6 +1744,12 @@ function cfxZones.extractPropertyFromDCS(theKey, theProperties)
if existingKey == theKey then if existingKey == theKey then
return theP.value return theP.value
end end
-- now check after removing all blanks
existingKey = dcsCommon.removeBlanks(existingKey)
if existingKey == theKey then
return theP.value
end
end end
return nil return nil
end end

View File

@ -1,5 +1,5 @@
changer = {} changer = {}
changer.version = "1.0.1" changer.version = "1.0.2"
changer.verbose = false changer.verbose = false
changer.ups = 1 changer.ups = 1
changer.requiredLibs = { changer.requiredLibs = {
@ -11,6 +11,7 @@ changer.changers = {}
Version History Version History
1.0.0 - Initial version 1.0.0 - Initial version
1.0.1 - Better guards in config to avoid <none> Zone getter warning 1.0.1 - Better guards in config to avoid <none> Zone getter warning
1.0.2 - on/off: verbosity
Transmogrify an incoming signal to an output signal Transmogrify an incoming signal to an output signal
- not - not
@ -210,6 +211,10 @@ function changer.update()
if aZone.changerOnOff then if aZone.changerOnOff then
if cfxZones.getFlagValue(aZone.changerOnOff, aZone) > 0 then if cfxZones.getFlagValue(aZone.changerOnOff, aZone) > 0 then
changer.process(aZone) changer.process(aZone)
else
if changer.verbose or aZone.verbose then
trigger.action.outText("+++chgr: " .. aZone.name .. " gate closed.", 30)
end
end end
else else
changer.process(aZone) changer.process(aZone)

View File

@ -1,5 +1,5 @@
dcsCommon = {} dcsCommon = {}
dcsCommon.version = "2.6.5" dcsCommon.version = "2.6.6"
--[[-- VERSION HISTORY --[[-- VERSION HISTORY
2.2.6 - compassPositionOfARelativeToB 2.2.6 - compassPositionOfARelativeToB
- clockPositionOfARelativeToB - clockPositionOfARelativeToB
@ -77,6 +77,11 @@ dcsCommon.version = "2.6.5"
2.6.5 - new bearing2compass() 2.6.5 - new bearing2compass()
- new bearingdegrees2compass() - new bearingdegrees2compass()
- new latLon2Text() - based on mist - new latLon2Text() - based on mist
2.6.6 - new nowString()
- new str2num()
- new stringRemainsStartingWith()
- new stripLF()
- new removeBlanks()
--]]-- --]]--
@ -1746,6 +1751,14 @@ dcsCommon.version = "2.6.5"
return trimmedArray return trimmedArray
end end
function dcsCommon.stripLF(theString)
return theString:gsub("[\r\n]", "")
end
function dcsCommon.removeBlanks(theString)
return theString:gsub("%s", "")
end
function dcsCommon.stringIsPositiveNumber(theString) function dcsCommon.stringIsPositiveNumber(theString)
-- only full integer positive numbers supported -- only full integer positive numbers supported
if not theString then return false end if not theString then return false end
@ -1818,8 +1831,8 @@ dcsCommon.version = "2.6.5"
if not p then return "<!NIL!>" end if not p then return "<!NIL!>" end
local t = "[x=" local t = "[x="
if p.x then t = t .. p.x .. ", " else t = t .. "<nil>, " end 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.y then t = t .. "y=" .. p.y .. ", " else t = t .. "y=<nil>, " end
if p.z then t = t .. p.z .. "]" else t = t .. "<nil>]" end if p.z then t = t .. "z=" .. p.z .. "]" else t = t .. "z=<nil>]" end
return t return t
end end
@ -2047,6 +2060,33 @@ dcsCommon.version = "2.6.5"
return msg return msg
end end
function dcsCommon.nowString()
local absSecs = timer.getAbsTime()-- + env.mission.start_time
while absSecs > 86400 do
absSecs = absSecs - 86400 -- subtract out all days
end
return dcsCommon.processHMS("<:h>:<:m>:<:s>", absSecs)
end
function dcsCommon.str2num(inVal, default)
if not default then default = 0 end
if not inVal then return default end
if type(inVal) == "number" then return inVal end
local num = nil
if type(inVal) == "string" then num = tonumber(inVal) end
if not num then return default end
return num
end
function dcsCommon.stringRemainsStartingWith(theString, startingWith)
-- find the first position where startingWith starts
local pos = theString:find(startingWith)
if not pos then return theString end
-- now return the entire remainder of the string from pos
local nums = theString:len() - pos + 1
return theString:sub(-nums)
end
-- --
-- --
-- V E C T O R M A T H -- V E C T O R M A T H

View File

@ -1,6 +1,7 @@
guardianAngel = {} guardianAngel = {}
guardianAngel.version = "3.0.1" guardianAngel.version = "3.0.2"
guardianAngel.ups = 10 guardianAngel.ups = 10
guardianAngel.name = "Guardian Angel" -- just in case someone accesses .name
guardianAngel.launchWarning = true -- detect launches and warn pilot guardianAngel.launchWarning = true -- detect launches and warn pilot
guardianAngel.intervention = true -- remove missiles just before hitting guardianAngel.intervention = true -- remove missiles just before hitting
guardianAngel.explosion = -1 -- small poof when missile explodes. -1 = off. guardianAngel.explosion = -1 -- small poof when missile explodes. -1 = off.
@ -56,6 +57,7 @@ guardianAngel.requiredLibs = {
3.0.1 - corrected error on collateral (missing delay) 3.0.1 - corrected error on collateral (missing delay)
- Supporst cloned units - Supporst cloned units
- removed legacy code - removed legacy code
3.0.2 - added guardianAngel.name for those who use local flags on activate
This script detects missiles launched against protected aircraft an This script detects missiles launched against protected aircraft an

View File

@ -1,6 +1,6 @@
impostors={} impostors={}
impostors.version = "1.0.0" impostors.version = "1.0.1"
impostors.verbose = false impostors.verbose = false
impostors.ups = 1 impostors.ups = 1
impostors.requiredLibs = { impostors.requiredLibs = {
@ -15,6 +15,11 @@ impostors.callbacks = {}
impostors.uniqueCounter = 8200000 -- clones start at 9200000 impostors.uniqueCounter = 8200000 -- clones start at 9200000
--[[-- --[[--
Version History
1.0.0 - initial version
1.0.1 - added some verbosity
LIMITATIONS: LIMITATIONS:
must be on ground (or would be very silly must be on ground (or would be very silly
does not work with any units deployed on ships does not work with any units deployed on ships
@ -379,6 +384,12 @@ function impostors.delayedSpawn(args)
local newGroup = coalition.addGroup(ctry, cat, rawData) local newGroup = coalition.addGroup(ctry, cat, rawData)
impostors.relinkZonesForGroup(relinkZones, newGroup) impostors.relinkZonesForGroup(relinkZones, newGroup)
if newGroup then
-- trigger.action.outText("+++ipst: SUCCESS!!! Spawned group <" .. newGroup:getName() .. "> for impostor <" .. rawData.name .. ">", 30)
else
trigger.action.outText("+++ipst: failed to spawn group for impostor <" .. rawData.name .. ">", 30)
end
if theZone.trackWith and groupTracker.addGroupToTrackerNamed then if theZone.trackWith and groupTracker.addGroupToTrackerNamed then
-- add these groups to the group tracker -- add these groups to the group tracker
if theZone.verbose or impostors.verbose then if theZone.verbose or impostors.verbose then

View File

@ -1,5 +1,5 @@
pulseFlags = {} pulseFlags = {}
pulseFlags.version = "1.2.1" pulseFlags.version = "1.2.3"
pulseFlags.verbose = false pulseFlags.verbose = false
pulseFlags.requiredLibs = { pulseFlags.requiredLibs = {
"dcsCommon", -- always "dcsCommon", -- always
@ -32,6 +32,9 @@ pulseFlags.requiredLibs = {
- 1.2.1 pulseInterval synonym for time - 1.2.1 pulseInterval synonym for time
pulses now supports range pulses now supports range
zone-local verbosity zone-local verbosity
- 1.2.2 outputMethod synonym
- 1.2.3 deprecated paused/pulsePaused
returned onStart, defaulting to true
--]]-- --]]--
@ -111,17 +114,27 @@ function pulseFlags.createPulseWithZone(theZone)
theZone.lastPauseValue = cfxZones.getFlagValue(theZone.pausePulseFlag, 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) -- harmonizing on onStart, and converting to old pulsePaused
local onStart = cfxZones.getBoolFromZoneProperty(theZone, "onStart", true)
theZone.pulsePaused = not (onStart)
-- old code, to be deprecated
if cfxZones.hasProperty(theZone, "paused") then
theZone.pulsePaused = cfxZones.getBoolFromZoneProperty(theZone, "paused", false)
if cfxZones.hasProperty(theZone, "pulseStopped") then elseif cfxZones.hasProperty(theZone, "pulseStopped") then
theZone.pulsePaused = cfxZones.getBoolFromZoneProperty(theZone, "pulseStopped", false) theZone.pulsePaused = cfxZones.getBoolFromZoneProperty(theZone, "pulseStopped", false)
end end
--]]--
theZone.pulseMethod = 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.pulseMethod = cfxZones.getStringFromZoneProperty(theZone, "pulseMethod", "flip") theZone.pulseMethod = cfxZones.getStringFromZoneProperty(theZone, "pulseMethod", "flip")
end end
if cfxZones.hasProperty(theZone, "outputMethod") then
theZone.pulseMethod = cfxZones.getStringFromZoneProperty(theZone, "outputMethod", "flip")
end
-- done flag -- done flag
if cfxZones.hasProperty(theZone, "done+1") then if cfxZones.hasProperty(theZone, "done+1") then
theZone.pulseDoneFlag = cfxZones.getStringFromZoneProperty(theZone, "done+1", "*none") theZone.pulseDoneFlag = cfxZones.getStringFromZoneProperty(theZone, "done+1", "*none")

1175
modules/theDebugger.lua Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
unitZone={} unitZone={}
unitZone.version = "1.2.2" unitZone.version = "1.2.3"
unitZone.verbose = false unitZone.verbose = false
unitZone.ups = 1 unitZone.ups = 1
unitZone.requiredLibs = { unitZone.requiredLibs = {
@ -14,6 +14,8 @@ unitZone.requiredLibs = {
1.2.0 - uzOn?, uzOff?, triggerMethod 1.2.0 - uzOn?, uzOff?, triggerMethod
1.2.1 - uzDirect 1.2.1 - uzDirect
1.2.2 - uzDirectInv 1.2.2 - uzDirectInv
1.2.3 - better guards for enterZone!, exitZone!, chsngeZone!
- better guards for uzOn? and uzOff?
--]]-- --]]--
@ -86,9 +88,16 @@ function unitZone.createUnitZone(theZone)
theZone.uzMethod = cfxZones.getStringFromZoneProperty(theZone, "uzMethod", "inc") theZone.uzMethod = cfxZones.getStringFromZoneProperty(theZone, "uzMethod", "inc")
end end
theZone.enterZone = cfxZones.getStringFromZoneProperty(theZone, "enterZone!", "<none>") if cfxZones.hasProperty(theZone, "enterZone!") then
theZone.exitZone = cfxZones.getStringFromZoneProperty(theZone, "exitZone!", "<none>") theZone.enterZone = cfxZones.getStringFromZoneProperty(theZone, "enterZone!", "*<none>")
theZone.changeZone = cfxZones.getStringFromZoneProperty(theZone, "changeZone!", "<none>") end
if cfxZones.hasProperty(theZone, "exitZone!") then
theZone.exitZone = cfxZones.getStringFromZoneProperty(theZone, "exitZone!", "*<none>")
end
if cfxZones.hasProperty(theZone, "changeZone!") then
theZone.changeZone = cfxZones.getStringFromZoneProperty(theZone, "changeZone!", "*<none>")
end
if cfxZones.hasProperty(theZone, "filterFor") then if cfxZones.hasProperty(theZone, "filterFor") then
local filterString = cfxZones.getStringFromZoneProperty(theZone, "filterFor", "1") -- ground local filterString = cfxZones.getStringFromZoneProperty(theZone, "filterFor", "1") -- ground
@ -108,11 +117,15 @@ function unitZone.createUnitZone(theZone)
-- on/off flags -- on/off flags
theZone.uzPaused = false -- we are turned on theZone.uzPaused = false -- we are turned on
theZone.triggerOnFlag = cfxZones.getStringFromZoneProperty(theZone, "uzOn?", "*<none1>") if cfxZones.hasProperty(theZone, "uzOn?") then
theZone.lastTriggerOnValue = cfxZones.getFlagValue(theZone.triggerOnFlag, theZone) theZone.triggerOnFlag = cfxZones.getStringFromZoneProperty(theZone, "uzOn?", "*<none1>")
theZone.lastTriggerOnValue = cfxZones.getFlagValue(theZone.triggerOnFlag, theZone)
end
theZone.triggerOffFlag = cfxZones.getStringFromZoneProperty(theZone, "uzOff?", "*<none2>") if cfxZones.hasProperty(theZone, "uzOff?") then
theZone.lastTriggerOffValue = cfxZones.getFlagValue(theZone.triggerOffFlag, theZone) theZone.triggerOffFlag = cfxZones.getStringFromZoneProperty(theZone, "uzOff?", "*<none2>")
theZone.lastTriggerOffValue = cfxZones.getFlagValue(theZone.triggerOffFlag, theZone)
end
theZone.uzTriggerMethod = cfxZones.getStringFromZoneProperty(theZone, "triggerMethod", "change") theZone.uzTriggerMethod = cfxZones.getStringFromZoneProperty(theZone, "triggerMethod", "change")
if cfxZones.hasProperty(theZone, "uzTriggerMethod") then if cfxZones.hasProperty(theZone, "uzTriggerMethod") then
@ -227,16 +240,22 @@ end
-- --
function unitZone.bangState(theZone, newState) function unitZone.bangState(theZone, newState)
cfxZones.pollFlag(theZone.changeZone, theZone.uzMethod, theZone) if theZone.changeZone then
cfxZones.pollFlag(theZone.changeZone, theZone.uzMethod, theZone)
end
if newState then if newState then
cfxZones.pollFlag(theZone.enterZone, theZone.uzMethod, theZone) if theZone.enterZone then
if unitZone.verbose then cfxZones.pollFlag(theZone.enterZone, theZone.uzMethod, theZone)
trigger.action.outText("+++uZone: banging enter! with <" .. theZone.uzMethod .. "> on <" .. theZone.enterZone .. "> for " .. theZone.name, 30) if unitZone.verbose then
trigger.action.outText("+++uZone: banging enter! with <" .. theZone.uzMethod .. "> on <" .. theZone.enterZone .. "> for " .. theZone.name, 30)
end
end end
else else
cfxZones.pollFlag(theZone.exitZone, theZone.uzMethod, theZone) if theZone.exitZone then
if unitZone.verbose then cfxZones.pollFlag(theZone.exitZone, theZone.uzMethod, theZone)
trigger.action.outText("+++uZone: banging exit! with <" .. theZone.uzMethod .. "> on <" .. theZone.exitZone .. "> for " .. theZone.name, 30) if unitZone.verbose then
trigger.action.outText("+++uZone: banging exit! with <" .. theZone.uzMethod .. "> on <" .. theZone.exitZone .. "> for " .. theZone.name, 30)
end
end end
end end
end end
@ -247,14 +266,14 @@ function unitZone.update()
for idx, aZone in pairs(unitZone.unitZones) do for idx, aZone in pairs(unitZone.unitZones) do
-- check if we need to pause/unpause -- check if we need to pause/unpause
if cfxZones.testZoneFlag(aZone, aZone.triggerOnFlag, aZone.uzTriggerMethod, "lastTriggerOnValue") then if aZone.triggerOnFlag and cfxZones.testZoneFlag(aZone, aZone.triggerOnFlag, aZone.uzTriggerMethod, "lastTriggerOnValue") then
if unitZone.verbose or aZone.verbose then if unitZone.verbose or aZone.verbose then
trigger.action.outText("+++uZone: turning " .. aZone.name .. " on", 30) trigger.action.outText("+++uZone: turning " .. aZone.name .. " on", 30)
end end
aZone.uzPaused = false aZone.uzPaused = false
end end
if cfxZones.testZoneFlag(aZone, aZone.triggerOffFlag, aZone.uzTriggerMethod, "lastTriggerOffValue") then if aZone.triggerOffFlag and cfxZones.testZoneFlag(aZone, aZone.triggerOffFlag, aZone.uzTriggerMethod, "lastTriggerOffValue") then
if unitZone.verbose or aZone.verbose then if unitZone.verbose or aZone.verbose then
trigger.action.outText("+++uZone: turning " .. aZone.name .. " OFF", 30) trigger.action.outText("+++uZone: turning " .. aZone.name .. " OFF", 30)
end end

Binary file not shown.