diff --git a/src/DamageReport_1_21_UnitStart.lua b/src/DamageReport_1_21_UnitStart.lua
deleted file mode 100644
index 4681996..0000000
--- a/src/DamageReport_1_21_UnitStart.lua
+++ /dev/null
@@ -1,625 +0,0 @@
---[[
- DamageReport v1.21
-
- Created By Dorian Gray
-
- Discord: Dorian Gray#2623
- InGame: DorianGray
- GitHub: https://github.com/DorianTheGrey/DU-DamageReport
-
- GNU Public License 3.0. Use whatever you want, be so kind to leave credit.
-
- Thanks to Jericho, Dmentia and Archaegeo for learning from their fine scripts.
-]]
-
------------------------------------------------
--- CONFIG
------------------------------------------------
-
-UseMyElementNames = false --export: If you active this, the display will not show the element type of damaged/broken elements but the name you gave them (truncated to 25 characters)
-UpdateInterval = 1 --export: Interval in seconds between updates of the calculations and (if anything changed) redrawing to the screen(s). You need to restart the script after changing this value.
-SimulationMode = false --export Randomize simluated damage on elements to check out the functionality of this script. And, no, your elements won't be harmed in the process :) You need to restart the script after changing this value.
-
-DebugMode = false -- Activate if you want some console messages
-VersionNumber = 1.2 -- Version number
-
-core = nil
-screens = {}
-
-shipID = 0
-forceRedraw = false
-SimulationActive=false
-
-clickAreas = {}
-DamagedSortingMode = 1 -- Define default sorting mode for damaged elements. 1 to sort by damage amount, 2 to sort by element id, 3 to sort by damage percent,
-BrokenSortingMode = 1 -- Define default sorting mode for broken elements. 1 to sort by damage amount, 2 to sort by element id
-
-CurrentDamagedPage = 1
-CurrentBrokenPage = 1
-
-totalShipHP = 0
-totalShipMaxHP = 0
-totalShipIntegrity = 100
-elementsId = {}
-damagedElements = {}
-brokenElements = {}
-ElementCounter = 0
-healthyElements = 0
-
------------------------------------------------
--- FUNCTIONS
------------------------------------------------
-
-
-function GenerateCommaValue(amount)
- local formatted = amount
- while true do
- formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
- if (k==0) then break end
- end
- return formatted
-end
-
-function PrintDebug(output, highlight)
- highlight = highlight or false
- if DebugMode then
- if highlight then system.print("------------------------------------------------------------------------") end
- system.print(output)
- if highlight then system.print("------------------------------------------------------------------------") end
- end
-end
-
-function PrintError(output)
- system.print(output)
-end
-
-function DrawCenteredText(output)
- for i=1,#screens,1 do
- screens[i].setCenteredText(output)
- end
-end
-
-function DrawSVG(output)
- for i=1,#screens,1 do
- screens[i].setSVG(output)
- end
-end
-
-function ClearConsole()
- for i=1,10,1 do
- PrintDebug()
- end
-end
-
-function SwitchScreens(state)
- state = state or true
- if #screens > 0 then
- for i=1,#screens,1 do
- if state then
- screens[i].clear()
- screens[i].activate()
- else
- screens[i].deactivate()
- screens[i].clear()
- end
- end
- end
-end
-
-function InitiateSlots()
- for slot_name, slot in pairs(unit) do
- if
- type(slot) == "table"
- and type(slot.export) == "table"
- and slot.getElementClass
- then
- if slot.getElementClass():lower():find("coreunit") then
- core = slot
- end
- if slot.getElementClass():lower():find("screenunit") then
- screens[#screens + 1] = slot
- end
- end
- end
-end
-
-function AddClickArea(newEntry)
- table.insert(clickAreas, newEntry)
-end
-
-function RemoveFromClickAreas(candidate)
- for k, v in pairs(clickAreas) do
- if v.id==candidate then
- clickAreas[k]=nil
- break
- end
- end
-end
-
-function UpdateClickArea(candidate, newEntry)
- for k, v in pairs(clickAreas) do
- if v.id==candidate then
- clickAreas[k]=newEntry
- break
- end
- end
-end
-
-function DisableClickArea(candidate)
- for k, v in pairs(clickAreas) do
- if v.id==candidate then
- UpdateClickArea(candidate, { id = candidate, x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )
- break
- end
- end
-end
-
-function InitiateClickAreas()
- clickAreas = {}
- AddClickArea( { id = "DamagedDamage", x1 = 725, x2 = 870, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "DamagedHealth", x1 = 520, x2 = 655, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "DamagedID", x1 = 90, x2 = 150, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "BrokenDamage", x1 = 1675, x2 = 1835, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "BrokenID", x1 = 1050, x2 = 1110, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "ToggleSimulation", x1 = 65, x2 = 660, y1 = 100, y2 = 145 } )
- AddClickArea( { id = "DamagedPageDown", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )
- AddClickArea( { id = "DamagedPageUp", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )
- AddClickArea( { id = "BrokenPageDown", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )
- AddClickArea( { id = "BrokenPageUp", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )
-end
-
-function CheckClick(x, y)
- PrintDebug("Clicked at "..x.." / "..y)
- local HitTarget=""
- for k, v in pairs(clickAreas) do
- if v and x>=v.x1 and x<=v.x2 and y>=v.y1 and y<=v.y2 then
- HitTarget=v.id
- break
- end
- end
- if HitTarget=="DamagedDamage" then
- DamagedSortingMode=1
- CurrentDamagedPage=1
- SortTables()
- DrawScreens()
- elseif HitTarget=="DamagedHealth" then
- DamagedSortingMode=3
- CurrentDamagedPage=1
- SortTables()
- DrawScreens()
- elseif HitTarget=="DamagedID" then
- DamagedSortingMode=2
- CurrentDamagedPage=1
- SortTables()
- DrawScreens()
- elseif HitTarget=="BrokenDamage" then
- BrokenSortingMode=1
- CurrentBrokenPage=1
- SortTables()
- DrawScreens()
- elseif HitTarget=="BrokenID" then
- BrokenSortingMode=2
- CurrentBrokenPage=1
- SortTables()
- DrawScreens()
- elseif HitTarget=="DamagedPageDown" then
- CurrentDamagedPage = CurrentDamagedPage + 1
- if CurrentDamagedPage > math.ceil(#damagedElements/12) then CurrentDamagedPage = math.ceil(#damagedElements/12) end
- DrawScreens()
- elseif HitTarget=="DamagedPageUp" then
- CurrentDamagedPage = CurrentDamagedPage - 1
- if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end
- DrawScreens()
- elseif HitTarget=="BrokenPageDown" then
- CurrentBrokenPage = CurrentBrokenPage + 1
- if CurrentBrokenPage > math.ceil(#brokenElements/12) then CurrentBrokenPage = math.ceil(#brokenElements/12) end
- DrawScreens()
- elseif HitTarget=="BrokenPageUp" then
- CurrentBrokenPage = CurrentBrokenPage - 1
- if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end
- DrawScreens()
- elseif HitTarget=="ToggleSimulation" then
- CurrentDamagedPage=1
- CurrentBrokenPage=1
- if SimulationMode == true then
- SimulationMode = false
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- DrawScreens()
- else
- SimulationMode = true
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- DrawScreens()
- end
-
- end
-end
-
-function SortTables()
- -- Sort damaged elements descending by percent damaged according to setting
- if DamagedSortingMode==1 then table.sort(damagedElements, function(a,b) return a.missinghp > b.missinghp end)
- elseif DamagedSortingMode==2 then table.sort(damagedElements, function(a,b) return a.id < b.id end)
- else table.sort(damagedElements, function(a,b) return a.percent < b.percent end)
- end
-
- -- Sort broken elements descending according to setting
- if BrokenSortingMode==1 then table.sort(brokenElements, function(a,b) return a.maxhp > b.maxhp end)
- else table.sort(brokenElements, function(a,b) return a.id < b.id end)
- end
-end
-
-function GenerateDamageData()
- if SimulationActive==true then
- return
- end
-
- local formerTotalShipHP = totalShipHP
- totalShipHP = 0
- totalShipMaxHP = 0
- totalShipIntegrity = 100
- elementsId = {}
- damagedElements = {}
- brokenElements = {}
- ElementCounter = 0
- healthyElements = 0
-
- elementsIdList = core.getElementIdList()
-
- for _,id in pairs(elementsIdList) do
- ElementCounter = ElementCounter + 1
- idHP = core.getElementHitPointsById(id) or 0
- idMaxHP = core.getElementMaxHitPointsById(id) or 0
-
- if SimulationMode then
- SimulationActive=true
- local dice =math.random(0,10)
- if dice < 2 then idHP = 0
- elseif dice >=2 and dice < 5 then idHP = idMaxHP
- else
- idHP = math.random(1, math.ceil(idMaxHP))
- end
- end
-
- totalShipHP = totalShipHP+idHP
- totalShipMaxHP = totalShipMaxHP+idMaxHP
-
- -- Is element damaged?
- if idMaxHP > idHP then
- idPos = core.getElementPositionById(id)
- idName = core.getElementNameById(id)
- idType = core.getElementTypeById(id)
- if idHP>0 then
- table.insert(damagedElements,
- {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP-idHP,
- percent = math.ceil(100/idMaxHP*idHP),
- pos =idPos
- }
- )
- if DebugMode then PrintDebug("Damaged: "..idName.." --- Type: "..idType.."") end
- -- Is element broken?
- else
- table.insert(brokenElements,
- {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP-idHP,
- percent = 0,
- pos =idPos
- }
- )
- if DebugMode then PrintDebug("Broken: "..idName.." --- Type: "..idType.."") end
- end
- else
- healthyElements = healthyElements + 1
- end
- end
-
- -- Sort tables by current settings
- SortTables()
-
- -- Update clickAreas
-
-
- -- Determine total ship integrity
- totalShipIntegrity = string.format("%2.0f", 100/totalShipMaxHP*totalShipHP)
-
- -- Has anything changes since last check? If yes, force redrawing the screens
- if formerTotalShipHP ~= totalShipHP then
- forceRedraw=true
- formerTotalShipHP = totalShipHP
- else forceRedraw=false
- end
-end
-
-function DrawScreens()
- if #screens > 0 then
-
- local healthyColor = "#00aa00"
- local brokenColor = "#aa0000"
- local damagedColor = "#aaaa00"
- local integrityColor = "#aaaaaa"
- local healthyTextColor = "white"
- local brokenTextColor = "#ff4444"
- local damagedTextColor = "#ffff44"
- local integrityTextColor = "white"
-
- if #damagedElements ==0 then
- damagedColor = "#aaaaaa"
- damagedTextColor = "white"
- end
- if #brokenElements == 0 then
- brokenColor = "#aaaaaa"
- brokenTextColor = "white"
- end
-
- -- Draw Header
- screenOutput = [[]]
-
- DrawSVG(screenOutput)
-
- forceRedraw=false
- end
-end
-
------------------------------------------------
--- Execute
------------------------------------------------
-
-unit.hide()
-ClearConsole()
-PrintDebug("SCRIPT STARTED", true)
-
-InitiateSlots()
-SwitchScreens(true)
-InitiateClickAreas()
-
-if core == nil then
- DrawCenteredText("ERROR: No core connected.")
- PrintError("ERROR: No core connected.")
- goto exit
-else
- shipID = core.getConstructId()
-end
-
-GenerateDamageData()
-if forceRedraw then
- DrawScreens()
-end
-
-unit.setTimer('UpdateData', UpdateInterval)
-
-::exit::
\ No newline at end of file
diff --git a/src/DamageReport_1_31_UnitStart.lua b/src/DamageReport_1_31_UnitStart.lua
deleted file mode 100644
index 095bdec..0000000
--- a/src/DamageReport_1_31_UnitStart.lua
+++ /dev/null
@@ -1,645 +0,0 @@
---[[
- DamageReport v1.31
-
- Created By Dorian Gray
-
- Discord: Dorian Gray#2623
- InGame: DorianGray
- GitHub: https://github.com/DorianTheGrey/DU-DamageReport
-
- GNU Public License 3.0. Use whatever you want, be so kind to leave credit.
-
- Thanks to Jericho, Dmentia and Archaegeo for learning from their fine scripts.
-]]
-
------------------------------------------------
--- CONFIG
------------------------------------------------
-
-UseMyElementNames = false --export: If you active this, the display will not show the element type of damaged/broken elements but the name you gave them (truncated to 25 characters)
-UpdateInterval = 1 --export: Interval in seconds between updates of the calculations and (if anything changed) redrawing to the screen(s). You need to restart the script after changing this value.
-SimulationMode = false --export Randomize simluated damage on elements to check out the functionality of this script. And, no, your elements won't be harmed in the process :) You need to restart the script after changing this value.
-
-DebugMode = false -- Activate if you want some console messages
-VersionNumber = 1.31 -- Version number
-
-core = nil
-screens = {}
-
-shipID = 0
-forceRedraw = false
-SimulationActive=false
-
-clickAreas = {}
-DamagedSortingMode = 1 -- Define default sorting mode for damaged elements. 1 to sort by damage amount, 2 to sort by element id, 3 to sort by damage percent,
-BrokenSortingMode = 1 -- Define default sorting mode for broken elements. 1 to sort by damage amount, 2 to sort by element id
-
-HUDMode = false
-CurrentDamagedPage = 1
-CurrentBrokenPage = 1
-
-totalShipHP = 0
-totalShipMaxHP = 0
-totalShipIntegrity = 100
-elementsId = {}
-damagedElements = {}
-brokenElements = {}
-ElementCounter = 0
-healthyElements = 0
-
------------------------------------------------
--- FUNCTIONS
------------------------------------------------
-
-
-function GenerateCommaValue(amount)
- local formatted = amount
- while true do
- formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
- if (k==0) then break end
- end
- return formatted
-end
-
-function PrintDebug(output, highlight)
- highlight = highlight or false
- if DebugMode then
- if highlight then system.print("------------------------------------------------------------------------") end
- system.print(output)
- if highlight then system.print("------------------------------------------------------------------------") end
- end
-end
-
-function PrintError(output)
- system.print(output)
-end
-
-function DrawCenteredText(output)
- for i=1,#screens,1 do
- screens[i].setCenteredText(output)
- end
-end
-
-function DrawSVG(output)
- for i=1,#screens,1 do
- screens[i].setSVG(output)
- end
-end
-
-function ClearConsole()
- for i=1,10,1 do
- PrintDebug()
- end
-end
-
-function SwitchScreens(state)
- state = state or true
- if #screens > 0 then
- for i=1,#screens,1 do
- if state then
- screens[i].clear()
- screens[i].activate()
- else
- screens[i].deactivate()
- screens[i].clear()
- end
- end
- end
-end
-
-function InitiateSlots()
- for slot_name, slot in pairs(unit) do
- if
- type(slot) == "table"
- and type(slot.export) == "table"
- and slot.getElementClass
- then
- if slot.getElementClass():lower():find("coreunit") then
- core = slot
- end
- if slot.getElementClass():lower():find("screenunit") then
- screens[#screens + 1] = slot
- end
- end
- end
-end
-
-function AddClickArea(newEntry)
- table.insert(clickAreas, newEntry)
-end
-
-function RemoveFromClickAreas(candidate)
- for k, v in pairs(clickAreas) do
- if v.id==candidate then
- clickAreas[k]=nil
- break
- end
- end
-end
-
-function UpdateClickArea(candidate, newEntry)
- for k, v in pairs(clickAreas) do
- if v.id==candidate then
- clickAreas[k]=newEntry
- break
- end
- end
-end
-
-function DisableClickArea(candidate)
- for k, v in pairs(clickAreas) do
- if v.id==candidate then
- UpdateClickArea(candidate, { id = candidate, x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )
- break
- end
- end
-end
-
-function InitiateClickAreas()
- clickAreas = {}
- AddClickArea( { id = "DamagedDamage", x1 = 725, x2 = 870, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "DamagedHealth", x1 = 520, x2 = 655, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "DamagedID", x1 = 90, x2 = 150, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "BrokenDamage", x1 = 1675, x2 = 1835, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "BrokenID", x1 = 1050, x2 = 1110, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "ToggleSimulation", x1 = 65, x2 = 660, y1 = 100, y2 = 145 } )
- AddClickArea( { id = "ToggleElementLabel", x1 = 225, x2 = 460, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "ToggleElementLabel2", x1 = 1185, x2 = 1440, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "DamagedPageDown", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )
- AddClickArea( { id = "DamagedPageUp", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )
- AddClickArea( { id = "BrokenPageDown", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )
- AddClickArea( { id = "BrokenPageUp", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )
-end
-
-function FlushClickAreas()
- clickAreas = {}
-end
-
-function CheckClick(x, y)
- PrintDebug("Clicked at "..x.." / "..y)
- local HitTarget=""
- for k, v in pairs(clickAreas) do
- if v and x>=v.x1 and x<=v.x2 and y>=v.y1 and y<=v.y2 then
- HitTarget=v.id
- break
- end
- end
- if HitTarget=="DamagedDamage" then
- DamagedSortingMode=1
- CurrentDamagedPage=1
- SortTables()
- DrawScreens()
- elseif HitTarget=="DamagedHealth" then
- DamagedSortingMode=3
- CurrentDamagedPage=1
- SortTables()
- DrawScreens()
- elseif HitTarget=="DamagedID" then
- DamagedSortingMode=2
- CurrentDamagedPage=1
- SortTables()
- DrawScreens()
- elseif HitTarget=="BrokenDamage" then
- BrokenSortingMode=1
- CurrentBrokenPage=1
- SortTables()
- DrawScreens()
- elseif HitTarget=="BrokenID" then
- BrokenSortingMode=2
- CurrentBrokenPage=1
- SortTables()
- DrawScreens()
- elseif HitTarget=="DamagedPageDown" then
- CurrentDamagedPage = CurrentDamagedPage + 1
- if CurrentDamagedPage > math.ceil(#damagedElements/12) then CurrentDamagedPage = math.ceil(#damagedElements/12) end
- DrawScreens()
- elseif HitTarget=="DamagedPageUp" then
- CurrentDamagedPage = CurrentDamagedPage - 1
- if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end
- DrawScreens()
- elseif HitTarget=="BrokenPageDown" then
- CurrentBrokenPage = CurrentBrokenPage + 1
- if CurrentBrokenPage > math.ceil(#brokenElements/12) then CurrentBrokenPage = math.ceil(#brokenElements/12) end
- DrawScreens()
- elseif HitTarget=="BrokenPageUp" then
- CurrentBrokenPage = CurrentBrokenPage - 1
- if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end
- DrawScreens()
- elseif HitTarget=="ToggleSimulation" then
- CurrentDamagedPage=1
- CurrentBrokenPage=1
- if SimulationMode == true then
- SimulationMode = false
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- DrawScreens()
- else
- SimulationMode = true
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- DrawScreens()
- end
- elseif HitTarget=="ToggleElementLabel" or HitTarget=="ToggleElementLabel2" then
- if UseMyElementNames == true then
- UseMyElementNames = false
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- DrawScreens()
- else
- UseMyElementNames = true
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- DrawScreens()
- end
- end
-end
-
-function SortTables()
- -- Sort damaged elements descending by percent damaged according to setting
- if DamagedSortingMode==1 then table.sort(damagedElements, function(a,b) return a.missinghp > b.missinghp end)
- elseif DamagedSortingMode==2 then table.sort(damagedElements, function(a,b) return a.id < b.id end)
- else table.sort(damagedElements, function(a,b) return a.percent < b.percent end)
- end
-
- -- Sort broken elements descending according to setting
- if BrokenSortingMode==1 then table.sort(brokenElements, function(a,b) return a.maxhp > b.maxhp end)
- else table.sort(brokenElements, function(a,b) return a.id < b.id end)
- end
-end
-
-function GenerateDamageData()
- if SimulationActive==true then
- return
- end
-
- local formerTotalShipHP = totalShipHP
- totalShipHP = 0
- totalShipMaxHP = 0
- totalShipIntegrity = 100
- elementsId = {}
- damagedElements = {}
- brokenElements = {}
- ElementCounter = 0
- healthyElements = 0
-
- elementsIdList = core.getElementIdList()
-
- for _,id in pairs(elementsIdList) do
- ElementCounter = ElementCounter + 1
- idHP = core.getElementHitPointsById(id) or 0
- idMaxHP = core.getElementMaxHitPointsById(id) or 0
-
- if SimulationMode then
- SimulationActive=true
- local dice =math.random(0,10)
- if dice < 2 then idHP = 0
- elseif dice >=2 and dice < 5 then idHP = idMaxHP
- else
- idHP = math.random(1, math.ceil(idMaxHP))
- end
- end
-
- totalShipHP = totalShipHP+idHP
- totalShipMaxHP = totalShipMaxHP+idMaxHP
-
- -- Is element damaged?
- if idMaxHP > idHP then
- idPos = core.getElementPositionById(id)
- idName = core.getElementNameById(id)
- idType = core.getElementTypeById(id)
- if idHP>0 then
- table.insert(damagedElements,
- {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP-idHP,
- percent = math.ceil(100/idMaxHP*idHP),
- pos =idPos
- }
- )
- -- if DebugMode then PrintDebug("Damaged: "..idName.." --- Type: "..idType.."") end
- -- Is element broken?
- else
- table.insert(brokenElements,
- {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP-idHP,
- percent = 0,
- pos =idPos
- }
- )
- -- if DebugMode then PrintDebug("Broken: "..idName.." --- Type: "..idType.."") end
- end
- else
- healthyElements = healthyElements + 1
- end
- end
-
- -- Sort tables by current settings
- SortTables()
-
- -- Update clickAreas
-
-
- -- Determine total ship integrity
- totalShipIntegrity = string.format("%2.0f", 100/totalShipMaxHP*totalShipHP)
-
- -- Has anything changes since last check? If yes, force redrawing the screens
- if formerTotalShipHP ~= totalShipHP then
- forceRedraw=true
- formerTotalShipHP = totalShipHP
- else forceRedraw=false
- end
-end
-
-function DrawScreens()
- if #screens > 0 then
-
- local healthyColor = "#00aa00"
- local brokenColor = "#aa0000"
- local damagedColor = "#aaaa00"
- local integrityColor = "#aaaaaa"
- local healthyTextColor = "white"
- local brokenTextColor = "#ff4444"
- local damagedTextColor = "#ffff44"
- local integrityTextColor = "white"
-
- if #damagedElements ==0 then
- damagedColor = "#aaaaaa"
- damagedTextColor = "white"
- end
- if #brokenElements == 0 then
- brokenColor = "#aaaaaa"
- brokenTextColor = "white"
- end
-
- -- Draw Header
- screenOutput = [[
- ]]
-
- -- Draw main background
- screenOutput = screenOutput..
- [[
-
-
-
-
-
-
-
-
-
-
-
- ]]
-
- -- Draw Title and summary
- if SimulationActive==true then
- screenOutput = screenOutput..[[Simulated Report]]
- else
- screenOutput = screenOutput..[[Damage Report]]
- end
- screenOutput = screenOutput..
- [[SHIP ID ]]..shipID..[[
-
- Healthy
- ]]..healthyElements..[[
-
- Damaged
- ]]..#damagedElements..[[
-
- Broken
- ]]..#brokenElements..[[
-
- Integrity
- ]]..totalShipIntegrity..[[%]]
-
- -- Draw damage elements
- if #damagedElements > 0 then
- local damagedElementsToDraw = #damagedElements
- if damagedElementsToDraw>12 then damagedElementsToDraw=12 end
- if CurrentDamagedPage==math.ceil(#damagedElements/12) then damagedElementsToDraw = #damagedElements%12 end
- screenOutput = screenOutput..
- [[]]
- screenOutput = screenOutput .. [[]]
- if (DamagedSortingMode==2) then
- screenOutput = screenOutput ..[[ID]]
- else
- screenOutput = screenOutput ..[[ID]]
- end
- if UseMyElementNames==true then screenOutput = screenOutput ..[[Element Name]]
- else screenOutput = screenOutput ..[[Element Type]]
- end
-
- if (DamagedSortingMode==3) then
- screenOutput = screenOutput ..[[Health]]
- else
- screenOutput = screenOutput ..[[Health]]
- end
- if (DamagedSortingMode==1) then
- screenOutput = screenOutput ..[[Damage]]
- else
- screenOutput = screenOutput ..[[Damage]]
- end
-
- local i=0
- for j=1+(CurrentDamagedPage-1)*12,damagedElementsToDraw+(CurrentDamagedPage-1)*12,1 do
- i = i + 1
- local DP = damagedElements[j]
- screenOutput = screenOutput ..
- [[]]..string.format("%03.0f",DP.id)..[[]]
- if UseMyElementNames==true then
- screenOutput = screenOutput .. [[]]..string.format("%.25s", DP.name)..[[]]
- else
- screenOutput = screenOutput .. [[]]..string.format("%.25s", DP.type)..[[]]
- end
- screenOutput = screenOutput ..
- [[]]..DP.percent..[[%]]..
- [[]]..GenerateCommaValue(string.format("%.0f", DP.missinghp))..[[]]..
- [[]]
- end
- screenOutput = screenOutput ..
- [[
-
- ]]
-
- if #damagedElements>12 then
- screenOutput = screenOutput ..
- [[Page ]]..CurrentDamagedPage.." of "..math.ceil(#damagedElements/12)..[[]]
-
- if CurrentDamagedPage < math.ceil(#damagedElements/12) then
- screenOutput = screenOutput ..
- [[
-
-
- ]]
- UpdateClickArea( "DamagedPageDown", { id = "DamagedPageDown", x1 = 70, x2 = 270, y1 = 350+11+(damagedElementsToDraw+1)*50, y2 = 350+11+50+(damagedElementsToDraw+1)*50 } )
- else
- DisableClickArea( "DamagedPageDown" )
- end
-
- if CurrentDamagedPage > 1 then
- screenOutput = screenOutput ..
- [[
-
-
- ]]
- UpdateClickArea( "DamagedPageUp", { id = "DamagedPageUp", x1 = 280, x2 = 480, y1 = 350+11+(damagedElementsToDraw+1)*50, y2 = 350+11+50+(damagedElementsToDraw+1)*50 } )
- else
- DisableClickArea( "DamagedPageUp" )
- end
- end
-
-
-
-
- end
-
- -- Draw broken elements
- if #brokenElements > 0 then
- local brokenElementsToDraw = #brokenElements
- if brokenElementsToDraw>12 then brokenElementsToDraw=12 end
- if CurrentBrokenPage==math.ceil(#brokenElements/12) then brokenElementsToDraw = #brokenElements%12 end
- screenOutput = screenOutput..
- [[]]
- screenOutput = screenOutput .. [[]]
- if (BrokenSortingMode==2) then
- screenOutput = screenOutput ..[[ID]]
- else
- screenOutput = screenOutput ..[[ID]]
- end
- if UseMyElementNames==true then screenOutput = screenOutput .. [[Element Name]]
- else screenOutput = screenOutput .. [[Element Type]]
- end
- if (BrokenSortingMode==1) then
- screenOutput = screenOutput ..[[Damage]]
- else
- screenOutput = screenOutput ..[[Damage]]
- end
-
- local i=0
- for j=1+(CurrentBrokenPage-1)*12,brokenElementsToDraw+(CurrentBrokenPage-1)*12,1 do
- i = i + 1
- local DP = brokenElements[j]
- screenOutput = screenOutput ..
- [[]]..string.format("%03.0f",DP.id)..[[]]
- if UseMyElementNames==true then
- screenOutput = screenOutput .. [[]]..string.format("%.25s", DP.name)..[[]]
- else
- screenOutput = screenOutput .. [[]]..string.format("%.25s", DP.type)..[[]]
- end
- screenOutput = screenOutput ..
- [[]]..GenerateCommaValue(string.format("%.0f", DP.missinghp))..[[]]..
- [[]]
- end
-
- screenOutput = screenOutput..
- [[
-
- ]]
-
-
- if #brokenElements>12 then
- screenOutput = screenOutput ..
- [[Page ]]..CurrentBrokenPage.." of "..math.ceil(#brokenElements/12)..[[]]
-
- if CurrentBrokenPage > 1 then
- screenOutput = screenOutput ..
- [[
-
-
- ]]
- UpdateClickArea( "BrokenPageUp", { id = "BrokenPageUp", x1 = 1442, x2 = 1642, y1 = 350+11+(brokenElementsToDraw+1)*50, y2 = 350+11+50+(brokenElementsToDraw+1)*50 } )
- else
- DisableClickArea( "BrokenPageUp" )
- end
-
- if CurrentBrokenPage < math.ceil(#brokenElements/12) then
- screenOutput = screenOutput ..
- [[
-
-
- ]]
- UpdateClickArea( "BrokenPageDown", { id = "BrokenPageDown", x1 = 1652, x2 = 1852, y1 = 350+11+(brokenElementsToDraw+1)*50, y2 = 350+11+50+(brokenElementsToDraw+1)*50 } )
- else
- DisableClickArea( "BrokenPageDown" )
- end
- end
-
-
-
- end
-
- -- Draw damage summary
- if #damagedElements>0 or #brokenElements > 0 then
- screenOutput = screenOutput..
- [[]]..GenerateCommaValue(string.format("%.0f", totalShipMaxHP-totalShipHP))..[[ HP damage in total]]
-
- end
-
- screenOutput = screenOutput..[[]]
-
- DrawSVG(screenOutput)
-
- forceRedraw=false
- end
-end
-
------------------------------------------------
--- Execute
------------------------------------------------
-
-unit.hide()
-ClearConsole()
-PrintDebug("SCRIPT STARTED", true)
-
-InitiateSlots()
-SwitchScreens(true)
-InitiateClickAreas()
-
-if core == nil then
- DrawCenteredText("ERROR: No core connected.")
- PrintError("ERROR: No core connected.")
- goto exit
-else
- shipID = core.getConstructId()
-end
-
-GenerateDamageData()
-if forceRedraw then
- DrawScreens()
-end
-
-unit.setTimer('UpdateData', UpdateInterval)
-
-::exit::
\ No newline at end of file
diff --git a/src/DamageReport_1_3_UnitStart.lua b/src/DamageReport_1_3_UnitStart.lua
deleted file mode 100644
index e2b1d8d..0000000
--- a/src/DamageReport_1_3_UnitStart.lua
+++ /dev/null
@@ -1,644 +0,0 @@
---[[
- DamageReport v1.3
-
- Created By Dorian Gray
-
- Discord: Dorian Gray#2623
- InGame: DorianGray
- GitHub: https://github.com/DorianTheGrey/DU-DamageReport
-
- GNU Public License 3.0. Use whatever you want, be so kind to leave credit.
-
- Thanks to Jericho, Dmentia and Archaegeo for learning from their fine scripts.
-]]
-
------------------------------------------------
--- CONFIG
------------------------------------------------
-
-UseMyElementNames = false --export: If you active this, the display will not show the element type of damaged/broken elements but the name you gave them (truncated to 25 characters)
-UpdateInterval = 1 --export: Interval in seconds between updates of the calculations and (if anything changed) redrawing to the screen(s). You need to restart the script after changing this value.
-SimulationMode = false --export Randomize simluated damage on elements to check out the functionality of this script. And, no, your elements won't be harmed in the process :) You need to restart the script after changing this value.
-
-DebugMode = false -- Activate if you want some console messages
-VersionNumber = 1.3 -- Version number
-
-core = nil
-screens = {}
-
-shipID = 0
-forceRedraw = false
-SimulationActive=false
-
-clickAreas = {}
-DamagedSortingMode = 1 -- Define default sorting mode for damaged elements. 1 to sort by damage amount, 2 to sort by element id, 3 to sort by damage percent,
-BrokenSortingMode = 1 -- Define default sorting mode for broken elements. 1 to sort by damage amount, 2 to sort by element id
-
-HUDMode = false
-CurrentDamagedPage = 1
-CurrentBrokenPage = 1
-
-totalShipHP = 0
-totalShipMaxHP = 0
-totalShipIntegrity = 100
-elementsId = {}
-damagedElements = {}
-brokenElements = {}
-ElementCounter = 0
-healthyElements = 0
-
------------------------------------------------
--- FUNCTIONS
------------------------------------------------
-
-
-function GenerateCommaValue(amount)
- local formatted = amount
- while true do
- formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
- if (k==0) then break end
- end
- return formatted
-end
-
-function PrintDebug(output, highlight)
- highlight = highlight or false
- if DebugMode then
- if highlight then system.print("------------------------------------------------------------------------") end
- system.print(output)
- if highlight then system.print("------------------------------------------------------------------------") end
- end
-end
-
-function PrintError(output)
- system.print(output)
-end
-
-function DrawCenteredText(output)
- for i=1,#screens,1 do
- screens[i].setCenteredText(output)
- end
-end
-
-function DrawSVG(output)
- for i=1,#screens,1 do
- screens[i].setSVG(output)
- end
-end
-
-function ClearConsole()
- for i=1,10,1 do
- PrintDebug()
- end
-end
-
-function SwitchScreens(state)
- state = state or true
- if #screens > 0 then
- for i=1,#screens,1 do
- if state then
- screens[i].clear()
- screens[i].activate()
- else
- screens[i].deactivate()
- screens[i].clear()
- end
- end
- end
-end
-
-function InitiateSlots()
- for slot_name, slot in pairs(unit) do
- if
- type(slot) == "table"
- and type(slot.export) == "table"
- and slot.getElementClass
- then
- if slot.getElementClass():lower():find("coreunit") then
- core = slot
- end
- if slot.getElementClass():lower():find("screenunit") then
- screens[#screens + 1] = slot
- end
- end
- end
-end
-
-function AddClickArea(newEntry)
- table.insert(clickAreas, newEntry)
-end
-
-function RemoveFromClickAreas(candidate)
- for k, v in pairs(clickAreas) do
- if v.id==candidate then
- clickAreas[k]=nil
- break
- end
- end
-end
-
-function UpdateClickArea(candidate, newEntry)
- for k, v in pairs(clickAreas) do
- if v.id==candidate then
- clickAreas[k]=newEntry
- break
- end
- end
-end
-
-function DisableClickArea(candidate)
- for k, v in pairs(clickAreas) do
- if v.id==candidate then
- UpdateClickArea(candidate, { id = candidate, x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )
- break
- end
- end
-end
-
-function InitiateClickAreas()
- clickAreas = {}
- AddClickArea( { id = "DamagedDamage", x1 = 725, x2 = 870, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "DamagedHealth", x1 = 520, x2 = 655, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "DamagedID", x1 = 90, x2 = 150, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "BrokenDamage", x1 = 1675, x2 = 1835, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "BrokenID", x1 = 1050, x2 = 1110, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "ToggleSimulation", x1 = 65, x2 = 660, y1 = 100, y2 = 145 } )
- AddClickArea( { id = "ToggleElementLabel", x1 = 225, x2 = 460, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "DamagedPageDown", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )
- AddClickArea( { id = "DamagedPageUp", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )
- AddClickArea( { id = "BrokenPageDown", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )
- AddClickArea( { id = "BrokenPageUp", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )
-end
-
-function FlushClickAreas()
- clickAreas = {}
-end
-
-function CheckClick(x, y)
- PrintDebug("Clicked at "..x.." / "..y)
- local HitTarget=""
- for k, v in pairs(clickAreas) do
- if v and x>=v.x1 and x<=v.x2 and y>=v.y1 and y<=v.y2 then
- HitTarget=v.id
- break
- end
- end
- if HitTarget=="DamagedDamage" then
- DamagedSortingMode=1
- CurrentDamagedPage=1
- SortTables()
- DrawScreens()
- elseif HitTarget=="DamagedHealth" then
- DamagedSortingMode=3
- CurrentDamagedPage=1
- SortTables()
- DrawScreens()
- elseif HitTarget=="DamagedID" then
- DamagedSortingMode=2
- CurrentDamagedPage=1
- SortTables()
- DrawScreens()
- elseif HitTarget=="BrokenDamage" then
- BrokenSortingMode=1
- CurrentBrokenPage=1
- SortTables()
- DrawScreens()
- elseif HitTarget=="BrokenID" then
- BrokenSortingMode=2
- CurrentBrokenPage=1
- SortTables()
- DrawScreens()
- elseif HitTarget=="DamagedPageDown" then
- CurrentDamagedPage = CurrentDamagedPage + 1
- if CurrentDamagedPage > math.ceil(#damagedElements/12) then CurrentDamagedPage = math.ceil(#damagedElements/12) end
- DrawScreens()
- elseif HitTarget=="DamagedPageUp" then
- CurrentDamagedPage = CurrentDamagedPage - 1
- if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end
- DrawScreens()
- elseif HitTarget=="BrokenPageDown" then
- CurrentBrokenPage = CurrentBrokenPage + 1
- if CurrentBrokenPage > math.ceil(#brokenElements/12) then CurrentBrokenPage = math.ceil(#brokenElements/12) end
- DrawScreens()
- elseif HitTarget=="BrokenPageUp" then
- CurrentBrokenPage = CurrentBrokenPage - 1
- if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end
- DrawScreens()
- elseif HitTarget=="ToggleSimulation" then
- CurrentDamagedPage=1
- CurrentBrokenPage=1
- if SimulationMode == true then
- SimulationMode = false
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- DrawScreens()
- else
- SimulationMode = true
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- DrawScreens()
- end
- elseif HitTarget=="ToggleElementLabel" then
- if UseMyElementNames == true then
- UseMyElementNames = false
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- DrawScreens()
- else
- UseMyElementNames = true
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- DrawScreens()
- end
- end
-end
-
-function SortTables()
- -- Sort damaged elements descending by percent damaged according to setting
- if DamagedSortingMode==1 then table.sort(damagedElements, function(a,b) return a.missinghp > b.missinghp end)
- elseif DamagedSortingMode==2 then table.sort(damagedElements, function(a,b) return a.id < b.id end)
- else table.sort(damagedElements, function(a,b) return a.percent < b.percent end)
- end
-
- -- Sort broken elements descending according to setting
- if BrokenSortingMode==1 then table.sort(brokenElements, function(a,b) return a.maxhp > b.maxhp end)
- else table.sort(brokenElements, function(a,b) return a.id < b.id end)
- end
-end
-
-function GenerateDamageData()
- if SimulationActive==true then
- return
- end
-
- local formerTotalShipHP = totalShipHP
- totalShipHP = 0
- totalShipMaxHP = 0
- totalShipIntegrity = 100
- elementsId = {}
- damagedElements = {}
- brokenElements = {}
- ElementCounter = 0
- healthyElements = 0
-
- elementsIdList = core.getElementIdList()
-
- for _,id in pairs(elementsIdList) do
- ElementCounter = ElementCounter + 1
- idHP = core.getElementHitPointsById(id) or 0
- idMaxHP = core.getElementMaxHitPointsById(id) or 0
-
- if SimulationMode then
- SimulationActive=true
- local dice =math.random(0,10)
- if dice < 2 then idHP = 0
- elseif dice >=2 and dice < 5 then idHP = idMaxHP
- else
- idHP = math.random(1, math.ceil(idMaxHP))
- end
- end
-
- totalShipHP = totalShipHP+idHP
- totalShipMaxHP = totalShipMaxHP+idMaxHP
-
- -- Is element damaged?
- if idMaxHP > idHP then
- idPos = core.getElementPositionById(id)
- idName = core.getElementNameById(id)
- idType = core.getElementTypeById(id)
- if idHP>0 then
- table.insert(damagedElements,
- {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP-idHP,
- percent = math.ceil(100/idMaxHP*idHP),
- pos =idPos
- }
- )
- -- if DebugMode then PrintDebug("Damaged: "..idName.." --- Type: "..idType.."") end
- -- Is element broken?
- else
- table.insert(brokenElements,
- {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP-idHP,
- percent = 0,
- pos =idPos
- }
- )
- -- if DebugMode then PrintDebug("Broken: "..idName.." --- Type: "..idType.."") end
- end
- else
- healthyElements = healthyElements + 1
- end
- end
-
- -- Sort tables by current settings
- SortTables()
-
- -- Update clickAreas
-
-
- -- Determine total ship integrity
- totalShipIntegrity = string.format("%2.0f", 100/totalShipMaxHP*totalShipHP)
-
- -- Has anything changes since last check? If yes, force redrawing the screens
- if formerTotalShipHP ~= totalShipHP then
- forceRedraw=true
- formerTotalShipHP = totalShipHP
- else forceRedraw=false
- end
-end
-
-function DrawScreens()
- if #screens > 0 then
-
- local healthyColor = "#00aa00"
- local brokenColor = "#aa0000"
- local damagedColor = "#aaaa00"
- local integrityColor = "#aaaaaa"
- local healthyTextColor = "white"
- local brokenTextColor = "#ff4444"
- local damagedTextColor = "#ffff44"
- local integrityTextColor = "white"
-
- if #damagedElements ==0 then
- damagedColor = "#aaaaaa"
- damagedTextColor = "white"
- end
- if #brokenElements == 0 then
- brokenColor = "#aaaaaa"
- brokenTextColor = "white"
- end
-
- -- Draw Header
- screenOutput = [[
- ]]
-
- -- Draw main background
- screenOutput = screenOutput..
- [[
-
-
-
-
-
-
-
-
-
-
-
- ]]
-
- -- Draw Title and summary
- if SimulationActive==true then
- screenOutput = screenOutput..[[Simulated Report]]
- else
- screenOutput = screenOutput..[[Damage Report]]
- end
- screenOutput = screenOutput..
- [[SHIP ID ]]..shipID..[[
-
- Healthy
- ]]..healthyElements..[[
-
- Damaged
- ]]..#damagedElements..[[
-
- Broken
- ]]..#brokenElements..[[
-
- Integrity
- ]]..totalShipIntegrity..[[%]]
-
- -- Draw damage elements
- if #damagedElements > 0 then
- local damagedElementsToDraw = #damagedElements
- if damagedElementsToDraw>12 then damagedElementsToDraw=12 end
- if CurrentDamagedPage==math.ceil(#damagedElements/12) then damagedElementsToDraw = #damagedElements%12 end
- screenOutput = screenOutput..
- [[]]
- screenOutput = screenOutput .. [[]]
- if (DamagedSortingMode==2) then
- screenOutput = screenOutput ..[[ID]]
- else
- screenOutput = screenOutput ..[[ID]]
- end
- if UseMyElementNames==true then screenOutput = screenOutput ..[[Element Name]]
- else screenOutput = screenOutput ..[[Element Type]]
- end
-
- if (DamagedSortingMode==3) then
- screenOutput = screenOutput ..[[Health]]
- else
- screenOutput = screenOutput ..[[Health]]
- end
- if (DamagedSortingMode==1) then
- screenOutput = screenOutput ..[[Damage]]
- else
- screenOutput = screenOutput ..[[Damage]]
- end
-
- local i=0
- for j=1+(CurrentDamagedPage-1)*12,damagedElementsToDraw+(CurrentDamagedPage-1)*12,1 do
- i = i + 1
- local DP = damagedElements[j]
- screenOutput = screenOutput ..
- [[]]..string.format("%03.0f",DP.id)..[[]]
- if UseMyElementNames==true then
- screenOutput = screenOutput .. [[]]..string.format("%.25s", DP.name)..[[]]
- else
- screenOutput = screenOutput .. [[]]..string.format("%.25s", DP.type)..[[]]
- end
- screenOutput = screenOutput ..
- [[]]..DP.percent..[[%]]..
- [[]]..GenerateCommaValue(string.format("%.0f", DP.missinghp))..[[]]..
- [[]]
- end
- screenOutput = screenOutput ..
- [[
-
- ]]
-
- if #damagedElements>12 then
- screenOutput = screenOutput ..
- [[Page ]]..CurrentDamagedPage.." of "..math.ceil(#damagedElements/12)..[[]]
-
- if CurrentDamagedPage < math.ceil(#damagedElements/12) then
- screenOutput = screenOutput ..
- [[
-
-
- ]]
- UpdateClickArea( "DamagedPageDown", { id = "DamagedPageDown", x1 = 70, x2 = 270, y1 = 350+11+(damagedElementsToDraw+1)*50, y2 = 350+11+50+(damagedElementsToDraw+1)*50 } )
- else
- DisableClickArea( "DamagedPageDown" )
- end
-
- if CurrentDamagedPage > 1 then
- screenOutput = screenOutput ..
- [[
-
-
- ]]
- UpdateClickArea( "DamagedPageUp", { id = "DamagedPageUp", x1 = 280, x2 = 480, y1 = 350+11+(damagedElementsToDraw+1)*50, y2 = 350+11+50+(damagedElementsToDraw+1)*50 } )
- else
- DisableClickArea( "DamagedPageUp" )
- end
- end
-
-
-
-
- end
-
- -- Draw broken elements
- if #brokenElements > 0 then
- local brokenElementsToDraw = #brokenElements
- if brokenElementsToDraw>12 then brokenElementsToDraw=12 end
- if CurrentBrokenPage==math.ceil(#brokenElements/12) then brokenElementsToDraw = #brokenElements%12 end
- screenOutput = screenOutput..
- [[]]
- screenOutput = screenOutput .. [[]]
- if (BrokenSortingMode==2) then
- screenOutput = screenOutput ..[[ID]]
- else
- screenOutput = screenOutput ..[[ID]]
- end
- if UseMyElementNames==true then screenOutput = screenOutput .. [[Element Name]]
- else screenOutput = screenOutput .. [[Element Type]]
- end
- if (BrokenSortingMode==1) then
- screenOutput = screenOutput ..[[Damage]]
- else
- screenOutput = screenOutput ..[[Damage]]
- end
-
- local i=0
- for j=1+(CurrentBrokenPage-1)*12,brokenElementsToDraw+(CurrentBrokenPage-1)*12,1 do
- i = i + 1
- local DP = brokenElements[j]
- screenOutput = screenOutput ..
- [[]]..string.format("%03.0f",DP.id)..[[]]
- if UseMyElementNames==true then
- screenOutput = screenOutput .. [[]]..string.format("%.25s", DP.name)..[[]]
- else
- screenOutput = screenOutput .. [[]]..string.format("%.25s", DP.type)..[[]]
- end
- screenOutput = screenOutput ..
- [[]]..GenerateCommaValue(string.format("%.0f", DP.missinghp))..[[]]..
- [[]]
- end
-
- screenOutput = screenOutput..
- [[
-
- ]]
-
-
- if #brokenElements>12 then
- screenOutput = screenOutput ..
- [[Page ]]..CurrentBrokenPage.." of "..math.ceil(#brokenElements/12)..[[]]
-
- if CurrentBrokenPage > 1 then
- screenOutput = screenOutput ..
- [[
-
-
- ]]
- UpdateClickArea( "BrokenPageUp", { id = "BrokenPageUp", x1 = 1442, x2 = 1642, y1 = 350+11+(brokenElementsToDraw+1)*50, y2 = 350+11+50+(brokenElementsToDraw+1)*50 } )
- else
- DisableClickArea( "BrokenPageUp" )
- end
-
- if CurrentBrokenPage < math.ceil(#brokenElements/12) then
- screenOutput = screenOutput ..
- [[
-
-
- ]]
- UpdateClickArea( "BrokenPageDown", { id = "BrokenPageDown", x1 = 1652, x2 = 1852, y1 = 350+11+(brokenElementsToDraw+1)*50, y2 = 350+11+50+(brokenElementsToDraw+1)*50 } )
- else
- DisableClickArea( "BrokenPageDown" )
- end
- end
-
-
-
- end
-
- -- Draw damage summary
- if #damagedElements>0 or #brokenElements > 0 then
- screenOutput = screenOutput..
- [[]]..GenerateCommaValue(string.format("%.0f", totalShipMaxHP-totalShipHP))..[[ HP damage in total]]
-
- end
-
- screenOutput = screenOutput..[[]]
-
- DrawSVG(screenOutput)
-
- forceRedraw=false
- end
-end
-
------------------------------------------------
--- Execute
------------------------------------------------
-
-unit.hide()
-ClearConsole()
-PrintDebug("SCRIPT STARTED", true)
-
-InitiateSlots()
-SwitchScreens(true)
-InitiateClickAreas()
-
-if core == nil then
- DrawCenteredText("ERROR: No core connected.")
- PrintError("ERROR: No core connected.")
- goto exit
-else
- shipID = core.getConstructId()
-end
-
-GenerateDamageData()
-if forceRedraw then
- DrawScreens()
-end
-
-unit.setTimer('UpdateData', UpdateInterval)
-
-::exit::
\ No newline at end of file
diff --git a/src/DamageReport_1_4_UnitStart.lua b/src/DamageReport_1_4_UnitStart.lua
deleted file mode 100644
index c693d2c..0000000
--- a/src/DamageReport_1_4_UnitStart.lua
+++ /dev/null
@@ -1,738 +0,0 @@
---[[
- DamageReport v1.4
-
- Created By Dorian Gray
-
- Discord: Dorian Gray#2623
- InGame: DorianGray
- GitHub: https://github.com/DorianTheGrey/DU-DamageReport
-
- GNU Public License 3.0. Use whatever you want, be so kind to leave credit.
-
- Thanks to Jericho, Dmentia and Archaegeo for learning from their fine scripts.
-]]
-
------------------------------------------------
--- CONFIG
------------------------------------------------
-
-UseMyElementNames = false --export: If you active this, the display will not show the element type of damaged/broken elements but the name you gave them (truncated to 25 characters)
-UpdateInterval = 1 --export: Interval in seconds between updates of the calculations and (if anything changed) redrawing to the screen(s). You need to restart the script after changing this value.
-SimulationMode = false --export Randomize simluated damage on elements to check out the functionality of this script. And, no, your elements won't be harmed in the process :) You need to restart the script after changing this value.
-
-DebugMode = false -- Activate if you want some console messages
-VersionNumber = 1.4 -- Version number
-
-core = nil
-screens = {}
-
-shipID = 0
-forceRedraw = false
-SimulationActive=false
-
-clickAreas = {}
-DamagedSortingMode = 1 -- Define default sorting mode for damaged elements. 1 to sort by damage amount, 2 to sort by element id, 3 to sort by damage percent,
-BrokenSortingMode = 1 -- Define default sorting mode for broken elements. 1 to sort by damage amount, 2 to sort by element id
-
-HUDMode = false
-CurrentDamagedPage = 1
-CurrentBrokenPage = 1
-
-totalShipHP = 0
-totalShipMaxHP = 0
-totalShipIntegrity = 100
-elementsId = {}
-damagedElements = {}
-brokenElements = {}
-ElementCounter = 0
-healthyElements = 0
-
-OkayCenterMessage = "All systems nominal."
-
------------------------------------------------
--- FUNCTIONS
------------------------------------------------
-
-
-function GenerateCommaValue(amount)
- local formatted = amount
- while true do
- formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
- if (k==0) then break end
- end
- return formatted
-end
-
-function PrintDebug(output, highlight)
- highlight = highlight or false
- if DebugMode then
- if highlight then system.print("------------------------------------------------------------------------") end
- system.print(output)
- if highlight then system.print("------------------------------------------------------------------------") end
- end
-end
-
-function PrintError(output)
- system.print(output)
-end
-
-function DrawCenteredText(output)
- for i=1,#screens,1 do
- screens[i].setCenteredText(output)
- end
-end
-
-function DrawSVG(output)
- for i=1,#screens,1 do
- screens[i].setSVG(output)
- end
-end
-
-function ClearConsole()
- for i=1,10,1 do
- PrintDebug()
- end
-end
-
-function SwitchScreens(state)
- state = state or true
- if #screens > 0 then
- for i=1,#screens,1 do
- if state then
- screens[i].clear()
- screens[i].activate()
- else
- screens[i].deactivate()
- screens[i].clear()
- end
- end
- end
-end
-
-function InitiateSlots()
- for slot_name, slot in pairs(unit) do
- if
- type(slot) == "table"
- and type(slot.export) == "table"
- and slot.getElementClass
- then
- if slot.getElementClass():lower():find("coreunit") then
- core = slot
- end
- if slot.getElementClass():lower():find("screenunit") then
- screens[#screens + 1] = slot
- end
- end
- end
-end
-
-function AddClickArea(newEntry)
- table.insert(clickAreas, newEntry)
-end
-
-function RemoveFromClickAreas(candidate)
- for k, v in pairs(clickAreas) do
- if v.id==candidate then
- clickAreas[k]=nil
- break
- end
- end
-end
-
-function UpdateClickArea(candidate, newEntry)
- for k, v in pairs(clickAreas) do
- if v.id==candidate then
- clickAreas[k]=newEntry
- break
- end
- end
-end
-
-function DisableClickArea(candidate)
- for k, v in pairs(clickAreas) do
- if v.id==candidate then
- UpdateClickArea(candidate, { id = candidate, x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )
- break
- end
- end
-end
-
-function InitiateClickAreas()
- clickAreas = {}
- AddClickArea( { id = "DamagedDamage", x1 = 725, x2 = 870, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "DamagedHealth", x1 = 520, x2 = 655, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "DamagedID", x1 = 90, x2 = 150, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "BrokenDamage", x1 = 1675, x2 = 1835, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "BrokenID", x1 = 1050, x2 = 1110, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "ToggleSimulation", x1 = 65, x2 = 660, y1 = 100, y2 = 145 } )
- AddClickArea( { id = "ToggleElementLabel", x1 = 225, x2 = 460, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "ToggleElementLabel2", x1 = 1185, x2 = 1440, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "DamagedPageDown", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )
- AddClickArea( { id = "DamagedPageUp", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )
- AddClickArea( { id = "BrokenPageDown", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )
- AddClickArea( { id = "BrokenPageUp", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )
-end
-
-function FlushClickAreas()
- clickAreas = {}
-end
-
-function CheckClick(x, y)
- PrintDebug("Clicked at "..x.." / "..y)
- local HitTarget=""
- for k, v in pairs(clickAreas) do
- if v and x>=v.x1 and x<=v.x2 and y>=v.y1 and y<=v.y2 then
- HitTarget=v.id
- break
- end
- end
- if HitTarget=="DamagedDamage" then
- DamagedSortingMode=1
- CurrentDamagedPage=1
- SortTables()
- DrawScreens()
- elseif HitTarget=="DamagedHealth" then
- DamagedSortingMode=3
- CurrentDamagedPage=1
- SortTables()
- DrawScreens()
- elseif HitTarget=="DamagedID" then
- DamagedSortingMode=2
- CurrentDamagedPage=1
- SortTables()
- DrawScreens()
- elseif HitTarget=="BrokenDamage" then
- BrokenSortingMode=1
- CurrentBrokenPage=1
- SortTables()
- DrawScreens()
- elseif HitTarget=="BrokenID" then
- BrokenSortingMode=2
- CurrentBrokenPage=1
- SortTables()
- DrawScreens()
- elseif HitTarget=="DamagedPageDown" then
- CurrentDamagedPage = CurrentDamagedPage + 1
- if CurrentDamagedPage > math.ceil(#damagedElements/12) then CurrentDamagedPage = math.ceil(#damagedElements/12) end
- DrawScreens()
- elseif HitTarget=="DamagedPageUp" then
- CurrentDamagedPage = CurrentDamagedPage - 1
- if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end
- DrawScreens()
- elseif HitTarget=="BrokenPageDown" then
- CurrentBrokenPage = CurrentBrokenPage + 1
- if CurrentBrokenPage > math.ceil(#brokenElements/12) then CurrentBrokenPage = math.ceil(#brokenElements/12) end
- DrawScreens()
- elseif HitTarget=="BrokenPageUp" then
- CurrentBrokenPage = CurrentBrokenPage - 1
- if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end
- DrawScreens()
- elseif HitTarget=="ToggleSimulation" then
- CurrentDamagedPage=1
- CurrentBrokenPage=1
- if SimulationMode == true then
- SimulationMode = false
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- DrawScreens()
- else
- SimulationMode = true
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- DrawScreens()
- end
- elseif HitTarget=="ToggleElementLabel" or HitTarget=="ToggleElementLabel2" then
- if UseMyElementNames == true then
- UseMyElementNames = false
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- DrawScreens()
- else
- UseMyElementNames = true
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- DrawScreens()
- end
- end
-end
-
-function SortTables()
- -- Sort damaged elements descending by percent damaged according to setting
- if DamagedSortingMode==1 then table.sort(damagedElements, function(a,b) return a.missinghp > b.missinghp end)
- elseif DamagedSortingMode==2 then table.sort(damagedElements, function(a,b) return a.id < b.id end)
- else table.sort(damagedElements, function(a,b) return a.percent < b.percent end)
- end
-
- -- Sort broken elements descending according to setting
- if BrokenSortingMode==1 then table.sort(brokenElements, function(a,b) return a.maxhp > b.maxhp end)
- else table.sort(brokenElements, function(a,b) return a.id < b.id end)
- end
-end
-
-function GenerateDamageData()
- if SimulationActive==true then
- return
- end
-
- local formerTotalShipHP = totalShipHP
- totalShipHP = 0
- totalShipMaxHP = 0
- totalShipIntegrity = 100
- elementsId = {}
- damagedElements = {}
- brokenElements = {}
- ElementCounter = 0
- healthyElements = 0
-
- elementsIdList = core.getElementIdList()
-
- for _,id in pairs(elementsIdList) do
- ElementCounter = ElementCounter + 1
- idHP = core.getElementHitPointsById(id) or 0
- idMaxHP = core.getElementMaxHitPointsById(id) or 0
-
- if SimulationMode then
- SimulationActive=true
- local dice =math.random(0,10)
- if dice < 2 then idHP = 0
- elseif dice >=2 and dice < 5 then idHP = idMaxHP
- else
- idHP = math.random(1, math.ceil(idMaxHP))
- end
- end
-
- totalShipHP = totalShipHP+idHP
- totalShipMaxHP = totalShipMaxHP+idMaxHP
-
- -- Is element damaged?
- if idMaxHP > idHP then
- idPos = core.getElementPositionById(id)
- idName = core.getElementNameById(id)
- idType = core.getElementTypeById(id)
- if idHP>0 then
- table.insert(damagedElements,
- {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP-idHP,
- percent = math.ceil(100/idMaxHP*idHP),
- pos =idPos
- }
- )
- -- if DebugMode then PrintDebug("Damaged: "..idName.." --- Type: "..idType.."") end
- -- Is element broken?
- else
- table.insert(brokenElements,
- {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP-idHP,
- percent = 0,
- pos =idPos
- }
- )
- -- if DebugMode then PrintDebug("Broken: "..idName.." --- Type: "..idType.."") end
- end
- else
- healthyElements = healthyElements + 1
- end
- end
-
- -- Sort tables by current settings
- SortTables()
-
- -- Update clickAreas
-
-
- -- Determine total ship integrity
- totalShipIntegrity = string.format("%2.0f", 100/totalShipMaxHP*totalShipHP)
-
- -- Has anything changes since last check? If yes, force redrawing the screens
- if formerTotalShipHP ~= totalShipHP then
- forceRedraw=true
- formerTotalShipHP = totalShipHP
- else forceRedraw=false
- end
-end
-
-function GetAllSystemsNominalBackground()
- local output=""
- output = output..
- [[
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function DrawScreens()
- if #screens > 0 then
-
- local healthyColor = "#00aa00"
- local brokenColor = "#aa0000"
- local damagedColor = "#aaaa00"
- local integrityColor = "#aaaaaa"
- local healthyTextColor = "white"
- local brokenTextColor = "#ff4444"
- local damagedTextColor = "#ffff44"
- local integrityTextColor = "white"
-
- if #damagedElements ==0 then
- damagedColor = "#aaaaaa"
- damagedTextColor = "white"
- end
- if #brokenElements == 0 then
- brokenColor = "#aaaaaa"
- brokenTextColor = "white"
- end
-
- -- Draw Header
- screenOutput = [[
- ]]
-
- -- Draw main background
- screenOutput = screenOutput..
- [[
-
-
-
-
-
-
-
-
-
-
-
- ]]
-
- -- Draw Title and summary
- if SimulationActive==true then
- screenOutput = screenOutput..[[Simulated Report]]
- else
- screenOutput = screenOutput..[[Damage Report]]
- end
- screenOutput = screenOutput..
- [[SHIP ID ]]..shipID..[[
-
- Healthy
- ]]..healthyElements..[[
-
- Damaged
- ]]..#damagedElements..[[
-
- Broken
- ]]..#brokenElements..[[
-
- Integrity
- ]]..totalShipIntegrity..[[%]]
-
- -- Draw damage elements
-
- if #damagedElements > 0 then
- local damagedElementsToDraw = #damagedElements
- if damagedElementsToDraw>12 then damagedElementsToDraw=12 end
- if CurrentDamagedPage==math.ceil(#damagedElements/12) then damagedElementsToDraw = #damagedElements%12 end
- screenOutput = screenOutput..
- [[]]
- screenOutput = screenOutput .. [[]]
- if (DamagedSortingMode==2) then
- screenOutput = screenOutput ..[[ID]]
- else
- screenOutput = screenOutput ..[[ID]]
- end
- if UseMyElementNames==true then screenOutput = screenOutput ..[[Element Name]]
- else screenOutput = screenOutput ..[[Element Type]]
- end
-
- if (DamagedSortingMode==3) then
- screenOutput = screenOutput ..[[Health]]
- else
- screenOutput = screenOutput ..[[Health]]
- end
- if (DamagedSortingMode==1) then
- screenOutput = screenOutput ..[[Damage]]
- else
- screenOutput = screenOutput ..[[Damage]]
- end
-
- local i=0
- for j=1+(CurrentDamagedPage-1)*12,damagedElementsToDraw+(CurrentDamagedPage-1)*12,1 do
- i = i + 1
- local DP = damagedElements[j]
- screenOutput = screenOutput ..
- [[]]..string.format("%03.0f",DP.id)..[[]]
- if UseMyElementNames==true then
- screenOutput = screenOutput .. [[]]..string.format("%.25s", DP.name)..[[]]
- else
- screenOutput = screenOutput .. [[]]..string.format("%.25s", DP.type)..[[]]
- end
- screenOutput = screenOutput ..
- [[]]..DP.percent..[[%]]..
- [[]]..GenerateCommaValue(string.format("%.0f", DP.missinghp))..[[]]..
- [[]]
- end
- screenOutput = screenOutput ..
- [[
-
- ]]
-
- if #damagedElements>12 then
- screenOutput = screenOutput ..
- [[Page ]]..CurrentDamagedPage.." of "..math.ceil(#damagedElements/12)..[[]]
-
- if CurrentDamagedPage < math.ceil(#damagedElements/12) then
- screenOutput = screenOutput ..
- [[
-
-
- ]]
- UpdateClickArea( "DamagedPageDown", { id = "DamagedPageDown", x1 = 70, x2 = 270, y1 = 350+11+(damagedElementsToDraw+1)*50, y2 = 350+11+50+(damagedElementsToDraw+1)*50 } )
- else
- DisableClickArea( "DamagedPageDown" )
- end
-
- if CurrentDamagedPage > 1 then
- screenOutput = screenOutput ..
- [[
-
-
- ]]
- UpdateClickArea( "DamagedPageUp", { id = "DamagedPageUp", x1 = 280, x2 = 480, y1 = 350+11+(damagedElementsToDraw+1)*50, y2 = 350+11+50+(damagedElementsToDraw+1)*50 } )
- else
- DisableClickArea( "DamagedPageUp" )
- end
- end
-
-
-
-
- end
-
- -- Draw broken elements
- if #brokenElements > 0 then
- local brokenElementsToDraw = #brokenElements
- if brokenElementsToDraw>12 then brokenElementsToDraw=12 end
- if CurrentBrokenPage==math.ceil(#brokenElements/12) then brokenElementsToDraw = #brokenElements%12 end
- screenOutput = screenOutput..
- [[]]
- screenOutput = screenOutput .. [[]]
- if (BrokenSortingMode==2) then
- screenOutput = screenOutput ..[[ID]]
- else
- screenOutput = screenOutput ..[[ID]]
- end
- if UseMyElementNames==true then screenOutput = screenOutput .. [[Element Name]]
- else screenOutput = screenOutput .. [[Element Type]]
- end
- if (BrokenSortingMode==1) then
- screenOutput = screenOutput ..[[Damage]]
- else
- screenOutput = screenOutput ..[[Damage]]
- end
-
- local i=0
- for j=1+(CurrentBrokenPage-1)*12,brokenElementsToDraw+(CurrentBrokenPage-1)*12,1 do
- i = i + 1
- local DP = brokenElements[j]
- screenOutput = screenOutput ..
- [[]]..string.format("%03.0f",DP.id)..[[]]
- if UseMyElementNames==true then
- screenOutput = screenOutput .. [[]]..string.format("%.25s", DP.name)..[[]]
- else
- screenOutput = screenOutput .. [[]]..string.format("%.25s", DP.type)..[[]]
- end
- screenOutput = screenOutput ..
- [[]]..GenerateCommaValue(string.format("%.0f", DP.missinghp))..[[]]..
- [[]]
- end
-
- screenOutput = screenOutput..
- [[
-
- ]]
-
-
- if #brokenElements>12 then
- screenOutput = screenOutput ..
- [[Page ]]..CurrentBrokenPage.." of "..math.ceil(#brokenElements/12)..[[]]
-
- if CurrentBrokenPage > 1 then
- screenOutput = screenOutput ..
- [[
-
-
- ]]
- UpdateClickArea( "BrokenPageUp", { id = "BrokenPageUp", x1 = 1442, x2 = 1642, y1 = 350+11+(brokenElementsToDraw+1)*50, y2 = 350+11+50+(brokenElementsToDraw+1)*50 } )
- else
- DisableClickArea( "BrokenPageUp" )
- end
-
- if CurrentBrokenPage < math.ceil(#brokenElements/12) then
- screenOutput = screenOutput ..
- [[
-
-
- ]]
- UpdateClickArea( "BrokenPageDown", { id = "BrokenPageDown", x1 = 1652, x2 = 1852, y1 = 350+11+(brokenElementsToDraw+1)*50, y2 = 350+11+50+(brokenElementsToDraw+1)*50 } )
- else
- DisableClickArea( "BrokenPageDown" )
- end
- end
-
-
-
- end
-
- -- Draw damage summary
- if #damagedElements>0 or #brokenElements > 0 then
- screenOutput = screenOutput..
- [[]]..GenerateCommaValue(string.format("%.0f", totalShipMaxHP-totalShipHP))..[[ HP damage in total]]
- else
- screenOutput = screenOutput..
- [[]]..
- GetAllSystemsNominalBackground()..
- [[]]..
- [[]]..OkayCenterMessage..[[]]
- end
-
- -- Draw HUD Mode button
- screenOutput = screenOutput..[[]]
-
- DrawSVG(screenOutput)
-
- forceRedraw=false
- end
-end
-
------------------------------------------------
--- Execute
------------------------------------------------
-
-unit.hide()
-ClearConsole()
-PrintDebug("SCRIPT STARTED", true)
-
-InitiateSlots()
-SwitchScreens(true)
-InitiateClickAreas()
-
-if core == nil then
- DrawCenteredText("ERROR: No core connected.")
- PrintError("ERROR: No core connected.")
- goto exit
-else
- shipID = core.getConstructId()
-end
-
-GenerateDamageData()
-if forceRedraw then
- DrawScreens()
-end
-
-unit.setTimer('UpdateData', UpdateInterval)
-
-::exit::
\ No newline at end of file
diff --git a/src/DamageReport_1_51_UnitStart.lua b/src/DamageReport_1_51_UnitStart.lua
deleted file mode 100644
index 0178364..0000000
--- a/src/DamageReport_1_51_UnitStart.lua
+++ /dev/null
@@ -1,743 +0,0 @@
---[[
- DamageReport v1.52
-
- Created By Dorian Gray
-
- Discord: Dorian Gray#2623
- InGame: DorianGray
- GitHub: https://github.com/DorianTheGrey/DU-DamageReport
-
- GNU Public License 3.0. Use whatever you want, be so kind to leave credit.
-
- Thanks to Jericho, Dmentia and Archaegeo for learning from their fine scripts.
-]]
-
------------------------------------------------
--- CONFIG
------------------------------------------------
-
-UseMyElementNames = false --export: If you active this, the display will not show the element type of damaged/broken elements but the name you gave them (truncated to 25 characters)
-UpdateInterval = 1 --export: Interval in seconds between updates of the calculations and (if anything changed) redrawing to the screen(s). You need to restart the script after changing this value.
-SimulationMode = false --export Randomize simluated damage on elements to check out the functionality of this script. And, no, your elements won't be harmed in the process :) You need to restart the script after changing this value.
-YourShipsName = "Enter here" --export Enter your ship name here if you want it displayed instead of the ship's ID. YOU NEED TO LEAVE THE QUOTATION MARKS.
-
-DebugMode = false -- Activate if you want some console messages
-VersionNumber = 1.52 -- Version number
-
-core = nil
-screens = {}
-
-shipID = 0
-forceRedraw = false
-SimulationActive=false
-
-clickAreas = {}
-DamagedSortingMode = 1 -- Define default sorting mode for damaged elements. 1 to sort by damage amount, 2 to sort by element id, 3 to sort by damage percent,
-BrokenSortingMode = 1 -- Define default sorting mode for broken elements. 1 to sort by damage amount, 2 to sort by element id
-
-HUDMode = false
-CurrentDamagedPage = 1
-CurrentBrokenPage = 1
-
-totalShipHP = 0
-totalShipMaxHP = 0
-totalShipIntegrity = 100
-elementsId = {}
-damagedElements = {}
-brokenElements = {}
-ElementCounter = 0
-healthyElements = 0
-
-OkayCenterMessage = "All systems nominal."
-
------------------------------------------------
--- FUNCTIONS
------------------------------------------------
-
-
-function GenerateCommaValue(amount)
- local formatted = amount
- while true do
- formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
- if (k==0) then break end
- end
- return formatted
-end
-
-function PrintDebug(output, highlight)
- highlight = highlight or false
- if DebugMode then
- if highlight then system.print("------------------------------------------------------------------------") end
- system.print(output)
- if highlight then system.print("------------------------------------------------------------------------") end
- end
-end
-
-function PrintError(output)
- system.print(output)
-end
-
-function DrawCenteredText(output)
- for i=1,#screens,1 do
- screens[i].setCenteredText(output)
- end
-end
-
-function DrawSVG(output)
- for i=1,#screens,1 do
- screens[i].setSVG(output)
- end
-end
-
-function ClearConsole()
- for i=1,10,1 do
- PrintDebug()
- end
-end
-
-function SwitchScreens(state)
- state = state or true
- if #screens > 0 then
- for i=1,#screens,1 do
- if state then
- screens[i].clear()
- screens[i].activate()
- else
- screens[i].deactivate()
- screens[i].clear()
- end
- end
- end
-end
-
-function InitiateSlots()
- for slot_name, slot in pairs(unit) do
- if
- type(slot) == "table"
- and type(slot.export) == "table"
- and slot.getElementClass
- then
- if slot.getElementClass():lower():find("coreunit") then
- core = slot
- end
- if slot.getElementClass():lower():find("screenunit") then
- screens[#screens + 1] = slot
- end
- end
- end
-end
-
-function AddClickArea(newEntry)
- table.insert(clickAreas, newEntry)
-end
-
-function RemoveFromClickAreas(candidate)
- for k, v in pairs(clickAreas) do
- if v.id==candidate then
- clickAreas[k]=nil
- break
- end
- end
-end
-
-function UpdateClickArea(candidate, newEntry)
- for k, v in pairs(clickAreas) do
- if v.id==candidate then
- clickAreas[k]=newEntry
- break
- end
- end
-end
-
-function DisableClickArea(candidate)
- for k, v in pairs(clickAreas) do
- if v.id==candidate then
- UpdateClickArea(candidate, { id = candidate, x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )
- break
- end
- end
-end
-
-function InitiateClickAreas()
- clickAreas = {}
- AddClickArea( { id = "DamagedDamage", x1 = 725, x2 = 870, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "DamagedHealth", x1 = 520, x2 = 655, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "DamagedID", x1 = 90, x2 = 150, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "BrokenDamage", x1 = 1675, x2 = 1835, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "BrokenID", x1 = 1050, x2 = 1110, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "ToggleSimulation", x1 = 65, x2 = 660, y1 = 100, y2 = 145 } )
- AddClickArea( { id = "ToggleElementLabel", x1 = 225, x2 = 460, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "ToggleElementLabel2", x1 = 1185, x2 = 1440, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "ToggleHudMode", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )
- AddClickArea( { id = "DamagedPageDown", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )
- AddClickArea( { id = "DamagedPageUp", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )
- AddClickArea( { id = "BrokenPageDown", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )
- AddClickArea( { id = "BrokenPageUp", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )
-end
-
-function FlushClickAreas()
- clickAreas = {}
-end
-
-function CheckClick(x, y)
- PrintDebug("Clicked at "..x.." / "..y)
- local HitTarget=""
- for k, v in pairs(clickAreas) do
- if v and x>=v.x1 and x<=v.x2 and y>=v.y1 and y<=v.y2 then
- HitTarget=v.id
- break
- end
- end
- if HitTarget=="DamagedDamage" then
- DamagedSortingMode=1
- CurrentDamagedPage=1
- SortTables()
- DrawScreens()
- elseif HitTarget=="DamagedHealth" then
- DamagedSortingMode=3
- CurrentDamagedPage=1
- SortTables()
- DrawScreens()
- elseif HitTarget=="DamagedID" then
- DamagedSortingMode=2
- CurrentDamagedPage=1
- SortTables()
- DrawScreens()
- elseif HitTarget=="BrokenDamage" then
- BrokenSortingMode=1
- CurrentBrokenPage=1
- SortTables()
- DrawScreens()
- elseif HitTarget=="BrokenID" then
- BrokenSortingMode=2
- CurrentBrokenPage=1
- SortTables()
- DrawScreens()
- elseif HitTarget=="DamagedPageDown" then
- CurrentDamagedPage = CurrentDamagedPage + 1
- if CurrentDamagedPage > math.ceil(#damagedElements/12) then CurrentDamagedPage = math.ceil(#damagedElements/12) end
- DrawScreens()
- elseif HitTarget=="DamagedPageUp" then
- CurrentDamagedPage = CurrentDamagedPage - 1
- if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end
- DrawScreens()
- elseif HitTarget=="BrokenPageDown" then
- CurrentBrokenPage = CurrentBrokenPage + 1
- if CurrentBrokenPage > math.ceil(#brokenElements/12) then CurrentBrokenPage = math.ceil(#brokenElements/12) end
- DrawScreens()
- elseif HitTarget=="BrokenPageUp" then
- CurrentBrokenPage = CurrentBrokenPage - 1
- if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end
- DrawScreens()
- elseif HitTarget=="ToggleSimulation" then
- CurrentDamagedPage=1
- CurrentBrokenPage=1
- if SimulationMode == true then
- SimulationMode = false
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- DrawScreens()
- else
- SimulationMode = true
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- DrawScreens()
- end
- elseif HitTarget=="ToggleElementLabel" or HitTarget=="ToggleElementLabel2" then
- if UseMyElementNames == true then
- UseMyElementNames = false
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- DrawScreens()
- else
- UseMyElementNames = true
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- DrawScreens()
- end
- end
-end
-
-function SortTables()
- -- Sort damaged elements descending by percent damaged according to setting
- if DamagedSortingMode==1 then table.sort(damagedElements, function(a,b) return a.missinghp > b.missinghp end)
- elseif DamagedSortingMode==2 then table.sort(damagedElements, function(a,b) return a.id < b.id end)
- else table.sort(damagedElements, function(a,b) return a.percent < b.percent end)
- end
-
- -- Sort broken elements descending according to setting
- if BrokenSortingMode==1 then table.sort(brokenElements, function(a,b) return a.maxhp > b.maxhp end)
- else table.sort(brokenElements, function(a,b) return a.id < b.id end)
- end
-end
-
-function GenerateDamageData()
- if SimulationActive==true then
- return
- end
-
- local formerTotalShipHP = totalShipHP
- totalShipHP = 0
- totalShipMaxHP = 0
- totalShipIntegrity = 100
- elementsId = {}
- damagedElements = {}
- brokenElements = {}
- ElementCounter = 0
- healthyElements = 0
-
- elementsIdList = core.getElementIdList()
-
- for _,id in pairs(elementsIdList) do
- ElementCounter = ElementCounter + 1
- idHP = core.getElementHitPointsById(id) or 0
- idMaxHP = core.getElementMaxHitPointsById(id) or 0
-
- if SimulationMode then
- SimulationActive=true
- local dice =math.random(0,10)
- if dice < 2 then idHP = 0
- elseif dice >=2 and dice < 5 then idHP = idMaxHP
- else
- idHP = math.random(1, math.ceil(idMaxHP))
- end
- end
-
- totalShipHP = totalShipHP+idHP
- totalShipMaxHP = totalShipMaxHP+idMaxHP
-
- -- Is element damaged?
- if idMaxHP > idHP then
- idPos = core.getElementPositionById(id)
- idName = core.getElementNameById(id)
- idType = core.getElementTypeById(id)
- if idHP>0 then
- table.insert(damagedElements,
- {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP-idHP,
- percent = math.ceil(100/idMaxHP*idHP),
- pos =idPos
- }
- )
- -- if DebugMode then PrintDebug("Damaged: "..idName.." --- Type: "..idType.."") end
- -- Is element broken?
- else
- table.insert(brokenElements,
- {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP-idHP,
- percent = 0,
- pos =idPos
- }
- )
- -- if DebugMode then PrintDebug("Broken: "..idName.." --- Type: "..idType.."") end
- end
- else
- healthyElements = healthyElements + 1
- end
- end
-
- -- Sort tables by current settings
- SortTables()
-
- -- Update clickAreas
-
-
- -- Determine total ship integrity
- totalShipIntegrity = string.format("%2.0f", 100/totalShipMaxHP*totalShipHP)
-
- -- Has anything changes since last check? If yes, force redrawing the screens
- if formerTotalShipHP ~= totalShipHP then
- forceRedraw=true
- formerTotalShipHP = totalShipHP
- else forceRedraw=false
- end
-end
-
-function GetAllSystemsNominalBackground()
- local output=""
- output = output..
- [[
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function DrawScreens()
- if #screens > 0 then
-
- local healthyColor = "#00aa00"
- local brokenColor = "#aa0000"
- local damagedColor = "#aaaa00"
- local integrityColor = "#aaaaaa"
- local healthyTextColor = "white"
- local brokenTextColor = "#ff4444"
- local damagedTextColor = "#ffff44"
- local integrityTextColor = "white"
-
- if #damagedElements ==0 then
- damagedColor = "#aaaaaa"
- damagedTextColor = "white"
- end
- if #brokenElements == 0 then
- brokenColor = "#aaaaaa"
- brokenTextColor = "white"
- end
-
- -- Draw Header
- screenOutput = [[
- ]]
-
- -- Draw main background
- screenOutput = screenOutput..
- [[
-
-
-
-
-
-
-
-
-
-
-
- ]]
-
- -- Draw Title and summary
- if SimulationActive==true then
- screenOutput = screenOutput..[[Simulated Report]]
- else
- screenOutput = screenOutput..[[Damage Report]]
- end
- if YourShipsName==nil or YourShipsName=="" or YourShipsName=="Enter here" then screenOutput = screenOutput.. [[SHIP ID ]]..shipID..[[]]
- else screenOutput = screenOutput.. [[]]..YourShipsName..[[]]
- end
- screenOutput = screenOutput..
- [[
- Healthy
- ]]..healthyElements..[[
-
- Damaged
- ]]..#damagedElements..[[
-
- Broken
- ]]..#brokenElements..[[
-
- Integrity
- ]]..totalShipIntegrity..[[%]]
-
- -- Draw damage elements
-
- if #damagedElements > 0 then
- local damagedElementsToDraw = #damagedElements
- if damagedElementsToDraw>12 then damagedElementsToDraw=12 end
- if CurrentDamagedPage==math.ceil(#damagedElements/12) then damagedElementsToDraw = #damagedElements%12 end
- screenOutput = screenOutput..
- [[]]
- screenOutput = screenOutput .. [[]]
- if (DamagedSortingMode==2) then
- screenOutput = screenOutput ..[[ID]]
- else
- screenOutput = screenOutput ..[[ID]]
- end
- if UseMyElementNames==true then screenOutput = screenOutput ..[[Element Name]]
- else screenOutput = screenOutput ..[[Element Type]]
- end
-
- if (DamagedSortingMode==3) then
- screenOutput = screenOutput ..[[Health]]
- else
- screenOutput = screenOutput ..[[Health]]
- end
- if (DamagedSortingMode==1) then
- screenOutput = screenOutput ..[[Damage]]
- else
- screenOutput = screenOutput ..[[Damage]]
- end
-
- local i=0
- for j=1+(CurrentDamagedPage-1)*12,damagedElementsToDraw+(CurrentDamagedPage-1)*12,1 do
- i = i + 1
- local DP = damagedElements[j]
- screenOutput = screenOutput ..
- [[]]..string.format("%03.0f",DP.id)..[[]]
- if UseMyElementNames==true then
- screenOutput = screenOutput .. [[]]..string.format("%.25s", DP.name)..[[]]
- else
- screenOutput = screenOutput .. [[]]..string.format("%.25s", DP.type)..[[]]
- end
- screenOutput = screenOutput ..
- [[]]..DP.percent..[[%]]..
- [[]]..GenerateCommaValue(string.format("%.0f", DP.missinghp))..[[]]..
- [[]]
- end
- screenOutput = screenOutput ..
- [[
-
- ]]
-
- if #damagedElements>12 then
- screenOutput = screenOutput ..
- [[Page ]]..CurrentDamagedPage.." of "..math.ceil(#damagedElements/12)..[[]]
-
- if CurrentDamagedPage < math.ceil(#damagedElements/12) then
- screenOutput = screenOutput ..
- [[
-
-
- ]]
- UpdateClickArea( "DamagedPageDown", { id = "DamagedPageDown", x1 = 70, x2 = 270, y1 = 350+11+(damagedElementsToDraw+1)*50, y2 = 350+11+50+(damagedElementsToDraw+1)*50 } )
- else
- DisableClickArea( "DamagedPageDown" )
- end
-
- if CurrentDamagedPage > 1 then
- screenOutput = screenOutput ..
- [[
-
-
- ]]
- UpdateClickArea( "DamagedPageUp", { id = "DamagedPageUp", x1 = 280, x2 = 480, y1 = 350+11+(damagedElementsToDraw+1)*50, y2 = 350+11+50+(damagedElementsToDraw+1)*50 } )
- else
- DisableClickArea( "DamagedPageUp" )
- end
- end
-
-
-
-
- end
-
- -- Draw broken elements
- if #brokenElements > 0 then
- local brokenElementsToDraw = #brokenElements
- if brokenElementsToDraw>12 then brokenElementsToDraw=12 end
- if CurrentBrokenPage==math.ceil(#brokenElements/12) then brokenElementsToDraw = #brokenElements%12 end
- screenOutput = screenOutput..
- [[]]
- screenOutput = screenOutput .. [[]]
- if (BrokenSortingMode==2) then
- screenOutput = screenOutput ..[[ID]]
- else
- screenOutput = screenOutput ..[[ID]]
- end
- if UseMyElementNames==true then screenOutput = screenOutput .. [[Element Name]]
- else screenOutput = screenOutput .. [[Element Type]]
- end
- if (BrokenSortingMode==1) then
- screenOutput = screenOutput ..[[Damage]]
- else
- screenOutput = screenOutput ..[[Damage]]
- end
-
- local i=0
- for j=1+(CurrentBrokenPage-1)*12,brokenElementsToDraw+(CurrentBrokenPage-1)*12,1 do
- i = i + 1
- local DP = brokenElements[j]
- screenOutput = screenOutput ..
- [[]]..string.format("%03.0f",DP.id)..[[]]
- if UseMyElementNames==true then
- screenOutput = screenOutput .. [[]]..string.format("%.25s", DP.name)..[[]]
- else
- screenOutput = screenOutput .. [[]]..string.format("%.25s", DP.type)..[[]]
- end
- screenOutput = screenOutput ..
- [[]]..GenerateCommaValue(string.format("%.0f", DP.missinghp))..[[]]..
- [[]]
- end
-
- screenOutput = screenOutput..
- [[
-
- ]]
-
-
- if #brokenElements>12 then
- screenOutput = screenOutput ..
- [[Page ]]..CurrentBrokenPage.." of "..math.ceil(#brokenElements/12)..[[]]
-
- if CurrentBrokenPage > 1 then
- screenOutput = screenOutput ..
- [[
-
-
- ]]
- UpdateClickArea( "BrokenPageUp", { id = "BrokenPageUp", x1 = 1442, x2 = 1642, y1 = 350+11+(brokenElementsToDraw+1)*50, y2 = 350+11+50+(brokenElementsToDraw+1)*50 } )
- else
- DisableClickArea( "BrokenPageUp" )
- end
-
- if CurrentBrokenPage < math.ceil(#brokenElements/12) then
- screenOutput = screenOutput ..
- [[
-
-
- ]]
- UpdateClickArea( "BrokenPageDown", { id = "BrokenPageDown", x1 = 1652, x2 = 1852, y1 = 350+11+(brokenElementsToDraw+1)*50, y2 = 350+11+50+(brokenElementsToDraw+1)*50 } )
- else
- DisableClickArea( "BrokenPageDown" )
- end
- end
-
-
-
- end
-
- -- Draw damage summary
- if #damagedElements>0 or #brokenElements > 0 then
- screenOutput = screenOutput..
- [[]]..GenerateCommaValue(string.format("%.0f", totalShipMaxHP-totalShipHP))..[[ HP damage in total]]
- else
- screenOutput = screenOutput..
- [[]]..
- GetAllSystemsNominalBackground()..
- [[]]..
- [[]]..OkayCenterMessage..[[]]
- [[Ship stands ]]..GenerateCommaValue(string.format("%.0f", totalShipMaxHP))..[[ HP strong.]]
- end
-
- -- Draw HUD Mode button
- screenOutput = screenOutput..[[]]
-
- DrawSVG(screenOutput)
-
- forceRedraw=false
- end
-end
-
------------------------------------------------
--- Execute
------------------------------------------------
-
-unit.hide()
-ClearConsole()
-PrintDebug("SCRIPT STARTED", true)
-
-InitiateSlots()
-SwitchScreens(true)
-InitiateClickAreas()
-
-if core == nil then
- DrawCenteredText("ERROR: No core connected.")
- PrintError("ERROR: No core connected.")
- goto exit
-else
- shipID = core.getConstructId()
-end
-
-GenerateDamageData()
-if forceRedraw then
- DrawScreens()
-end
-
-unit.setTimer('UpdateData', UpdateInterval)
-
-::exit::
\ No newline at end of file
diff --git a/src/DamageReport_1_52_UnitStart.lua b/src/DamageReport_1_52_UnitStart.lua
deleted file mode 100644
index 860a682..0000000
--- a/src/DamageReport_1_52_UnitStart.lua
+++ /dev/null
@@ -1,743 +0,0 @@
---[[
- DamageReport v1.52
-
- Created By Dorian Gray
-
- Discord: Dorian Gray#2623
- InGame: DorianGray
- GitHub: https://github.com/DorianTheGrey/DU-DamageReport
-
- GNU Public License 3.0. Use whatever you want, be so kind to leave credit.
-
- Thanks to Jericho, Dmentia and Archaegeo for learning from their fine scripts.
-]]
-
------------------------------------------------
--- CONFIG
------------------------------------------------
-
-UseMyElementNames = false --export: If you active this, the display will not show the element type of damaged/broken elements but the name you gave them (truncated to 25 characters)
-UpdateInterval = 1 --export: Interval in seconds between updates of the calculations and (if anything changed) redrawing to the screen(s). You need to restart the script after changing this value.
-SimulationMode = false --export Randomize simluated damage on elements to check out the functionality of this script. And, no, your elements won't be harmed in the process :) You need to restart the script after changing this value.
-YourShipsName = "Enter here" --export Enter your ship name here if you want it displayed instead of the ship's ID. YOU NEED TO LEAVE THE QUOTATION MARKS.
-
-DebugMode = false -- Activate if you want some console messages
-VersionNumber = 1.52 -- Version number
-
-core = nil
-screens = {}
-
-shipID = 0
-forceRedraw = false
-SimulationActive=false
-
-clickAreas = {}
-DamagedSortingMode = 1 -- Define default sorting mode for damaged elements. 1 to sort by damage amount, 2 to sort by element id, 3 to sort by damage percent,
-BrokenSortingMode = 1 -- Define default sorting mode for broken elements. 1 to sort by damage amount, 2 to sort by element id
-
-HUDMode = false
-CurrentDamagedPage = 1
-CurrentBrokenPage = 1
-
-totalShipHP = 0
-totalShipMaxHP = 0
-totalShipIntegrity = 100
-elementsId = {}
-damagedElements = {}
-brokenElements = {}
-ElementCounter = 0
-healthyElements = 0
-
-OkayCenterMessage = "All systems nominal."
-
------------------------------------------------
--- FUNCTIONS
------------------------------------------------
-
-
-function GenerateCommaValue(amount)
- local formatted = amount
- while true do
- formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
- if (k==0) then break end
- end
- return formatted
-end
-
-function PrintDebug(output, highlight)
- highlight = highlight or false
- if DebugMode then
- if highlight then system.print("------------------------------------------------------------------------") end
- system.print(output)
- if highlight then system.print("------------------------------------------------------------------------") end
- end
-end
-
-function PrintError(output)
- system.print(output)
-end
-
-function DrawCenteredText(output)
- for i=1,#screens,1 do
- screens[i].setCenteredText(output)
- end
-end
-
-function DrawSVG(output)
- for i=1,#screens,1 do
- screens[i].setSVG(output)
- end
-end
-
-function ClearConsole()
- for i=1,10,1 do
- PrintDebug()
- end
-end
-
-function SwitchScreens(state)
- state = state or true
- if #screens > 0 then
- for i=1,#screens,1 do
- if state then
- screens[i].clear()
- screens[i].activate()
- else
- screens[i].deactivate()
- screens[i].clear()
- end
- end
- end
-end
-
-function InitiateSlots()
- for slot_name, slot in pairs(unit) do
- if
- type(slot) == "table"
- and type(slot.export) == "table"
- and slot.getElementClass
- then
- if slot.getElementClass():lower():find("coreunit") then
- core = slot
- end
- if slot.getElementClass():lower():find("screenunit") then
- screens[#screens + 1] = slot
- end
- end
- end
-end
-
-function AddClickArea(newEntry)
- table.insert(clickAreas, newEntry)
-end
-
-function RemoveFromClickAreas(candidate)
- for k, v in pairs(clickAreas) do
- if v.id==candidate then
- clickAreas[k]=nil
- break
- end
- end
-end
-
-function UpdateClickArea(candidate, newEntry)
- for k, v in pairs(clickAreas) do
- if v.id==candidate then
- clickAreas[k]=newEntry
- break
- end
- end
-end
-
-function DisableClickArea(candidate)
- for k, v in pairs(clickAreas) do
- if v.id==candidate then
- UpdateClickArea(candidate, { id = candidate, x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )
- break
- end
- end
-end
-
-function InitiateClickAreas()
- clickAreas = {}
- AddClickArea( { id = "DamagedDamage", x1 = 725, x2 = 870, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "DamagedHealth", x1 = 520, x2 = 655, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "DamagedID", x1 = 90, x2 = 150, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "BrokenDamage", x1 = 1675, x2 = 1835, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "BrokenID", x1 = 1050, x2 = 1110, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "ToggleSimulation", x1 = 65, x2 = 660, y1 = 100, y2 = 145 } )
- AddClickArea( { id = "ToggleElementLabel", x1 = 225, x2 = 460, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "ToggleElementLabel2", x1 = 1185, x2 = 1440, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "ToggleHudMode", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )
- AddClickArea( { id = "DamagedPageDown", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )
- AddClickArea( { id = "DamagedPageUp", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )
- AddClickArea( { id = "BrokenPageDown", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )
- AddClickArea( { id = "BrokenPageUp", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )
-end
-
-function FlushClickAreas()
- clickAreas = {}
-end
-
-function CheckClick(x, y)
- PrintDebug("Clicked at "..x.." / "..y)
- local HitTarget=""
- for k, v in pairs(clickAreas) do
- if v and x>=v.x1 and x<=v.x2 and y>=v.y1 and y<=v.y2 then
- HitTarget=v.id
- break
- end
- end
- if HitTarget=="DamagedDamage" then
- DamagedSortingMode=1
- CurrentDamagedPage=1
- SortTables()
- DrawScreens()
- elseif HitTarget=="DamagedHealth" then
- DamagedSortingMode=3
- CurrentDamagedPage=1
- SortTables()
- DrawScreens()
- elseif HitTarget=="DamagedID" then
- DamagedSortingMode=2
- CurrentDamagedPage=1
- SortTables()
- DrawScreens()
- elseif HitTarget=="BrokenDamage" then
- BrokenSortingMode=1
- CurrentBrokenPage=1
- SortTables()
- DrawScreens()
- elseif HitTarget=="BrokenID" then
- BrokenSortingMode=2
- CurrentBrokenPage=1
- SortTables()
- DrawScreens()
- elseif HitTarget=="DamagedPageDown" then
- CurrentDamagedPage = CurrentDamagedPage + 1
- if CurrentDamagedPage > math.ceil(#damagedElements/12) then CurrentDamagedPage = math.ceil(#damagedElements/12) end
- DrawScreens()
- elseif HitTarget=="DamagedPageUp" then
- CurrentDamagedPage = CurrentDamagedPage - 1
- if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end
- DrawScreens()
- elseif HitTarget=="BrokenPageDown" then
- CurrentBrokenPage = CurrentBrokenPage + 1
- if CurrentBrokenPage > math.ceil(#brokenElements/12) then CurrentBrokenPage = math.ceil(#brokenElements/12) end
- DrawScreens()
- elseif HitTarget=="BrokenPageUp" then
- CurrentBrokenPage = CurrentBrokenPage - 1
- if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end
- DrawScreens()
- elseif HitTarget=="ToggleSimulation" then
- CurrentDamagedPage=1
- CurrentBrokenPage=1
- if SimulationMode == true then
- SimulationMode = false
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- DrawScreens()
- else
- SimulationMode = true
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- DrawScreens()
- end
- elseif HitTarget=="ToggleElementLabel" or HitTarget=="ToggleElementLabel2" then
- if UseMyElementNames == true then
- UseMyElementNames = false
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- DrawScreens()
- else
- UseMyElementNames = true
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- DrawScreens()
- end
- end
-end
-
-function SortTables()
- -- Sort damaged elements descending by percent damaged according to setting
- if DamagedSortingMode==1 then table.sort(damagedElements, function(a,b) return a.missinghp > b.missinghp end)
- elseif DamagedSortingMode==2 then table.sort(damagedElements, function(a,b) return a.id < b.id end)
- else table.sort(damagedElements, function(a,b) return a.percent < b.percent end)
- end
-
- -- Sort broken elements descending according to setting
- if BrokenSortingMode==1 then table.sort(brokenElements, function(a,b) return a.maxhp > b.maxhp end)
- else table.sort(brokenElements, function(a,b) return a.id < b.id end)
- end
-end
-
-function GenerateDamageData()
- if SimulationActive==true then
- return
- end
-
- local formerTotalShipHP = totalShipHP
- totalShipHP = 0
- totalShipMaxHP = 0
- totalShipIntegrity = 100
- elementsId = {}
- damagedElements = {}
- brokenElements = {}
- ElementCounter = 0
- healthyElements = 0
-
- elementsIdList = core.getElementIdList()
-
- for _,id in pairs(elementsIdList) do
- ElementCounter = ElementCounter + 1
- idHP = core.getElementHitPointsById(id) or 0
- idMaxHP = core.getElementMaxHitPointsById(id) or 0
-
- if SimulationMode then
- SimulationActive=true
- local dice =math.random(0,10)
- if dice < 2 then idHP = 0
- elseif dice >=2 and dice < 5 then idHP = idMaxHP
- else
- idHP = math.random(1, math.ceil(idMaxHP))
- end
- end
-
- totalShipHP = totalShipHP+idHP
- totalShipMaxHP = totalShipMaxHP+idMaxHP
-
- -- Is element damaged?
- if idMaxHP > idHP then
- idPos = core.getElementPositionById(id)
- idName = core.getElementNameById(id)
- idType = core.getElementTypeById(id)
- if idHP>0 then
- table.insert(damagedElements,
- {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP-idHP,
- percent = math.ceil(100/idMaxHP*idHP),
- pos =idPos
- }
- )
- -- if DebugMode then PrintDebug("Damaged: "..idName.." --- Type: "..idType.."") end
- -- Is element broken?
- else
- table.insert(brokenElements,
- {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP-idHP,
- percent = 0,
- pos =idPos
- }
- )
- -- if DebugMode then PrintDebug("Broken: "..idName.." --- Type: "..idType.."") end
- end
- else
- healthyElements = healthyElements + 1
- end
- end
-
- -- Sort tables by current settings
- SortTables()
-
- -- Update clickAreas
-
-
- -- Determine total ship integrity
- totalShipIntegrity = string.format("%2.0f", 100/totalShipMaxHP*totalShipHP)
-
- -- Has anything changes since last check? If yes, force redrawing the screens
- if formerTotalShipHP ~= totalShipHP then
- forceRedraw=true
- formerTotalShipHP = totalShipHP
- else forceRedraw=false
- end
-end
-
-function GetAllSystemsNominalBackground()
- local output=""
- output = output..
- [[
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function DrawScreens()
- if #screens > 0 then
-
- local healthyColor = "#00aa00"
- local brokenColor = "#aa0000"
- local damagedColor = "#aaaa00"
- local integrityColor = "#aaaaaa"
- local healthyTextColor = "white"
- local brokenTextColor = "#ff4444"
- local damagedTextColor = "#ffff44"
- local integrityTextColor = "white"
-
- if #damagedElements ==0 then
- damagedColor = "#aaaaaa"
- damagedTextColor = "white"
- end
- if #brokenElements == 0 then
- brokenColor = "#aaaaaa"
- brokenTextColor = "white"
- end
-
- -- Draw Header
- screenOutput = [[
- ]]
-
- -- Draw main background
- screenOutput = screenOutput..
- [[
-
-
-
-
-
-
-
-
-
-
-
- ]]
-
- -- Draw Title and summary
- if SimulationActive==true then
- screenOutput = screenOutput..[[Simulated Report]]
- else
- screenOutput = screenOutput..[[Damage Report]]
- end
- if YourShipsName==nil or YourShipsName=="" or YourShipsName=="Enter here" then screenOutput = screenOutput.. [[SHIP ID ]]..shipID..[[]]
- else screenOutput = screenOutput.. [[]]..YourShipsName..[[]]
- end
- screenOutput = screenOutput..
- [[
- Healthy
- ]]..healthyElements..[[
-
- Damaged
- ]]..#damagedElements..[[
-
- Broken
- ]]..#brokenElements..[[
-
- Integrity
- ]]..totalShipIntegrity..[[%]]
-
- -- Draw damage elements
-
- if #damagedElements > 0 then
- local damagedElementsToDraw = #damagedElements
- if damagedElementsToDraw>12 then damagedElementsToDraw=12 end
- if CurrentDamagedPage==math.ceil(#damagedElements/12) then damagedElementsToDraw = #damagedElements%12 end
- screenOutput = screenOutput..
- [[]]
- screenOutput = screenOutput .. [[]]
- if (DamagedSortingMode==2) then
- screenOutput = screenOutput ..[[ID]]
- else
- screenOutput = screenOutput ..[[ID]]
- end
- if UseMyElementNames==true then screenOutput = screenOutput ..[[Element Name]]
- else screenOutput = screenOutput ..[[Element Type]]
- end
-
- if (DamagedSortingMode==3) then
- screenOutput = screenOutput ..[[Health]]
- else
- screenOutput = screenOutput ..[[Health]]
- end
- if (DamagedSortingMode==1) then
- screenOutput = screenOutput ..[[Damage]]
- else
- screenOutput = screenOutput ..[[Damage]]
- end
-
- local i=0
- for j=1+(CurrentDamagedPage-1)*12,damagedElementsToDraw+(CurrentDamagedPage-1)*12,1 do
- i = i + 1
- local DP = damagedElements[j]
- screenOutput = screenOutput ..
- [[]]..string.format("%03.0f",DP.id)..[[]]
- if UseMyElementNames==true then
- screenOutput = screenOutput .. [[]]..string.format("%.25s", DP.name)..[[]]
- else
- screenOutput = screenOutput .. [[]]..string.format("%.25s", DP.type)..[[]]
- end
- screenOutput = screenOutput ..
- [[]]..DP.percent..[[%]]..
- [[]]..GenerateCommaValue(string.format("%.0f", DP.missinghp))..[[]]..
- [[]]
- end
- screenOutput = screenOutput ..
- [[
-
- ]]
-
- if #damagedElements>12 then
- screenOutput = screenOutput ..
- [[Page ]]..CurrentDamagedPage.." of "..math.ceil(#damagedElements/12)..[[]]
-
- if CurrentDamagedPage < math.ceil(#damagedElements/12) then
- screenOutput = screenOutput ..
- [[
-
-
- ]]
- UpdateClickArea( "DamagedPageDown", { id = "DamagedPageDown", x1 = 70, x2 = 270, y1 = 350+11+(damagedElementsToDraw+1)*50, y2 = 350+11+50+(damagedElementsToDraw+1)*50 } )
- else
- DisableClickArea( "DamagedPageDown" )
- end
-
- if CurrentDamagedPage > 1 then
- screenOutput = screenOutput ..
- [[
-
-
- ]]
- UpdateClickArea( "DamagedPageUp", { id = "DamagedPageUp", x1 = 280, x2 = 480, y1 = 350+11+(damagedElementsToDraw+1)*50, y2 = 350+11+50+(damagedElementsToDraw+1)*50 } )
- else
- DisableClickArea( "DamagedPageUp" )
- end
- end
-
-
-
-
- end
-
- -- Draw broken elements
- if #brokenElements > 0 then
- local brokenElementsToDraw = #brokenElements
- if brokenElementsToDraw>12 then brokenElementsToDraw=12 end
- if CurrentBrokenPage==math.ceil(#brokenElements/12) then brokenElementsToDraw = #brokenElements%12 end
- screenOutput = screenOutput..
- [[]]
- screenOutput = screenOutput .. [[]]
- if (BrokenSortingMode==2) then
- screenOutput = screenOutput ..[[ID]]
- else
- screenOutput = screenOutput ..[[ID]]
- end
- if UseMyElementNames==true then screenOutput = screenOutput .. [[Element Name]]
- else screenOutput = screenOutput .. [[Element Type]]
- end
- if (BrokenSortingMode==1) then
- screenOutput = screenOutput ..[[Damage]]
- else
- screenOutput = screenOutput ..[[Damage]]
- end
-
- local i=0
- for j=1+(CurrentBrokenPage-1)*12,brokenElementsToDraw+(CurrentBrokenPage-1)*12,1 do
- i = i + 1
- local DP = brokenElements[j]
- screenOutput = screenOutput ..
- [[]]..string.format("%03.0f",DP.id)..[[]]
- if UseMyElementNames==true then
- screenOutput = screenOutput .. [[]]..string.format("%.25s", DP.name)..[[]]
- else
- screenOutput = screenOutput .. [[]]..string.format("%.25s", DP.type)..[[]]
- end
- screenOutput = screenOutput ..
- [[]]..GenerateCommaValue(string.format("%.0f", DP.missinghp))..[[]]..
- [[]]
- end
-
- screenOutput = screenOutput..
- [[
-
- ]]
-
-
- if #brokenElements>12 then
- screenOutput = screenOutput ..
- [[Page ]]..CurrentBrokenPage.." of "..math.ceil(#brokenElements/12)..[[]]
-
- if CurrentBrokenPage > 1 then
- screenOutput = screenOutput ..
- [[
-
-
- ]]
- UpdateClickArea( "BrokenPageUp", { id = "BrokenPageUp", x1 = 1442, x2 = 1642, y1 = 350+11+(brokenElementsToDraw+1)*50, y2 = 350+11+50+(brokenElementsToDraw+1)*50 } )
- else
- DisableClickArea( "BrokenPageUp" )
- end
-
- if CurrentBrokenPage < math.ceil(#brokenElements/12) then
- screenOutput = screenOutput ..
- [[
-
-
- ]]
- UpdateClickArea( "BrokenPageDown", { id = "BrokenPageDown", x1 = 1652, x2 = 1852, y1 = 350+11+(brokenElementsToDraw+1)*50, y2 = 350+11+50+(brokenElementsToDraw+1)*50 } )
- else
- DisableClickArea( "BrokenPageDown" )
- end
- end
-
-
-
- end
-
- -- Draw damage summary
- if #damagedElements>0 or #brokenElements > 0 then
- screenOutput = screenOutput..
- [[]]..GenerateCommaValue(string.format("%.0f", totalShipMaxHP-totalShipHP))..[[ HP damage in total]]
- else
- screenOutput = screenOutput ..
- [[]] ..
- GetAllSystemsNominalBackground() ..
- [[]] ..
- [[]]..OkayCenterMessage..[[]] ..
- [[Ship stands ]]..GenerateCommaValue(string.format("%.0f", totalShipMaxHP))..[[ HP strong.]]
- end
-
- -- Draw HUD Mode button
- screenOutput = screenOutput..[[]]
-
- DrawSVG(screenOutput)
-
- forceRedraw=false
- end
-end
-
------------------------------------------------
--- Execute
------------------------------------------------
-
-unit.hide()
-ClearConsole()
-PrintDebug("SCRIPT STARTED", true)
-
-InitiateSlots()
-SwitchScreens(true)
-InitiateClickAreas()
-
-if core == nil then
- DrawCenteredText("ERROR: No core connected.")
- PrintError("ERROR: No core connected.")
- goto exit
-else
- shipID = core.getConstructId()
-end
-
-GenerateDamageData()
-if forceRedraw then
- DrawScreens()
-end
-
-unit.setTimer('UpdateData', UpdateInterval)
-
-::exit::
\ No newline at end of file
diff --git a/src/DamageReport_1_5_UnitStart.lua b/src/DamageReport_1_5_UnitStart.lua
deleted file mode 100644
index 7d6fbf9..0000000
--- a/src/DamageReport_1_5_UnitStart.lua
+++ /dev/null
@@ -1,742 +0,0 @@
---[[
- DamageReport v1.51
-
- Created By Dorian Gray
-
- Discord: Dorian Gray#2623
- InGame: DorianGray
- GitHub: https://github.com/DorianTheGrey/DU-DamageReport
-
- GNU Public License 3.0. Use whatever you want, be so kind to leave credit.
-
- Thanks to Jericho, Dmentia and Archaegeo for learning from their fine scripts.
-]]
-
------------------------------------------------
--- CONFIG
------------------------------------------------
-
-UseMyElementNames = false --export: If you active this, the display will not show the element type of damaged/broken elements but the name you gave them (truncated to 25 characters)
-UpdateInterval = 1 --export: Interval in seconds between updates of the calculations and (if anything changed) redrawing to the screen(s). You need to restart the script after changing this value.
-SimulationMode = false --export Randomize simluated damage on elements to check out the functionality of this script. And, no, your elements won't be harmed in the process :) You need to restart the script after changing this value.
-YourShipsName = "Enter here" --export Enter your ship name here if you want it displayed instead of the ship's ID. YOU NEED TO LEAVE THE QUOTATION MARKS.
-
-DebugMode = false -- Activate if you want some console messages
-VersionNumber = 1.51 -- Version number
-
-core = nil
-screens = {}
-
-shipID = 0
-forceRedraw = false
-SimulationActive=false
-
-clickAreas = {}
-DamagedSortingMode = 1 -- Define default sorting mode for damaged elements. 1 to sort by damage amount, 2 to sort by element id, 3 to sort by damage percent,
-BrokenSortingMode = 1 -- Define default sorting mode for broken elements. 1 to sort by damage amount, 2 to sort by element id
-
-HUDMode = false
-CurrentDamagedPage = 1
-CurrentBrokenPage = 1
-
-totalShipHP = 0
-totalShipMaxHP = 0
-totalShipIntegrity = 100
-elementsId = {}
-damagedElements = {}
-brokenElements = {}
-ElementCounter = 0
-healthyElements = 0
-
-OkayCenterMessage = "All systems nominal."
-
------------------------------------------------
--- FUNCTIONS
------------------------------------------------
-
-
-function GenerateCommaValue(amount)
- local formatted = amount
- while true do
- formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
- if (k==0) then break end
- end
- return formatted
-end
-
-function PrintDebug(output, highlight)
- highlight = highlight or false
- if DebugMode then
- if highlight then system.print("------------------------------------------------------------------------") end
- system.print(output)
- if highlight then system.print("------------------------------------------------------------------------") end
- end
-end
-
-function PrintError(output)
- system.print(output)
-end
-
-function DrawCenteredText(output)
- for i=1,#screens,1 do
- screens[i].setCenteredText(output)
- end
-end
-
-function DrawSVG(output)
- for i=1,#screens,1 do
- screens[i].setSVG(output)
- end
-end
-
-function ClearConsole()
- for i=1,10,1 do
- PrintDebug()
- end
-end
-
-function SwitchScreens(state)
- state = state or true
- if #screens > 0 then
- for i=1,#screens,1 do
- if state then
- screens[i].clear()
- screens[i].activate()
- else
- screens[i].deactivate()
- screens[i].clear()
- end
- end
- end
-end
-
-function InitiateSlots()
- for slot_name, slot in pairs(unit) do
- if
- type(slot) == "table"
- and type(slot.export) == "table"
- and slot.getElementClass
- then
- if slot.getElementClass():lower():find("coreunit") then
- core = slot
- end
- if slot.getElementClass():lower():find("screenunit") then
- screens[#screens + 1] = slot
- end
- end
- end
-end
-
-function AddClickArea(newEntry)
- table.insert(clickAreas, newEntry)
-end
-
-function RemoveFromClickAreas(candidate)
- for k, v in pairs(clickAreas) do
- if v.id==candidate then
- clickAreas[k]=nil
- break
- end
- end
-end
-
-function UpdateClickArea(candidate, newEntry)
- for k, v in pairs(clickAreas) do
- if v.id==candidate then
- clickAreas[k]=newEntry
- break
- end
- end
-end
-
-function DisableClickArea(candidate)
- for k, v in pairs(clickAreas) do
- if v.id==candidate then
- UpdateClickArea(candidate, { id = candidate, x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )
- break
- end
- end
-end
-
-function InitiateClickAreas()
- clickAreas = {}
- AddClickArea( { id = "DamagedDamage", x1 = 725, x2 = 870, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "DamagedHealth", x1 = 520, x2 = 655, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "DamagedID", x1 = 90, x2 = 150, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "BrokenDamage", x1 = 1675, x2 = 1835, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "BrokenID", x1 = 1050, x2 = 1110, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "ToggleSimulation", x1 = 65, x2 = 660, y1 = 100, y2 = 145 } )
- AddClickArea( { id = "ToggleElementLabel", x1 = 225, x2 = 460, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "ToggleElementLabel2", x1 = 1185, x2 = 1440, y1 = 380, y2 = 415 } )
- AddClickArea( { id = "ToggleHudMode", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )
- AddClickArea( { id = "DamagedPageDown", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )
- AddClickArea( { id = "DamagedPageUp", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )
- AddClickArea( { id = "BrokenPageDown", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )
- AddClickArea( { id = "BrokenPageUp", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )
-end
-
-function FlushClickAreas()
- clickAreas = {}
-end
-
-function CheckClick(x, y)
- PrintDebug("Clicked at "..x.." / "..y)
- local HitTarget=""
- for k, v in pairs(clickAreas) do
- if v and x>=v.x1 and x<=v.x2 and y>=v.y1 and y<=v.y2 then
- HitTarget=v.id
- break
- end
- end
- if HitTarget=="DamagedDamage" then
- DamagedSortingMode=1
- CurrentDamagedPage=1
- SortTables()
- DrawScreens()
- elseif HitTarget=="DamagedHealth" then
- DamagedSortingMode=3
- CurrentDamagedPage=1
- SortTables()
- DrawScreens()
- elseif HitTarget=="DamagedID" then
- DamagedSortingMode=2
- CurrentDamagedPage=1
- SortTables()
- DrawScreens()
- elseif HitTarget=="BrokenDamage" then
- BrokenSortingMode=1
- CurrentBrokenPage=1
- SortTables()
- DrawScreens()
- elseif HitTarget=="BrokenID" then
- BrokenSortingMode=2
- CurrentBrokenPage=1
- SortTables()
- DrawScreens()
- elseif HitTarget=="DamagedPageDown" then
- CurrentDamagedPage = CurrentDamagedPage + 1
- if CurrentDamagedPage > math.ceil(#damagedElements/12) then CurrentDamagedPage = math.ceil(#damagedElements/12) end
- DrawScreens()
- elseif HitTarget=="DamagedPageUp" then
- CurrentDamagedPage = CurrentDamagedPage - 1
- if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end
- DrawScreens()
- elseif HitTarget=="BrokenPageDown" then
- CurrentBrokenPage = CurrentBrokenPage + 1
- if CurrentBrokenPage > math.ceil(#brokenElements/12) then CurrentBrokenPage = math.ceil(#brokenElements/12) end
- DrawScreens()
- elseif HitTarget=="BrokenPageUp" then
- CurrentBrokenPage = CurrentBrokenPage - 1
- if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end
- DrawScreens()
- elseif HitTarget=="ToggleSimulation" then
- CurrentDamagedPage=1
- CurrentBrokenPage=1
- if SimulationMode == true then
- SimulationMode = false
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- DrawScreens()
- else
- SimulationMode = true
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- DrawScreens()
- end
- elseif HitTarget=="ToggleElementLabel" or HitTarget=="ToggleElementLabel2" then
- if UseMyElementNames == true then
- UseMyElementNames = false
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- DrawScreens()
- else
- UseMyElementNames = true
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- DrawScreens()
- end
- end
-end
-
-function SortTables()
- -- Sort damaged elements descending by percent damaged according to setting
- if DamagedSortingMode==1 then table.sort(damagedElements, function(a,b) return a.missinghp > b.missinghp end)
- elseif DamagedSortingMode==2 then table.sort(damagedElements, function(a,b) return a.id < b.id end)
- else table.sort(damagedElements, function(a,b) return a.percent < b.percent end)
- end
-
- -- Sort broken elements descending according to setting
- if BrokenSortingMode==1 then table.sort(brokenElements, function(a,b) return a.maxhp > b.maxhp end)
- else table.sort(brokenElements, function(a,b) return a.id < b.id end)
- end
-end
-
-function GenerateDamageData()
- if SimulationActive==true then
- return
- end
-
- local formerTotalShipHP = totalShipHP
- totalShipHP = 0
- totalShipMaxHP = 0
- totalShipIntegrity = 100
- elementsId = {}
- damagedElements = {}
- brokenElements = {}
- ElementCounter = 0
- healthyElements = 0
-
- elementsIdList = core.getElementIdList()
-
- for _,id in pairs(elementsIdList) do
- ElementCounter = ElementCounter + 1
- idHP = core.getElementHitPointsById(id) or 0
- idMaxHP = core.getElementMaxHitPointsById(id) or 0
-
- if SimulationMode then
- SimulationActive=true
- local dice =math.random(0,10)
- if dice < 2 then idHP = 0
- elseif dice >=2 and dice < 5 then idHP = idMaxHP
- else
- idHP = math.random(1, math.ceil(idMaxHP))
- end
- end
-
- totalShipHP = totalShipHP+idHP
- totalShipMaxHP = totalShipMaxHP+idMaxHP
-
- -- Is element damaged?
- if idMaxHP > idHP then
- idPos = core.getElementPositionById(id)
- idName = core.getElementNameById(id)
- idType = core.getElementTypeById(id)
- if idHP>0 then
- table.insert(damagedElements,
- {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP-idHP,
- percent = math.ceil(100/idMaxHP*idHP),
- pos =idPos
- }
- )
- -- if DebugMode then PrintDebug("Damaged: "..idName.." --- Type: "..idType.."") end
- -- Is element broken?
- else
- table.insert(brokenElements,
- {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP-idHP,
- percent = 0,
- pos =idPos
- }
- )
- -- if DebugMode then PrintDebug("Broken: "..idName.." --- Type: "..idType.."") end
- end
- else
- healthyElements = healthyElements + 1
- end
- end
-
- -- Sort tables by current settings
- SortTables()
-
- -- Update clickAreas
-
-
- -- Determine total ship integrity
- totalShipIntegrity = string.format("%2.0f", 100/totalShipMaxHP*totalShipHP)
-
- -- Has anything changes since last check? If yes, force redrawing the screens
- if formerTotalShipHP ~= totalShipHP then
- forceRedraw=true
- formerTotalShipHP = totalShipHP
- else forceRedraw=false
- end
-end
-
-function GetAllSystemsNominalBackground()
- local output=""
- output = output..
- [[
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function DrawScreens()
- if #screens > 0 then
-
- local healthyColor = "#00aa00"
- local brokenColor = "#aa0000"
- local damagedColor = "#aaaa00"
- local integrityColor = "#aaaaaa"
- local healthyTextColor = "white"
- local brokenTextColor = "#ff4444"
- local damagedTextColor = "#ffff44"
- local integrityTextColor = "white"
-
- if #damagedElements ==0 then
- damagedColor = "#aaaaaa"
- damagedTextColor = "white"
- end
- if #brokenElements == 0 then
- brokenColor = "#aaaaaa"
- brokenTextColor = "white"
- end
-
- -- Draw Header
- screenOutput = [[
- ]]
-
- -- Draw main background
- screenOutput = screenOutput..
- [[
-
-
-
-
-
-
-
-
-
-
-
- ]]
-
- -- Draw Title and summary
- if SimulationActive==true then
- screenOutput = screenOutput..[[Simulated Report]]
- else
- screenOutput = screenOutput..[[Damage Report]]
- end
- if YourShipsName==nil or YourShipsName=="" or YourShipsName=="Enter here" then screenOutput = screenOutput.. [[SHIP ID ]]..shipID..[[]]
- else screenOutput = screenOutput.. [[]]..YourShipsName..[[]]
- end
- screenOutput = screenOutput..
- [[
- Healthy
- ]]..healthyElements..[[
-
- Damaged
- ]]..#damagedElements..[[
-
- Broken
- ]]..#brokenElements..[[
-
- Integrity
- ]]..totalShipIntegrity..[[%]]
-
- -- Draw damage elements
-
- if #damagedElements > 0 then
- local damagedElementsToDraw = #damagedElements
- if damagedElementsToDraw>12 then damagedElementsToDraw=12 end
- if CurrentDamagedPage==math.ceil(#damagedElements/12) then damagedElementsToDraw = #damagedElements%12 end
- screenOutput = screenOutput..
- [[]]
- screenOutput = screenOutput .. [[]]
- if (DamagedSortingMode==2) then
- screenOutput = screenOutput ..[[ID]]
- else
- screenOutput = screenOutput ..[[ID]]
- end
- if UseMyElementNames==true then screenOutput = screenOutput ..[[Element Name]]
- else screenOutput = screenOutput ..[[Element Type]]
- end
-
- if (DamagedSortingMode==3) then
- screenOutput = screenOutput ..[[Health]]
- else
- screenOutput = screenOutput ..[[Health]]
- end
- if (DamagedSortingMode==1) then
- screenOutput = screenOutput ..[[Damage]]
- else
- screenOutput = screenOutput ..[[Damage]]
- end
-
- local i=0
- for j=1+(CurrentDamagedPage-1)*12,damagedElementsToDraw+(CurrentDamagedPage-1)*12,1 do
- i = i + 1
- local DP = damagedElements[j]
- screenOutput = screenOutput ..
- [[]]..string.format("%03.0f",DP.id)..[[]]
- if UseMyElementNames==true then
- screenOutput = screenOutput .. [[]]..string.format("%.25s", DP.name)..[[]]
- else
- screenOutput = screenOutput .. [[]]..string.format("%.25s", DP.type)..[[]]
- end
- screenOutput = screenOutput ..
- [[]]..DP.percent..[[%]]..
- [[]]..GenerateCommaValue(string.format("%.0f", DP.missinghp))..[[]]..
- [[]]
- end
- screenOutput = screenOutput ..
- [[
-
- ]]
-
- if #damagedElements>12 then
- screenOutput = screenOutput ..
- [[Page ]]..CurrentDamagedPage.." of "..math.ceil(#damagedElements/12)..[[]]
-
- if CurrentDamagedPage < math.ceil(#damagedElements/12) then
- screenOutput = screenOutput ..
- [[
-
-
- ]]
- UpdateClickArea( "DamagedPageDown", { id = "DamagedPageDown", x1 = 70, x2 = 270, y1 = 350+11+(damagedElementsToDraw+1)*50, y2 = 350+11+50+(damagedElementsToDraw+1)*50 } )
- else
- DisableClickArea( "DamagedPageDown" )
- end
-
- if CurrentDamagedPage > 1 then
- screenOutput = screenOutput ..
- [[
-
-
- ]]
- UpdateClickArea( "DamagedPageUp", { id = "DamagedPageUp", x1 = 280, x2 = 480, y1 = 350+11+(damagedElementsToDraw+1)*50, y2 = 350+11+50+(damagedElementsToDraw+1)*50 } )
- else
- DisableClickArea( "DamagedPageUp" )
- end
- end
-
-
-
-
- end
-
- -- Draw broken elements
- if #brokenElements > 0 then
- local brokenElementsToDraw = #brokenElements
- if brokenElementsToDraw>12 then brokenElementsToDraw=12 end
- if CurrentBrokenPage==math.ceil(#brokenElements/12) then brokenElementsToDraw = #brokenElements%12 end
- screenOutput = screenOutput..
- [[]]
- screenOutput = screenOutput .. [[]]
- if (BrokenSortingMode==2) then
- screenOutput = screenOutput ..[[ID]]
- else
- screenOutput = screenOutput ..[[ID]]
- end
- if UseMyElementNames==true then screenOutput = screenOutput .. [[Element Name]]
- else screenOutput = screenOutput .. [[Element Type]]
- end
- if (BrokenSortingMode==1) then
- screenOutput = screenOutput ..[[Damage]]
- else
- screenOutput = screenOutput ..[[Damage]]
- end
-
- local i=0
- for j=1+(CurrentBrokenPage-1)*12,brokenElementsToDraw+(CurrentBrokenPage-1)*12,1 do
- i = i + 1
- local DP = brokenElements[j]
- screenOutput = screenOutput ..
- [[]]..string.format("%03.0f",DP.id)..[[]]
- if UseMyElementNames==true then
- screenOutput = screenOutput .. [[]]..string.format("%.25s", DP.name)..[[]]
- else
- screenOutput = screenOutput .. [[]]..string.format("%.25s", DP.type)..[[]]
- end
- screenOutput = screenOutput ..
- [[]]..GenerateCommaValue(string.format("%.0f", DP.missinghp))..[[]]..
- [[]]
- end
-
- screenOutput = screenOutput..
- [[
-
- ]]
-
-
- if #brokenElements>12 then
- screenOutput = screenOutput ..
- [[Page ]]..CurrentBrokenPage.." of "..math.ceil(#brokenElements/12)..[[]]
-
- if CurrentBrokenPage > 1 then
- screenOutput = screenOutput ..
- [[
-
-
- ]]
- UpdateClickArea( "BrokenPageUp", { id = "BrokenPageUp", x1 = 1442, x2 = 1642, y1 = 350+11+(brokenElementsToDraw+1)*50, y2 = 350+11+50+(brokenElementsToDraw+1)*50 } )
- else
- DisableClickArea( "BrokenPageUp" )
- end
-
- if CurrentBrokenPage < math.ceil(#brokenElements/12) then
- screenOutput = screenOutput ..
- [[
-
-
- ]]
- UpdateClickArea( "BrokenPageDown", { id = "BrokenPageDown", x1 = 1652, x2 = 1852, y1 = 350+11+(brokenElementsToDraw+1)*50, y2 = 350+11+50+(brokenElementsToDraw+1)*50 } )
- else
- DisableClickArea( "BrokenPageDown" )
- end
- end
-
-
-
- end
-
- -- Draw damage summary
- if #damagedElements>0 or #brokenElements > 0 then
- screenOutput = screenOutput..
- [[]]..GenerateCommaValue(string.format("%.0f", totalShipMaxHP-totalShipHP))..[[ HP damage in total]]
- else
- screenOutput = screenOutput..
- [[]]..
- GetAllSystemsNominalBackground()..
- [[]]..
- [[]]..OkayCenterMessage..[[]]
- end
-
- -- Draw HUD Mode button
- screenOutput = screenOutput..[[]]
-
- DrawSVG(screenOutput)
-
- forceRedraw=false
- end
-end
-
------------------------------------------------
--- Execute
------------------------------------------------
-
-unit.hide()
-ClearConsole()
-PrintDebug("SCRIPT STARTED", true)
-
-InitiateSlots()
-SwitchScreens(true)
-InitiateClickAreas()
-
-if core == nil then
- DrawCenteredText("ERROR: No core connected.")
- PrintError("ERROR: No core connected.")
- goto exit
-else
- shipID = core.getConstructId()
-end
-
-GenerateDamageData()
-if forceRedraw then
- DrawScreens()
-end
-
-unit.setTimer('UpdateData', UpdateInterval)
-
-::exit::
\ No newline at end of file
diff --git a/src/DamageReport_2_1_UnitStart.lua b/src/DamageReport_2_1_UnitStart.lua
deleted file mode 100644
index ced1a02..0000000
--- a/src/DamageReport_2_1_UnitStart.lua
+++ /dev/null
@@ -1,1388 +0,0 @@
---[[
- DamageReport v2.1
-
- Created By Dorian Gray
-
- Discord: Dorian Gray#2623
- InGame: DorianGray
- GitHub: https://github.com/DorianTheGrey/DU-DamageReport
-
- GNU Public License 3.0. Use whatever you want, be so kind to leave credit.
-
- Thanks to Jericho, Dmentia and Archaegeo for learning from their fine scripts.
-]] -----------------------------------------------
--- CONFIG
------------------------------------------------
-UseMyElementNames = true -- export: If you active this, the display will not show the element type of damaged/broken elements but the name you gave them (truncated to 25 characters)
-AllowElementHighlighting = true -- export: Are you allowing damaged/broken elements to be highlighted in 3D space when selected in the HUD?
-UpdateInterval = 1 -- export: Interval in seconds between updates of the calculations and (if anything changed) redrawing to the screen(s). You need to restart the script after changing this value.
-HighlightBlinkingInterval = 0.5 -- export: If an element is marked, how fast do you want the arrows to blink?
-SimulationMode = false -- export Randomize simluated damage on elements to check out the functionality of this script. And, no, your elements won't be harmed in the process :) You need to restart the script after changing this value.
-YourShipsName = "Enter here" -- export Enter your ship name here if you want it displayed instead of the ship's ID. YOU NEED TO LEAVE THE QUOTATION MARKS.
-
-DebugMode = false -- Activate if you want some console messages
-VersionNumber = 2.1 -- Version number
-
-core = nil
-screens = {}
-
-shipID = 0
-forceRedraw = false
-SimulationActive = false
-
-clickAreas = {}
-DamagedSortingMode = 1 -- Define default sorting mode for damaged elements. 1 to sort by damage amount, 2 to sort by element id, 3 to sort by damage percent,
-BrokenSortingMode = 1 -- Define default sorting mode for broken elements. 1 to sort by damage amount, 2 to sort by element id
-
-HUDMode = false -- Is Hud active?
-hudSelectedIndex = 0 -- Which element is selected?
-hudSelectedType = 0 -- Is selected element damaged (1) or broken (2)
-hudArrowSticker = {}
-highlightOn = false
-highlightX = 0
-highlightY = 0
-highlightZ = 0
-
-CurrentDamagedPage = 1
-CurrentBrokenPage = 1
-
-coreWorldOffset = 0
-totalShipHP = 0
-totalShipMaxHP = 0
-totalShipIntegrity = 100
-elementsId = {}
-damagedElements = {}
-brokenElements = {}
-ElementCounter = 0
-healthyElements = 0
-
-OkayCenterMessage = "All systems nominal."
-
------------------------------------------------
--- FUNCTIONS
------------------------------------------------
-
-function GenerateCommaValue(amount)
- local formatted = amount
- while true do
- formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
- if (k == 0) then break end
- end
- return formatted
-end
-
-function PrintDebug(output, highlight)
- highlight = highlight or false
- if DebugMode then
- if highlight then
- system.print(
- "------------------------------------------------------------------------")
- end
- system.print(output)
- if highlight then
- system.print(
- "------------------------------------------------------------------------")
- end
- end
-end
-
-function PrintError(output) system.print(output) end
-
-function DrawCenteredText(output)
- for i = 1, #screens, 1 do screens[i].setCenteredText(output) end
-end
-
-function DrawSVG(output) for i = 1, #screens, 1 do screens[i].setSVG(output) end end
-
-function ClearConsole() for i = 1, 10, 1 do PrintDebug() end end
-
-function SwitchScreens(state)
- state = state or true
- if #screens > 0 then
- for i = 1, #screens, 1 do
- if state then
- screens[i].clear()
- screens[i].activate()
- else
- screens[i].deactivate()
- screens[i].clear()
- end
- end
- end
-end
-
-function InitiateSlots()
- for slot_name, slot in pairs(unit) do
- if type(slot) == "table" and type(slot.export) == "table" and
- slot.getElementClass then
- if slot.getElementClass():lower():find("coreunit") then
- core = slot
- local coreHP = core.getMaxHitPoints()
- if coreHP > 10000 then
- coreWorldOffset = 128
- elseif coreHP > 1000 then
- coreWorldOffset = 64
- elseif coreHP > 150 then
- coreWorldOffset = 32
- else
- coreWorldOffset = 16
- end
- end
- if slot.getElementClass():lower():find("screenunit") then
- screens[#screens + 1] = slot
- end
- end
- end
-end
-
-function AddClickArea(newEntry) table.insert(clickAreas, newEntry) end
-
-function RemoveFromClickAreas(candidate)
- for k, v in pairs(clickAreas) do
- if v.id == candidate then
- clickAreas[k] = nil
- break
- end
- end
-end
-
-function UpdateClickArea(candidate, newEntry)
- for k, v in pairs(clickAreas) do
- if v.id == candidate then
- clickAreas[k] = newEntry
- break
- end
- end
-end
-
-function DisableClickArea(candidate)
- for k, v in pairs(clickAreas) do
- if v.id == candidate then
- UpdateClickArea(candidate, {
- id = candidate,
- x1 = -1,
- x2 = -1,
- y1 = -1,
- y2 = -1
- })
- break
- end
- end
-end
-
-function InitiateClickAreas()
- clickAreas = {}
- AddClickArea({id = "DamagedDamage", x1 = 725, x2 = 870, y1 = 380, y2 = 415})
- AddClickArea({id = "DamagedHealth", x1 = 520, x2 = 655, y1 = 380, y2 = 415})
- AddClickArea({id = "DamagedID", x1 = 90, x2 = 150, y1 = 380, y2 = 415})
- AddClickArea({id = "BrokenDamage", x1 = 1675, x2 = 1835, y1 = 380, y2 = 415})
- AddClickArea({id = "BrokenID", x1 = 1050, x2 = 1110, y1 = 380, y2 = 415})
- AddClickArea({
- id = "ToggleSimulation",
- x1 = 65,
- x2 = 660,
- y1 = 100,
- y2 = 145
- })
- AddClickArea({
- id = "ToggleElementLabel",
- x1 = 225,
- x2 = 460,
- y1 = 380,
- y2 = 415
- })
- AddClickArea({
- id = "ToggleElementLabel2",
- x1 = 1185,
- x2 = 1440,
- y1 = 380,
- y2 = 415
- })
- AddClickArea({
- id = "ToggleHudMode",
- x1 = 1397,
- x2 = 1840,
- y1 = 133,
- y2 = 220
- })
- AddClickArea({id = "DamagedPageDown", x1 = -1, x2 = -1, y1 = -1, y2 = -1})
- AddClickArea({id = "DamagedPageUp", x1 = -1, x2 = -1, y1 = -1, y2 = -1})
- AddClickArea({id = "BrokenPageDown", x1 = -1, x2 = -1, y1 = -1, y2 = -1})
- AddClickArea({id = "BrokenPageUp", x1 = -1, x2 = -1, y1 = -1, y2 = -1})
-end
-
-function FlushClickAreas() clickAreas = {} end
-
-function CheckClick(x, y, HitTarget)
- HitTarget = HitTarget or ""
- if HitTarget == "" then
- for k, v in pairs(clickAreas) do
- if v and x >= v.x1 and x <= v.x2 and y >= v.y1 and y <= v.y2 then
- HitTarget = v.id
- break
- end
- end
- end
- if HitTarget == "DamagedDamage" then
- DamagedSortingMode = 1
- CurrentDamagedPage = 1
- SortTables()
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "DamagedHealth" then
- DamagedSortingMode = 3
- CurrentDamagedPage = 1
- SortTables()
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "DamagedID" then
- DamagedSortingMode = 2
- CurrentDamagedPage = 1
- SortTables()
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "BrokenDamage" then
- BrokenSortingMode = 1
- CurrentBrokenPage = 1
- SortTables()
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "BrokenID" then
- BrokenSortingMode = 2
- CurrentBrokenPage = 1
- SortTables()
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "DamagedPageDown" then
- CurrentDamagedPage = CurrentDamagedPage + 1
- if CurrentDamagedPage > math.ceil(#damagedElements / 12) then
- CurrentDamagedPage = math.ceil(#damagedElements / 12)
- end
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "DamagedPageUp" then
- CurrentDamagedPage = CurrentDamagedPage - 1
- if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "BrokenPageDown" then
- CurrentBrokenPage = CurrentBrokenPage + 1
- if CurrentBrokenPage > math.ceil(#brokenElements / 12) then
- CurrentBrokenPage = math.ceil(#brokenElements / 12)
- end
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "BrokenPageUp" then
- CurrentBrokenPage = CurrentBrokenPage - 1
- if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "ToggleHudMode" then
- if HUDMode == true then
- HUDMode = false
- forceRedraw = true
- HudDeselectElement()
- DrawScreens()
- else
- HUDMode = true
- forceRedraw = true
- HudDeselectElement()
- DrawScreens()
- end
- elseif HitTarget == "ToggleSimulation" then
- CurrentDamagedPage = 1
- CurrentBrokenPage = 1
- if SimulationMode == true then
- SimulationMode = false
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- HudDeselectElement()
- DrawScreens()
- else
- SimulationMode = true
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- HudDeselectElement()
- DrawScreens()
- end
- elseif HitTarget == "ToggleElementLabel" or HitTarget ==
- "ToggleElementLabel2" then
- if UseMyElementNames == true then
- UseMyElementNames = false
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- HudDeselectElement()
- DrawScreens()
- else
- UseMyElementNames = true
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- HudDeselectElement()
- DrawScreens()
- end
- end
-end
-
-function ToggleHUD()
- HideHighlight()
- CheckClick(nil, nil, "ToggleHudMode")
-end
-
-function HudDeselectElement()
- if HUDMode == true then
- hudSelectedType = 0
- hudSelectedIndex = 0
- HideHighlight()
- DrawScreens()
- end
-end
-
-function ChangeHudSelectedElement(step)
- if HUDMode == true and (#damagedElements or #brokenElements) then
- local damagedElementsHUD = 12
- if #damagedElements < 12 then
- damagedElementsHUD = #damagedElements
- end
- local brokenElementsHUD = 12
- if #brokenElements < 12 then brokenElementsHUD = #brokenElements end
- if step == 1 then
- if hudSelectedIndex == 0 then
- if damagedElementsHUD > 0 then
- hudSelectedType = 1
- hudSelectedIndex = 1
- elseif brokenElementsHUD > 0 then
- hudSelectedType = 2
- hudSelectedIndex = 1
- end
- elseif hudSelectedType == 1 then
- if damagedElementsHUD > hudSelectedIndex then
- hudSelectedIndex = hudSelectedIndex + 1
- elseif brokenElementsHUD > 0 then
- hudSelectedType = 2
- hudSelectedIndex = 1
- elseif damagedElementsHUD > 0 then
- hudSelectedIndex = 1
- end
- elseif hudSelectedType == 2 then
- if brokenElementsHUD > hudSelectedIndex then
- hudSelectedIndex = hudSelectedIndex + 1
- elseif damagedElementsHUD > 0 then
- hudSelectedType = 1
- hudSelectedIndex = 1
- elseif brokenElementsHUD > 0 then
- hudSelectedIndex = 1
- end
- end
- elseif step == -1 then
- if hudSelectedIndex == 0 then
- if brokenElementsHUD > 0 then
- hudSelectedType = 2
- hudSelectedIndex = 1
- elseif damagedElementsHUD > 0 then
- hudSelectedType = 1
- hudSelectedIndex = 1
- end
- elseif hudSelectedType == 1 then
- if hudSelectedIndex > 1 then
- hudSelectedIndex = hudSelectedIndex - 1
- elseif brokenElementsHUD > 0 then
- hudSelectedType = 2
- hudSelectedIndex = brokenElementsHUD
- elseif damagedElementsHUD > 0 then
- hudSelectedIndex = damagedElementsHUD
- end
- elseif hudSelectedType == 2 then
- if hudSelectedIndex > 1 then
- hudSelectedIndex = hudSelectedIndex - 1
- elseif damagedElementsHUD > 0 then
- hudSelectedType = 1
- hudSelectedIndex = damagedElementsHUD
- elseif brokenElementsHUD > 0 then
- hudSelectedIndex = brokenElementsHUD
- end
- end
- end
- HighlightElement()
- DrawScreens()
- -- PrintDebug("-> Type: "..hudSelectedType.. " Index: "..hudSelectedIndex)
- end
-end
-
-function HideHighlight()
- if #hudArrowSticker > 0 then
- for i in pairs(hudArrowSticker) do
- core.deleteSticker(hudArrowSticker[i])
- end
- hudArrowSticker = {}
- end
-end
-
-function ShowHighlight()
- if highlightOn == true then
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX + 2,
- highlightY,
- highlightZ, "north"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,
- highlightY - 2,
- highlightZ, "east"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX - 2,
- highlightY,
- highlightZ, "south"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,
- highlightY + 2,
- highlightZ, "west"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,
- highlightY,
- highlightZ - 2,
- "up"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,
- highlightY,
- highlightZ + 2,
- "down"))
- end
-end
-
-function ToggleHighlight()
- if highlightOn == true then
- highlightOn = false
- HideHighlight()
- else
- highlightOn = true
- ShowHighlight()
- end
-end
-
-function HighlightElement(elementID)
- elementID = elementID or 0
- local targetElement = {}
-
- if elementID == 0 then
- if hudSelectedType == 1 then
- elementID = damagedElements[(CurrentDamagedPage - 1) * 12 +
- hudSelectedIndex].id
- elseif hudSelectedType == 2 then
- elementID = brokenElements[(CurrentBrokenPage - 1) * 12 +
- hudSelectedIndex].id
- end
-
- if elementID ~= 0 then
- local bFound = false
- for k, v in pairs(damagedElements) do
- if v.id == elementID then
- targetElement = v
- bFound = true
- break
- end
- end
- if bFound == false then
- for k, v in pairs(brokenElements) do
- if v.id == elementID then
- targetElement = v
- bFound = true
- break
- end
- end
- end
-
- if bFound == true and AllowElementHighlighting == true then
- HideHighlight()
- elementPosition = vec3(targetElement.pos)
- highlightX = elementPosition.x - coreWorldOffset
- highlightY = elementPosition.y - coreWorldOffset
- highlightZ = elementPosition.z - coreWorldOffset
- highlightOn = true
- ShowHighlight()
- end
- end
- end
-end
-
-function SortTables()
- -- Sort damaged elements descending by percent damaged according to setting
- if DamagedSortingMode == 1 then
- table.sort(damagedElements,
- function(a, b) return a.missinghp > b.missinghp end)
- elseif DamagedSortingMode == 2 then
- table.sort(damagedElements, function(a, b) return a.id < b.id end)
- else
- table.sort(damagedElements,
- function(a, b) return a.percent < b.percent end)
- end
-
- -- Sort broken elements descending according to setting
- if BrokenSortingMode == 1 then
- table.sort(brokenElements, function(a, b)
- return a.maxhp > b.maxhp
- end)
- else
- table.sort(brokenElements, function(a, b) return a.id < b.id end)
- end
-end
-
-function GenerateDamageData()
- if SimulationActive == true then return end
-
- local formerTotalShipHP = totalShipHP
- totalShipHP = 0
- totalShipMaxHP = 0
- totalShipIntegrity = 100
- elementsId = {}
- damagedElements = {}
- brokenElements = {}
- ElementCounter = 0
- healthyElements = 0
-
- elementsIdList = core.getElementIdList()
-
- for _, id in pairs(elementsIdList) do
- ElementCounter = ElementCounter + 1
- idHP = core.getElementHitPointsById(id) or 0
- idMaxHP = core.getElementMaxHitPointsById(id) or 0
-
- if SimulationMode then
- SimulationActive = true
- local dice = math.random(0, 10)
- if dice < 2 then
- idHP = 0
- elseif dice >= 2 and dice < 5 then
- idHP = idMaxHP
- else
- idHP = math.random(1, math.ceil(idMaxHP))
- end
- end
-
- totalShipHP = totalShipHP + idHP
- totalShipMaxHP = totalShipMaxHP + idMaxHP
-
- idName = core.getElementNameById(id)
-
- -- Is element damaged?
- if idMaxHP > idHP then
- idPos = core.getElementPositionById(id)
- idType = core.getElementTypeById(id)
- if idHP > 0 then
- table.insert(damagedElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP - idHP,
- percent = math.ceil(100 / idMaxHP * idHP),
- pos = idPos
- })
- -- if DebugMode then PrintDebug("Damaged: "..idName.." --- Type: "..idType.."") end
- -- Is element broken?
- else
- table.insert(brokenElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP - idHP,
- percent = 0,
- pos = idPos
- })
- -- if DebugMode then PrintDebug("Broken: "..idName.." --- Type: "..idType.."") end
- end
- else
- healthyElements = healthyElements + 1
- end
- end
-
- -- Sort tables by current settings
- SortTables()
-
- -- Update clickAreas
-
- -- Determine total ship integrity
- totalShipIntegrity = string.format("%2.0f",
- 100 / totalShipMaxHP * totalShipHP)
-
- -- Has anything changes since last check? If yes, force redrawing the screens
- if formerTotalShipHP ~= totalShipHP then
- forceRedraw = true
- formerTotalShipHP = totalShipHP
- else
- forceRedraw = false
- end
-end
-
-function GetAllSystemsNominalBackground()
- local output = ""
- output = output .. [[
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetDRLogo()
- output =
- [[]]
- return output
-end
-
-function GenerateHUDOutput()
-
- local hudWidth = 300
- local hudHeight = 125
- if #damagedElements > 0 or #brokenElements > 0 then hudHeight = 780 end
- local screenHeight = 1080
-
- local healthyColor = "#00aa00"
- local brokenColor = "#aa0000"
- local damagedColor = "#aaaa00"
- local integrityColor = "#aaaaaa"
- local healthyTextColor = "white"
- local brokenTextColor = "#ff4444"
- local damagedTextColor = "#ffff44"
- local integrityTextColor = "white"
-
- if #damagedElements == 0 then
- damagedColor = "#aaaaaa"
- damagedTextColor = "white"
- end
- if #brokenElements == 0 then
- brokenColor = "#aaaaaa"
- brokenTextColor = "white"
- end
-
- local hudOutput = ""
-
- -- Draw Header
- hudOutput = hudOutput .. [[
- ]]
-
- hudOutput = hudOutput .. [[]] ..
- [[]] .. GetDRLogo() .. [[]]
-
- hudOutput = hudOutput .. [[
-
- ]] .. healthyElements ..
- [[
-
- ]] .. #damagedElements ..
- [[
-
- ]] .. #brokenElements ..
- [[]]
- if #damagedElements > 0 or #brokenElements > 0 then
- hudOutput = hudOutput ..
- [[ ]] ..
- [[]] ..
- GenerateCommaValue(
- string.format("%.0f", totalShipMaxHP - totalShipHP)) ..
- [[ HP damage in total]]
- else
- hudOutput = hudOutput .. [[]] ..
- OkayCenterMessage .. [[]] ..
- [[Ship stands ]] ..
- GenerateCommaValue(string.format("%.0f", totalShipMaxHP)) ..
- [[ HP strong.]]
-
- end
- hudOutput = hudOutput .. [[]]
-
- hudRowDistance = 25
- if #damagedElements > 0 then
- local damagedElementsToDraw = #damagedElements
- if damagedElementsToDraw > 12 then damagedElementsToDraw = 12 end
- if CurrentDamagedPage == math.ceil(#damagedElements / 12) then
- damagedElementsToDraw = #damagedElements % 12
- end
- local i = 0
- hudOutput = hudOutput .. [[]] ..
- [[]]
-
- for j = 1 + (CurrentDamagedPage - 1) * 12, damagedElementsToDraw +
- (CurrentDamagedPage - 1) * 12, 1 do
- i = i + 1
- local DP = damagedElements[j]
- if (hudSelectedType == 1 and hudSelectedIndex == i) then
- hudOutput = hudOutput .. [[]]
- if UseMyElementNames == true then
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.name) ..
- [[]]
- else
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.type) ..
- [[]]
- end
- if (DamagedSortingMode == 3) then
- hudOutput = hudOutput .. [[]] .. DP.percent ..
- [[%]]
- else
- hudOutput = hudOutput .. [[]] ..
- GenerateCommaValue(
- string.format("%.0f", DP.missinghp)) ..
- [[]]
- end
- else
- if UseMyElementNames == true then
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.name) ..
- [[]]
- else
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.type) ..
- [[]]
- end
- if (DamagedSortingMode == 3) then
- hudOutput = hudOutput .. [[]] .. DP.percent ..
- [[%]]
- else
- hudOutput = hudOutput .. [[]] ..
- GenerateCommaValue(
- string.format("%.0f", DP.missinghp)) ..
- [[]]
- end
- hudOutput = hudOutput .. [[]]
- end
- end
- hudOutput = hudOutput .. [[]]
- end
-
- if #brokenElements > 0 then
- local brokenElementsToDraw = #brokenElements
- if brokenElementsToDraw > 12 then brokenElementsToDraw = 12 end
- if CurrentbrokenPage == math.ceil(#brokenElements / 12) then
- brokenElementsToDraw = #brokenElements % 12
- end
- local i = 0
- hudOutput = hudOutput .. [[]] ..
- [[]]
-
- for j = 1 + (CurrentBrokenPage - 1) * 12, brokenElementsToDraw +
- (CurrentBrokenPage - 1) * 12, 1 do
- i = i + 1
- local DP = brokenElements[j]
- if (hudSelectedType == 2 and hudSelectedIndex == i) then
- hudOutput = hudOutput .. [[]]
- if UseMyElementNames == true then
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.name) ..
- [[]]
- else
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.type) ..
- [[]]
- end
- if (brokenSortingMode == 3) then
- hudOutput = hudOutput .. [[]] .. DP.percent ..
- [[%]]
- else
- hudOutput = hudOutput .. [[]] ..
- GenerateCommaValue(
- string.format("%.0f", DP.missinghp)) ..
- [[]]
- end
- else
- if UseMyElementNames == true then
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.name) ..
- [[]]
- else
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.type) ..
- [[]]
- end
- if (brokenSortingMode == 3) then
- hudOutput = hudOutput .. [[]] .. DP.percent ..
- [[%]]
- else
- hudOutput = hudOutput .. [[]] ..
- GenerateCommaValue(
- string.format("%.0f", DP.missinghp)) ..
- [[]]
- end
- hudOutput = hudOutput .. [[]]
- end
- end
- hudOutput = hudOutput .. [[]]
- end
-
- if #damagedElements or #brokenElements then
- hudOutput = hudOutput .. [[]] ..
- [[Use up/down arrows to select element to find.]] ..
- [[Use right arrow to deselect.]] ..
- [[Use left arrow to exit HUD mode.]] ..
- [[]]
- end
-
- hudOutput = hudOutput .. [[]]
-
- return hudOutput
-end
-
-function DrawScreens()
- if #screens > 0 then
-
- local healthyColor = "#00aa00"
- local brokenColor = "#aa0000"
- local damagedColor = "#aaaa00"
- local integrityColor = "#aaaaaa"
- local healthyTextColor = "white"
- local brokenTextColor = "#ff4444"
- local damagedTextColor = "#ffff44"
- local integrityTextColor = "white"
-
- if #damagedElements == 0 then
- damagedColor = "#aaaaaa"
- damagedTextColor = "white"
- end
- if #brokenElements == 0 then
- brokenColor = "#aaaaaa"
- brokenTextColor = "white"
- end
-
- local screenOutput = ""
-
- -- Draw Header
- screenOutput = screenOutput ..
- [[
- ]]
-
- -- Draw main background
- screenOutput = screenOutput ..
- [[
-
-
-
-
-
-
-
-
-
-
-
- ]]
-
- -- Draw Title and summary
- if SimulationActive == true then
- screenOutput = screenOutput ..
- [[Simulated Report]]
- else
- screenOutput = screenOutput ..
- [[Damage Report]]
- end
- if YourShipsName == nil or YourShipsName == "" or YourShipsName ==
- "Enter here" then
- screenOutput = screenOutput ..
- [[SHIP ID ]] ..
- shipID .. [[]]
- else
- screenOutput = screenOutput ..
- [[]] ..
- YourShipsName .. [[]]
- end
- screenOutput = screenOutput .. [[
- Healthy
- ]] .. healthyElements ..
- [[
-
- Damaged
- ]] .. #damagedElements ..
- [[
-
- Broken
- ]] .. #brokenElements ..
- [[
-
- Integrity
- ]] .. totalShipIntegrity ..
- [[%]]
-
- -- Draw damage elements
-
- if #damagedElements > 0 then
- local damagedElementsToDraw = #damagedElements
- if damagedElementsToDraw > 12 then
- damagedElementsToDraw = 12
- end
- if CurrentDamagedPage == math.ceil(#damagedElements / 12) then
- damagedElementsToDraw = #damagedElements % 12
- end
- screenOutput = screenOutput ..
- [[]]
- screenOutput = screenOutput ..
- [[]]
- if (DamagedSortingMode == 2) then
- screenOutput = screenOutput ..
- [[ID]]
- else
- screenOutput = screenOutput ..
- [[ID]]
- end
- if UseMyElementNames == true then
- screenOutput = screenOutput ..
- [[Element Name]]
- else
- screenOutput = screenOutput ..
- [[Element Type]]
- end
-
- if (DamagedSortingMode == 3) then
- screenOutput = screenOutput ..
- [[Health]]
- else
- screenOutput = screenOutput ..
- [[Health]]
- end
- if (DamagedSortingMode == 1) then
- screenOutput = screenOutput ..
- [[Damage]]
- else
- screenOutput = screenOutput ..
- [[Damage]]
- end
-
- local i = 0
- for j = 1 + (CurrentDamagedPage - 1) * 12, damagedElementsToDraw +
- (CurrentDamagedPage - 1) * 12, 1 do
- i = i + 1
- local DP = damagedElements[j]
- screenOutput = screenOutput .. [[]] ..
- string.format("%03.0f", DP.id) .. [[]]
- if UseMyElementNames == true then
- screenOutput = screenOutput .. [[]] ..
- string.format("%.25s", DP.name) ..
- [[]]
- else
- screenOutput = screenOutput .. [[]] ..
- string.format("%.25s", DP.type) ..
- [[]]
- end
- screenOutput = screenOutput .. [[]] ..
- DP.percent .. [[%]] ..
- [[]] ..
- GenerateCommaValue(
- string.format("%.0f", DP.missinghp)) ..
- [[]] ..
- [[]]
- end
- screenOutput = screenOutput ..
- [[
-
- ]]
-
- if #damagedElements > 12 then
- screenOutput = screenOutput ..
- [[Page ]] ..
- CurrentDamagedPage .. " of " ..
- math.ceil(#damagedElements / 12) ..
- [[]]
-
- if CurrentDamagedPage < math.ceil(#damagedElements / 12) then
- screenOutput = screenOutput .. [[
-
-
- ]]
- UpdateClickArea("DamagedPageDown", {
- id = "DamagedPageDown",
- x1 = 70,
- x2 = 270,
- y1 = 350 + 11 + (damagedElementsToDraw + 1) * 50,
- y2 = 350 + 11 + 50 + (damagedElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("DamagedPageDown")
- end
-
- if CurrentDamagedPage > 1 then
- screenOutput = screenOutput .. [[
-
-
- ]]
- UpdateClickArea("DamagedPageUp", {
- id = "DamagedPageUp",
- x1 = 280,
- x2 = 480,
- y1 = 350 + 11 + (damagedElementsToDraw + 1) * 50,
- y2 = 350 + 11 + 50 + (damagedElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("DamagedPageUp")
- end
- end
- end
-
- -- Draw broken elements
- if #brokenElements > 0 then
- local brokenElementsToDraw = #brokenElements
- if brokenElementsToDraw > 12 then
- brokenElementsToDraw = 12
- end
- if CurrentBrokenPage == math.ceil(#brokenElements / 12) then
- brokenElementsToDraw = #brokenElements % 12
- end
- screenOutput = screenOutput ..
- [[]]
- screenOutput = screenOutput ..
- [[]]
- if (BrokenSortingMode == 2) then
- screenOutput = screenOutput ..
- [[ID]]
- else
- screenOutput = screenOutput ..
- [[ID]]
- end
- if UseMyElementNames == true then
- screenOutput = screenOutput ..
- [[Element Name]]
- else
- screenOutput = screenOutput ..
- [[Element Type]]
- end
- if (BrokenSortingMode == 1) then
- screenOutput = screenOutput ..
- [[Damage]]
- else
- screenOutput = screenOutput ..
- [[Damage]]
- end
-
- local i = 0
- for j = 1 + (CurrentBrokenPage - 1) * 12, brokenElementsToDraw +
- (CurrentBrokenPage - 1) * 12, 1 do
- i = i + 1
- local DP = brokenElements[j]
- screenOutput = screenOutput .. [[]] ..
- string.format("%03.0f", DP.id) .. [[]]
- if UseMyElementNames == true then
- screenOutput = screenOutput .. [[]] ..
- string.format("%.25s", DP.name) ..
- [[]]
- else
- screenOutput = screenOutput .. [[]] ..
- string.format("%.25s", DP.type) ..
- [[]]
- end
- screenOutput = screenOutput .. [[]] ..
- GenerateCommaValue(
- string.format("%.0f", DP.missinghp)) ..
- [[]] ..
- [[]]
- end
-
- screenOutput = screenOutput ..
- [[
-
- ]]
-
- if #brokenElements > 12 then
- screenOutput = screenOutput ..
- [[Page ]] ..
- CurrentBrokenPage .. " of " ..
- math.ceil(#brokenElements / 12) ..
- [[]]
-
- if CurrentBrokenPage > 1 then
- screenOutput = screenOutput .. [[
-
-
- ]]
- UpdateClickArea("BrokenPageUp", {
- id = "BrokenPageUp",
- x1 = 1442,
- x2 = 1642,
- y1 = 350 + 11 + (brokenElementsToDraw + 1) * 50,
- y2 = 350 + 11 + 50 + (brokenElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("BrokenPageUp")
- end
-
- if CurrentBrokenPage < math.ceil(#brokenElements / 12) then
- screenOutput = screenOutput .. [[
-
-
- ]]
- UpdateClickArea("BrokenPageDown", {
- id = "BrokenPageDown",
- x1 = 1652,
- x2 = 1852,
- y1 = 350 + 11 + (brokenElementsToDraw + 1) * 50,
- y2 = 350 + 11 + 50 + (brokenElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("BrokenPageDown")
- end
- end
-
- end
-
- -- Draw damage summary
- if #damagedElements > 0 or #brokenElements > 0 then
- screenOutput = screenOutput ..
- [[]] ..
- GenerateCommaValue(
- string.format("%.0f",
- totalShipMaxHP - totalShipHP)) ..
- [[ HP damage in total]]
- else
- screenOutput = screenOutput .. [[]] ..
- GetAllSystemsNominalBackground() .. [[]] ..
- [[]] ..
- OkayCenterMessage .. [[]] ..
- [[Ship stands ]] ..
- GenerateCommaValue(
- string.format("%.0f", totalShipMaxHP)) ..
- [[ HP strong.]]
- end
-
- -- Draw HUD Mode button
- if HUDMode == true then
- screenOutput = screenOutput ..
- [[]] ..
- [[HUD Mode activated]]
-
- else
- screenOutput = screenOutput ..
- [[]] ..
- [[Activate HUD Mode]]
- end
-
- screenOutput = screenOutput .. [[]]
-
- if HUDMode == true then
- system.setScreen(GenerateHUDOutput())
- system.showScreen(1)
- else
- system.showScreen(0)
- end
-
- DrawSVG(screenOutput)
-
- forceRedraw = false
- end
-end
-
------------------------------------------------
--- Execute
------------------------------------------------
-
-unit.hide()
-ClearConsole()
-PrintDebug("SCRIPT STARTED", true)
-
-InitiateSlots()
-SwitchScreens(true)
-InitiateClickAreas()
-
-if core == nil then
- DrawCenteredText("ERROR: No core connected.")
- PrintError("ERROR: No core connected.")
- goto exit
-else
- shipID = core.getConstructId()
-end
-
-GenerateDamageData()
-if forceRedraw then DrawScreens() end
-
-unit.setTimer('UpdateData', UpdateInterval)
-unit.setTimer('UpdateHighlight', HighlightBlinkingInterval)
-
-::exit::
diff --git a/src/DamageReport_2_2_UnitStart.lua b/src/DamageReport_2_2_UnitStart.lua
deleted file mode 100644
index 8e996ad..0000000
--- a/src/DamageReport_2_2_UnitStart.lua
+++ /dev/null
@@ -1,1393 +0,0 @@
---[[
- DamageReport v2.2
-
- Created By Dorian Gray
-
- Discord: Dorian Gray#2623
- InGame: DorianGray
- GitHub: https://github.com/DorianTheGrey/DU-DamageReport
-
- GNU Public License 3.0. Use whatever you want, be so kind to leave credit.
-
- Thanks to Jericho, Dmentia and Archaegeo for learning from their fine scripts.
-]] -----------------------------------------------
--- CONFIG
------------------------------------------------
-UseMyElementNames = true -- export: If you active this, the display will not show the element type of damaged/broken elements but the name you gave them (truncated to 25 characters)
-AllowElementHighlighting = true -- export: Are you allowing damaged/broken elements to be highlighted in 3D space when selected in the HUD?
-UpdateInterval = 1 -- export: Interval in seconds between updates of the calculations and (if anything changed) redrawing to the screen(s). You need to restart the script after changing this value.
-HighlightBlinkingInterval = 0.5 -- export: If an element is marked, how fast do you want the arrows to blink?
-SimulationMode = false -- export Randomize simluated damage on elements to check out the functionality of this script. And, no, your elements won't be harmed in the process :) You need to restart the script after changing this value.
-YourShipsName = "Enter here" -- export Enter your ship name here if you want it displayed instead of the ship's ID. YOU NEED TO LEAVE THE QUOTATION MARKS.
-
-DebugMode = false -- Activate if you want some console messages
-VersionNumber = 2.2 -- Version number
-
-core = nil
-screens = {}
-
-shipID = 0
-forceRedraw = false
-SimulationActive = false
-
-clickAreas = {}
-DamagedSortingMode = 1 -- Define default sorting mode for damaged elements. 1 to sort by damage amount, 2 to sort by element id, 3 to sort by damage percent,
-BrokenSortingMode = 1 -- Define default sorting mode for broken elements. 1 to sort by damage amount, 2 to sort by element id
-
-HUDMode = false -- Is Hud active?
-hudSelectedIndex = 0 -- Which element is selected?
-hudSelectedType = 0 -- Is selected element damaged (1) or broken (2)
-hudArrowSticker = {}
-highlightOn = false
-highlightID = 0
-highlightX = 0
-highlightY = 0
-highlightZ = 0
-
-CurrentDamagedPage = 1
-CurrentBrokenPage = 1
-
-coreWorldOffset = 0
-totalShipHP = 0
-totalShipMaxHP = 0
-totalShipIntegrity = 100
-elementsId = {}
-damagedElements = {}
-brokenElements = {}
-ElementCounter = 0
-healthyElements = 0
-
-OkayCenterMessage = "All systems nominal."
-
------------------------------------------------
--- FUNCTIONS
------------------------------------------------
-
-function GenerateCommaValue(amount)
- local formatted = amount
- while true do
- formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
- if (k == 0) then break end
- end
- return formatted
-end
-
-function PrintDebug(output, highlight)
- highlight = highlight or false
- if DebugMode then
- if highlight then
- system.print(
- "------------------------------------------------------------------------")
- end
- system.print(output)
- if highlight then
- system.print(
- "------------------------------------------------------------------------")
- end
- end
-end
-
-function PrintError(output) system.print(output) end
-
-function DrawCenteredText(output)
- for i = 1, #screens, 1 do screens[i].setCenteredText(output) end
-end
-
-function DrawSVG(output) for i = 1, #screens, 1 do screens[i].setSVG(output) end end
-
-function ClearConsole() for i = 1, 10, 1 do PrintDebug() end end
-
-function SwitchScreens(state)
- state = state or true
- if #screens > 0 then
- for i = 1, #screens, 1 do
- if state==true then
- screens[i].clear()
- screens[i].activate()
- else
- screens[i].deactivate()
- screens[i].clear()
- end
- end
- end
-end
-
-function InitiateSlots()
- for slot_name, slot in pairs(unit) do
- if type(slot) == "table" and type(slot.export) == "table" and
- slot.getElementClass then
- if slot.getElementClass():lower():find("coreunit") then
- core = slot
- local coreHP = core.getMaxHitPoints()
- if coreHP > 10000 then
- coreWorldOffset = 128
- elseif coreHP > 1000 then
- coreWorldOffset = 64
- elseif coreHP > 150 then
- coreWorldOffset = 32
- else
- coreWorldOffset = 16
- end
- end
- if slot.getElementClass():lower():find("screenunit") then
- screens[#screens + 1] = slot
- end
- end
- end
-end
-
-function AddClickArea(newEntry) table.insert(clickAreas, newEntry) end
-
-function RemoveFromClickAreas(candidate)
- for k, v in pairs(clickAreas) do
- if v.id == candidate then
- clickAreas[k] = nil
- break
- end
- end
-end
-
-function UpdateClickArea(candidate, newEntry)
- for k, v in pairs(clickAreas) do
- if v.id == candidate then
- clickAreas[k] = newEntry
- break
- end
- end
-end
-
-function DisableClickArea(candidate)
- for k, v in pairs(clickAreas) do
- if v.id == candidate then
- UpdateClickArea(candidate, {
- id = candidate,
- x1 = -1,
- x2 = -1,
- y1 = -1,
- y2 = -1
- })
- break
- end
- end
-end
-
-function InitiateClickAreas()
- clickAreas = {}
- AddClickArea({id = "DamagedDamage", x1 = 725, x2 = 870, y1 = 380, y2 = 415})
- AddClickArea({id = "DamagedHealth", x1 = 520, x2 = 655, y1 = 380, y2 = 415})
- AddClickArea({id = "DamagedID", x1 = 90, x2 = 150, y1 = 380, y2 = 415})
- AddClickArea({id = "BrokenDamage", x1 = 1675, x2 = 1835, y1 = 380, y2 = 415})
- AddClickArea({id = "BrokenID", x1 = 1050, x2 = 1110, y1 = 380, y2 = 415})
- AddClickArea({
- id = "ToggleSimulation",
- x1 = 65,
- x2 = 660,
- y1 = 100,
- y2 = 145
- })
- AddClickArea({
- id = "ToggleElementLabel",
- x1 = 225,
- x2 = 460,
- y1 = 380,
- y2 = 415
- })
- AddClickArea({
- id = "ToggleElementLabel2",
- x1 = 1185,
- x2 = 1440,
- y1 = 380,
- y2 = 415
- })
- AddClickArea({
- id = "ToggleHudMode",
- x1 = 1397,
- x2 = 1840,
- y1 = 133,
- y2 = 220
- })
- AddClickArea({id = "DamagedPageDown", x1 = -1, x2 = -1, y1 = -1, y2 = -1})
- AddClickArea({id = "DamagedPageUp", x1 = -1, x2 = -1, y1 = -1, y2 = -1})
- AddClickArea({id = "BrokenPageDown", x1 = -1, x2 = -1, y1 = -1, y2 = -1})
- AddClickArea({id = "BrokenPageUp", x1 = -1, x2 = -1, y1 = -1, y2 = -1})
-end
-
-function FlushClickAreas() clickAreas = {} end
-
-function CheckClick(x, y, HitTarget)
- HitTarget = HitTarget or ""
- if HitTarget == "" then
- for k, v in pairs(clickAreas) do
- if v and x >= v.x1 and x <= v.x2 and y >= v.y1 and y <= v.y2 then
- HitTarget = v.id
- break
- end
- end
- end
- if HitTarget == "DamagedDamage" then
- DamagedSortingMode = 1
- CurrentDamagedPage = 1
- SortTables()
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "DamagedHealth" then
- DamagedSortingMode = 3
- CurrentDamagedPage = 1
- SortTables()
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "DamagedID" then
- DamagedSortingMode = 2
- CurrentDamagedPage = 1
- SortTables()
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "BrokenDamage" then
- BrokenSortingMode = 1
- CurrentBrokenPage = 1
- SortTables()
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "BrokenID" then
- BrokenSortingMode = 2
- CurrentBrokenPage = 1
- SortTables()
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "DamagedPageDown" then
- CurrentDamagedPage = CurrentDamagedPage + 1
- if CurrentDamagedPage > math.ceil(#damagedElements / 12) then
- CurrentDamagedPage = math.ceil(#damagedElements / 12)
- end
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "DamagedPageUp" then
- CurrentDamagedPage = CurrentDamagedPage - 1
- if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "BrokenPageDown" then
- CurrentBrokenPage = CurrentBrokenPage + 1
- if CurrentBrokenPage > math.ceil(#brokenElements / 12) then
- CurrentBrokenPage = math.ceil(#brokenElements / 12)
- end
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "BrokenPageUp" then
- CurrentBrokenPage = CurrentBrokenPage - 1
- if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "ToggleHudMode" then
- if HUDMode == true then
- HUDMode = false
- forceRedraw = true
- HudDeselectElement()
- DrawScreens()
- else
- HUDMode = true
- forceRedraw = true
- HudDeselectElement()
- DrawScreens()
- end
- elseif HitTarget == "ToggleSimulation" then
- CurrentDamagedPage = 1
- CurrentBrokenPage = 1
- if SimulationMode == true then
- SimulationMode = false
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- HudDeselectElement()
- DrawScreens()
- else
- SimulationMode = true
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- HudDeselectElement()
- DrawScreens()
- end
- elseif HitTarget == "ToggleElementLabel" or HitTarget ==
- "ToggleElementLabel2" then
- if UseMyElementNames == true then
- UseMyElementNames = false
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- HudDeselectElement()
- DrawScreens()
- else
- UseMyElementNames = true
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- HudDeselectElement()
- DrawScreens()
- end
- end
-end
-
-function ToggleHUD()
- HideHighlight()
- CheckClick(nil, nil, "ToggleHudMode")
-end
-
-function HudDeselectElement()
- if HUDMode == true then
- hudSelectedType = 0
- hudSelectedIndex = 0
- HideHighlight()
- DrawScreens()
- end
-end
-
-function ChangeHudSelectedElement(step)
- if HUDMode == true and (#damagedElements or #brokenElements) then
- local damagedElementsHUD = 12
- if #damagedElements < 12 then
- damagedElementsHUD = #damagedElements
- end
- local brokenElementsHUD = 12
- if #brokenElements < 12 then brokenElementsHUD = #brokenElements end
- if step == 1 then
- if hudSelectedIndex == 0 then
- if damagedElementsHUD > 0 then
- hudSelectedType = 1
- hudSelectedIndex = 1
- elseif brokenElementsHUD > 0 then
- hudSelectedType = 2
- hudSelectedIndex = 1
- end
- elseif hudSelectedType == 1 then
- if damagedElementsHUD > hudSelectedIndex then
- hudSelectedIndex = hudSelectedIndex + 1
- elseif brokenElementsHUD > 0 then
- hudSelectedType = 2
- hudSelectedIndex = 1
- elseif damagedElementsHUD > 0 then
- hudSelectedIndex = 1
- end
- elseif hudSelectedType == 2 then
- if brokenElementsHUD > hudSelectedIndex then
- hudSelectedIndex = hudSelectedIndex + 1
- elseif damagedElementsHUD > 0 then
- hudSelectedType = 1
- hudSelectedIndex = 1
- elseif brokenElementsHUD > 0 then
- hudSelectedIndex = 1
- end
- end
- elseif step == -1 then
- if hudSelectedIndex == 0 then
- if brokenElementsHUD > 0 then
- hudSelectedType = 2
- hudSelectedIndex = 1
- elseif damagedElementsHUD > 0 then
- hudSelectedType = 1
- hudSelectedIndex = 1
- end
- elseif hudSelectedType == 1 then
- if hudSelectedIndex > 1 then
- hudSelectedIndex = hudSelectedIndex - 1
- elseif brokenElementsHUD > 0 then
- hudSelectedType = 2
- hudSelectedIndex = brokenElementsHUD
- elseif damagedElementsHUD > 0 then
- hudSelectedIndex = damagedElementsHUD
- end
- elseif hudSelectedType == 2 then
- if hudSelectedIndex > 1 then
- hudSelectedIndex = hudSelectedIndex - 1
- elseif damagedElementsHUD > 0 then
- hudSelectedType = 1
- hudSelectedIndex = damagedElementsHUD
- elseif brokenElementsHUD > 0 then
- hudSelectedIndex = brokenElementsHUD
- end
- end
- end
- HighlightElement()
- DrawScreens()
- -- PrintDebug("-> Type: "..hudSelectedType.. " Index: "..hudSelectedIndex)
- end
-end
-
-function HideHighlight()
- if #hudArrowSticker > 0 then
- for i in pairs(hudArrowSticker) do
- core.deleteSticker(hudArrowSticker[i])
- end
- hudArrowSticker = {}
- end
-end
-
-function ShowHighlight()
- if highlightOn == true and highlightID > 0 then
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX + 2,
- highlightY,
- highlightZ, "north"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,
- highlightY - 2,
- highlightZ, "east"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX - 2,
- highlightY,
- highlightZ, "south"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,
- highlightY + 2,
- highlightZ, "west"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,
- highlightY,
- highlightZ - 2,
- "up"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,
- highlightY,
- highlightZ + 2,
- "down"))
- end
-end
-
-function ToggleHighlight()
- if highlightOn == true then
- highlightOn = false
- HideHighlight()
- else
- highlightOn = true
- ShowHighlight()
- end
-end
-
-function HighlightElement(elementID)
- elementID = elementID or 0
- local targetElement = {}
-
- if elementID == 0 then
- if hudSelectedType == 1 then
- elementID = damagedElements[(CurrentDamagedPage - 1) * 12 +
- hudSelectedIndex].id
- elseif hudSelectedType == 2 then
- elementID = brokenElements[(CurrentBrokenPage - 1) * 12 +
- hudSelectedIndex].id
- end
-
- if elementID ~= 0 then
- local bFound = false
- for k, v in pairs(damagedElements) do
- if v.id == elementID then
- targetElement = v
- bFound = true
- break
- end
- end
- if bFound == false then
- for k, v in pairs(brokenElements) do
- if v.id == elementID then
- targetElement = v
- bFound = true
- break
- end
- end
- end
-
- if bFound == true and AllowElementHighlighting == true then
- HideHighlight()
- elementPosition = vec3(targetElement.pos)
- highlightX = elementPosition.x - coreWorldOffset
- highlightY = elementPosition.y - coreWorldOffset
- highlightZ = elementPosition.z - coreWorldOffset
- highlightID = targetElement.id
- highlightOn = true
- ShowHighlight()
- end
- end
- end
-end
-
-function SortTables()
- -- Sort damaged elements descending by percent damaged according to setting
- if DamagedSortingMode == 1 then
- table.sort(damagedElements,
- function(a, b) return a.missinghp > b.missinghp end)
- elseif DamagedSortingMode == 2 then
- table.sort(damagedElements, function(a, b) return a.id < b.id end)
- else
- table.sort(damagedElements,
- function(a, b) return a.percent < b.percent end)
- end
-
- -- Sort broken elements descending according to setting
- if BrokenSortingMode == 1 then
- table.sort(brokenElements, function(a, b)
- return a.maxhp > b.maxhp
- end)
- else
- table.sort(brokenElements, function(a, b) return a.id < b.id end)
- end
-end
-
-function GenerateDamageData()
- if SimulationActive == true then return end
-
- local formerTotalShipHP = totalShipHP
- totalShipHP = 0
- totalShipMaxHP = 0
- totalShipIntegrity = 100
- elementsId = {}
- damagedElements = {}
- brokenElements = {}
- ElementCounter = 0
- healthyElements = 0
-
- elementsIdList = core.getElementIdList()
-
- for _, id in pairs(elementsIdList) do
- ElementCounter = ElementCounter + 1
- idHP = core.getElementHitPointsById(id) or 0
- idMaxHP = core.getElementMaxHitPointsById(id) or 0
-
- if SimulationMode then
- SimulationActive = true
- local dice = math.random(0, 10)
- if dice < 2 then
- idHP = 0
- elseif dice >= 2 and dice < 5 then
- idHP = idMaxHP
- else
- idHP = math.random(1, math.ceil(idMaxHP))
- end
- end
-
- totalShipHP = totalShipHP + idHP
- totalShipMaxHP = totalShipMaxHP + idMaxHP
-
- idName = core.getElementNameById(id)
-
- -- Is element damaged?
- if idMaxHP > idHP then
- idPos = core.getElementPositionById(id)
- idType = core.getElementTypeById(id)
- if idHP > 0 then
- table.insert(damagedElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP - idHP,
- percent = math.ceil(100 / idMaxHP * idHP),
- pos = idPos
- })
- -- if DebugMode then PrintDebug("Damaged: "..idName.." --- Type: "..idType.."") end
- -- Is element broken?
- else
- table.insert(brokenElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP - idHP,
- percent = 0,
- pos = idPos
- })
- -- if DebugMode then PrintDebug("Broken: "..idName.." --- Type: "..idType.."") end
- end
- else
- healthyElements = healthyElements + 1
- if id == highlightID then
- highlightID = 0
- end
- end
- end
-
- -- Sort tables by current settings
- SortTables()
-
- -- Update clickAreas
-
- -- Determine total ship integrity
- totalShipIntegrity = string.format("%2.0f",
- 100 / totalShipMaxHP * totalShipHP)
-
- -- Has anything changes since last check? If yes, force redrawing the screens
- if formerTotalShipHP ~= totalShipHP then
- forceRedraw = true
- formerTotalShipHP = totalShipHP
- else
- forceRedraw = false
- end
-end
-
-function GetAllSystemsNominalBackground()
- local output = ""
- output = output .. [[
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetDRLogo()
- output =
- [[]]
- return output
-end
-
-function GenerateHUDOutput()
-
- local hudWidth = 300
- local hudHeight = 125
- if #damagedElements > 0 or #brokenElements > 0 then hudHeight = 780 end
- local screenHeight = 1080
-
- local healthyColor = "#00aa00"
- local brokenColor = "#aa0000"
- local damagedColor = "#aaaa00"
- local integrityColor = "#aaaaaa"
- local healthyTextColor = "white"
- local brokenTextColor = "#ff4444"
- local damagedTextColor = "#ffff44"
- local integrityTextColor = "white"
-
- if #damagedElements == 0 then
- damagedColor = "#aaaaaa"
- damagedTextColor = "white"
- end
- if #brokenElements == 0 then
- brokenColor = "#aaaaaa"
- brokenTextColor = "white"
- end
-
- local hudOutput = ""
-
- -- Draw Header
- hudOutput = hudOutput .. [[
- ]]
-
- hudOutput = hudOutput .. [[]] ..
- [[]] .. GetDRLogo() .. [[]]
-
- hudOutput = hudOutput .. [[
-
- ]] .. healthyElements ..
- [[
-
- ]] .. #damagedElements ..
- [[
-
- ]] .. #brokenElements ..
- [[]]
- if #damagedElements > 0 or #brokenElements > 0 then
- hudOutput = hudOutput ..
- [[ ]] ..
- [[]] ..
- GenerateCommaValue(
- string.format("%.0f", totalShipMaxHP - totalShipHP)) ..
- [[ HP damage in total]]
- else
- hudOutput = hudOutput .. [[]] ..
- OkayCenterMessage .. [[]] ..
- [[Ship stands ]] ..
- GenerateCommaValue(string.format("%.0f", totalShipMaxHP)) ..
- [[ HP strong.]]
-
- end
- hudOutput = hudOutput .. [[]]
-
- hudRowDistance = 25
- if #damagedElements > 0 then
- local damagedElementsToDraw = #damagedElements
- if damagedElementsToDraw > 12 then damagedElementsToDraw = 12 end
- if CurrentDamagedPage == math.ceil(#damagedElements / 12) then
- damagedElementsToDraw = #damagedElements % 12
- end
- local i = 0
- hudOutput = hudOutput .. [[]] ..
- [[]]
-
- for j = 1 + (CurrentDamagedPage - 1) * 12, damagedElementsToDraw +
- (CurrentDamagedPage - 1) * 12, 1 do
- i = i + 1
- local DP = damagedElements[j]
- if (hudSelectedType == 1 and hudSelectedIndex == i) then
- hudOutput = hudOutput .. [[]]
- if UseMyElementNames == true then
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.name) ..
- [[]]
- else
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.type) ..
- [[]]
- end
- if (DamagedSortingMode == 3) then
- hudOutput = hudOutput .. [[]] .. DP.percent ..
- [[%]]
- else
- hudOutput = hudOutput .. [[]] ..
- GenerateCommaValue(
- string.format("%.0f", DP.missinghp)) ..
- [[]]
- end
- else
- if UseMyElementNames == true then
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.name) ..
- [[]]
- else
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.type) ..
- [[]]
- end
- if (DamagedSortingMode == 3) then
- hudOutput = hudOutput .. [[]] .. DP.percent ..
- [[%]]
- else
- hudOutput = hudOutput .. [[]] ..
- GenerateCommaValue(
- string.format("%.0f", DP.missinghp)) ..
- [[]]
- end
- hudOutput = hudOutput .. [[]]
- end
- end
- hudOutput = hudOutput .. [[]]
- end
-
- if #brokenElements > 0 then
- local brokenElementsToDraw = #brokenElements
- if brokenElementsToDraw > 12 then brokenElementsToDraw = 12 end
- if CurrentbrokenPage == math.ceil(#brokenElements / 12) then
- brokenElementsToDraw = #brokenElements % 12
- end
- local i = 0
- hudOutput = hudOutput .. [[]] ..
- [[]]
-
- for j = 1 + (CurrentBrokenPage - 1) * 12, brokenElementsToDraw +
- (CurrentBrokenPage - 1) * 12, 1 do
- i = i + 1
- local DP = brokenElements[j]
- if (hudSelectedType == 2 and hudSelectedIndex == i) then
- hudOutput = hudOutput .. [[]]
- if UseMyElementNames == true then
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.name) ..
- [[]]
- else
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.type) ..
- [[]]
- end
- if (brokenSortingMode == 3) then
- hudOutput = hudOutput .. [[]] .. DP.percent ..
- [[%]]
- else
- hudOutput = hudOutput .. [[]] ..
- GenerateCommaValue(
- string.format("%.0f", DP.missinghp)) ..
- [[]]
- end
- else
- if UseMyElementNames == true then
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.name) ..
- [[]]
- else
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.type) ..
- [[]]
- end
- if (brokenSortingMode == 3) then
- hudOutput = hudOutput .. [[]] .. DP.percent ..
- [[%]]
- else
- hudOutput = hudOutput .. [[]] ..
- GenerateCommaValue(
- string.format("%.0f", DP.missinghp)) ..
- [[]]
- end
- hudOutput = hudOutput .. [[]]
- end
- end
- hudOutput = hudOutput .. [[]]
- end
-
- if #damagedElements or #brokenElements then
- hudOutput = hudOutput .. [[]] ..
- [[Use up/down arrows to select element to find.]] ..
- [[Use right arrow to deselect.]] ..
- [[Use left arrow to exit HUD mode.]] ..
- [[]]
- end
-
- hudOutput = hudOutput .. [[]]
-
- return hudOutput
-end
-
-function DrawScreens()
- if #screens > 0 then
-
- local healthyColor = "#00aa00"
- local brokenColor = "#aa0000"
- local damagedColor = "#aaaa00"
- local integrityColor = "#aaaaaa"
- local healthyTextColor = "white"
- local brokenTextColor = "#ff4444"
- local damagedTextColor = "#ffff44"
- local integrityTextColor = "white"
-
- if #damagedElements == 0 then
- damagedColor = "#aaaaaa"
- damagedTextColor = "white"
- end
- if #brokenElements == 0 then
- brokenColor = "#aaaaaa"
- brokenTextColor = "white"
- end
-
- local screenOutput = ""
-
- -- Draw Header
- screenOutput = screenOutput ..
- [[
- ]]
-
- -- Draw main background
- screenOutput = screenOutput ..
- [[
-
-
-
-
-
-
-
-
-
-
-
- ]]
-
- -- Draw Title and summary
- if SimulationActive == true then
- screenOutput = screenOutput ..
- [[Simulated Report]]
- else
- screenOutput = screenOutput ..
- [[Damage Report]]
- end
- if YourShipsName == nil or YourShipsName == "" or YourShipsName ==
- "Enter here" then
- screenOutput = screenOutput ..
- [[SHIP ID ]] ..
- shipID .. [[]]
- else
- screenOutput = screenOutput ..
- [[]] ..
- YourShipsName .. [[]]
- end
- screenOutput = screenOutput .. [[
- Healthy
- ]] .. healthyElements ..
- [[
-
- Damaged
- ]] .. #damagedElements ..
- [[
-
- Broken
- ]] .. #brokenElements ..
- [[
-
- Integrity
- ]] .. totalShipIntegrity ..
- [[%]]
-
- -- Draw damage elements
-
- if #damagedElements > 0 then
- local damagedElementsToDraw = #damagedElements
- if damagedElementsToDraw > 12 then
- damagedElementsToDraw = 12
- end
- if CurrentDamagedPage == math.ceil(#damagedElements / 12) then
- damagedElementsToDraw = #damagedElements % 12
- end
- screenOutput = screenOutput ..
- [[]]
- screenOutput = screenOutput ..
- [[]]
- if (DamagedSortingMode == 2) then
- screenOutput = screenOutput ..
- [[ID]]
- else
- screenOutput = screenOutput ..
- [[ID]]
- end
- if UseMyElementNames == true then
- screenOutput = screenOutput ..
- [[Element Name]]
- else
- screenOutput = screenOutput ..
- [[Element Type]]
- end
-
- if (DamagedSortingMode == 3) then
- screenOutput = screenOutput ..
- [[Health]]
- else
- screenOutput = screenOutput ..
- [[Health]]
- end
- if (DamagedSortingMode == 1) then
- screenOutput = screenOutput ..
- [[Damage]]
- else
- screenOutput = screenOutput ..
- [[Damage]]
- end
-
- local i = 0
- for j = 1 + (CurrentDamagedPage - 1) * 12, damagedElementsToDraw +
- (CurrentDamagedPage - 1) * 12, 1 do
- i = i + 1
- local DP = damagedElements[j]
- screenOutput = screenOutput .. [[]] ..
- string.format("%03.0f", DP.id) .. [[]]
- if UseMyElementNames == true then
- screenOutput = screenOutput .. [[]] ..
- string.format("%.25s", DP.name) ..
- [[]]
- else
- screenOutput = screenOutput .. [[]] ..
- string.format("%.25s", DP.type) ..
- [[]]
- end
- screenOutput = screenOutput .. [[]] ..
- DP.percent .. [[%]] ..
- [[]] ..
- GenerateCommaValue(
- string.format("%.0f", DP.missinghp)) ..
- [[]] ..
- [[]]
- end
- screenOutput = screenOutput ..
- [[
-
- ]]
-
- if #damagedElements > 12 then
- screenOutput = screenOutput ..
- [[Page ]] ..
- CurrentDamagedPage .. " of " ..
- math.ceil(#damagedElements / 12) ..
- [[]]
-
- if CurrentDamagedPage < math.ceil(#damagedElements / 12) then
- screenOutput = screenOutput .. [[
-
-
- ]]
- UpdateClickArea("DamagedPageDown", {
- id = "DamagedPageDown",
- x1 = 70,
- x2 = 270,
- y1 = 350 + 11 + (damagedElementsToDraw + 1) * 50,
- y2 = 350 + 11 + 50 + (damagedElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("DamagedPageDown")
- end
-
- if CurrentDamagedPage > 1 then
- screenOutput = screenOutput .. [[
-
-
- ]]
- UpdateClickArea("DamagedPageUp", {
- id = "DamagedPageUp",
- x1 = 280,
- x2 = 480,
- y1 = 350 + 11 + (damagedElementsToDraw + 1) * 50,
- y2 = 350 + 11 + 50 + (damagedElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("DamagedPageUp")
- end
- end
- end
-
- -- Draw broken elements
- if #brokenElements > 0 then
- local brokenElementsToDraw = #brokenElements
- if brokenElementsToDraw > 12 then
- brokenElementsToDraw = 12
- end
- if CurrentBrokenPage == math.ceil(#brokenElements / 12) then
- brokenElementsToDraw = #brokenElements % 12
- end
- screenOutput = screenOutput ..
- [[]]
- screenOutput = screenOutput ..
- [[]]
- if (BrokenSortingMode == 2) then
- screenOutput = screenOutput ..
- [[ID]]
- else
- screenOutput = screenOutput ..
- [[ID]]
- end
- if UseMyElementNames == true then
- screenOutput = screenOutput ..
- [[Element Name]]
- else
- screenOutput = screenOutput ..
- [[Element Type]]
- end
- if (BrokenSortingMode == 1) then
- screenOutput = screenOutput ..
- [[Damage]]
- else
- screenOutput = screenOutput ..
- [[Damage]]
- end
-
- local i = 0
- for j = 1 + (CurrentBrokenPage - 1) * 12, brokenElementsToDraw +
- (CurrentBrokenPage - 1) * 12, 1 do
- i = i + 1
- local DP = brokenElements[j]
- screenOutput = screenOutput .. [[]] ..
- string.format("%03.0f", DP.id) .. [[]]
- if UseMyElementNames == true then
- screenOutput = screenOutput .. [[]] ..
- string.format("%.25s", DP.name) ..
- [[]]
- else
- screenOutput = screenOutput .. [[]] ..
- string.format("%.25s", DP.type) ..
- [[]]
- end
- screenOutput = screenOutput .. [[]] ..
- GenerateCommaValue(
- string.format("%.0f", DP.missinghp)) ..
- [[]] ..
- [[]]
- end
-
- screenOutput = screenOutput ..
- [[
-
- ]]
-
- if #brokenElements > 12 then
- screenOutput = screenOutput ..
- [[Page ]] ..
- CurrentBrokenPage .. " of " ..
- math.ceil(#brokenElements / 12) ..
- [[]]
-
- if CurrentBrokenPage > 1 then
- screenOutput = screenOutput .. [[
-
-
- ]]
- UpdateClickArea("BrokenPageUp", {
- id = "BrokenPageUp",
- x1 = 1442,
- x2 = 1642,
- y1 = 350 + 11 + (brokenElementsToDraw + 1) * 50,
- y2 = 350 + 11 + 50 + (brokenElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("BrokenPageUp")
- end
-
- if CurrentBrokenPage < math.ceil(#brokenElements / 12) then
- screenOutput = screenOutput .. [[
-
-
- ]]
- UpdateClickArea("BrokenPageDown", {
- id = "BrokenPageDown",
- x1 = 1652,
- x2 = 1852,
- y1 = 350 + 11 + (brokenElementsToDraw + 1) * 50,
- y2 = 350 + 11 + 50 + (brokenElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("BrokenPageDown")
- end
- end
-
- end
-
- -- Draw damage summary
- if #damagedElements > 0 or #brokenElements > 0 then
- screenOutput = screenOutput ..
- [[]] ..
- GenerateCommaValue(
- string.format("%.0f",
- totalShipMaxHP - totalShipHP)) ..
- [[ HP damage in total]]
- else
- screenOutput = screenOutput .. [[]] ..
- GetAllSystemsNominalBackground() .. [[]] ..
- [[]] ..
- OkayCenterMessage .. [[]] ..
- [[Ship stands ]] ..
- GenerateCommaValue(
- string.format("%.0f", totalShipMaxHP)) ..
- [[ HP strong.]]
- end
-
- -- Draw HUD Mode button
- if HUDMode == true then
- screenOutput = screenOutput ..
- [[]] ..
- [[HUD Mode activated]]
-
- else
- screenOutput = screenOutput ..
- [[]] ..
- [[Activate HUD Mode]]
- end
-
- screenOutput = screenOutput .. [[]]
-
- if HUDMode == true then
- system.setScreen(GenerateHUDOutput())
- system.showScreen(1)
- else
- system.showScreen(0)
- end
-
- DrawSVG(screenOutput)
-
- forceRedraw = false
- end
-end
-
------------------------------------------------
--- Execute
------------------------------------------------
-
-unit.hide()
-ClearConsole()
-PrintDebug("SCRIPT STARTED", true)
-
-InitiateSlots()
-SwitchScreens(true)
-InitiateClickAreas()
-
-if core == nil then
- DrawCenteredText("ERROR: No core connected.")
- PrintError("ERROR: No core connected.")
- goto exit
-else
- shipID = core.getConstructId()
-end
-
-GenerateDamageData()
-if forceRedraw then DrawScreens() end
-
-unit.setTimer('UpdateData', UpdateInterval)
-unit.setTimer('UpdateHighlight', HighlightBlinkingInterval)
-
-::exit::
diff --git a/src/DamageReport_2_31_UnitStart.lua b/src/DamageReport_2_31_UnitStart.lua
deleted file mode 100644
index ad0e0ed..0000000
--- a/src/DamageReport_2_31_UnitStart.lua
+++ /dev/null
@@ -1,1382 +0,0 @@
---[[
- DamageReport v2.31
- Created By Dorian Gray
-
- Discord: Dorian Gray#2623
- InGame: DorianGray
- GitHub: https://github.com/DorianTheGrey/DU-DamageReport
-
- GNU Public License 3.0. Use whatever you want, be so kind to leave credit.
-
- Thanks to Jericho, Dmentia and Archaegeo for learning from their fine scripts.
-]]
------------------------------------------------
--- CONFIG
------------------------------------------------
-UseMyElementNames = true --export: If you active this, the display will not show the element type of damaged/broken elements but the name you gave them (truncated to 25 characters)
-AllowElementHighlighting = true --export: Are you allowing damaged/broken elements to be highlighted in 3D space when selected in the HUD?
-UpdateInterval = 1 --export: Interval in seconds between updates of the calculations and (if anything changed) redrawing to the screen(s). You need to restart the script after changing this value.
-HighlightBlinkingInterval = 0.5 --export: If an element is marked, how fast do you want the arrows to blink?
-SimulationMode = false --export Randomize simluated damage on elements to check out the functionality of this script. And, no, your elements won't be harmed in the process :) You need to restart the script after changing this value.
-YourShipsName = "Enter here" --export Enter your ship name here if you want it displayed instead of the ship's ID. YOU NEED TO LEAVE THE QUOTATION MARKS.
-
-DebugMode = false -- Activate if you want some console messages
-VersionNumber = 2.31 -- Version number
-
-core = nil
-screens = {}
-
-shipID = 0
-forceRedraw = false
-SimulationActive = false
-
-clickAreas = {}
-DamagedSortingMode = 1 -- Define default sorting mode for damaged elements. 1 to sort by damage amount, 2 to sort by element id, 3 to sort by damage percent,
-BrokenSortingMode = 1 -- Define default sorting mode for broken elements. 1 to sort by damage amount, 2 to sort by element id
-
-HUDMode = false -- Is Hud active?
-hudSelectedIndex = 0 -- Which element is selected?
-hudSelectedType = 0 -- Is selected element damaged (1) or broken (2)
-hudArrowSticker = {}
-highlightOn = false
-highlightID = 0
-highlightX = 0
-highlightY = 0
-highlightZ = 0
-
-CurrentDamagedPage = 1
-CurrentBrokenPage = 1
-
-coreWorldOffset = 0
-totalShipHP = 0
-totalShipMaxHP = 0
-totalShipIntegrity = 100
-elementsId = {}
-damagedElements = {}
-brokenElements = {}
-ElementCounter = 0
-healthyElements = 0
-
-OkayCenterMessage = "All systems nominal."
-
------------------------------------------------
--- FUNCTIONS
------------------------------------------------
-
-function GenerateCommaValue(amount)
- local formatted = amount
- while true do
- formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
- if (k == 0) then break end
- end
- return formatted
-end
-
-function PrintDebug(output, highlight)
- highlight = highlight or false
- if DebugMode then
- if highlight then
- system.print(
- "------------------------------------------------------------------------")
- end
- system.print(output)
- if highlight then
- system.print(
- "------------------------------------------------------------------------")
- end
- end
-end
-
-function PrintError(output) system.print(output) end
-
-function DrawCenteredText(output)
- for i = 1, #screens, 1 do screens[i].setCenteredText(output) end
-end
-
-function DrawSVG(output) for i = 1, #screens, 1 do screens[i].setSVG(output) end end
-
-function ClearConsole() for i = 1, 10, 1 do PrintDebug() end end
-
-function SwitchScreens(state)
- state = state or true
- if #screens > 0 then
- for i = 1, #screens, 1 do
- if state==true then
- screens[i].clear()
- screens[i].activate()
- else
- screens[i].deactivate()
- screens[i].clear()
- end
- end
- end
-end
-
-function InitiateSlots()
- for slot_name, slot in pairs(unit) do
- if type(slot) == "table" and type(slot.export) == "table" and
- slot.getElementClass then
- if slot.getElementClass():lower():find("coreunit") then
- core = slot
- local coreHP = core.getMaxHitPoints()
- if coreHP > 10000 then
- coreWorldOffset = 128
- elseif coreHP > 1000 then
- coreWorldOffset = 64
- elseif coreHP > 150 then
- coreWorldOffset = 32
- else
- coreWorldOffset = 16
- end
- end
- if slot.getElementClass():lower():find("screenunit") then
- screens[#screens + 1] = slot
- end
- end
- end
-end
-
-function AddClickArea(newEntry) table.insert(clickAreas, newEntry) end
-
-function RemoveFromClickAreas(candidate)
- for k, v in pairs(clickAreas) do
- if v.id == candidate then
- clickAreas[k] = nil
- break
- end
- end
-end
-
-function UpdateClickArea(candidate, newEntry)
- for k, v in pairs(clickAreas) do
- if v.id == candidate then
- clickAreas[k] = newEntry
- break
- end
- end
-end
-
-function DisableClickArea(candidate)
- for k, v in pairs(clickAreas) do
- if v.id == candidate then
- UpdateClickArea(candidate, {
- id = candidate,
- x1 = -1,
- x2 = -1,
- y1 = -1,
- y2 = -1
- })
- break
- end
- end
-end
-
-function InitiateClickAreas()
- clickAreas = {}
- AddClickArea({id = "DamagedDamage", x1 = 725, x2 = 870, y1 = 380, y2 = 415})
- AddClickArea({id = "DamagedHealth", x1 = 520, x2 = 655, y1 = 380, y2 = 415})
- AddClickArea({id = "DamagedID", x1 = 90, x2 = 150, y1 = 380, y2 = 415})
- AddClickArea({id = "BrokenDamage", x1 = 1675, x2 = 1835, y1 = 380, y2 = 415})
- AddClickArea({id = "BrokenID", x1 = 1050, x2 = 1110, y1 = 380, y2 = 415})
- AddClickArea({id = "ToggleSimulation", x1 = 65, x2 = 660, y1 = 100, y2 = 145})
- AddClickArea({id = "ToggleSimulation2", x1 = 1650, x2 = 1850, y1 = 75, y2 = 117})
- AddClickArea({id = "ToggleElementLabel", x1 = 225, x2 = 460, y1 = 380, y2 = 415})
- AddClickArea({id = "ToggleElementLabel2", x1 = 1185, x2 = 1440, y1 = 380, y2 = 415})
- AddClickArea({id = "ToggleHudMode", x1 = 1650, x2 = 1850, y1 = 125, y2 = 167})
- AddClickArea({id = "DamagedPageDown", x1 = -1, x2 = -1, y1 = -1, y2 = -1})
- AddClickArea({id = "DamagedPageUp", x1 = -1, x2 = -1, y1 = -1, y2 = -1})
- AddClickArea({id = "BrokenPageDown", x1 = -1, x2 = -1, y1 = -1, y2 = -1})
- AddClickArea({id = "BrokenPageUp", x1 = -1, x2 = -1, y1 = -1, y2 = -1})
-end
-
-function FlushClickAreas() clickAreas = {} end
-
-function CheckClick(x, y, HitTarget)
- HitTarget = HitTarget or ""
- if HitTarget == "" then
- for k, v in pairs(clickAreas) do
- if v and x >= v.x1 and x <= v.x2 and y >= v.y1 and y <= v.y2 then
- HitTarget = v.id
- break
- end
- end
- end
- if HitTarget == "DamagedDamage" then
- DamagedSortingMode = 1
- CurrentDamagedPage = 1
- SortTables()
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "DamagedHealth" then
- DamagedSortingMode = 3
- CurrentDamagedPage = 1
- SortTables()
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "DamagedID" then
- DamagedSortingMode = 2
- CurrentDamagedPage = 1
- SortTables()
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "BrokenDamage" then
- BrokenSortingMode = 1
- CurrentBrokenPage = 1
- SortTables()
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "BrokenID" then
- BrokenSortingMode = 2
- CurrentBrokenPage = 1
- SortTables()
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "DamagedPageDown" then
- CurrentDamagedPage = CurrentDamagedPage + 1
- if CurrentDamagedPage > math.ceil(#damagedElements / 12) then
- CurrentDamagedPage = math.ceil(#damagedElements / 12)
- end
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "DamagedPageUp" then
- CurrentDamagedPage = CurrentDamagedPage - 1
- if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "BrokenPageDown" then
- CurrentBrokenPage = CurrentBrokenPage + 1
- if CurrentBrokenPage > math.ceil(#brokenElements / 12) then
- CurrentBrokenPage = math.ceil(#brokenElements / 12)
- end
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "BrokenPageUp" then
- CurrentBrokenPage = CurrentBrokenPage - 1
- if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "ToggleHudMode" then
- if HUDMode == true then
- HUDMode = false
- forceRedraw = true
- HudDeselectElement()
- DrawScreens()
- else
- HUDMode = true
- forceRedraw = true
- HudDeselectElement()
- DrawScreens()
- end
- elseif HitTarget == "ToggleSimulation" or HitTarget == "ToggleSimulation2" then
- CurrentDamagedPage = 1
- CurrentBrokenPage = 1
- if SimulationMode == true then
- SimulationMode = false
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- HudDeselectElement()
- DrawScreens()
- else
- SimulationMode = true
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- HudDeselectElement()
- DrawScreens()
- end
- elseif HitTarget == "ToggleElementLabel" or HitTarget ==
- "ToggleElementLabel2" then
- if UseMyElementNames == true then
- UseMyElementNames = false
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- HudDeselectElement()
- DrawScreens()
- else
- UseMyElementNames = true
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- HudDeselectElement()
- DrawScreens()
- end
- end
-end
-
-function ToggleHUD()
- HideHighlight()
- CheckClick(nil, nil, "ToggleHudMode")
-end
-
-function HudDeselectElement()
- if HUDMode == true then
- hudSelectedType = 0
- hudSelectedIndex = 0
- HideHighlight()
- DrawScreens()
- end
-end
-
-function ChangeHudSelectedElement(step)
- if HUDMode == true and (#damagedElements or #brokenElements) then
- local damagedElementsHUD = 12
- if #damagedElements < 12 then
- damagedElementsHUD = #damagedElements
- end
- local brokenElementsHUD = 12
- if #brokenElements < 12 then brokenElementsHUD = #brokenElements end
- if step == 1 then
- if hudSelectedIndex == 0 then
- if damagedElementsHUD > 0 then
- hudSelectedType = 1
- hudSelectedIndex = 1
- elseif brokenElementsHUD > 0 then
- hudSelectedType = 2
- hudSelectedIndex = 1
- end
- elseif hudSelectedType == 1 then
- if damagedElementsHUD > hudSelectedIndex then
- hudSelectedIndex = hudSelectedIndex + 1
- elseif brokenElementsHUD > 0 then
- hudSelectedType = 2
- hudSelectedIndex = 1
- elseif damagedElementsHUD > 0 then
- hudSelectedIndex = 1
- end
- elseif hudSelectedType == 2 then
- if brokenElementsHUD > hudSelectedIndex then
- hudSelectedIndex = hudSelectedIndex + 1
- elseif damagedElementsHUD > 0 then
- hudSelectedType = 1
- hudSelectedIndex = 1
- elseif brokenElementsHUD > 0 then
- hudSelectedIndex = 1
- end
- end
- elseif step == -1 then
- if hudSelectedIndex == 0 then
- if brokenElementsHUD > 0 then
- hudSelectedType = 2
- hudSelectedIndex = 1
- elseif damagedElementsHUD > 0 then
- hudSelectedType = 1
- hudSelectedIndex = 1
- end
- elseif hudSelectedType == 1 then
- if hudSelectedIndex > 1 then
- hudSelectedIndex = hudSelectedIndex - 1
- elseif brokenElementsHUD > 0 then
- hudSelectedType = 2
- hudSelectedIndex = brokenElementsHUD
- elseif damagedElementsHUD > 0 then
- hudSelectedIndex = damagedElementsHUD
- end
- elseif hudSelectedType == 2 then
- if hudSelectedIndex > 1 then
- hudSelectedIndex = hudSelectedIndex - 1
- elseif damagedElementsHUD > 0 then
- hudSelectedType = 1
- hudSelectedIndex = damagedElementsHUD
- elseif brokenElementsHUD > 0 then
- hudSelectedIndex = brokenElementsHUD
- end
- end
- end
- HighlightElement()
- DrawScreens()
- -- PrintDebug("-> Type: "..hudSelectedType.. " Index: "..hudSelectedIndex)
- end
-end
-
-function HideHighlight()
- if #hudArrowSticker > 0 then
- for i in pairs(hudArrowSticker) do
- core.deleteSticker(hudArrowSticker[i])
- end
- hudArrowSticker = {}
- end
-end
-
-function ShowHighlight()
- if highlightOn == true and highlightID > 0 then
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX + 2,
- highlightY,
- highlightZ, "north"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,
- highlightY - 2,
- highlightZ, "east"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX - 2,
- highlightY,
- highlightZ, "south"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,
- highlightY + 2,
- highlightZ, "west"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,
- highlightY,
- highlightZ - 2,
- "up"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,
- highlightY,
- highlightZ + 2,
- "down"))
- end
-end
-
-function ToggleHighlight()
- if highlightOn == true then
- highlightOn = false
- HideHighlight()
- else
- highlightOn = true
- ShowHighlight()
- end
-end
-
-function HighlightElement(elementID)
- elementID = elementID or 0
- local targetElement = {}
-
- if elementID == 0 then
- if hudSelectedType == 1 then
- elementID = damagedElements[(CurrentDamagedPage - 1) * 12 +
- hudSelectedIndex].id
- elseif hudSelectedType == 2 then
- elementID = brokenElements[(CurrentBrokenPage - 1) * 12 +
- hudSelectedIndex].id
- end
-
- if elementID ~= 0 then
- local bFound = false
- for k, v in pairs(damagedElements) do
- if v.id == elementID then
- targetElement = v
- bFound = true
- break
- end
- end
- if bFound == false then
- for k, v in pairs(brokenElements) do
- if v.id == elementID then
- targetElement = v
- bFound = true
- break
- end
- end
- end
-
- if bFound == true and AllowElementHighlighting == true then
- HideHighlight()
- elementPosition = vec3(targetElement.pos)
- highlightX = elementPosition.x - coreWorldOffset
- highlightY = elementPosition.y - coreWorldOffset
- highlightZ = elementPosition.z - coreWorldOffset
- highlightID = targetElement.id
- highlightOn = true
- ShowHighlight()
- end
- end
- end
-end
-
-function SortTables()
- -- Sort damaged elements descending by percent damaged according to setting
- if DamagedSortingMode == 1 then
- table.sort(damagedElements,
- function(a, b) return a.missinghp > b.missinghp end)
- elseif DamagedSortingMode == 2 then
- table.sort(damagedElements, function(a, b) return a.id < b.id end)
- else
- table.sort(damagedElements,
- function(a, b) return a.percent < b.percent end)
- end
-
- -- Sort broken elements descending according to setting
- if BrokenSortingMode == 1 then
- table.sort(brokenElements, function(a, b)
- return a.maxhp > b.maxhp
- end)
- else
- table.sort(brokenElements, function(a, b) return a.id < b.id end)
- end
-end
-
-function GenerateDamageData()
- if SimulationActive == true then return end
-
- local formerTotalShipHP = totalShipHP
- totalShipHP = 0
- totalShipMaxHP = 0
- totalShipIntegrity = 100
- elementsId = {}
- damagedElements = {}
- brokenElements = {}
- ElementCounter = 0
- healthyElements = 0
-
- elementsIdList = core.getElementIdList()
-
- for _, id in pairs(elementsIdList) do
- ElementCounter = ElementCounter + 1
- idHP = core.getElementHitPointsById(id) or 0
- idMaxHP = core.getElementMaxHitPointsById(id) or 0
-
- if SimulationMode then
- SimulationActive = true
- local dice = math.random(0, 10)
- if dice < 2 then
- idHP = 0
- elseif dice >= 2 and dice < 5 then
- idHP = idMaxHP
- else
- idHP = math.random(1, math.ceil(idMaxHP))
- end
- end
-
- totalShipHP = totalShipHP + idHP
- totalShipMaxHP = totalShipMaxHP + idMaxHP
-
- idName = core.getElementNameById(id)
- idType = core.getElementTypeById(id)
-
- -- Is element damaged?
- if idMaxHP > idHP then
- idPos = core.getElementPositionById(id)
- if idHP > 0 then
- table.insert(damagedElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP - idHP,
- percent = math.ceil(100 / idMaxHP * idHP),
- pos = idPos
- })
- -- if DebugMode then PrintDebug("Damaged: "..idName.." --- Type: "..idType.."") end
- -- Is element broken?
- else
- table.insert(brokenElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP - idHP,
- percent = 0,
- pos = idPos
- })
- -- if DebugMode then PrintDebug("Broken: "..idName.." --- Type: "..idType.."") end
- end
- else
- healthyElements = healthyElements + 1
- if id == highlightID then
- highlightID = 0
- end
- end
- end
-
- -- Sort tables by current settings
- SortTables()
-
- -- Update clickAreas
-
- -- Determine total ship integrity
- totalShipIntegrity = string.format("%2.0f",
- 100 / totalShipMaxHP * totalShipHP)
-
- -- Has anything changes since last check? If yes, force redrawing the screens
- if formerTotalShipHP ~= totalShipHP then
- forceRedraw = true
- formerTotalShipHP = totalShipHP
- else
- forceRedraw = false
- end
-end
-
-function GetAllSystemsNominalBackground()
- local output = ""
- output = output .. [[
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetDRLogo()
- output =
- [[]]
- return output
-end
-
-function GenerateHUDOutput()
-
- local hudWidth = 300
- local hudHeight = 125
- if #damagedElements > 0 or #brokenElements > 0 then hudHeight = 780 end
- local screenHeight = 1080
-
- local healthyColor = "#00aa00"
- local brokenColor = "#aa0000"
- local damagedColor = "#aaaa00"
- local integrityColor = "#aaaaaa"
- local healthyTextColor = "white"
- local brokenTextColor = "#ff4444"
- local damagedTextColor = "#ffff44"
- local integrityTextColor = "white"
-
- if #damagedElements == 0 then
- damagedColor = "#aaaaaa"
- damagedTextColor = "white"
- end
- if #brokenElements == 0 then
- brokenColor = "#aaaaaa"
- brokenTextColor = "white"
- end
-
- local hudOutput = ""
-
- -- Draw Header
- hudOutput = hudOutput .. [[
- ]]
-
- hudOutput = hudOutput .. [[]] ..
- [[]] .. GetDRLogo() .. [[]]
-
- hudOutput = hudOutput .. [[
-
- ]] .. healthyElements ..
- [[
-
- ]] .. #damagedElements ..
- [[
-
- ]] .. #brokenElements ..
- [[]]
- if #damagedElements > 0 or #brokenElements > 0 then
- hudOutput = hudOutput ..
- [[ ]] ..
- [[]] ..
- GenerateCommaValue(
- string.format("%.0f", totalShipMaxHP - totalShipHP)) ..
- [[ HP damage in total]]
- else
- hudOutput = hudOutput .. [[]] ..
- OkayCenterMessage .. [[]] ..
- [[Ship stands ]] ..
- GenerateCommaValue(string.format("%.0f", totalShipMaxHP)) ..
- [[ HP strong.]]
-
- end
- hudOutput = hudOutput .. [[]]
-
- hudRowDistance = 25
- if #damagedElements > 0 then
- local damagedElementsToDraw = #damagedElements
- if damagedElementsToDraw > 12 then damagedElementsToDraw = 12 end
- if CurrentDamagedPage == math.ceil(#damagedElements / 12) then
- damagedElementsToDraw = #damagedElements % 12
- end
- local i = 0
- hudOutput = hudOutput .. [[]] ..
- [[]]
-
- for j = 1 + (CurrentDamagedPage - 1) * 12, damagedElementsToDraw +
- (CurrentDamagedPage - 1) * 12, 1 do
- i = i + 1
- local DP = damagedElements[j]
- if (hudSelectedType == 1 and hudSelectedIndex == i) then
- hudOutput = hudOutput .. [[]]
- if UseMyElementNames == true then
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.name) ..
- [[]]
- else
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.type) ..
- [[]]
- end
- if (DamagedSortingMode == 3) then
- hudOutput = hudOutput .. [[]] .. DP.percent ..
- [[%]]
- else
- hudOutput = hudOutput .. [[]] ..
- GenerateCommaValue(
- string.format("%.0f", DP.missinghp)) ..
- [[]]
- end
- else
- if UseMyElementNames == true then
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.name) ..
- [[]]
- else
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.type) ..
- [[]]
- end
- if (DamagedSortingMode == 3) then
- hudOutput = hudOutput .. [[]] .. DP.percent ..
- [[%]]
- else
- hudOutput = hudOutput .. [[]] ..
- GenerateCommaValue(
- string.format("%.0f", DP.missinghp)) ..
- [[]]
- end
- hudOutput = hudOutput .. [[]]
- end
- end
- hudOutput = hudOutput .. [[]]
- end
-
- if #brokenElements > 0 then
- local brokenElementsToDraw = #brokenElements
- if brokenElementsToDraw > 12 then brokenElementsToDraw = 12 end
- if CurrentbrokenPage == math.ceil(#brokenElements / 12) then
- brokenElementsToDraw = #brokenElements % 12
- end
- local i = 0
- hudOutput = hudOutput .. [[]] ..
- [[]]
-
- for j = 1 + (CurrentBrokenPage - 1) * 12, brokenElementsToDraw +
- (CurrentBrokenPage - 1) * 12, 1 do
- i = i + 1
- local DP = brokenElements[j]
- if (hudSelectedType == 2 and hudSelectedIndex == i) then
- hudOutput = hudOutput .. [[]]
- if UseMyElementNames == true then
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.name) ..
- [[]]
- else
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.type) ..
- [[]]
- end
- if (brokenSortingMode == 3) then
- hudOutput = hudOutput .. [[]] .. DP.percent ..
- [[%]]
- else
- hudOutput = hudOutput .. [[]] ..
- GenerateCommaValue(
- string.format("%.0f", DP.missinghp)) ..
- [[]]
- end
- else
- if UseMyElementNames == true then
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.name) ..
- [[]]
- else
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.type) ..
- [[]]
- end
- if (brokenSortingMode == 3) then
- hudOutput = hudOutput .. [[]] .. DP.percent ..
- [[%]]
- else
- hudOutput = hudOutput .. [[]] ..
- GenerateCommaValue(
- string.format("%.0f", DP.missinghp)) ..
- [[]]
- end
- hudOutput = hudOutput .. [[]]
- end
- end
- hudOutput = hudOutput .. [[]]
- end
-
- if #damagedElements or #brokenElements then
- hudOutput = hudOutput .. [[]] ..
- [[Use up/down arrows to select element to find.]] ..
- [[Use right arrow to deselect.]] ..
- [[Use left arrow to exit HUD mode.]] ..
- [[]]
- end
-
- hudOutput = hudOutput .. [[]]
-
- return hudOutput
-end
-
-function DrawScreens()
- if #screens > 0 then
-
- local healthyColor = "#00aa00"
- local brokenColor = "#aa0000"
- local damagedColor = "#aaaa00"
- local integrityColor = "#aaaaaa"
- local healthyTextColor = "white"
- local brokenTextColor = "#ff4444"
- local damagedTextColor = "#ffff44"
- local integrityTextColor = "white"
-
- if #damagedElements == 0 then
- damagedColor = "#aaaaaa"
- damagedTextColor = "white"
- end
- if #brokenElements == 0 then
- brokenColor = "#aaaaaa"
- brokenTextColor = "white"
- end
-
- local screenOutput = ""
-
- -- Draw Header
- screenOutput = screenOutput ..
- [[
- ]]
-
- -- Draw main background
- screenOutput = screenOutput ..
- [[
-
-
-
-
-
-
-
-
-
-
-
- ]]
-
- -- Draw Title and summary
- if SimulationActive == true then
- screenOutput = screenOutput ..
- [[Simulated Report]]
- else
- screenOutput = screenOutput ..
- [[Damage Report]]
- end
- if YourShipsName == nil or YourShipsName == "" or YourShipsName ==
- "Enter here" then
- screenOutput = screenOutput ..
- [[SHIP ID ]] ..
- shipID .. [[]]
- else
- screenOutput = screenOutput ..
- [[]] ..
- YourShipsName .. [[]]
- end
- screenOutput = screenOutput .. [[
- Healthy
- ]] .. healthyElements ..
- [[
-
- Damaged
- ]] .. #damagedElements ..
- [[
-
- Broken
- ]] .. #brokenElements ..
- [[
-
- Integrity
- ]] .. totalShipIntegrity ..
- [[%]]
-
- -- Draw damage elements
-
- if #damagedElements > 0 then
- local damagedElementsToDraw = #damagedElements
- if damagedElementsToDraw > 12 then
- damagedElementsToDraw = 12
- end
- if CurrentDamagedPage == math.ceil(#damagedElements / 12) then
- damagedElementsToDraw = #damagedElements % 12
- end
- screenOutput = screenOutput ..
- [[]]
- screenOutput = screenOutput ..
- [[]]
- if (DamagedSortingMode == 2) then
- screenOutput = screenOutput ..
- [[ID]]
- else
- screenOutput = screenOutput ..
- [[ID]]
- end
- if UseMyElementNames == true then
- screenOutput = screenOutput ..
- [[Element Name]]
- else
- screenOutput = screenOutput ..
- [[Element Type]]
- end
-
- if (DamagedSortingMode == 3) then
- screenOutput = screenOutput ..
- [[Health]]
- else
- screenOutput = screenOutput ..
- [[Health]]
- end
- if (DamagedSortingMode == 1) then
- screenOutput = screenOutput ..
- [[Damage]]
- else
- screenOutput = screenOutput ..
- [[Damage]]
- end
-
- local i = 0
- for j = 1 + (CurrentDamagedPage - 1) * 12, damagedElementsToDraw +
- (CurrentDamagedPage - 1) * 12, 1 do
- i = i + 1
- local DP = damagedElements[j]
- screenOutput = screenOutput .. [[]] ..
- string.format("%03.0f", DP.id) .. [[]]
- if UseMyElementNames == true then
- screenOutput = screenOutput .. [[]] ..
- string.format("%.25s", DP.name) ..
- [[]]
- else
- screenOutput = screenOutput .. [[]] ..
- string.format("%.25s", DP.type) ..
- [[]]
- end
- screenOutput = screenOutput .. [[]] ..
- DP.percent .. [[%]] ..
- [[]] ..
- GenerateCommaValue(
- string.format("%.0f", DP.missinghp)) ..
- [[]] ..
- [[]]
- end
- screenOutput = screenOutput ..
- [[
-
- ]]
-
- if #damagedElements > 12 then
- screenOutput = screenOutput ..
- [[Page ]] ..
- CurrentDamagedPage .. " of " ..
- math.ceil(#damagedElements / 12) ..
- [[]]
-
- if CurrentDamagedPage < math.ceil(#damagedElements / 12) then
- screenOutput = screenOutput .. [[
-
-
- ]]
- UpdateClickArea("DamagedPageDown", {
- id = "DamagedPageDown",
- x1 = 70,
- x2 = 270,
- y1 = 350 + 11 + (damagedElementsToDraw + 1) * 50,
- y2 = 350 + 11 + 50 + (damagedElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("DamagedPageDown")
- end
-
- if CurrentDamagedPage > 1 then
- screenOutput = screenOutput .. [[
-
-
- ]]
- UpdateClickArea("DamagedPageUp", {
- id = "DamagedPageUp",
- x1 = 280,
- x2 = 480,
- y1 = 350 + 11 + (damagedElementsToDraw + 1) * 50,
- y2 = 350 + 11 + 50 + (damagedElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("DamagedPageUp")
- end
- end
- end
-
- -- Draw broken elements
- if #brokenElements > 0 then
- local brokenElementsToDraw = #brokenElements
- if brokenElementsToDraw > 12 then
- brokenElementsToDraw = 12
- end
- if CurrentBrokenPage == math.ceil(#brokenElements / 12) then
- brokenElementsToDraw = #brokenElements % 12
- end
- screenOutput = screenOutput ..
- [[]]
- screenOutput = screenOutput ..
- [[]]
- if (BrokenSortingMode == 2) then
- screenOutput = screenOutput ..
- [[ID]]
- else
- screenOutput = screenOutput ..
- [[ID]]
- end
- if UseMyElementNames == true then
- screenOutput = screenOutput ..
- [[Element Name]]
- else
- screenOutput = screenOutput ..
- [[Element Type]]
- end
- if (BrokenSortingMode == 1) then
- screenOutput = screenOutput ..
- [[Damage]]
- else
- screenOutput = screenOutput ..
- [[Damage]]
- end
-
- local i = 0
- for j = 1 + (CurrentBrokenPage - 1) * 12, brokenElementsToDraw +
- (CurrentBrokenPage - 1) * 12, 1 do
- i = i + 1
- local DP = brokenElements[j]
- screenOutput = screenOutput .. [[]] ..
- string.format("%03.0f", DP.id) .. [[]]
- if UseMyElementNames == true then
- screenOutput = screenOutput .. [[]] ..
- string.format("%.25s", DP.name) ..
- [[]]
- else
- screenOutput = screenOutput .. [[]] ..
- string.format("%.25s", DP.type) ..
- [[]]
- end
- screenOutput = screenOutput .. [[]] ..
- GenerateCommaValue(
- string.format("%.0f", DP.missinghp)) ..
- [[]] ..
- [[]]
- end
-
- screenOutput = screenOutput ..
- [[
-
- ]]
-
- if #brokenElements > 12 then
- screenOutput = screenOutput ..
- [[Page ]] ..
- CurrentBrokenPage .. " of " ..
- math.ceil(#brokenElements / 12) ..
- [[]]
-
- if CurrentBrokenPage > 1 then
- screenOutput = screenOutput .. [[
-
-
- ]]
- UpdateClickArea("BrokenPageUp", {
- id = "BrokenPageUp",
- x1 = 1442,
- x2 = 1642,
- y1 = 350 + 11 + (brokenElementsToDraw + 1) * 50,
- y2 = 350 + 11 + 50 + (brokenElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("BrokenPageUp")
- end
-
- if CurrentBrokenPage < math.ceil(#brokenElements / 12) then
- screenOutput = screenOutput .. [[
-
-
- ]]
- UpdateClickArea("BrokenPageDown", {
- id = "BrokenPageDown",
- x1 = 1652,
- x2 = 1852,
- y1 = 350 + 11 + (brokenElementsToDraw + 1) * 50,
- y2 = 350 + 11 + 50 + (brokenElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("BrokenPageDown")
- end
- end
-
- end
-
- -- Draw damage summary
- if #damagedElements > 0 or #brokenElements > 0 then
- screenOutput = screenOutput ..
- [[]] ..
- GenerateCommaValue(
- string.format("%.0f",
- totalShipMaxHP - totalShipHP)) ..
- [[ HP damage in total]]
- else
- screenOutput = screenOutput .. [[]] ..
- GetAllSystemsNominalBackground() .. [[]] ..
- [[]] ..
- OkayCenterMessage .. [[]] ..
- [[Ship stands ]] ..
- GenerateCommaValue(
- string.format("%.0f", totalShipMaxHP)) ..
- [[ HP strong.]]
- end
-
- -- Draw Sim Mode button
- if SimulationMode == true then
- screenOutput = screenOutput ..
- [[]] ..
- [[Sim Mode]]
-
- else
- screenOutput = screenOutput ..
- [[]] ..
- [[Sim Mode]]
- end
-
- -- Draw HUD Mode button
- if HUDMode == true then
- screenOutput = screenOutput ..
- [[]] ..
- [[HUD Mode]]
-
- else
- screenOutput = screenOutput ..
- [[]] ..
- [[HUD Mode]]
- end
-
- screenOutput = screenOutput .. [[]]
-
- if HUDMode == true then
- system.setScreen(GenerateHUDOutput())
- system.showScreen(1)
- else
- system.showScreen(0)
- end
-
- DrawSVG(screenOutput)
-
- forceRedraw = false
- end
-end
-
------------------------------------------------
--- Execute
------------------------------------------------
-
-unit.hide()
-ClearConsole()
-PrintDebug("SCRIPT STARTED", true)
-
-InitiateSlots()
-SwitchScreens(true)
-InitiateClickAreas()
-
-if core == nil then
- DrawCenteredText("ERROR: No core connected.")
- PrintError("ERROR: No core connected.")
- goto exit
-else
- shipID = core.getConstructId()
-end
-
-GenerateDamageData()
-if forceRedraw then DrawScreens() end
-
-unit.setTimer('UpdateData', UpdateInterval)
-unit.setTimer('UpdateHighlight', HighlightBlinkingInterval)
-
-::exit::
diff --git a/src/DamageReport_2_32_UnitStart.lua b/src/DamageReport_2_32_UnitStart.lua
deleted file mode 100644
index 61b5cca..0000000
--- a/src/DamageReport_2_32_UnitStart.lua
+++ /dev/null
@@ -1,1379 +0,0 @@
---[[
- DamageReport v2.32
- Created By Dorian Gray
-
- Discord: Dorian Gray#2623
- InGame: DorianGray
- GitHub: https://github.com/DorianTheGrey/DU-DamageReport
-
- GNU Public License 3.0. Use whatever you want, be so kind to leave credit.
-
- Thanks to Jericho, Dmentia and Archaegeo for learning from their fine scripts.
-]]
------------------------------------------------
--- CONFIG
------------------------------------------------
-UseMyElementNames = true --export: If you active this, the display will not show the element type of damaged/broken elements but the name you gave them (truncated to 25 characters)
-AllowElementHighlighting = true --export: Are you allowing damaged/broken elements to be highlighted in 3D space when selected in the HUD?
-UpdateInterval = 1 --export: Interval in seconds between updates of the calculations and (if anything changed) redrawing to the screen(s). You need to restart the script after changing this value.
-HighlightBlinkingInterval = 0.5 --export: If an element is marked, how fast do you want the arrows to blink?
-SimulationMode = false --export Randomize simluated damage on elements to check out the functionality of this script. And, no, your elements won't be harmed in the process :) You need to restart the script after changing this value.
-YourShipsName = "Enter here" --export Enter your ship name here if you want it displayed instead of the ship's ID. YOU NEED TO LEAVE THE QUOTATION MARKS.
-
-DebugMode = false -- Activate if you want some console messages
-VersionNumber = 2.32 -- Version number
-
-core = nil
-screens = {}
-
-shipID = 0
-forceRedraw = false
-SimulationActive = false
-
-clickAreas = {}
-DamagedSortingMode = 1 -- Define default sorting mode for damaged elements. 1 to sort by damage amount, 2 to sort by element id, 3 to sort by damage percent,
-BrokenSortingMode = 1 -- Define default sorting mode for broken elements. 1 to sort by damage amount, 2 to sort by element id
-
-HUDMode = false -- Is Hud active?
-hudSelectedIndex = 0 -- Which element is selected?
-hudSelectedType = 0 -- Is selected element damaged (1) or broken (2)
-hudArrowSticker = {}
-highlightOn = false
-highlightID = 0
-highlightX = 0
-highlightY = 0
-highlightZ = 0
-
-CurrentDamagedPage = 1
-CurrentBrokenPage = 1
-
-coreWorldOffset = 0
-totalShipHP = 0
-totalShipMaxHP = 0
-totalShipIntegrity = 100
-elementsId = {}
-damagedElements = {}
-brokenElements = {}
-ElementCounter = 0
-healthyElements = 0
-
-OkayCenterMessage = "All systems nominal."
-
------------------------------------------------
--- FUNCTIONS
------------------------------------------------
-
-function GenerateCommaValue(amount)
- local formatted = amount
- while true do
- formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
- if (k == 0) then break end
- end
- return formatted
-end
-
-function PrintDebug(output, highlight)
- highlight = highlight or false
- if DebugMode then
- if highlight then
- system.print(
- "------------------------------------------------------------------------")
- end
- system.print(output)
- if highlight then
- system.print(
- "------------------------------------------------------------------------")
- end
- end
-end
-
-function PrintError(output) system.print(output) end
-
-function DrawCenteredText(output)
- for i = 1, #screens, 1 do screens[i].setCenteredText(output) end
-end
-
-function DrawSVG(output) for i = 1, #screens, 1 do screens[i].setSVG(output) end end
-
-function ClearConsole() for i = 1, 10, 1 do PrintDebug() end end
-
-function SwitchScreens(state)
- state = state or true
- if #screens > 0 then
- for i = 1, #screens, 1 do
- if state==true then
- screens[i].clear()
- screens[i].activate()
- else
- screens[i].deactivate()
- screens[i].clear()
- end
- end
- end
-end
-
-function InitiateSlots()
- for slot_name, slot in pairs(unit) do
- if type(slot) == "table" and type(slot.export) == "table" and
- slot.getElementClass then
- if slot.getElementClass():lower():find("coreunit") then
- core = slot
- local coreHP = core.getMaxHitPoints()
- if coreHP > 10000 then
- coreWorldOffset = 128
- elseif coreHP > 1000 then
- coreWorldOffset = 64
- elseif coreHP > 150 then
- coreWorldOffset = 32
- else
- coreWorldOffset = 16
- end
- end
- if slot.getElementClass():lower():find("screenunit") then
- screens[#screens + 1] = slot
- end
- end
- end
-end
-
-function AddClickArea(newEntry) table.insert(clickAreas, newEntry) end
-
-function RemoveFromClickAreas(candidate)
- for k, v in pairs(clickAreas) do
- if v.id == candidate then
- clickAreas[k] = nil
- break
- end
- end
-end
-
-function UpdateClickArea(candidate, newEntry)
- for k, v in pairs(clickAreas) do
- if v.id == candidate then
- clickAreas[k] = newEntry
- break
- end
- end
-end
-
-function DisableClickArea(candidate)
- for k, v in pairs(clickAreas) do
- if v.id == candidate then
- UpdateClickArea(candidate, {
- id = candidate,
- x1 = -1,
- x2 = -1,
- y1 = -1,
- y2 = -1
- })
- break
- end
- end
-end
-
-function InitiateClickAreas()
- clickAreas = {}
- AddClickArea({id = "DamagedDamage", x1 = 725, x2 = 870, y1 = 380, y2 = 415})
- AddClickArea({id = "DamagedHealth", x1 = 520, x2 = 655, y1 = 380, y2 = 415})
- AddClickArea({id = "DamagedID", x1 = 90, x2 = 150, y1 = 380, y2 = 415})
- AddClickArea({id = "BrokenDamage", x1 = 1675, x2 = 1835, y1 = 380, y2 = 415})
- AddClickArea({id = "BrokenID", x1 = 1050, x2 = 1110, y1 = 380, y2 = 415})
- AddClickArea({id = "ToggleSimulation", x1 = 65, x2 = 660, y1 = 100, y2 = 145})
- AddClickArea({id = "ToggleSimulation2", x1 = 1650, x2 = 1850, y1 = 75, y2 = 117})
- AddClickArea({id = "ToggleElementLabel", x1 = 225, x2 = 460, y1 = 380, y2 = 415})
- AddClickArea({id = "ToggleElementLabel2", x1 = 1185, x2 = 1440, y1 = 380, y2 = 415})
- AddClickArea({id = "ToggleHudMode", x1 = 1650, x2 = 1850, y1 = 125, y2 = 167})
- AddClickArea({id = "DamagedPageDown", x1 = -1, x2 = -1, y1 = -1, y2 = -1})
- AddClickArea({id = "DamagedPageUp", x1 = -1, x2 = -1, y1 = -1, y2 = -1})
- AddClickArea({id = "BrokenPageDown", x1 = -1, x2 = -1, y1 = -1, y2 = -1})
- AddClickArea({id = "BrokenPageUp", x1 = -1, x2 = -1, y1 = -1, y2 = -1})
-end
-
-function FlushClickAreas() clickAreas = {} end
-
-function CheckClick(x, y, HitTarget)
- HitTarget = HitTarget or ""
- if HitTarget == "" then
- for k, v in pairs(clickAreas) do
- if v and x >= v.x1 and x <= v.x2 and y >= v.y1 and y <= v.y2 then
- HitTarget = v.id
- break
- end
- end
- end
- if HitTarget == "DamagedDamage" then
- DamagedSortingMode = 1
- CurrentDamagedPage = 1
- SortTables()
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "DamagedHealth" then
- DamagedSortingMode = 3
- CurrentDamagedPage = 1
- SortTables()
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "DamagedID" then
- DamagedSortingMode = 2
- CurrentDamagedPage = 1
- SortTables()
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "BrokenDamage" then
- BrokenSortingMode = 1
- CurrentBrokenPage = 1
- SortTables()
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "BrokenID" then
- BrokenSortingMode = 2
- CurrentBrokenPage = 1
- SortTables()
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "DamagedPageDown" then
- CurrentDamagedPage = CurrentDamagedPage + 1
- if CurrentDamagedPage > math.ceil(#damagedElements / 12) then
- CurrentDamagedPage = math.ceil(#damagedElements / 12)
- end
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "DamagedPageUp" then
- CurrentDamagedPage = CurrentDamagedPage - 1
- if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "BrokenPageDown" then
- CurrentBrokenPage = CurrentBrokenPage + 1
- if CurrentBrokenPage > math.ceil(#brokenElements / 12) then
- CurrentBrokenPage = math.ceil(#brokenElements / 12)
- end
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "BrokenPageUp" then
- CurrentBrokenPage = CurrentBrokenPage - 1
- if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "ToggleHudMode" then
- if HUDMode == true then
- HUDMode = false
- forceRedraw = true
- HudDeselectElement()
- DrawScreens()
- else
- HUDMode = true
- forceRedraw = true
- HudDeselectElement()
- DrawScreens()
- end
- elseif HitTarget == "ToggleSimulation" or HitTarget == "ToggleSimulation2" then
- CurrentDamagedPage = 1
- CurrentBrokenPage = 1
- if SimulationMode == true then
- SimulationMode = false
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- HudDeselectElement()
- DrawScreens()
- else
- SimulationMode = true
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- HudDeselectElement()
- DrawScreens()
- end
- elseif HitTarget == "ToggleElementLabel" or HitTarget ==
- "ToggleElementLabel2" then
- if UseMyElementNames == true then
- UseMyElementNames = false
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- HudDeselectElement()
- DrawScreens()
- else
- UseMyElementNames = true
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- HudDeselectElement()
- DrawScreens()
- end
- end
-end
-
-function ToggleHUD()
- HideHighlight()
- CheckClick(nil, nil, "ToggleHudMode")
-end
-
-function HudDeselectElement()
- if HUDMode == true then
- hudSelectedType = 0
- hudSelectedIndex = 0
- HideHighlight()
- DrawScreens()
- end
-end
-
-function ChangeHudSelectedElement(step)
- if HUDMode == true and (#damagedElements or #brokenElements) then
- local damagedElementsHUD = 12
- if #damagedElements < 12 then
- damagedElementsHUD = #damagedElements
- end
- local brokenElementsHUD = 12
- if #brokenElements < 12 then brokenElementsHUD = #brokenElements end
- if step == 1 then
- if hudSelectedIndex == 0 then
- if damagedElementsHUD > 0 then
- hudSelectedType = 1
- hudSelectedIndex = 1
- elseif brokenElementsHUD > 0 then
- hudSelectedType = 2
- hudSelectedIndex = 1
- end
- elseif hudSelectedType == 1 then
- if damagedElementsHUD > hudSelectedIndex then
- hudSelectedIndex = hudSelectedIndex + 1
- elseif brokenElementsHUD > 0 then
- hudSelectedType = 2
- hudSelectedIndex = 1
- elseif damagedElementsHUD > 0 then
- hudSelectedIndex = 1
- end
- elseif hudSelectedType == 2 then
- if brokenElementsHUD > hudSelectedIndex then
- hudSelectedIndex = hudSelectedIndex + 1
- elseif damagedElementsHUD > 0 then
- hudSelectedType = 1
- hudSelectedIndex = 1
- elseif brokenElementsHUD > 0 then
- hudSelectedIndex = 1
- end
- end
- elseif step == -1 then
- if hudSelectedIndex == 0 then
- if brokenElementsHUD > 0 then
- hudSelectedType = 2
- hudSelectedIndex = 1
- elseif damagedElementsHUD > 0 then
- hudSelectedType = 1
- hudSelectedIndex = 1
- end
- elseif hudSelectedType == 1 then
- if hudSelectedIndex > 1 then
- hudSelectedIndex = hudSelectedIndex - 1
- elseif brokenElementsHUD > 0 then
- hudSelectedType = 2
- hudSelectedIndex = brokenElementsHUD
- elseif damagedElementsHUD > 0 then
- hudSelectedIndex = damagedElementsHUD
- end
- elseif hudSelectedType == 2 then
- if hudSelectedIndex > 1 then
- hudSelectedIndex = hudSelectedIndex - 1
- elseif damagedElementsHUD > 0 then
- hudSelectedType = 1
- hudSelectedIndex = damagedElementsHUD
- elseif brokenElementsHUD > 0 then
- hudSelectedIndex = brokenElementsHUD
- end
- end
- end
- HighlightElement()
- DrawScreens()
- -- PrintDebug("-> Type: "..hudSelectedType.. " Index: "..hudSelectedIndex)
- end
-end
-
-function HideHighlight()
- if #hudArrowSticker > 0 then
- for i in pairs(hudArrowSticker) do
- core.deleteSticker(hudArrowSticker[i])
- end
- hudArrowSticker = {}
- end
-end
-
-function ShowHighlight()
- if highlightOn == true and highlightID > 0 then
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX + 2,
- highlightY,
- highlightZ, "north"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,
- highlightY - 2,
- highlightZ, "east"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX - 2,
- highlightY,
- highlightZ, "south"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,
- highlightY + 2,
- highlightZ, "west"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,
- highlightY,
- highlightZ - 2,
- "up"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,
- highlightY,
- highlightZ + 2,
- "down"))
- end
-end
-
-function ToggleHighlight()
- if highlightOn == true then
- highlightOn = false
- HideHighlight()
- else
- highlightOn = true
- ShowHighlight()
- end
-end
-
-function HighlightElement(elementID)
- elementID = elementID or 0
- local targetElement = {}
-
- if elementID == 0 then
- if hudSelectedType == 1 then
- elementID = damagedElements[(CurrentDamagedPage - 1) * 12 +
- hudSelectedIndex].id
- elseif hudSelectedType == 2 then
- elementID = brokenElements[(CurrentBrokenPage - 1) * 12 +
- hudSelectedIndex].id
- end
-
- if elementID ~= 0 then
- local bFound = false
- for k, v in pairs(damagedElements) do
- if v.id == elementID then
- targetElement = v
- bFound = true
- break
- end
- end
- if bFound == false then
- for k, v in pairs(brokenElements) do
- if v.id == elementID then
- targetElement = v
- bFound = true
- break
- end
- end
- end
-
- if bFound == true and AllowElementHighlighting == true then
- HideHighlight()
- elementPosition = vec3(targetElement.pos)
- highlightX = elementPosition.x - coreWorldOffset
- highlightY = elementPosition.y - coreWorldOffset
- highlightZ = elementPosition.z - coreWorldOffset
- highlightID = targetElement.id
- highlightOn = true
- ShowHighlight()
- end
- end
- end
-end
-
-function SortTables()
- -- Sort damaged elements descending by percent damaged according to setting
- if DamagedSortingMode == 1 then
- table.sort(damagedElements,
- function(a, b) return a.missinghp > b.missinghp end)
- elseif DamagedSortingMode == 2 then
- table.sort(damagedElements, function(a, b) return a.id < b.id end)
- else
- table.sort(damagedElements,
- function(a, b) return a.percent < b.percent end)
- end
-
- -- Sort broken elements descending according to setting
- if BrokenSortingMode == 1 then
- table.sort(brokenElements, function(a, b)
- return a.maxhp > b.maxhp
- end)
- else
- table.sort(brokenElements, function(a, b) return a.id < b.id end)
- end
-end
-
-function GenerateDamageData()
- if SimulationActive == true then return end
-
- local formerTotalShipHP = totalShipHP
- totalShipHP = 0
- totalShipMaxHP = 0
- totalShipIntegrity = 100
- elementsId = {}
- damagedElements = {}
- brokenElements = {}
- ElementCounter = 0
- healthyElements = 0
-
- elementsIdList = core.getElementIdList()
-
- for _, id in pairs(elementsIdList) do
- ElementCounter = ElementCounter + 1
- idHP = core.getElementHitPointsById(id) or 0
- idMaxHP = core.getElementMaxHitPointsById(id) or 0
-
- if SimulationMode then
- SimulationActive = true
- local dice = math.random(0, 10)
- if dice < 2 then
- idHP = 0
- elseif dice >= 2 and dice < 5 then
- idHP = idMaxHP
- else
- idHP = math.random(1, math.ceil(idMaxHP))
- end
- end
-
- totalShipHP = totalShipHP + idHP
- totalShipMaxHP = totalShipMaxHP + idMaxHP
-
- idName = core.getElementNameById(id)
- idType = core.getElementTypeById(id)
-
- -- Is element damaged?
- if idMaxHP > idHP then
- idPos = core.getElementPositionById(id)
- if idHP > 0 then
- table.insert(damagedElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP - idHP,
- percent = math.ceil(100 / idMaxHP * idHP),
- pos = idPos
- })
- -- if DebugMode then PrintDebug("Damaged: "..idName.." --- Type: "..idType.."") end
- -- Is element broken?
- else
- table.insert(brokenElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP - idHP,
- percent = 0,
- pos = idPos
- })
- -- if DebugMode then PrintDebug("Broken: "..idName.." --- Type: "..idType.."") end
- end
- else
- healthyElements = healthyElements + 1
- if id == highlightID then
- highlightID = 0
- end
- end
- end
-
- -- Sort tables by current settings
- SortTables()
-
- -- Update clickAreas
-
- -- Determine total ship integrity
- totalShipIntegrity = string.format("%2.0f",
- 100 / totalShipMaxHP * totalShipHP)
-
- -- Has anything changes since last check? If yes, force redrawing the screens
- if formerTotalShipHP ~= totalShipHP then
- forceRedraw = true
- formerTotalShipHP = totalShipHP
- else
- forceRedraw = false
- end
-end
-
-function GetAllSystemsNominalBackground()
- local output = ""
- output = output .. [[
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetDRLogo()
- output =
- [[]]
- return output
-end
-
-function GenerateHUDOutput()
-
- local hudWidth = 300
- local hudHeight = 125
- if #damagedElements > 0 or #brokenElements > 0 then hudHeight = 780 end
- local screenHeight = 1080
-
- local healthyColor = "#00aa00"
- local brokenColor = "#aa0000"
- local damagedColor = "#aaaa00"
- local integrityColor = "#aaaaaa"
- local healthyTextColor = "white"
- local brokenTextColor = "#ff4444"
- local damagedTextColor = "#ffff44"
- local integrityTextColor = "white"
-
- if #damagedElements == 0 then
- damagedColor = "#aaaaaa"
- damagedTextColor = "white"
- end
- if #brokenElements == 0 then
- brokenColor = "#aaaaaa"
- brokenTextColor = "white"
- end
-
- local hudOutput = ""
-
- -- Draw Header
- hudOutput = hudOutput .. [[
- ]]
-
- hudOutput = hudOutput .. [[]] ..
- [[]] .. GetDRLogo() .. [[]]
-
- hudOutput = hudOutput .. [[
-
- ]] .. healthyElements ..
- [[
-
- ]] .. #damagedElements ..
- [[
-
- ]] .. #brokenElements ..
- [[]]
- if #damagedElements > 0 or #brokenElements > 0 then
- hudOutput = hudOutput ..
- [[ ]] ..
- [[]] ..
- GenerateCommaValue(
- string.format("%.0f", totalShipMaxHP - totalShipHP)) ..
- [[ HP damage in total]]
- else
- hudOutput = hudOutput .. [[]] ..
- OkayCenterMessage .. [[]] ..
- [[Ship stands ]] ..
- GenerateCommaValue(string.format("%.0f", totalShipMaxHP)) ..
- [[ HP strong.]]
-
- end
- hudOutput = hudOutput .. [[]]
-
- hudRowDistance = 25
- if #damagedElements > 0 then
- local damagedElementsToDraw = #damagedElements
- if damagedElementsToDraw > 12 then damagedElementsToDraw = 12 end
- if CurrentDamagedPage == math.ceil(#damagedElements / 12) then
- damagedElementsToDraw = #damagedElements % 12
- end
- local i = 0
- hudOutput = hudOutput .. [[]] ..
- [[]]
-
- for j = 1 + (CurrentDamagedPage - 1) * 12, damagedElementsToDraw +
- (CurrentDamagedPage - 1) * 12, 1 do
- i = i + 1
- local DP = damagedElements[j]
- if (hudSelectedType == 1 and hudSelectedIndex == i) then
- hudOutput = hudOutput .. [[]]
- if UseMyElementNames == true then
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.name) ..
- [[]]
- else
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.type) ..
- [[]]
- end
- if (DamagedSortingMode == 3) then
- hudOutput = hudOutput .. [[]] .. DP.percent ..
- [[%]]
- else
- hudOutput = hudOutput .. [[]] ..
- GenerateCommaValue(
- string.format("%.0f", DP.missinghp)) ..
- [[]]
- end
- else
- if UseMyElementNames == true then
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.name) ..
- [[]]
- else
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.type) ..
- [[]]
- end
- if (DamagedSortingMode == 3) then
- hudOutput = hudOutput .. [[]] .. DP.percent ..
- [[%]]
- else
- hudOutput = hudOutput .. [[]] ..
- GenerateCommaValue(
- string.format("%.0f", DP.missinghp)) ..
- [[]]
- end
- hudOutput = hudOutput .. [[]]
- end
- end
- hudOutput = hudOutput .. [[]]
- end
-
- if #brokenElements > 0 then
- local brokenElementsToDraw = #brokenElements
- if brokenElementsToDraw > 12 then brokenElementsToDraw = 12 end
- if CurrentbrokenPage == math.ceil(#brokenElements / 12) then
- brokenElementsToDraw = #brokenElements % 12
- end
- local i = 0
- hudOutput = hudOutput .. [[]] ..
- [[]]
-
- for j = 1 + (CurrentBrokenPage - 1) * 12, brokenElementsToDraw +
- (CurrentBrokenPage - 1) * 12, 1 do
- i = i + 1
- local DP = brokenElements[j]
- if (hudSelectedType == 2 and hudSelectedIndex == i) then
- hudOutput = hudOutput .. [[]]
- if UseMyElementNames == true then
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.name) ..
- [[]]
- else
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.type) ..
- [[]]
- end
- if (brokenSortingMode == 3) then
- hudOutput = hudOutput .. [[]] .. DP.percent ..
- [[%]]
- else
- hudOutput = hudOutput .. [[]] ..
- GenerateCommaValue(
- string.format("%.0f", DP.missinghp)) ..
- [[]]
- end
- else
- if UseMyElementNames == true then
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.name) ..
- [[]]
- else
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.type) ..
- [[]]
- end
- if (brokenSortingMode == 3) then
- hudOutput = hudOutput .. [[]] .. DP.percent ..
- [[%]]
- else
- hudOutput = hudOutput .. [[]] ..
- GenerateCommaValue(
- string.format("%.0f", DP.missinghp)) ..
- [[]]
- end
- hudOutput = hudOutput .. [[]]
- end
- end
- hudOutput = hudOutput .. [[]]
- end
-
- if #damagedElements or #brokenElements then
- hudOutput = hudOutput .. [[]] ..
- [[Use up/down arrows to select element to find.]] ..
- [[Use right arrow to deselect.]] ..
- [[Use left arrow to exit HUD mode.]] ..
- [[]]
- end
-
- hudOutput = hudOutput .. [[]]
-
- return hudOutput
-end
-
-function DrawScreens()
- if #screens > 0 then
-
- local healthyColor = "#00aa00"
- local brokenColor = "#aa0000"
- local damagedColor = "#aaaa00"
- local integrityColor = "#aaaaaa"
- local healthyTextColor = "white"
- local brokenTextColor = "#ff4444"
- local damagedTextColor = "#ffff44"
- local integrityTextColor = "white"
-
- if #damagedElements == 0 then
- damagedColor = "#aaaaaa"
- damagedTextColor = "white"
- end
- if #brokenElements == 0 then
- brokenColor = "#aaaaaa"
- brokenTextColor = "white"
- end
-
- local screenOutput = ""
-
- -- Draw Header
- screenOutput = screenOutput ..
- [[
- ]]
-
- -- Draw main background
- screenOutput = screenOutput ..
- [[
-
-
-
-
-
-
-
-
-
-
-
- ]]
-
- -- Draw Title and summary
- if SimulationActive == true then
- screenOutput = screenOutput ..
- [[Simulated Report]]
- else
- screenOutput = screenOutput ..
- [[Damage Report]]
- end
- if YourShipsName == nil or YourShipsName == "" or YourShipsName ==
- "Enter here" then
- screenOutput = screenOutput ..
- [[SHIP ID ]] ..
- shipID .. [[]]
- else
- screenOutput = screenOutput ..
- [[]] ..
- YourShipsName .. [[]]
- end
- screenOutput = screenOutput .. [[
- Healthy
- ]] .. healthyElements ..
- [[
-
- Damaged
- ]] .. #damagedElements ..
- [[
-
- Broken
- ]] .. #brokenElements ..
- [[
-
- Integrity
- ]] .. totalShipIntegrity ..
- [[%]]
-
- -- Draw damage elements
-
- if #damagedElements > 0 then
- local damagedElementsToDraw = #damagedElements
- if damagedElementsToDraw > 12 then
- damagedElementsToDraw = 12
- end
- if CurrentDamagedPage == math.ceil(#damagedElements / 12) then
- damagedElementsToDraw = #damagedElements % 12
- end
- screenOutput = screenOutput ..
- [[]]
- screenOutput = screenOutput ..
- [[]]
- if (DamagedSortingMode == 2) then
- screenOutput = screenOutput ..
- [[ID]]
- else
- screenOutput = screenOutput ..
- [[ID]]
- end
- if UseMyElementNames == true then
- screenOutput = screenOutput ..
- [[Element Name]]
- else
- screenOutput = screenOutput ..
- [[Element Type]]
- end
-
- if (DamagedSortingMode == 3) then
- screenOutput = screenOutput ..
- [[Health]]
- else
- screenOutput = screenOutput ..
- [[Health]]
- end
- if (DamagedSortingMode == 1) then
- screenOutput = screenOutput ..
- [[Damage]]
- else
- screenOutput = screenOutput ..
- [[Damage]]
- end
-
- local i = 0
- for j = 1 + (CurrentDamagedPage - 1) * 12, damagedElementsToDraw +
- (CurrentDamagedPage - 1) * 12, 1 do
- i = i + 1
- local DP = damagedElements[j]
- screenOutput = screenOutput .. [[]] ..
- string.format("%03.0f", DP.id) .. [[]]
- if UseMyElementNames == true then
- screenOutput = screenOutput .. [[]] ..
- string.format("%.25s", DP.name) ..
- [[]]
- else
- screenOutput = screenOutput .. [[]] ..
- string.format("%.25s", DP.type) ..
- [[]]
- end
- screenOutput = screenOutput .. [[]] ..
- DP.percent .. [[%]] ..
- [[]] ..
- GenerateCommaValue(
- string.format("%.0f", DP.missinghp)) ..
- [[]] ..
- [[]]
- end
- screenOutput = screenOutput ..
- [[
-
- ]]
-
- if #damagedElements > 12 then
- screenOutput = screenOutput ..
- [[Page ]] ..
- CurrentDamagedPage .. " of " ..
- math.ceil(#damagedElements / 12) ..
- [[]]
-
- if CurrentDamagedPage < math.ceil(#damagedElements / 12) then
- screenOutput = screenOutput .. [[
-
-
- ]]
- UpdateClickArea("DamagedPageDown", {
- id = "DamagedPageDown",
- x1 = 70,
- x2 = 270,
- y1 = 350 + 11 + (damagedElementsToDraw + 1) * 50,
- y2 = 350 + 11 + 50 + (damagedElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("DamagedPageDown")
- end
-
- if CurrentDamagedPage > 1 then
- screenOutput = screenOutput .. [[
-
-
- ]]
- UpdateClickArea("DamagedPageUp", {
- id = "DamagedPageUp",
- x1 = 280,
- x2 = 480,
- y1 = 350 + 11 + (damagedElementsToDraw + 1) * 50,
- y2 = 350 + 11 + 50 + (damagedElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("DamagedPageUp")
- end
- end
- end
-
- -- Draw broken elements
- if #brokenElements > 0 then
- local brokenElementsToDraw = #brokenElements
- if brokenElementsToDraw > 12 then
- brokenElementsToDraw = 12
- end
- if CurrentBrokenPage == math.ceil(#brokenElements / 12) then
- brokenElementsToDraw = #brokenElements % 12
- end
- screenOutput = screenOutput ..
- [[]]
- screenOutput = screenOutput ..
- [[]]
- if (BrokenSortingMode == 2) then
- screenOutput = screenOutput ..
- [[ID]]
- else
- screenOutput = screenOutput ..
- [[ID]]
- end
- if UseMyElementNames == true then
- screenOutput = screenOutput ..
- [[Element Name]]
- else
- screenOutput = screenOutput ..
- [[Element Type]]
- end
- if (BrokenSortingMode == 1) then
- screenOutput = screenOutput ..
- [[Damage]]
- else
- screenOutput = screenOutput ..
- [[Damage]]
- end
-
- local i = 0
- for j = 1 + (CurrentBrokenPage - 1) * 12, brokenElementsToDraw +
- (CurrentBrokenPage - 1) * 12, 1 do
- i = i + 1
- local DP = brokenElements[j]
- screenOutput = screenOutput .. [[]] ..
- string.format("%03.0f", DP.id) .. [[]]
- if UseMyElementNames == true then
- screenOutput = screenOutput .. [[]] ..
- string.format("%.25s", DP.name) ..
- [[]]
- else
- screenOutput = screenOutput .. [[]] ..
- string.format("%.25s", DP.type) ..
- [[]]
- end
- screenOutput = screenOutput .. [[]] ..
- GenerateCommaValue(
- string.format("%.0f", DP.missinghp)) ..
- [[]] ..
- [[]]
- end
-
- screenOutput = screenOutput ..
- [[
-
- ]]
-
- if #brokenElements > 12 then
- screenOutput = screenOutput ..
- [[Page ]] ..
- CurrentBrokenPage .. " of " ..
- math.ceil(#brokenElements / 12) ..
- [[]]
-
- if CurrentBrokenPage > 1 then
- screenOutput = screenOutput .. [[
-
-
- ]]
- UpdateClickArea("BrokenPageUp", {
- id = "BrokenPageUp",
- x1 = 1442,
- x2 = 1642,
- y1 = 350 + 11 + (brokenElementsToDraw + 1) * 50,
- y2 = 350 + 11 + 50 + (brokenElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("BrokenPageUp")
- end
-
- if CurrentBrokenPage < math.ceil(#brokenElements / 12) then
- screenOutput = screenOutput .. [[
-
-
- ]]
- UpdateClickArea("BrokenPageDown", {
- id = "BrokenPageDown",
- x1 = 1652,
- x2 = 1852,
- y1 = 350 + 11 + (brokenElementsToDraw + 1) * 50,
- y2 = 350 + 11 + 50 + (brokenElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("BrokenPageDown")
- end
- end
-
- end
-
- -- Draw damage summary
- if #damagedElements > 0 or #brokenElements > 0 then
- screenOutput = screenOutput ..
- [[]] ..
- GenerateCommaValue(
- string.format("%.0f",
- totalShipMaxHP - totalShipHP)) ..
- [[ HP damage in total]]
- else
- screenOutput = screenOutput .. [[]] ..
- GetAllSystemsNominalBackground() .. [[]] ..
- [[]] ..
- OkayCenterMessage .. [[]] ..
- [[Ship stands ]] ..
- GenerateCommaValue(
- string.format("%.0f", totalShipMaxHP)) ..
- [[ HP strong.]]
- end
-
- -- Draw Sim Mode button
- if SimulationMode == true then
- screenOutput = screenOutput ..
- [[]] ..
- [[Sim Mode]]
-
- else
- screenOutput = screenOutput ..
- [[]] ..
- [[Sim Mode]]
- end
-
- -- Draw HUD Mode button
- if HUDMode == true then
- screenOutput = screenOutput ..
- [[]] ..
- [[HUD Mode]]
-
- else
- screenOutput = screenOutput ..
- [[]] ..
- [[HUD Mode]]
- end
-
- screenOutput = screenOutput .. [[]]
-
- DrawSVG(screenOutput)
-
- forceRedraw = false
- end
-end
-
------------------------------------------------
--- Execute
------------------------------------------------
-
-unit.hide()
-ClearConsole()
-PrintDebug("SCRIPT STARTED", true)
-
-InitiateSlots()
-SwitchScreens(true)
-InitiateClickAreas()
-
-if #screens ~= nil and #screens < 1 then
- HUDMode = true
-end
-
-if core == nil then
- DrawCenteredText("ERROR: No core connected.")
- PrintError("ERROR: No core connected.")
- goto exit
-else
- shipID = core.getConstructId()
-end
-
-GenerateDamageData()
-if forceRedraw then DrawScreens() end
-
-unit.setTimer('UpdateData', UpdateInterval)
-unit.setTimer('UpdateHighlight', HighlightBlinkingInterval)
-
-::exit::
diff --git a/src/DamageReport_2_33_UnitStart.lua b/src/DamageReport_2_33_UnitStart.lua
deleted file mode 100644
index 30947d7..0000000
--- a/src/DamageReport_2_33_UnitStart.lua
+++ /dev/null
@@ -1,1380 +0,0 @@
---[[
- DamageReport v2.33
- Created By Dorian Gray
-
- Discord: Dorian Gray#2623
- InGame: DorianGray
- GitHub: https://github.com/DorianTheGrey/DU-DamageReport
-
- GNU Public License 3.0. Use whatever you want, be so kind to leave credit.
-
- Thanks to Jericho, Dmentia and Archaegeo for learning from their fine scripts.
-]]
------------------------------------------------
--- CONFIG
------------------------------------------------
-UseMyElementNames = true --export: If you active this, the display will not show the element type of damaged/broken elements but the name you gave them (truncated to 25 characters)
-AllowElementHighlighting = true --export: Are you allowing damaged/broken elements to be highlighted in 3D space when selected in the HUD?
-UpdateInterval = 1 --export: Interval in seconds between updates of the calculations and (if anything changed) redrawing to the screen(s). You need to restart the script after changing this value.
-HighlightBlinkingInterval = 0.5 --export: If an element is marked, how fast do you want the arrows to blink?
-SimulationMode = false --export Randomize simluated damage on elements to check out the functionality of this script. And, no, your elements won't be harmed in the process :) You need to restart the script after changing this value.
-YourShipsName = "Enter here" --export Enter your ship name here if you want it displayed instead of the ship's ID. YOU NEED TO LEAVE THE QUOTATION MARKS.
-BackgroundColor = "1e1e1e" --export Set the background color of the screens. YOU NEED TO LEAVE THE QUOTATION MARKS.
-
-DebugMode = false -- Activate if you want some console messages
-VersionNumber = 2.33 -- Version number
-
-core = nil
-screens = {}
-
-shipID = 0
-forceRedraw = false
-SimulationActive = false
-
-clickAreas = {}
-DamagedSortingMode = 1 -- Define default sorting mode for damaged elements. 1 to sort by damage amount, 2 to sort by element id, 3 to sort by damage percent,
-BrokenSortingMode = 1 -- Define default sorting mode for broken elements. 1 to sort by damage amount, 2 to sort by element id
-
-HUDMode = false -- Is Hud active?
-hudSelectedIndex = 0 -- Which element is selected?
-hudSelectedType = 0 -- Is selected element damaged (1) or broken (2)
-hudArrowSticker = {}
-highlightOn = false
-highlightID = 0
-highlightX = 0
-highlightY = 0
-highlightZ = 0
-
-CurrentDamagedPage = 1
-CurrentBrokenPage = 1
-
-coreWorldOffset = 0
-totalShipHP = 0
-totalShipMaxHP = 0
-totalShipIntegrity = 100
-elementsId = {}
-damagedElements = {}
-brokenElements = {}
-ElementCounter = 0
-healthyElements = 0
-
-OkayCenterMessage = "All systems nominal."
-
------------------------------------------------
--- FUNCTIONS
------------------------------------------------
-
-function GenerateCommaValue(amount)
- local formatted = amount
- while true do
- formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
- if (k == 0) then break end
- end
- return formatted
-end
-
-function PrintDebug(output, highlight)
- highlight = highlight or false
- if DebugMode then
- if highlight then
- system.print(
- "------------------------------------------------------------------------")
- end
- system.print(output)
- if highlight then
- system.print(
- "------------------------------------------------------------------------")
- end
- end
-end
-
-function PrintError(output) system.print(output) end
-
-function DrawCenteredText(output)
- for i = 1, #screens, 1 do screens[i].setCenteredText(output) end
-end
-
-function DrawSVG(output) for i = 1, #screens, 1 do screens[i].setSVG(output) end end
-
-function ClearConsole() for i = 1, 10, 1 do PrintDebug() end end
-
-function SwitchScreens(state)
- state = state or true
- if #screens > 0 then
- for i = 1, #screens, 1 do
- if state==true then
- screens[i].clear()
- screens[i].activate()
- else
- screens[i].deactivate()
- screens[i].clear()
- end
- end
- end
-end
-
-function InitiateSlots()
- for slot_name, slot in pairs(unit) do
- if type(slot) == "table" and type(slot.export) == "table" and
- slot.getElementClass then
- if slot.getElementClass():lower():find("coreunit") then
- core = slot
- local coreHP = core.getMaxHitPoints()
- if coreHP > 10000 then
- coreWorldOffset = 128
- elseif coreHP > 1000 then
- coreWorldOffset = 64
- elseif coreHP > 150 then
- coreWorldOffset = 32
- else
- coreWorldOffset = 16
- end
- end
- if slot.getElementClass():lower():find("screenunit") then
- screens[#screens + 1] = slot
- end
- end
- end
-end
-
-function AddClickArea(newEntry) table.insert(clickAreas, newEntry) end
-
-function RemoveFromClickAreas(candidate)
- for k, v in pairs(clickAreas) do
- if v.id == candidate then
- clickAreas[k] = nil
- break
- end
- end
-end
-
-function UpdateClickArea(candidate, newEntry)
- for k, v in pairs(clickAreas) do
- if v.id == candidate then
- clickAreas[k] = newEntry
- break
- end
- end
-end
-
-function DisableClickArea(candidate)
- for k, v in pairs(clickAreas) do
- if v.id == candidate then
- UpdateClickArea(candidate, {
- id = candidate,
- x1 = -1,
- x2 = -1,
- y1 = -1,
- y2 = -1
- })
- break
- end
- end
-end
-
-function InitiateClickAreas()
- clickAreas = {}
- AddClickArea({id = "DamagedDamage", x1 = 725, x2 = 870, y1 = 380, y2 = 415})
- AddClickArea({id = "DamagedHealth", x1 = 520, x2 = 655, y1 = 380, y2 = 415})
- AddClickArea({id = "DamagedID", x1 = 90, x2 = 150, y1 = 380, y2 = 415})
- AddClickArea({id = "BrokenDamage", x1 = 1675, x2 = 1835, y1 = 380, y2 = 415})
- AddClickArea({id = "BrokenID", x1 = 1050, x2 = 1110, y1 = 380, y2 = 415})
- AddClickArea({id = "ToggleSimulation", x1 = 65, x2 = 660, y1 = 100, y2 = 145})
- AddClickArea({id = "ToggleSimulation2", x1 = 1650, x2 = 1850, y1 = 75, y2 = 117})
- AddClickArea({id = "ToggleElementLabel", x1 = 225, x2 = 460, y1 = 380, y2 = 415})
- AddClickArea({id = "ToggleElementLabel2", x1 = 1185, x2 = 1440, y1 = 380, y2 = 415})
- AddClickArea({id = "ToggleHudMode", x1 = 1650, x2 = 1850, y1 = 125, y2 = 167})
- AddClickArea({id = "DamagedPageDown", x1 = -1, x2 = -1, y1 = -1, y2 = -1})
- AddClickArea({id = "DamagedPageUp", x1 = -1, x2 = -1, y1 = -1, y2 = -1})
- AddClickArea({id = "BrokenPageDown", x1 = -1, x2 = -1, y1 = -1, y2 = -1})
- AddClickArea({id = "BrokenPageUp", x1 = -1, x2 = -1, y1 = -1, y2 = -1})
-end
-
-function FlushClickAreas() clickAreas = {} end
-
-function CheckClick(x, y, HitTarget)
- HitTarget = HitTarget or ""
- if HitTarget == "" then
- for k, v in pairs(clickAreas) do
- if v and x >= v.x1 and x <= v.x2 and y >= v.y1 and y <= v.y2 then
- HitTarget = v.id
- break
- end
- end
- end
- if HitTarget == "DamagedDamage" then
- DamagedSortingMode = 1
- CurrentDamagedPage = 1
- SortTables()
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "DamagedHealth" then
- DamagedSortingMode = 3
- CurrentDamagedPage = 1
- SortTables()
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "DamagedID" then
- DamagedSortingMode = 2
- CurrentDamagedPage = 1
- SortTables()
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "BrokenDamage" then
- BrokenSortingMode = 1
- CurrentBrokenPage = 1
- SortTables()
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "BrokenID" then
- BrokenSortingMode = 2
- CurrentBrokenPage = 1
- SortTables()
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "DamagedPageDown" then
- CurrentDamagedPage = CurrentDamagedPage + 1
- if CurrentDamagedPage > math.ceil(#damagedElements / 12) then
- CurrentDamagedPage = math.ceil(#damagedElements / 12)
- end
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "DamagedPageUp" then
- CurrentDamagedPage = CurrentDamagedPage - 1
- if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "BrokenPageDown" then
- CurrentBrokenPage = CurrentBrokenPage + 1
- if CurrentBrokenPage > math.ceil(#brokenElements / 12) then
- CurrentBrokenPage = math.ceil(#brokenElements / 12)
- end
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "BrokenPageUp" then
- CurrentBrokenPage = CurrentBrokenPage - 1
- if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "ToggleHudMode" then
- if HUDMode == true then
- HUDMode = false
- forceRedraw = true
- HudDeselectElement()
- DrawScreens()
- else
- HUDMode = true
- forceRedraw = true
- HudDeselectElement()
- DrawScreens()
- end
- elseif HitTarget == "ToggleSimulation" or HitTarget == "ToggleSimulation2" then
- CurrentDamagedPage = 1
- CurrentBrokenPage = 1
- if SimulationMode == true then
- SimulationMode = false
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- HudDeselectElement()
- DrawScreens()
- else
- SimulationMode = true
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- HudDeselectElement()
- DrawScreens()
- end
- elseif HitTarget == "ToggleElementLabel" or HitTarget ==
- "ToggleElementLabel2" then
- if UseMyElementNames == true then
- UseMyElementNames = false
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- HudDeselectElement()
- DrawScreens()
- else
- UseMyElementNames = true
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- HudDeselectElement()
- DrawScreens()
- end
- end
-end
-
-function ToggleHUD()
- HideHighlight()
- CheckClick(nil, nil, "ToggleHudMode")
-end
-
-function HudDeselectElement()
- if HUDMode == true then
- hudSelectedType = 0
- hudSelectedIndex = 0
- HideHighlight()
- DrawScreens()
- end
-end
-
-function ChangeHudSelectedElement(step)
- if HUDMode == true and (#damagedElements or #brokenElements) then
- local damagedElementsHUD = 12
- if #damagedElements < 12 then
- damagedElementsHUD = #damagedElements
- end
- local brokenElementsHUD = 12
- if #brokenElements < 12 then brokenElementsHUD = #brokenElements end
- if step == 1 then
- if hudSelectedIndex == 0 then
- if damagedElementsHUD > 0 then
- hudSelectedType = 1
- hudSelectedIndex = 1
- elseif brokenElementsHUD > 0 then
- hudSelectedType = 2
- hudSelectedIndex = 1
- end
- elseif hudSelectedType == 1 then
- if damagedElementsHUD > hudSelectedIndex then
- hudSelectedIndex = hudSelectedIndex + 1
- elseif brokenElementsHUD > 0 then
- hudSelectedType = 2
- hudSelectedIndex = 1
- elseif damagedElementsHUD > 0 then
- hudSelectedIndex = 1
- end
- elseif hudSelectedType == 2 then
- if brokenElementsHUD > hudSelectedIndex then
- hudSelectedIndex = hudSelectedIndex + 1
- elseif damagedElementsHUD > 0 then
- hudSelectedType = 1
- hudSelectedIndex = 1
- elseif brokenElementsHUD > 0 then
- hudSelectedIndex = 1
- end
- end
- elseif step == -1 then
- if hudSelectedIndex == 0 then
- if brokenElementsHUD > 0 then
- hudSelectedType = 2
- hudSelectedIndex = 1
- elseif damagedElementsHUD > 0 then
- hudSelectedType = 1
- hudSelectedIndex = 1
- end
- elseif hudSelectedType == 1 then
- if hudSelectedIndex > 1 then
- hudSelectedIndex = hudSelectedIndex - 1
- elseif brokenElementsHUD > 0 then
- hudSelectedType = 2
- hudSelectedIndex = brokenElementsHUD
- elseif damagedElementsHUD > 0 then
- hudSelectedIndex = damagedElementsHUD
- end
- elseif hudSelectedType == 2 then
- if hudSelectedIndex > 1 then
- hudSelectedIndex = hudSelectedIndex - 1
- elseif damagedElementsHUD > 0 then
- hudSelectedType = 1
- hudSelectedIndex = damagedElementsHUD
- elseif brokenElementsHUD > 0 then
- hudSelectedIndex = brokenElementsHUD
- end
- end
- end
- HighlightElement()
- DrawScreens()
- -- PrintDebug("-> Type: "..hudSelectedType.. " Index: "..hudSelectedIndex)
- end
-end
-
-function HideHighlight()
- if #hudArrowSticker > 0 then
- for i in pairs(hudArrowSticker) do
- core.deleteSticker(hudArrowSticker[i])
- end
- hudArrowSticker = {}
- end
-end
-
-function ShowHighlight()
- if highlightOn == true and highlightID > 0 then
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX + 2,
- highlightY,
- highlightZ, "north"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,
- highlightY - 2,
- highlightZ, "east"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX - 2,
- highlightY,
- highlightZ, "south"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,
- highlightY + 2,
- highlightZ, "west"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,
- highlightY,
- highlightZ - 2,
- "up"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,
- highlightY,
- highlightZ + 2,
- "down"))
- end
-end
-
-function ToggleHighlight()
- if highlightOn == true then
- highlightOn = false
- HideHighlight()
- else
- highlightOn = true
- ShowHighlight()
- end
-end
-
-function HighlightElement(elementID)
- elementID = elementID or 0
- local targetElement = {}
-
- if elementID == 0 then
- if hudSelectedType == 1 then
- elementID = damagedElements[(CurrentDamagedPage - 1) * 12 +
- hudSelectedIndex].id
- elseif hudSelectedType == 2 then
- elementID = brokenElements[(CurrentBrokenPage - 1) * 12 +
- hudSelectedIndex].id
- end
-
- if elementID ~= 0 then
- local bFound = false
- for k, v in pairs(damagedElements) do
- if v.id == elementID then
- targetElement = v
- bFound = true
- break
- end
- end
- if bFound == false then
- for k, v in pairs(brokenElements) do
- if v.id == elementID then
- targetElement = v
- bFound = true
- break
- end
- end
- end
-
- if bFound == true and AllowElementHighlighting == true then
- HideHighlight()
- elementPosition = vec3(targetElement.pos)
- highlightX = elementPosition.x - coreWorldOffset
- highlightY = elementPosition.y - coreWorldOffset
- highlightZ = elementPosition.z - coreWorldOffset
- highlightID = targetElement.id
- highlightOn = true
- ShowHighlight()
- end
- end
- end
-end
-
-function SortTables()
- -- Sort damaged elements descending by percent damaged according to setting
- if DamagedSortingMode == 1 then
- table.sort(damagedElements,
- function(a, b) return a.missinghp > b.missinghp end)
- elseif DamagedSortingMode == 2 then
- table.sort(damagedElements, function(a, b) return a.id < b.id end)
- else
- table.sort(damagedElements,
- function(a, b) return a.percent < b.percent end)
- end
-
- -- Sort broken elements descending according to setting
- if BrokenSortingMode == 1 then
- table.sort(brokenElements, function(a, b)
- return a.maxhp > b.maxhp
- end)
- else
- table.sort(brokenElements, function(a, b) return a.id < b.id end)
- end
-end
-
-function GenerateDamageData()
- if SimulationActive == true then return end
-
- local formerTotalShipHP = totalShipHP
- totalShipHP = 0
- totalShipMaxHP = 0
- totalShipIntegrity = 100
- elementsId = {}
- damagedElements = {}
- brokenElements = {}
- ElementCounter = 0
- healthyElements = 0
-
- elementsIdList = core.getElementIdList()
-
- for _, id in pairs(elementsIdList) do
- ElementCounter = ElementCounter + 1
- idHP = core.getElementHitPointsById(id) or 0
- idMaxHP = core.getElementMaxHitPointsById(id) or 0
-
- if SimulationMode then
- SimulationActive = true
- local dice = math.random(0, 10)
- if dice < 2 then
- idHP = 0
- elseif dice >= 2 and dice < 5 then
- idHP = idMaxHP
- else
- idHP = math.random(1, math.ceil(idMaxHP))
- end
- end
-
- totalShipHP = totalShipHP + idHP
- totalShipMaxHP = totalShipMaxHP + idMaxHP
-
- idName = core.getElementNameById(id)
- idType = core.getElementTypeById(id)
-
- -- Is element damaged?
- if idMaxHP > idHP then
- idPos = core.getElementPositionById(id)
- if idHP > 0 then
- table.insert(damagedElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP - idHP,
- percent = math.ceil(100 / idMaxHP * idHP),
- pos = idPos
- })
- -- if DebugMode then PrintDebug("Damaged: "..idName.." --- Type: "..idType.."") end
- -- Is element broken?
- else
- table.insert(brokenElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP - idHP,
- percent = 0,
- pos = idPos
- })
- -- if DebugMode then PrintDebug("Broken: "..idName.." --- Type: "..idType.."") end
- end
- else
- healthyElements = healthyElements + 1
- if id == highlightID then
- highlightID = 0
- end
- end
- end
-
- -- Sort tables by current settings
- SortTables()
-
- -- Update clickAreas
-
- -- Determine total ship integrity
- totalShipIntegrity = string.format("%2.0f",
- 100 / totalShipMaxHP * totalShipHP)
-
- -- Has anything changes since last check? If yes, force redrawing the screens
- if formerTotalShipHP ~= totalShipHP then
- forceRedraw = true
- formerTotalShipHP = totalShipHP
- else
- forceRedraw = false
- end
-end
-
-function GetAllSystemsNominalBackground()
- local output = ""
- output = output .. [[
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetDRLogo()
- output =
- [[]]
- return output
-end
-
-function GenerateHUDOutput()
-
- local hudWidth = 300
- local hudHeight = 125
- if #damagedElements > 0 or #brokenElements > 0 then hudHeight = 780 end
- local screenHeight = 1080
-
- local healthyColor = "#00aa00"
- local brokenColor = "#aa0000"
- local damagedColor = "#aaaa00"
- local integrityColor = "#aaaaaa"
- local healthyTextColor = "white"
- local brokenTextColor = "#ff4444"
- local damagedTextColor = "#ffff44"
- local integrityTextColor = "white"
-
- if #damagedElements == 0 then
- damagedColor = "#aaaaaa"
- damagedTextColor = "white"
- end
- if #brokenElements == 0 then
- brokenColor = "#aaaaaa"
- brokenTextColor = "white"
- end
-
- local hudOutput = ""
-
- -- Draw Header
- hudOutput = hudOutput .. [[
- ]]
-
- hudOutput = hudOutput .. [[]] ..
- [[]] .. GetDRLogo() .. [[]]
-
- hudOutput = hudOutput .. [[
-
- ]] .. healthyElements ..
- [[
-
- ]] .. #damagedElements ..
- [[
-
- ]] .. #brokenElements ..
- [[]]
- if #damagedElements > 0 or #brokenElements > 0 then
- hudOutput = hudOutput ..
- [[ ]] ..
- [[]] ..
- GenerateCommaValue(
- string.format("%.0f", totalShipMaxHP - totalShipHP)) ..
- [[ HP damage in total]]
- else
- hudOutput = hudOutput .. [[]] ..
- OkayCenterMessage .. [[]] ..
- [[Ship stands ]] ..
- GenerateCommaValue(string.format("%.0f", totalShipMaxHP)) ..
- [[ HP strong.]]
-
- end
- hudOutput = hudOutput .. [[]]
-
- hudRowDistance = 25
- if #damagedElements > 0 then
- local damagedElementsToDraw = #damagedElements
- if damagedElementsToDraw > 12 then damagedElementsToDraw = 12 end
- if CurrentDamagedPage == math.ceil(#damagedElements / 12) then
- damagedElementsToDraw = #damagedElements % 12
- end
- local i = 0
- hudOutput = hudOutput .. [[]] ..
- [[]]
-
- for j = 1 + (CurrentDamagedPage - 1) * 12, damagedElementsToDraw +
- (CurrentDamagedPage - 1) * 12, 1 do
- i = i + 1
- local DP = damagedElements[j]
- if (hudSelectedType == 1 and hudSelectedIndex == i) then
- hudOutput = hudOutput .. [[]]
- if UseMyElementNames == true then
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.name) ..
- [[]]
- else
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.type) ..
- [[]]
- end
- if (DamagedSortingMode == 3) then
- hudOutput = hudOutput .. [[]] .. DP.percent ..
- [[%]]
- else
- hudOutput = hudOutput .. [[]] ..
- GenerateCommaValue(
- string.format("%.0f", DP.missinghp)) ..
- [[]]
- end
- else
- if UseMyElementNames == true then
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.name) ..
- [[]]
- else
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.type) ..
- [[]]
- end
- if (DamagedSortingMode == 3) then
- hudOutput = hudOutput .. [[]] .. DP.percent ..
- [[%]]
- else
- hudOutput = hudOutput .. [[]] ..
- GenerateCommaValue(
- string.format("%.0f", DP.missinghp)) ..
- [[]]
- end
- hudOutput = hudOutput .. [[]]
- end
- end
- hudOutput = hudOutput .. [[]]
- end
-
- if #brokenElements > 0 then
- local brokenElementsToDraw = #brokenElements
- if brokenElementsToDraw > 12 then brokenElementsToDraw = 12 end
- if CurrentbrokenPage == math.ceil(#brokenElements / 12) then
- brokenElementsToDraw = #brokenElements % 12
- end
- local i = 0
- hudOutput = hudOutput .. [[]] ..
- [[]]
-
- for j = 1 + (CurrentBrokenPage - 1) * 12, brokenElementsToDraw +
- (CurrentBrokenPage - 1) * 12, 1 do
- i = i + 1
- local DP = brokenElements[j]
- if (hudSelectedType == 2 and hudSelectedIndex == i) then
- hudOutput = hudOutput .. [[]]
- if UseMyElementNames == true then
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.name) ..
- [[]]
- else
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.type) ..
- [[]]
- end
- if (brokenSortingMode == 3) then
- hudOutput = hudOutput .. [[]] .. DP.percent ..
- [[%]]
- else
- hudOutput = hudOutput .. [[]] ..
- GenerateCommaValue(
- string.format("%.0f", DP.missinghp)) ..
- [[]]
- end
- else
- if UseMyElementNames == true then
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.name) ..
- [[]]
- else
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.type) ..
- [[]]
- end
- if (brokenSortingMode == 3) then
- hudOutput = hudOutput .. [[]] .. DP.percent ..
- [[%]]
- else
- hudOutput = hudOutput .. [[]] ..
- GenerateCommaValue(
- string.format("%.0f", DP.missinghp)) ..
- [[]]
- end
- hudOutput = hudOutput .. [[]]
- end
- end
- hudOutput = hudOutput .. [[]]
- end
-
- if #damagedElements or #brokenElements then
- hudOutput = hudOutput .. [[]] ..
- [[Use up/down arrows to select element to find.]] ..
- [[Use right arrow to deselect.]] ..
- [[Use left arrow to exit HUD mode.]] ..
- [[]]
- end
-
- hudOutput = hudOutput .. [[]]
-
- return hudOutput
-end
-
-function DrawScreens()
- if #screens > 0 then
-
- local healthyColor = "#00aa00"
- local brokenColor = "#aa0000"
- local damagedColor = "#aaaa00"
- local integrityColor = "#aaaaaa"
- local healthyTextColor = "white"
- local brokenTextColor = "#ff4444"
- local damagedTextColor = "#ffff44"
- local integrityTextColor = "white"
-
- if #damagedElements == 0 then
- damagedColor = "#aaaaaa"
- damagedTextColor = "white"
- end
- if #brokenElements == 0 then
- brokenColor = "#aaaaaa"
- brokenTextColor = "white"
- end
-
- local screenOutput = ""
-
- -- Draw Header
- screenOutput = screenOutput ..
- [[
- ]]
-
- -- Draw main background
- screenOutput = screenOutput ..
- [[
-
-
-
-
-
-
-
-
-
-
-
- ]]
-
- -- Draw Title and summary
- if SimulationActive == true then
- screenOutput = screenOutput ..
- [[Simulated Report]]
- else
- screenOutput = screenOutput ..
- [[Damage Report]]
- end
- if YourShipsName == nil or YourShipsName == "" or YourShipsName ==
- "Enter here" then
- screenOutput = screenOutput ..
- [[SHIP ID ]] ..
- shipID .. [[]]
- else
- screenOutput = screenOutput ..
- [[]] ..
- YourShipsName .. [[]]
- end
- screenOutput = screenOutput .. [[
- Healthy
- ]] .. healthyElements ..
- [[
-
- Damaged
- ]] .. #damagedElements ..
- [[
-
- Broken
- ]] .. #brokenElements ..
- [[
-
- Integrity
- ]] .. totalShipIntegrity ..
- [[%]]
-
- -- Draw damage elements
-
- if #damagedElements > 0 then
- local damagedElementsToDraw = #damagedElements
- if damagedElementsToDraw > 12 then
- damagedElementsToDraw = 12
- end
- if CurrentDamagedPage == math.ceil(#damagedElements / 12) then
- damagedElementsToDraw = #damagedElements % 12
- end
- screenOutput = screenOutput ..
- [[]]
- screenOutput = screenOutput ..
- [[]]
- if (DamagedSortingMode == 2) then
- screenOutput = screenOutput ..
- [[ID]]
- else
- screenOutput = screenOutput ..
- [[ID]]
- end
- if UseMyElementNames == true then
- screenOutput = screenOutput ..
- [[Element Name]]
- else
- screenOutput = screenOutput ..
- [[Element Type]]
- end
-
- if (DamagedSortingMode == 3) then
- screenOutput = screenOutput ..
- [[Health]]
- else
- screenOutput = screenOutput ..
- [[Health]]
- end
- if (DamagedSortingMode == 1) then
- screenOutput = screenOutput ..
- [[Damage]]
- else
- screenOutput = screenOutput ..
- [[Damage]]
- end
-
- local i = 0
- for j = 1 + (CurrentDamagedPage - 1) * 12, damagedElementsToDraw +
- (CurrentDamagedPage - 1) * 12, 1 do
- i = i + 1
- local DP = damagedElements[j]
- screenOutput = screenOutput .. [[]] ..
- string.format("%03.0f", DP.id) .. [[]]
- if UseMyElementNames == true then
- screenOutput = screenOutput .. [[]] ..
- string.format("%.25s", DP.name) ..
- [[]]
- else
- screenOutput = screenOutput .. [[]] ..
- string.format("%.25s", DP.type) ..
- [[]]
- end
- screenOutput = screenOutput .. [[]] ..
- DP.percent .. [[%]] ..
- [[]] ..
- GenerateCommaValue(
- string.format("%.0f", DP.missinghp)) ..
- [[]] ..
- [[]]
- end
- screenOutput = screenOutput ..
- [[
-
- ]]
-
- if #damagedElements > 12 then
- screenOutput = screenOutput ..
- [[Page ]] ..
- CurrentDamagedPage .. " of " ..
- math.ceil(#damagedElements / 12) ..
- [[]]
-
- if CurrentDamagedPage < math.ceil(#damagedElements / 12) then
- screenOutput = screenOutput .. [[
-
-
- ]]
- UpdateClickArea("DamagedPageDown", {
- id = "DamagedPageDown",
- x1 = 70,
- x2 = 270,
- y1 = 350 + 11 + (damagedElementsToDraw + 1) * 50,
- y2 = 350 + 11 + 50 + (damagedElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("DamagedPageDown")
- end
-
- if CurrentDamagedPage > 1 then
- screenOutput = screenOutput .. [[
-
-
- ]]
- UpdateClickArea("DamagedPageUp", {
- id = "DamagedPageUp",
- x1 = 280,
- x2 = 480,
- y1 = 350 + 11 + (damagedElementsToDraw + 1) * 50,
- y2 = 350 + 11 + 50 + (damagedElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("DamagedPageUp")
- end
- end
- end
-
- -- Draw broken elements
- if #brokenElements > 0 then
- local brokenElementsToDraw = #brokenElements
- if brokenElementsToDraw > 12 then
- brokenElementsToDraw = 12
- end
- if CurrentBrokenPage == math.ceil(#brokenElements / 12) then
- brokenElementsToDraw = #brokenElements % 12
- end
- screenOutput = screenOutput ..
- [[]]
- screenOutput = screenOutput ..
- [[]]
- if (BrokenSortingMode == 2) then
- screenOutput = screenOutput ..
- [[ID]]
- else
- screenOutput = screenOutput ..
- [[ID]]
- end
- if UseMyElementNames == true then
- screenOutput = screenOutput ..
- [[Element Name]]
- else
- screenOutput = screenOutput ..
- [[Element Type]]
- end
- if (BrokenSortingMode == 1) then
- screenOutput = screenOutput ..
- [[Damage]]
- else
- screenOutput = screenOutput ..
- [[Damage]]
- end
-
- local i = 0
- for j = 1 + (CurrentBrokenPage - 1) * 12, brokenElementsToDraw +
- (CurrentBrokenPage - 1) * 12, 1 do
- i = i + 1
- local DP = brokenElements[j]
- screenOutput = screenOutput .. [[]] ..
- string.format("%03.0f", DP.id) .. [[]]
- if UseMyElementNames == true then
- screenOutput = screenOutput .. [[]] ..
- string.format("%.25s", DP.name) ..
- [[]]
- else
- screenOutput = screenOutput .. [[]] ..
- string.format("%.25s", DP.type) ..
- [[]]
- end
- screenOutput = screenOutput .. [[]] ..
- GenerateCommaValue(
- string.format("%.0f", DP.missinghp)) ..
- [[]] ..
- [[]]
- end
-
- screenOutput = screenOutput ..
- [[
-
- ]]
-
- if #brokenElements > 12 then
- screenOutput = screenOutput ..
- [[Page ]] ..
- CurrentBrokenPage .. " of " ..
- math.ceil(#brokenElements / 12) ..
- [[]]
-
- if CurrentBrokenPage > 1 then
- screenOutput = screenOutput .. [[
-
-
- ]]
- UpdateClickArea("BrokenPageUp", {
- id = "BrokenPageUp",
- x1 = 1442,
- x2 = 1642,
- y1 = 350 + 11 + (brokenElementsToDraw + 1) * 50,
- y2 = 350 + 11 + 50 + (brokenElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("BrokenPageUp")
- end
-
- if CurrentBrokenPage < math.ceil(#brokenElements / 12) then
- screenOutput = screenOutput .. [[
-
-
- ]]
- UpdateClickArea("BrokenPageDown", {
- id = "BrokenPageDown",
- x1 = 1652,
- x2 = 1852,
- y1 = 350 + 11 + (brokenElementsToDraw + 1) * 50,
- y2 = 350 + 11 + 50 + (brokenElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("BrokenPageDown")
- end
- end
-
- end
-
- -- Draw damage summary
- if #damagedElements > 0 or #brokenElements > 0 then
- screenOutput = screenOutput ..
- [[]] ..
- GenerateCommaValue(
- string.format("%.0f",
- totalShipMaxHP - totalShipHP)) ..
- [[ HP damage in total]]
- else
- screenOutput = screenOutput .. [[]] ..
- GetAllSystemsNominalBackground() .. [[]] ..
- [[]] ..
- OkayCenterMessage .. [[]] ..
- [[Ship stands ]] ..
- GenerateCommaValue(
- string.format("%.0f", totalShipMaxHP)) ..
- [[ HP strong.]]
- end
-
- -- Draw Sim Mode button
- if SimulationMode == true then
- screenOutput = screenOutput ..
- [[]] ..
- [[Sim Mode]]
-
- else
- screenOutput = screenOutput ..
- [[]] ..
- [[Sim Mode]]
- end
-
- -- Draw HUD Mode button
- if HUDMode == true then
- screenOutput = screenOutput ..
- [[]] ..
- [[HUD Mode]]
-
- else
- screenOutput = screenOutput ..
- [[]] ..
- [[HUD Mode]]
- end
-
- screenOutput = screenOutput .. [[]]
-
- DrawSVG(screenOutput)
-
- forceRedraw = false
- end
-end
-
------------------------------------------------
--- Execute
------------------------------------------------
-
-unit.hide()
-ClearConsole()
-PrintDebug("SCRIPT STARTED", true)
-
-InitiateSlots()
-SwitchScreens(true)
-InitiateClickAreas()
-
-if #screens ~= nil and #screens < 1 then
- HUDMode = true
-end
-
-if core == nil then
- DrawCenteredText("ERROR: No core connected.")
- PrintError("ERROR: No core connected.")
- goto exit
-else
- shipID = core.getConstructId()
-end
-
-GenerateDamageData()
-if forceRedraw then DrawScreens() end
-
-unit.setTimer('UpdateData', UpdateInterval)
-unit.setTimer('UpdateHighlight', HighlightBlinkingInterval)
-
-::exit::
diff --git a/src/DamageReport_2_3_UnitStart.lua b/src/DamageReport_2_3_UnitStart.lua
deleted file mode 100644
index 3f5d006..0000000
--- a/src/DamageReport_2_3_UnitStart.lua
+++ /dev/null
@@ -1,1383 +0,0 @@
---[[
- DamageReport v2.3
-
- Created By Dorian Gray
-
- Discord: Dorian Gray#2623
- InGame: DorianGray
- GitHub: https://github.com/DorianTheGrey/DU-DamageReport
-
- GNU Public License 3.0. Use whatever you want, be so kind to leave credit.
-
- Thanks to Jericho, Dmentia and Archaegeo for learning from their fine scripts.
-]]
------------------------------------------------
--- CONFIG
------------------------------------------------
-UseMyElementNames = true --export: If you active this, the display will not show the element type of damaged/broken elements but the name you gave them (truncated to 25 characters)
-AllowElementHighlighting = true --export: Are you allowing damaged/broken elements to be highlighted in 3D space when selected in the HUD?
-UpdateInterval = 1 --export: Interval in seconds between updates of the calculations and (if anything changed) redrawing to the screen(s). You need to restart the script after changing this value.
-HighlightBlinkingInterval = 0.5 --export: If an element is marked, how fast do you want the arrows to blink?
-SimulationMode = false --export Randomize simluated damage on elements to check out the functionality of this script. And, no, your elements won't be harmed in the process :) You need to restart the script after changing this value.
-YourShipsName = "Enter here" --export Enter your ship name here if you want it displayed instead of the ship's ID. YOU NEED TO LEAVE THE QUOTATION MARKS.
-
-DebugMode = false -- Activate if you want some console messages
-VersionNumber = 2.3 -- Version number
-
-core = nil
-screens = {}
-
-shipID = 0
-forceRedraw = false
-SimulationActive = false
-
-clickAreas = {}
-DamagedSortingMode = 1 -- Define default sorting mode for damaged elements. 1 to sort by damage amount, 2 to sort by element id, 3 to sort by damage percent,
-BrokenSortingMode = 1 -- Define default sorting mode for broken elements. 1 to sort by damage amount, 2 to sort by element id
-
-HUDMode = false -- Is Hud active?
-hudSelectedIndex = 0 -- Which element is selected?
-hudSelectedType = 0 -- Is selected element damaged (1) or broken (2)
-hudArrowSticker = {}
-highlightOn = false
-highlightID = 0
-highlightX = 0
-highlightY = 0
-highlightZ = 0
-
-CurrentDamagedPage = 1
-CurrentBrokenPage = 1
-
-coreWorldOffset = 0
-totalShipHP = 0
-totalShipMaxHP = 0
-totalShipIntegrity = 100
-elementsId = {}
-damagedElements = {}
-brokenElements = {}
-ElementCounter = 0
-healthyElements = 0
-
-OkayCenterMessage = "All systems nominal."
-
------------------------------------------------
--- FUNCTIONS
------------------------------------------------
-
-function GenerateCommaValue(amount)
- local formatted = amount
- while true do
- formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
- if (k == 0) then break end
- end
- return formatted
-end
-
-function PrintDebug(output, highlight)
- highlight = highlight or false
- if DebugMode then
- if highlight then
- system.print(
- "------------------------------------------------------------------------")
- end
- system.print(output)
- if highlight then
- system.print(
- "------------------------------------------------------------------------")
- end
- end
-end
-
-function PrintError(output) system.print(output) end
-
-function DrawCenteredText(output)
- for i = 1, #screens, 1 do screens[i].setCenteredText(output) end
-end
-
-function DrawSVG(output) for i = 1, #screens, 1 do screens[i].setSVG(output) end end
-
-function ClearConsole() for i = 1, 10, 1 do PrintDebug() end end
-
-function SwitchScreens(state)
- state = state or true
- if #screens > 0 then
- for i = 1, #screens, 1 do
- if state==true then
- screens[i].clear()
- screens[i].activate()
- else
- screens[i].deactivate()
- screens[i].clear()
- end
- end
- end
-end
-
-function InitiateSlots()
- for slot_name, slot in pairs(unit) do
- if type(slot) == "table" and type(slot.export) == "table" and
- slot.getElementClass then
- if slot.getElementClass():lower():find("coreunit") then
- core = slot
- local coreHP = core.getMaxHitPoints()
- if coreHP > 10000 then
- coreWorldOffset = 128
- elseif coreHP > 1000 then
- coreWorldOffset = 64
- elseif coreHP > 150 then
- coreWorldOffset = 32
- else
- coreWorldOffset = 16
- end
- end
- if slot.getElementClass():lower():find("screenunit") then
- screens[#screens + 1] = slot
- end
- end
- end
-end
-
-function AddClickArea(newEntry) table.insert(clickAreas, newEntry) end
-
-function RemoveFromClickAreas(candidate)
- for k, v in pairs(clickAreas) do
- if v.id == candidate then
- clickAreas[k] = nil
- break
- end
- end
-end
-
-function UpdateClickArea(candidate, newEntry)
- for k, v in pairs(clickAreas) do
- if v.id == candidate then
- clickAreas[k] = newEntry
- break
- end
- end
-end
-
-function DisableClickArea(candidate)
- for k, v in pairs(clickAreas) do
- if v.id == candidate then
- UpdateClickArea(candidate, {
- id = candidate,
- x1 = -1,
- x2 = -1,
- y1 = -1,
- y2 = -1
- })
- break
- end
- end
-end
-
-function InitiateClickAreas()
- clickAreas = {}
- AddClickArea({id = "DamagedDamage", x1 = 725, x2 = 870, y1 = 380, y2 = 415})
- AddClickArea({id = "DamagedHealth", x1 = 520, x2 = 655, y1 = 380, y2 = 415})
- AddClickArea({id = "DamagedID", x1 = 90, x2 = 150, y1 = 380, y2 = 415})
- AddClickArea({id = "BrokenDamage", x1 = 1675, x2 = 1835, y1 = 380, y2 = 415})
- AddClickArea({id = "BrokenID", x1 = 1050, x2 = 1110, y1 = 380, y2 = 415})
- AddClickArea({id = "ToggleSimulation", x1 = 65, x2 = 660, y1 = 100, y2 = 145})
- AddClickArea({id = "ToggleSimulation2", x1 = 1650, x2 = 1850, y1 = 75, y2 = 117})
- AddClickArea({id = "ToggleElementLabel", x1 = 225, x2 = 460, y1 = 380, y2 = 415})
- AddClickArea({id = "ToggleElementLabel2", x1 = 1185, x2 = 1440, y1 = 380, y2 = 415})
- AddClickArea({id = "ToggleHudMode", x1 = 1650, x2 = 1850, y1 = 125, y2 = 167})
- AddClickArea({id = "DamagedPageDown", x1 = -1, x2 = -1, y1 = -1, y2 = -1})
- AddClickArea({id = "DamagedPageUp", x1 = -1, x2 = -1, y1 = -1, y2 = -1})
- AddClickArea({id = "BrokenPageDown", x1 = -1, x2 = -1, y1 = -1, y2 = -1})
- AddClickArea({id = "BrokenPageUp", x1 = -1, x2 = -1, y1 = -1, y2 = -1})
-end
-
-function FlushClickAreas() clickAreas = {} end
-
-function CheckClick(x, y, HitTarget)
- HitTarget = HitTarget or ""
- if HitTarget == "" then
- for k, v in pairs(clickAreas) do
- if v and x >= v.x1 and x <= v.x2 and y >= v.y1 and y <= v.y2 then
- HitTarget = v.id
- break
- end
- end
- end
- if HitTarget == "DamagedDamage" then
- DamagedSortingMode = 1
- CurrentDamagedPage = 1
- SortTables()
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "DamagedHealth" then
- DamagedSortingMode = 3
- CurrentDamagedPage = 1
- SortTables()
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "DamagedID" then
- DamagedSortingMode = 2
- CurrentDamagedPage = 1
- SortTables()
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "BrokenDamage" then
- BrokenSortingMode = 1
- CurrentBrokenPage = 1
- SortTables()
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "BrokenID" then
- BrokenSortingMode = 2
- CurrentBrokenPage = 1
- SortTables()
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "DamagedPageDown" then
- CurrentDamagedPage = CurrentDamagedPage + 1
- if CurrentDamagedPage > math.ceil(#damagedElements / 12) then
- CurrentDamagedPage = math.ceil(#damagedElements / 12)
- end
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "DamagedPageUp" then
- CurrentDamagedPage = CurrentDamagedPage - 1
- if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "BrokenPageDown" then
- CurrentBrokenPage = CurrentBrokenPage + 1
- if CurrentBrokenPage > math.ceil(#brokenElements / 12) then
- CurrentBrokenPage = math.ceil(#brokenElements / 12)
- end
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "BrokenPageUp" then
- CurrentBrokenPage = CurrentBrokenPage - 1
- if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end
- HudDeselectElement()
- DrawScreens()
- elseif HitTarget == "ToggleHudMode" then
- if HUDMode == true then
- HUDMode = false
- forceRedraw = true
- HudDeselectElement()
- DrawScreens()
- else
- HUDMode = true
- forceRedraw = true
- HudDeselectElement()
- DrawScreens()
- end
- elseif HitTarget == "ToggleSimulation" or HitTarget == "ToggleSimulation2" then
- CurrentDamagedPage = 1
- CurrentBrokenPage = 1
- if SimulationMode == true then
- SimulationMode = false
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- HudDeselectElement()
- DrawScreens()
- else
- SimulationMode = true
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- HudDeselectElement()
- DrawScreens()
- end
- elseif HitTarget == "ToggleElementLabel" or HitTarget ==
- "ToggleElementLabel2" then
- if UseMyElementNames == true then
- UseMyElementNames = false
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- HudDeselectElement()
- DrawScreens()
- else
- UseMyElementNames = true
- SimulationActive = false
- GenerateDamageData()
- forceRedraw = true
- HudDeselectElement()
- DrawScreens()
- end
- end
-end
-
-function ToggleHUD()
- HideHighlight()
- CheckClick(nil, nil, "ToggleHudMode")
-end
-
-function HudDeselectElement()
- if HUDMode == true then
- hudSelectedType = 0
- hudSelectedIndex = 0
- HideHighlight()
- DrawScreens()
- end
-end
-
-function ChangeHudSelectedElement(step)
- if HUDMode == true and (#damagedElements or #brokenElements) then
- local damagedElementsHUD = 12
- if #damagedElements < 12 then
- damagedElementsHUD = #damagedElements
- end
- local brokenElementsHUD = 12
- if #brokenElements < 12 then brokenElementsHUD = #brokenElements end
- if step == 1 then
- if hudSelectedIndex == 0 then
- if damagedElementsHUD > 0 then
- hudSelectedType = 1
- hudSelectedIndex = 1
- elseif brokenElementsHUD > 0 then
- hudSelectedType = 2
- hudSelectedIndex = 1
- end
- elseif hudSelectedType == 1 then
- if damagedElementsHUD > hudSelectedIndex then
- hudSelectedIndex = hudSelectedIndex + 1
- elseif brokenElementsHUD > 0 then
- hudSelectedType = 2
- hudSelectedIndex = 1
- elseif damagedElementsHUD > 0 then
- hudSelectedIndex = 1
- end
- elseif hudSelectedType == 2 then
- if brokenElementsHUD > hudSelectedIndex then
- hudSelectedIndex = hudSelectedIndex + 1
- elseif damagedElementsHUD > 0 then
- hudSelectedType = 1
- hudSelectedIndex = 1
- elseif brokenElementsHUD > 0 then
- hudSelectedIndex = 1
- end
- end
- elseif step == -1 then
- if hudSelectedIndex == 0 then
- if brokenElementsHUD > 0 then
- hudSelectedType = 2
- hudSelectedIndex = 1
- elseif damagedElementsHUD > 0 then
- hudSelectedType = 1
- hudSelectedIndex = 1
- end
- elseif hudSelectedType == 1 then
- if hudSelectedIndex > 1 then
- hudSelectedIndex = hudSelectedIndex - 1
- elseif brokenElementsHUD > 0 then
- hudSelectedType = 2
- hudSelectedIndex = brokenElementsHUD
- elseif damagedElementsHUD > 0 then
- hudSelectedIndex = damagedElementsHUD
- end
- elseif hudSelectedType == 2 then
- if hudSelectedIndex > 1 then
- hudSelectedIndex = hudSelectedIndex - 1
- elseif damagedElementsHUD > 0 then
- hudSelectedType = 1
- hudSelectedIndex = damagedElementsHUD
- elseif brokenElementsHUD > 0 then
- hudSelectedIndex = brokenElementsHUD
- end
- end
- end
- HighlightElement()
- DrawScreens()
- -- PrintDebug("-> Type: "..hudSelectedType.. " Index: "..hudSelectedIndex)
- end
-end
-
-function HideHighlight()
- if #hudArrowSticker > 0 then
- for i in pairs(hudArrowSticker) do
- core.deleteSticker(hudArrowSticker[i])
- end
- hudArrowSticker = {}
- end
-end
-
-function ShowHighlight()
- if highlightOn == true and highlightID > 0 then
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX + 2,
- highlightY,
- highlightZ, "north"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,
- highlightY - 2,
- highlightZ, "east"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX - 2,
- highlightY,
- highlightZ, "south"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,
- highlightY + 2,
- highlightZ, "west"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,
- highlightY,
- highlightZ - 2,
- "up"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,
- highlightY,
- highlightZ + 2,
- "down"))
- end
-end
-
-function ToggleHighlight()
- if highlightOn == true then
- highlightOn = false
- HideHighlight()
- else
- highlightOn = true
- ShowHighlight()
- end
-end
-
-function HighlightElement(elementID)
- elementID = elementID or 0
- local targetElement = {}
-
- if elementID == 0 then
- if hudSelectedType == 1 then
- elementID = damagedElements[(CurrentDamagedPage - 1) * 12 +
- hudSelectedIndex].id
- elseif hudSelectedType == 2 then
- elementID = brokenElements[(CurrentBrokenPage - 1) * 12 +
- hudSelectedIndex].id
- end
-
- if elementID ~= 0 then
- local bFound = false
- for k, v in pairs(damagedElements) do
- if v.id == elementID then
- targetElement = v
- bFound = true
- break
- end
- end
- if bFound == false then
- for k, v in pairs(brokenElements) do
- if v.id == elementID then
- targetElement = v
- bFound = true
- break
- end
- end
- end
-
- if bFound == true and AllowElementHighlighting == true then
- HideHighlight()
- elementPosition = vec3(targetElement.pos)
- highlightX = elementPosition.x - coreWorldOffset
- highlightY = elementPosition.y - coreWorldOffset
- highlightZ = elementPosition.z - coreWorldOffset
- highlightID = targetElement.id
- highlightOn = true
- ShowHighlight()
- end
- end
- end
-end
-
-function SortTables()
- -- Sort damaged elements descending by percent damaged according to setting
- if DamagedSortingMode == 1 then
- table.sort(damagedElements,
- function(a, b) return a.missinghp > b.missinghp end)
- elseif DamagedSortingMode == 2 then
- table.sort(damagedElements, function(a, b) return a.id < b.id end)
- else
- table.sort(damagedElements,
- function(a, b) return a.percent < b.percent end)
- end
-
- -- Sort broken elements descending according to setting
- if BrokenSortingMode == 1 then
- table.sort(brokenElements, function(a, b)
- return a.maxhp > b.maxhp
- end)
- else
- table.sort(brokenElements, function(a, b) return a.id < b.id end)
- end
-end
-
-function GenerateDamageData()
- if SimulationActive == true then return end
-
- local formerTotalShipHP = totalShipHP
- totalShipHP = 0
- totalShipMaxHP = 0
- totalShipIntegrity = 100
- elementsId = {}
- damagedElements = {}
- brokenElements = {}
- ElementCounter = 0
- healthyElements = 0
-
- elementsIdList = core.getElementIdList()
-
- for _, id in pairs(elementsIdList) do
- ElementCounter = ElementCounter + 1
- idHP = core.getElementHitPointsById(id) or 0
- idMaxHP = core.getElementMaxHitPointsById(id) or 0
-
- if SimulationMode then
- SimulationActive = true
- local dice = math.random(0, 10)
- if dice < 2 then
- idHP = 0
- elseif dice >= 2 and dice < 5 then
- idHP = idMaxHP
- else
- idHP = math.random(1, math.ceil(idMaxHP))
- end
- end
-
- totalShipHP = totalShipHP + idHP
- totalShipMaxHP = totalShipMaxHP + idMaxHP
-
- idName = core.getElementNameById(id)
- idType = core.getElementTypeById(id)
-
- -- Is element damaged?
- if idMaxHP > idHP then
- idPos = core.getElementPositionById(id)
- if idHP > 0 then
- table.insert(damagedElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP - idHP,
- percent = math.ceil(100 / idMaxHP * idHP),
- pos = idPos
- })
- -- if DebugMode then PrintDebug("Damaged: "..idName.." --- Type: "..idType.."") end
- -- Is element broken?
- else
- table.insert(brokenElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP - idHP,
- percent = 0,
- pos = idPos
- })
- -- if DebugMode then PrintDebug("Broken: "..idName.." --- Type: "..idType.."") end
- end
- else
- healthyElements = healthyElements + 1
- if id == highlightID then
- highlightID = 0
- end
- end
- end
-
- -- Sort tables by current settings
- SortTables()
-
- -- Update clickAreas
-
- -- Determine total ship integrity
- totalShipIntegrity = string.format("%2.0f",
- 100 / totalShipMaxHP * totalShipHP)
-
- -- Has anything changes since last check? If yes, force redrawing the screens
- if formerTotalShipHP ~= totalShipHP then
- forceRedraw = true
- formerTotalShipHP = totalShipHP
- else
- forceRedraw = false
- end
-end
-
-function GetAllSystemsNominalBackground()
- local output = ""
- output = output .. [[
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetDRLogo()
- output =
- [[]]
- return output
-end
-
-function GenerateHUDOutput()
-
- local hudWidth = 300
- local hudHeight = 125
- if #damagedElements > 0 or #brokenElements > 0 then hudHeight = 780 end
- local screenHeight = 1080
-
- local healthyColor = "#00aa00"
- local brokenColor = "#aa0000"
- local damagedColor = "#aaaa00"
- local integrityColor = "#aaaaaa"
- local healthyTextColor = "white"
- local brokenTextColor = "#ff4444"
- local damagedTextColor = "#ffff44"
- local integrityTextColor = "white"
-
- if #damagedElements == 0 then
- damagedColor = "#aaaaaa"
- damagedTextColor = "white"
- end
- if #brokenElements == 0 then
- brokenColor = "#aaaaaa"
- brokenTextColor = "white"
- end
-
- local hudOutput = ""
-
- -- Draw Header
- hudOutput = hudOutput .. [[
- ]]
-
- hudOutput = hudOutput .. [[]] ..
- [[]] .. GetDRLogo() .. [[]]
-
- hudOutput = hudOutput .. [[
-
- ]] .. healthyElements ..
- [[
-
- ]] .. #damagedElements ..
- [[
-
- ]] .. #brokenElements ..
- [[]]
- if #damagedElements > 0 or #brokenElements > 0 then
- hudOutput = hudOutput ..
- [[ ]] ..
- [[]] ..
- GenerateCommaValue(
- string.format("%.0f", totalShipMaxHP - totalShipHP)) ..
- [[ HP damage in total]]
- else
- hudOutput = hudOutput .. [[]] ..
- OkayCenterMessage .. [[]] ..
- [[Ship stands ]] ..
- GenerateCommaValue(string.format("%.0f", totalShipMaxHP)) ..
- [[ HP strong.]]
-
- end
- hudOutput = hudOutput .. [[]]
-
- hudRowDistance = 25
- if #damagedElements > 0 then
- local damagedElementsToDraw = #damagedElements
- if damagedElementsToDraw > 12 then damagedElementsToDraw = 12 end
- if CurrentDamagedPage == math.ceil(#damagedElements / 12) then
- damagedElementsToDraw = #damagedElements % 12
- end
- local i = 0
- hudOutput = hudOutput .. [[]] ..
- [[]]
-
- for j = 1 + (CurrentDamagedPage - 1) * 12, damagedElementsToDraw +
- (CurrentDamagedPage - 1) * 12, 1 do
- i = i + 1
- local DP = damagedElements[j]
- if (hudSelectedType == 1 and hudSelectedIndex == i) then
- hudOutput = hudOutput .. [[]]
- if UseMyElementNames == true then
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.name) ..
- [[]]
- else
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.type) ..
- [[]]
- end
- if (DamagedSortingMode == 3) then
- hudOutput = hudOutput .. [[]] .. DP.percent ..
- [[%]]
- else
- hudOutput = hudOutput .. [[]] ..
- GenerateCommaValue(
- string.format("%.0f", DP.missinghp)) ..
- [[]]
- end
- else
- if UseMyElementNames == true then
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.name) ..
- [[]]
- else
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.type) ..
- [[]]
- end
- if (DamagedSortingMode == 3) then
- hudOutput = hudOutput .. [[]] .. DP.percent ..
- [[%]]
- else
- hudOutput = hudOutput .. [[]] ..
- GenerateCommaValue(
- string.format("%.0f", DP.missinghp)) ..
- [[]]
- end
- hudOutput = hudOutput .. [[]]
- end
- end
- hudOutput = hudOutput .. [[]]
- end
-
- if #brokenElements > 0 then
- local brokenElementsToDraw = #brokenElements
- if brokenElementsToDraw > 12 then brokenElementsToDraw = 12 end
- if CurrentbrokenPage == math.ceil(#brokenElements / 12) then
- brokenElementsToDraw = #brokenElements % 12
- end
- local i = 0
- hudOutput = hudOutput .. [[]] ..
- [[]]
-
- for j = 1 + (CurrentBrokenPage - 1) * 12, brokenElementsToDraw +
- (CurrentBrokenPage - 1) * 12, 1 do
- i = i + 1
- local DP = brokenElements[j]
- if (hudSelectedType == 2 and hudSelectedIndex == i) then
- hudOutput = hudOutput .. [[]]
- if UseMyElementNames == true then
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.name) ..
- [[]]
- else
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.type) ..
- [[]]
- end
- if (brokenSortingMode == 3) then
- hudOutput = hudOutput .. [[]] .. DP.percent ..
- [[%]]
- else
- hudOutput = hudOutput .. [[]] ..
- GenerateCommaValue(
- string.format("%.0f", DP.missinghp)) ..
- [[]]
- end
- else
- if UseMyElementNames == true then
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.name) ..
- [[]]
- else
- hudOutput = hudOutput .. [[]] ..
- string.format("%.32s", DP.type) ..
- [[]]
- end
- if (brokenSortingMode == 3) then
- hudOutput = hudOutput .. [[]] .. DP.percent ..
- [[%]]
- else
- hudOutput = hudOutput .. [[]] ..
- GenerateCommaValue(
- string.format("%.0f", DP.missinghp)) ..
- [[]]
- end
- hudOutput = hudOutput .. [[]]
- end
- end
- hudOutput = hudOutput .. [[]]
- end
-
- if #damagedElements or #brokenElements then
- hudOutput = hudOutput .. [[]] ..
- [[Use up/down arrows to select element to find.]] ..
- [[Use right arrow to deselect.]] ..
- [[Use left arrow to exit HUD mode.]] ..
- [[]]
- end
-
- hudOutput = hudOutput .. [[]]
-
- return hudOutput
-end
-
-function DrawScreens()
- if #screens > 0 then
-
- local healthyColor = "#00aa00"
- local brokenColor = "#aa0000"
- local damagedColor = "#aaaa00"
- local integrityColor = "#aaaaaa"
- local healthyTextColor = "white"
- local brokenTextColor = "#ff4444"
- local damagedTextColor = "#ffff44"
- local integrityTextColor = "white"
-
- if #damagedElements == 0 then
- damagedColor = "#aaaaaa"
- damagedTextColor = "white"
- end
- if #brokenElements == 0 then
- brokenColor = "#aaaaaa"
- brokenTextColor = "white"
- end
-
- local screenOutput = ""
-
- -- Draw Header
- screenOutput = screenOutput ..
- [[
- ]]
-
- -- Draw main background
- screenOutput = screenOutput ..
- [[
-
-
-
-
-
-
-
-
-
-
-
- ]]
-
- -- Draw Title and summary
- if SimulationActive == true then
- screenOutput = screenOutput ..
- [[Simulated Report]]
- else
- screenOutput = screenOutput ..
- [[Damage Report]]
- end
- if YourShipsName == nil or YourShipsName == "" or YourShipsName ==
- "Enter here" then
- screenOutput = screenOutput ..
- [[SHIP ID ]] ..
- shipID .. [[]]
- else
- screenOutput = screenOutput ..
- [[]] ..
- YourShipsName .. [[]]
- end
- screenOutput = screenOutput .. [[
- Healthy
- ]] .. healthyElements ..
- [[
-
- Damaged
- ]] .. #damagedElements ..
- [[
-
- Broken
- ]] .. #brokenElements ..
- [[
-
- Integrity
- ]] .. totalShipIntegrity ..
- [[%]]
-
- -- Draw damage elements
-
- if #damagedElements > 0 then
- local damagedElementsToDraw = #damagedElements
- if damagedElementsToDraw > 12 then
- damagedElementsToDraw = 12
- end
- if CurrentDamagedPage == math.ceil(#damagedElements / 12) then
- damagedElementsToDraw = #damagedElements % 12
- end
- screenOutput = screenOutput ..
- [[]]
- screenOutput = screenOutput ..
- [[]]
- if (DamagedSortingMode == 2) then
- screenOutput = screenOutput ..
- [[ID]]
- else
- screenOutput = screenOutput ..
- [[ID]]
- end
- if UseMyElementNames == true then
- screenOutput = screenOutput ..
- [[Element Name]]
- else
- screenOutput = screenOutput ..
- [[Element Type]]
- end
-
- if (DamagedSortingMode == 3) then
- screenOutput = screenOutput ..
- [[Health]]
- else
- screenOutput = screenOutput ..
- [[Health]]
- end
- if (DamagedSortingMode == 1) then
- screenOutput = screenOutput ..
- [[Damage]]
- else
- screenOutput = screenOutput ..
- [[Damage]]
- end
-
- local i = 0
- for j = 1 + (CurrentDamagedPage - 1) * 12, damagedElementsToDraw +
- (CurrentDamagedPage - 1) * 12, 1 do
- i = i + 1
- local DP = damagedElements[j]
- screenOutput = screenOutput .. [[]] ..
- string.format("%03.0f", DP.id) .. [[]]
- if UseMyElementNames == true then
- screenOutput = screenOutput .. [[]] ..
- string.format("%.25s", DP.name) ..
- [[]]
- else
- screenOutput = screenOutput .. [[]] ..
- string.format("%.25s", DP.type) ..
- [[]]
- end
- screenOutput = screenOutput .. [[]] ..
- DP.percent .. [[%]] ..
- [[]] ..
- GenerateCommaValue(
- string.format("%.0f", DP.missinghp)) ..
- [[]] ..
- [[]]
- end
- screenOutput = screenOutput ..
- [[
-
- ]]
-
- if #damagedElements > 12 then
- screenOutput = screenOutput ..
- [[Page ]] ..
- CurrentDamagedPage .. " of " ..
- math.ceil(#damagedElements / 12) ..
- [[]]
-
- if CurrentDamagedPage < math.ceil(#damagedElements / 12) then
- screenOutput = screenOutput .. [[
-
-
- ]]
- UpdateClickArea("DamagedPageDown", {
- id = "DamagedPageDown",
- x1 = 70,
- x2 = 270,
- y1 = 350 + 11 + (damagedElementsToDraw + 1) * 50,
- y2 = 350 + 11 + 50 + (damagedElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("DamagedPageDown")
- end
-
- if CurrentDamagedPage > 1 then
- screenOutput = screenOutput .. [[
-
-
- ]]
- UpdateClickArea("DamagedPageUp", {
- id = "DamagedPageUp",
- x1 = 280,
- x2 = 480,
- y1 = 350 + 11 + (damagedElementsToDraw + 1) * 50,
- y2 = 350 + 11 + 50 + (damagedElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("DamagedPageUp")
- end
- end
- end
-
- -- Draw broken elements
- if #brokenElements > 0 then
- local brokenElementsToDraw = #brokenElements
- if brokenElementsToDraw > 12 then
- brokenElementsToDraw = 12
- end
- if CurrentBrokenPage == math.ceil(#brokenElements / 12) then
- brokenElementsToDraw = #brokenElements % 12
- end
- screenOutput = screenOutput ..
- [[]]
- screenOutput = screenOutput ..
- [[]]
- if (BrokenSortingMode == 2) then
- screenOutput = screenOutput ..
- [[ID]]
- else
- screenOutput = screenOutput ..
- [[ID]]
- end
- if UseMyElementNames == true then
- screenOutput = screenOutput ..
- [[Element Name]]
- else
- screenOutput = screenOutput ..
- [[Element Type]]
- end
- if (BrokenSortingMode == 1) then
- screenOutput = screenOutput ..
- [[Damage]]
- else
- screenOutput = screenOutput ..
- [[Damage]]
- end
-
- local i = 0
- for j = 1 + (CurrentBrokenPage - 1) * 12, brokenElementsToDraw +
- (CurrentBrokenPage - 1) * 12, 1 do
- i = i + 1
- local DP = brokenElements[j]
- screenOutput = screenOutput .. [[]] ..
- string.format("%03.0f", DP.id) .. [[]]
- if UseMyElementNames == true then
- screenOutput = screenOutput .. [[]] ..
- string.format("%.25s", DP.name) ..
- [[]]
- else
- screenOutput = screenOutput .. [[]] ..
- string.format("%.25s", DP.type) ..
- [[]]
- end
- screenOutput = screenOutput .. [[]] ..
- GenerateCommaValue(
- string.format("%.0f", DP.missinghp)) ..
- [[]] ..
- [[]]
- end
-
- screenOutput = screenOutput ..
- [[
-
- ]]
-
- if #brokenElements > 12 then
- screenOutput = screenOutput ..
- [[Page ]] ..
- CurrentBrokenPage .. " of " ..
- math.ceil(#brokenElements / 12) ..
- [[]]
-
- if CurrentBrokenPage > 1 then
- screenOutput = screenOutput .. [[
-
-
- ]]
- UpdateClickArea("BrokenPageUp", {
- id = "BrokenPageUp",
- x1 = 1442,
- x2 = 1642,
- y1 = 350 + 11 + (brokenElementsToDraw + 1) * 50,
- y2 = 350 + 11 + 50 + (brokenElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("BrokenPageUp")
- end
-
- if CurrentBrokenPage < math.ceil(#brokenElements / 12) then
- screenOutput = screenOutput .. [[
-
-
- ]]
- UpdateClickArea("BrokenPageDown", {
- id = "BrokenPageDown",
- x1 = 1652,
- x2 = 1852,
- y1 = 350 + 11 + (brokenElementsToDraw + 1) * 50,
- y2 = 350 + 11 + 50 + (brokenElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("BrokenPageDown")
- end
- end
-
- end
-
- -- Draw damage summary
- if #damagedElements > 0 or #brokenElements > 0 then
- screenOutput = screenOutput ..
- [[]] ..
- GenerateCommaValue(
- string.format("%.0f",
- totalShipMaxHP - totalShipHP)) ..
- [[ HP damage in total]]
- else
- screenOutput = screenOutput .. [[]] ..
- GetAllSystemsNominalBackground() .. [[]] ..
- [[]] ..
- OkayCenterMessage .. [[]] ..
- [[Ship stands ]] ..
- GenerateCommaValue(
- string.format("%.0f", totalShipMaxHP)) ..
- [[ HP strong.]]
- end
-
- -- Draw Sim Mode button
- if SimulationMode == true then
- screenOutput = screenOutput ..
- [[]] ..
- [[Sim Mode]]
-
- else
- screenOutput = screenOutput ..
- [[]] ..
- [[Sim Mode]]
- end
-
- -- Draw HUD Mode button
- if HUDMode == true then
- screenOutput = screenOutput ..
- [[]] ..
- [[HUD Mode]]
-
- else
- screenOutput = screenOutput ..
- [[]] ..
- [[HUD Mode]]
- end
-
- screenOutput = screenOutput .. [[]]
-
- if HUDMode == true then
- system.setScreen(GenerateHUDOutput())
- system.showScreen(1)
- else
- system.showScreen(0)
- end
-
- DrawSVG(screenOutput)
-
- forceRedraw = false
- end
-end
-
------------------------------------------------
--- Execute
------------------------------------------------
-
-unit.hide()
-ClearConsole()
-PrintDebug("SCRIPT STARTED", true)
-
-InitiateSlots()
-SwitchScreens(true)
-InitiateClickAreas()
-
-if core == nil then
- DrawCenteredText("ERROR: No core connected.")
- PrintError("ERROR: No core connected.")
- goto exit
-else
- shipID = core.getConstructId()
-end
-
-GenerateDamageData()
-if forceRedraw then DrawScreens() end
-
-unit.setTimer('UpdateData', UpdateInterval)
-unit.setTimer('UpdateHighlight', HighlightBlinkingInterval)
-
-::exit::
diff --git a/src/DamageReport_3_00_UnitStart_1.lua b/src/DamageReport_3_00_UnitStart_1.lua
deleted file mode 100644
index e8da06e..0000000
--- a/src/DamageReport_3_00_UnitStart_1.lua
+++ /dev/null
@@ -1,1277 +0,0 @@
---[[
- Damage Report 3.0
- A LUA script for Dual Universe
-
- Created By Dorian Gray
- Ingame: DorianGray
- Discord: Dorian Gray#2623
-
- You can find/update this script on GitHub. Explanations, installation and usage information as well as screenshots can be found there too.
- GitHub: https://github.com/DorianTheGrey/DU-DamageReport
-
- GNU Public License 3.0. Use whatever you want, be so kind to leave credit.
-
- Credits & thanks:
- Thanks to NovaQuark for creating the MMO of the century.
- Thanks to Jericho, Dmentia and Archaegeo for learning a lot from their fine scripts.
- Thanks to TheBlacklist for testing and wonderful suggestions.
- SVG patterns by Hero Patterns.
- DU atlas data from Jayle Break.
-
-]]
-
---[[ 1. HELPER FUNCTIONS ]]
-
-function GenerateCommaValue(amount, kify, postcomma)
- kify = kify or false
- postcomma = postcomma or 1
- local formatted = amount
- if kify == true then
- if string.len(amount)>=4 then
- formatted = string.format("%."..postcomma.."fk", amount/1000)
- else
- formatted = string.format("%."..postcomma.."f", amount)
- end
- else
- while true do
- formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
- if (k == 0) then break end
- end
- end
- return formatted
-end
-
-function PrintConsole(output, highlight)
- highlight = highlight or false
- if highlight then
- system.print(
- "------------------------------------------------------------------------")
- end
- system.print(output)
- if highlight then
- system.print(
- "------------------------------------------------------------------------")
- end
-end
-
-function DrawCenteredText(output)
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- screens[i].element.setCenteredText(output)
- end
- end
-end
-
-function ClearConsole()
- for i = 1, 10, 1 do
- PrintConsole()
- end
-end
-
-function SwitchScreens(state)
- state = state or "on"
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- if state == "on" then
- screens[i].element.clear()
- screens[i].element.activate()
- screens[i].active = true
- else
- screens[i].element.clear()
- screens[i].element.deactivate()
- screens[i].active = false
- end
- end
- end
-end
-
---[[ Convert seconds to string (by Jericho) ]]
-function GetSecondsString(seconds)
- local seconds = tonumber(seconds)
-
- if seconds == nil or seconds <= 0 then
- return "-";
- else
- days = string.format("%2.f", math.floor(seconds/(3600*24)));
- hours = string.format("%2.f", math.floor(seconds/3600 - (days*24)));
- mins = string.format("%2.f", math.floor(seconds/60 - (hours*60) - (days*24*60)));
- secs = string.format("%2.f", math.floor(seconds - hours*3600 - (days*24*60*60) - mins *60));
- str = ""
- if tonumber(days) > 0 then str = str .. days.."d " end
- if tonumber(hours) > 0 then str = str .. hours.."h " end
- if tonumber(mins) > 0 then str = str .. mins.."m " end
- if tonumber(secs) > 0 then str = str .. secs .."s" end
- return str
- end
-end
-
-function replace_char(pos, str, r)
- return str:sub(1, pos-1) .. r .. str:sub(pos+1)
-end
-
---[[ 2. RENDER HELPER FUNCTIONS ]]
-
---[[ epochTime function by Leodr (clock script), enhanced by Jericho (DU Industry script) ]]
-function epochTime()
- function rZ(a)
- if string.len(a) <= 1 then
- return "0" .. a
- else
- return a
- end
- end
- function dPoint(b)
- if not (b == math.floor(b)) then
- return true
- else
- return false
- end
- end
- function lYear(year)
- if not dPoint(year / 4) then
- if dPoint(year / 100) then
- return true
- else
- if not dPoint(year / 400) then
- return true
- else
- return false
- end
- end
- else
- return false
- end
- end
- local c = 5;
- local d = 3600;
- local e = 86400;
- local f = 31536000;
- local g = 31622400;
- local h = 2419200;
- local i = 2505600;
- local j = 2592000;
- local k = 2678400;
- local l = {4, 6, 9, 11}
- local m = {1, 3, 5, 7, 8, 10, 12}
- local n = 0;
- local o = 1506816000;
- local q = system.getTime()
- _G["formerTime"] = q
- if AddSummertimeHour == true then q = q + 3600 end
- now = math.floor(q + o)
- year = 1970;
- secs = 0;
- n = 0;
- while secs + g < now or secs + f < now do
- if lYear(year + 1) then
- if secs + g < now then
- secs = secs + g;
- year = year + 1;
- n = n + 366
- end
- else
- if secs + f < now then
- secs = secs + f;
- year = year + 1;
- n = n + 365
- end
- end
- end
- secondsRemaining = now - secs;
- monthSecs = 0;
- yearlYear = lYear(year)
- month = 1;
- while monthSecs + h < secondsRemaining or monthSecs + j < secondsRemaining or
- monthSecs + k < secondsRemaining do
- if month == 1 then
- if monthSecs + k < secondsRemaining then
- month = 2;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 2 then
- if not yearlYear then
- if monthSecs + h < secondsRemaining then
- month = 3;
- monthSecs = monthSecs + h;
- n = n + 28
- else
- break
- end
- else
- if monthSecs + i < secondsRemaining then
- month = 3;
- monthSecs = monthSecs + i;
- n = n + 29
- else
- break
- end
- end
- end
- if month == 3 then
- if monthSecs + k < secondsRemaining then
- month = 4;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 4 then
- if monthSecs + j < secondsRemaining then
- month = 5;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- if month == 5 then
- if monthSecs + k < secondsRemaining then
- month = 6;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 6 then
- if monthSecs + j < secondsRemaining then
- month = 7;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- if month == 7 then
- if monthSecs + k < secondsRemaining then
- month = 8;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 8 then
- if monthSecs + k < secondsRemaining then
- month = 9;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 9 then
- if monthSecs + j < secondsRemaining then
- month = 10;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- if month == 10 then
- if monthSecs + k < secondsRemaining then
- month = 11;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 11 then
- if monthSecs + j < secondsRemaining then
- month = 12;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- end
- day = 1;
- daySecs = 0;
- daySecsRemaining = secondsRemaining - monthSecs;
- while daySecs + e < daySecsRemaining do
- day = day + 1;
- daySecs = daySecs + e;
- n = n + 1
- end
- hour = 0;
- hourSecs = 0;
- hourSecsRemaining = daySecsRemaining - daySecs;
- while hourSecs + d < hourSecsRemaining do
- hour = hour + 1;
- hourSecs = hourSecs + d
- end
- minute = 0;
- minuteSecs = 0;
- minuteSecsRemaining = hourSecsRemaining - hourSecs;
- while minuteSecs + 60 < minuteSecsRemaining do
- minute = minute + 1;
- minuteSecs = minuteSecs + 60
- end
- second = math.floor(now % 60)
- year = rZ(year)
- month = rZ(month)
- day = rZ(day)
- hour = rZ(hour)
- minute = rZ(minute)
- second = rZ(second)
-
- return [[]]..hour..":".. minute..[[]]..
- [[]]..year.."/".. month.."/"..day..[[]]
-end
-
-
-function ToggleHUD()
- if HUDMode == true then
- HUDMode = false
- forceDamageRedraw = true
- hudSelectedIndex = 0
- highlightID = 0
- HideHighlight()
- SetRefresh()
- RenderScreens()
- else
- HUDMode = true
- forceDamageRedraw = true
- hudSelectedIndex = 0
- highlightID = 0
- HideHighlight()
- SetRefresh()
- RenderScreens()
- end
-end
-
-function HudDeselectElement()
- hudSelectedIndex = 0
- hudStartIndex = 1
- highlightID = 0
- HideHighlight()
- if HUDMode == true then
- SetRefresh("damage")
- SetRefresh("damageoutline")
- RenderScreens()
- end
-end
-
-function ChangeHudSelectedElement(step)
- if HUDMode == true and #rE > 0 then
-
- hudSelectedIndex = hudSelectedIndex + step
- if hudSelectedIndex < 1 then hudSelectedIndex = 1
- elseif hudSelectedIndex > #rE then hudSelectedIndex = #rE
- end
-
- if hudSelectedIndex > 9 then
- hudStartIndex = hudSelectedIndex-9
- end
- if hudSelectedIndex ~= 0 then
- highlightID = rE[hudSelectedIndex].id
- if highlightID ~=nil and highlightID ~= 0 then
- -- PrintConsole("CHSE: hudSelectedIndex: "..hudSelectedIndex.." / hudStartIndex: "..hudStartIndex.." / highlightID: "..highlightID)
- HideHighlight()
- elementPosition = vec3(rE[hudSelectedIndex].pos)
- highlightX = elementPosition.x - coreWorldOffset
- highlightY = elementPosition.y - coreWorldOffset
- highlightZ = elementPosition.z - coreWorldOffset
- highlightOn = true
- ShowHighlight()
- end
- end
-
- SetRefresh("damage")
- SetRefresh("damageoutline")
- RenderScreens()
-
- end
-end
-
-function HideHighlight()
- if #hudArrowSticker > 0 then
- for i in pairs(hudArrowSticker) do
- core.deleteSticker(hudArrowSticker[i])
- end
- hudArrowSticker = {}
- end
-end
-
-function ShowHighlight()
- if highlightOn == true and highlightID > 0 then
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX + 2, highlightY, highlightZ, "north"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY - 2, highlightZ, "east"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX - 2, highlightY, highlightZ, "south"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY + 2, highlightZ, "west"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY, highlightZ - 2, "up"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY, highlightZ + 2,"down"))
- end
-end
-
-function ToggleHighlight()
- if highlightOn == true then
- highlightOn = false
- HideHighlight()
- else
- highlightOn = true
- ShowHighlight()
- end
-end
-
-function SortDamageTables()
- table.sort(damagedElements, function(a, b) return a.missinghp > b.missinghp end)
- table.sort(brokenElements, function(a, b) return a.maxhp > b.maxhp end)
-end
-
-function getScraps(damage,commaval)
- commaval = commaval or false
- damage = damage - SkillRepairToolOptimization * 0.05 * damage
- local res = math.ceil( damage / ( 10 * 5^(ScrapTier-1) ) )
- if commaval ==true then
- return GenerateCommaValue(string.format("%.0f", res ), false)
- else
- return res
- end
-end
-
-function getRepairTime(damage,buildstring)
- buildstring = buildstring or false
- damage = damage - SkillRepairToolOptimization * 0.05 * damage
- local res = math.ceil(damage / ScrapTierRepairTimes[ScrapTier])
- res = res - ( SkillRepairToolEfficiency * 0.1 * res )
- if buildstring == true then
- return GetSecondsString(string.format("%.0f", res ) )
- else
- return res
- end
-end
-
-function UpdateDataDamageoutline()
-
- dmgoElements = {}
-
- for i,element in ipairs(brokenElements) do
- if #dmgoElements < DMGOMaxElements then
- local elementPosition = vec3(element.pos)
- local x = elementPosition.x - coreWorldOffset
- local y = elementPosition.y - coreWorldOffset
- local z = elementPosition.z - coreWorldOffset
- if x < ShipXmin then ShipXmin = x end
- if y < ShipYmin then ShipYmin = y end
- if z < ShipZmin then ShipZmin = z end
- if x > ShipXmax then ShipXmax = x end
- if y > ShipYmax then ShipYmax = y end
- if z > ShipZmax then ShipZmax = z end
- table.insert( dmgoElements, {
- id = element.id,
- type = "b",
- size = element.maxhp,
- x = x, y = y, z = z,
- xp = 0, yp = 0, zp = 0,
- u = 0, v = 0
- })
- end
- end
-
- if #dmgoElements < DMGOMaxElements then
- for i,element in ipairs(damagedElements) do
- if #dmgoElements < DMGOMaxElements then
- local elementPosition = vec3(element.pos)
- local x = elementPosition.x - coreWorldOffset
- local y = elementPosition.y - coreWorldOffset
- local z = elementPosition.z - coreWorldOffset
- if x < ShipXmin then ShipXmin = x end
- if y < ShipYmin then ShipYmin = y end
- if z < ShipZmin then ShipZmin = z end
- if x > ShipXmax then ShipXmax = x end
- if y > ShipYmax then ShipYmax = y end
- if z > ShipZmax then ShipZmax = z end
- table.insert( dmgoElements, {
- id = element.id,
- type = "d",
- size = element.maxhp,
- x = x, y = y, z = z,
- xp = 0, yp = 0, zp = 0,
- u = 0, v = 0
- })
- end
- end
- end
-
- if #dmgoElements < DMGOMaxElements then
- for i,element in ipairs(healthyElements) do
- if #dmgoElements < DMGOMaxElements then
- local elementPosition = vec3(element.pos)
- local x = elementPosition.x - coreWorldOffset
- local y = elementPosition.y - coreWorldOffset
- local z = elementPosition.z - coreWorldOffset
- if x < ShipXmin then ShipXmin = x end
- if y < ShipYmin then ShipYmin = y end
- if z < ShipZmin then ShipZmin = z end
- if x > ShipXmax then ShipXmax = x end
- if y > ShipYmax then ShipYmax = y end
- if z > ShipZmax then ShipZmax = z end
- table.insert( dmgoElements, {
- id = element.id,
- type = "h",
- size = element.maxhp,
- x = x, y = y, z = z,
- xp = 0, yp = 0, zp = 0,
- u = 0, v = 0
- })
- end
- end
- end
-
- ShipX = math.abs(ShipXmax-ShipXmin)
- ShipY = math.abs(ShipYmax-ShipYmin)
- ShipZ = math.abs(ShipZmax-ShipZmin)
-
- --[[
- PrintConsole(
- "ShipXmin: "..string.format("%.2f",ShipXmin)..
- " - ShipYmin: "..string.format("%.2f",ShipYmin)..
- " - ShipZmin: "..string.format("%.2f",ShipZmin)..
- " - ShipXmax: "..string.format("%.2f",ShipXmax)..
- " - ShipYmax: "..string.format("%.2f",ShipYmax)..
- " - ShipZmax: "..string.format("%.2f",ShipZmax)
- )
-
- PrintConsole(
- "ShipX: "..string.format("%.2f",ShipX)..
- " - ShipY: "..string.format("%.2f",ShipY)..
- " - ShipZ: "..string.format("%.2f",ShipZ)
- )
- ]]
-
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].xp = math.abs(100/(ShipXmax-ShipXmin)*(element.x-ShipXmin))
- dmgoElements[i].yp = math.abs(100/(ShipYmax-ShipYmin)*(element.y-ShipYmin))
- dmgoElements[i].zp = math.abs(100/(ShipZmax-ShipZmin)*(element.z-ShipZmin))
- -- PrintConsole(i..". "..element.id..": "..string.format("%.2f",element.x).."/"..string.format("%.2f",element.y).."/"..string.format("%.2f",element.z).." - XP: "..dmgoElements[i].xp.." - YP: "..dmgoElements[i].yp.." - ZP: "..dmgoElements[i].zp)
- end
-
-end
-
-function UpdateViewDamageoutline(screen)
- -- Full Width of virtual screen:
- -- UStart = 20
- -- VStart = 180
- -- UDim = 1880
- -- VDim = 840
- -- Adding frames:
- UFrame = 40
- VFrame = 40
-
- UStart = 20 + UFrame
- VStart = 180 + VFrame
- UDim = 1880 - 2*UFrame
- VDim = 840 - 2*VFrame
-
- if screen.submode == "top" then
- if DMGOStretch == false then
- local UFactor = UDim/(ShipYmax-ShipYmin)
- local VFactor = VDim/(ShipXmax-ShipXmin)
- if UFactor>=VFactor then
- local cFactor = UFactor/VFactor
- local newUDim = math.floor(UDim/cFactor)
- UStart = UStart+(UDim-newUDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100/cFactor*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*element.xp+VStart)
- end
- else
- local cFactor = VFactor/UFactor
- local newVDim = math.floor(VDim/cFactor)
- VStart = VStart+(VDim-newVDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100/cFactor*element.xp+VStart)
- end
- end
- else
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*element.xp+VStart)
- end
- end
-
-
- elseif screen.submode == "front" then
- if DMGOStretch == false then
- local UFactor = UDim/(ShipXmax-ShipXmin)
- local VFactor = VDim/(ShipZmax-ShipZmin)
- if UFactor>=VFactor then
- local cFactor = UFactor/VFactor
- local newUDim = math.floor(UDim/cFactor)
- UStart = UStart+(UDim-newUDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100/cFactor*element.xp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- else
- local cFactor = VFactor/UFactor
- local newVDim = math.floor(VDim/cFactor)
- VStart = VStart+(VDim-newVDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.xp+UStart)
- dmgoElements[i].v = math.floor(VDim/100/cFactor*(100-element.zp)+VStart)
- end
- end
- else
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.xp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- end
-
- elseif screen.submode == "side" then
- if DMGOStretch == false then
- local UFactor = UDim/(ShipYmax-ShipYmin)
- local VFactor = VDim/(ShipXmax-ShipZmin)
- if UFactor>=VFactor then
- local cFactor = UFactor/VFactor
- local newUDim = math.floor(UDim/cFactor)
- UStart = UStart+(UDim-newUDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100/cFactor*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- else
- local cFactor = VFactor/UFactor
- local newVDim = math.floor(VDim/cFactor)
- VStart = VStart+(VDim-newVDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100/cFactor*(100-element.zp)+VStart)
- end
- end
- else
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- end
- else
- DrawCenteredText("ERROR: non-existing DMGO mode set.")
- PrintConsole("ERROR: non-existing DMGO mode set.")
- unit.exit()
- end
-end
-
-function GetDamageoutlineShip()
- local output = ""
-
- for i,element in ipairs(dmgoElements) do
- local cclass = ""
- local size = 1
-
- if element.type == "h" then
- cclass ="ch"
- elseif element.type == "d" then
- cclass = "cw"
- else
- cclass = "cc"
- end
- if element.id == highlightID then
- cclass = "f2"
- end
-
- if element.size > 0 and element.size < 1000 then
- size = 5
- elseif element.size >= 1000 and element.size < 2000 then
- size = 8
- elseif element.size >= 2000 and element.size < 5000 then
- size = 12
- elseif element.size >= 5000 and element.size < 10000 then
- size = 15
- elseif element.size >= 10000 and element.size < 20000 then
- size = 20
- elseif element.size >= 20000 then
- size = 30
- end
- output = output .. [[]]
- if element.id == highlightID then
- output = output .. [[]]
- output = output .. [[]]
- end
- end
-
- return output
-end
-
-function GetContentClickareas(screen)
- local output = ""
- if screen ~= nil and screen.ClickAreas ~= nil and #screen.ClickAreas > 0 then
- for i,ca in ipairs(screen.ClickAreas) do
- output = output ..
- [[]]
- end
- end
- return output
-end
-
-function GetElement1(x, y, width, height)
- x = x or 0
- y = y or 0
- width = width or 600
- height = height or 600
- local output = ""
- output = output ..
- [[
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetElement2(x, y)
- x = x or 0
- y = y or 0
- local output = ""
- output = output .. [[]]
- return output
-end
-
-function GetElementLogo(x, y, primaryC, secondaryC, tertiaryC)
- x = x or 812
- y = y or 380
- primaryC = primaryC or "f"
- secondaryC = secondaryC or "f2"
- tertiaryC = tertiaryC or "f3"
- local output = ""
- output = output .. [[
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetHeader(headertext)
- headertext = headertext or "ERROR: UNDEFINED"
- local output = ""
- output = output ..
- [[
- ]]..headertext..[[]]
- return output
-end
-
-function GetContentBackground(candidate, bgcolor)
- bgColor = ColorBackgroundPattern
-
- local output = ""
-
- if candidate == "dots" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' viewBox='0 0 4 4'%3E%3Cpath fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' d='M1 3h1v1H1V3zm2-2h1v1H3V1z'%3E%3C/path%3E%3C/svg%3E");]]
- elseif candidate == "rain" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='12' height='16' viewBox='0 0 12 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 .99C4 .445 4.444 0 5 0c.552 0 1 .45 1 .99v4.02C6 5.555 5.556 6 5 6c-.552 0-1-.45-1-.99V.99zm6 8c0-.546.444-.99 1-.99.552 0 1 .45 1 .99v4.02c0 .546-.444.99-1 .99-.552 0-1-.45-1-.99V8.99z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E");]]
- elseif candidate == "plus" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "signal" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='84' height='48' viewBox='0 0 84 48' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h12v6H0V0zm28 8h12v6H28V8zm14-8h12v6H42V0zm14 0h12v6H56V0zm0 8h12v6H56V8zM42 8h12v6H42V8zm0 16h12v6H42v-6zm14-8h12v6H56v-6zm14 0h12v6H70v-6zm0-16h12v6H70V0zM28 32h12v6H28v-6zM14 16h12v6H14v-6zM0 24h12v6H0v-6zm0 8h12v6H0v-6zm14 0h12v6H14v-6zm14 8h12v6H28v-6zm-14 0h12v6H14v-6zm28 0h12v6H42v-6zm14-8h12v6H56v-6zm0-8h12v6H56v-6zm14 8h12v6H70v-6zm0 8h12v6H70v-6zM14 24h12v6H14v-6zm14-8h12v6H28v-6zM14 8h12v6H14V8zM0 8h12v6H0V8z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E");]]
- elseif candidate == "deathstar" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='105' viewBox='0 0 80 105'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M20 10a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm15 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zM20 75a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zm30-65a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm0 65a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zM35 10a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zM5 45a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zm60 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10z' /%3E%3C/g%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "diamond" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='32' viewBox='0 0 16 32'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath fill-rule='evenodd' d='M0 24h4v2H0v-2zm0 4h6v2H0v-2zm0-8h2v2H0v-2zM0 0h4v2H0V0zm0 4h2v2H0V4zm16 20h-6v2h6v-2zm0 4H8v2h8v-2zm0-8h-4v2h4v-2zm0-20h-6v2h6V0zm0 4h-4v2h4V4zm-2 12h2v2h-2v-2zm0-8h2v2h-2V8zM2 8h10v2H2V8zm0 8h10v2H2v-2zm-2-4h14v2H0v-2zm4-8h6v2H4V4zm0 16h6v2H4v-2zM6 0h2v2H6V0zm0 24h2v2H6v-2z'/%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "hexagon" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='49' viewBox='0 0 28 49'%3E%3Cg fill-rule='evenodd'%3E%3Cg id='hexagons' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='nonzero'%3E%3Cpath d='M13.99 9.25l13 7.5v15l-13 7.5L1 31.75v-15l12.99-7.5zM3 17.9v12.7l10.99 6.34 11-6.35V17.9l-11-6.34L3 17.9zM0 15l12.98-7.5V0h-2v6.35L0 12.69v2.3zm0 18.5L12.98 41v8h-2v-6.85L0 35.81v-2.3zM15 0v7.5L27.99 15H28v-2.31h-.01L17 6.35V0h-2zm0 49v-8l12.99-7.5H28v2.31h-.01L17 42.15V49h-2z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "capsule" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='32' height='26' viewBox='0 0 32 26' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M14 0v3.994C14 7.864 10.858 11 7 11c-3.866 0-7-3.138-7-7.006V0h2v4.005C2 6.765 4.24 9 7 9c2.756 0 5-2.236 5-4.995V0h2zm0 26v-5.994C14 16.138 10.866 13 7 13c-3.858 0-7 3.137-7 7.006V26h2v-6.005C2 17.235 4.244 15 7 15c2.76 0 5 2.236 5 4.995V26h2zm2-18.994C16 3.136 19.142 0 23 0c3.866 0 7 3.138 7 7.006v9.988C30 20.864 26.858 24 23 24c-3.866 0-7-3.138-7-7.006V7.006zm2-.01C18 4.235 20.244 2 23 2c2.76 0 5 2.236 5 4.995v10.01C28 19.765 25.756 22 23 22c-2.76 0-5-2.236-5-4.995V6.995z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E");]]
- elseif candidate == "diagonal" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='6' height='6' viewBox='0 0 6 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'%3E%3Cpath d='M5 0h1L0 6V5zM6 5v1H5z'/%3E%3C/g%3E%3C/svg%3E");]]
- end
- return output;
-end
-
-function GetContentDamageHUDOutput()
- local hudWidth = 300
- local hudHeight = 165
- if #damagedElements > 0 or #brokenElements > 0 then hudHeight = 510 end
- local output = ""
-
- output = output .. [[
-
- ]]
- output = output .. [[]] ..
- [[]] ..
- [[]] ..
- [[]]..(YourShipsName=="Enter here" and ("Ship ID "..ShipID) or YourShipsName) .. [[]] ..
- [[]]
- if #brokenElements > 0 then
- output = output .. [[]]
- elseif #damagedElements > 0 then
- output = output .. [[]]
- else
- output = output .. [[]]
- end
-
- if #damagedElements > 0 or #brokenElements > 0 then
-
- output = output .. [[Total Damage]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", totalShipMaxHP - totalShipHP))..[[]]
- output = output .. [[T]]..ScrapTier..[[ Scrap Needed]] ..
- [[]]..getScraps(totalShipMaxHP - totalShipHP, true)..[[]]
- output = output .. [[Repair Time]] ..
- [[]]..getRepairTime(totalShipMaxHP - totalShipHP, true)..[[]]
-
- output = output .. [[]] ..
- [[]] ..
- [[]]..#healthyElements..[[]] ..
- [[]] ..
- [[]]..#damagedElements..[[]] ..
- [[]] ..
- [[]]..#brokenElements..[[]]
- local j=0
-
- for currentIndex=hudStartIndex,hudStartIndex+9,1 do
- if rE[currentIndex] ~= nil then
- v = rE[currentIndex]
- if v.hp > 0 then
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- if v.id == highlightID then
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- end
- else
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- if v.id == highlightID then
- highlightX = elementPosition.x - coreWorldOffset
- highlightY = elementPosition.y - coreWorldOffset
- highlightZ = elementPosition.z - coreWorldOffset
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- end
- end
- j=j+1
- end
- end
- output = output ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Up/down arrows to highlight]] ..
- [[CTRL + arrows to move HUD]] ..
- [[Left arrow to toggle HUD Mode]] ..
- [[ALT+1-4 to set Scrap Tier]] ..
- [[ALT+8 to reset HUD position]] ..
- [[ALT+9 to shut script off]] ..
- [[]] ..
- [[]]
- else
- output = output ..
- [[]] .. OkayCenterMessage .. [[]] ..
- [[]]..#healthyElements..[[ elements / ]] .. GenerateCommaValue(string.format("%.0f", totalShipMaxHP)) .. [[ HP.]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Left arrow to toggle HUD Mode]] ..
- [[CTRL + arrows to move HUD]] ..
- [[ALT+8 to reset HUD position]] ..
- [[ALT+9 to shut script off]] ..
- [[]] ..
- [[]]
- end
- output = output .. [[]]
- return output
-end
-
-function GetContentDamageScreen()
-
- local screenOutput = ""
-
- -- Draw damage elements
- if #damagedElements > 0 then
- local damagedElementsToDraw = #damagedElements
- if damagedElementsToDraw > DamagePageSize then
- damagedElementsToDraw = DamagePageSize
- end
- if CurrentDamagedPage == math.ceil(#damagedElements / DamagePageSize) then
- damagedElementsToDraw = #damagedElements % DamagePageSize + 12
- if damagedElementsToDraw > 12 then damagedElementsToDraw = damagedElementsToDraw - 12 end
- end
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
-
- if UseMyElementNames == true then screenOutput = screenOutput .. [[Damaged Name]]
- else screenOutput = screenOutput .. [[Damaged Type]]
- end
-
- screenOutput = screenOutput .. [[HLTHDMG]]
- screenOutput = screenOutput .. [[T]]..ScrapTier..[[ SCRREPTIME]]
-
- AddClickArea("damage", {
- id = "SwitchScrapTier",
- mode ="damage",
- x1 = 650,
- x2 = 775,
- y1 = 315,
- y2 = 360
- })
-
- local i = 0
- for j = 1 + (CurrentDamagedPage - 1) * DamagePageSize, damagedElementsToDraw + (CurrentDamagedPage - 1) * DamagePageSize, 1 do
- i = i + 1
- local DP = damagedElements[j]
- if UseMyElementNames == true then screenOutput = screenOutput .. [[]] .. string.format("%.23s", DP.name) .. [[]]
- else screenOutput = screenOutput .. [[]] .. string.format("%.23s", DP.type) .. [[]]
- end
- screenOutput = screenOutput .. [[]] .. DP.percent .. [[%]] ..
- [[]] .. GenerateCommaValue(string.format("%.0f", DP.missinghp), true) .. [[]] ..
- [[]] .. getScraps(DP.missinghp, true) .. [[]] ..
- [[]] .. getRepairTime(DP.missinghp, true) .. [[]] ..
- [[]]
- end
-
- if #damagedElements > DamagePageSize then
- screenOutput = screenOutput ..
- [[Page ]] .. CurrentDamagedPage .. " of " .. math.ceil(#damagedElements / DamagePageSize) ..[[]]
-
- if CurrentDamagedPage < math.ceil(#damagedElements / DamagePageSize) then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "DamagedPageDown",
- mode ="damage",
- x1 = 65,
- x2 = 260,
- y1 = 290 + (damagedElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (damagedElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("DamagedPageDown","damage")
- end
-
- if CurrentDamagedPage > 1 then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "DamagedPageUp",
- mode ="damage",
- x1 = 750,
- x2 = 950,
- y1 = 290 + (damagedElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (damagedElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("DamagedPageUp","damage")
- end
- end
- end
-
- -- Draw broken elements
- if #brokenElements > 0 then
- local brokenElementsToDraw = #brokenElements
- if brokenElementsToDraw > DamagePageSize then
- brokenElementsToDraw = DamagePageSize
- end
- if CurrentBrokenPage == math.ceil(#brokenElements / DamagePageSize) then
- brokenElementsToDraw = #brokenElements % DamagePageSize + 12
- if brokenElementsToDraw > 12 then brokenElementsToDraw = brokenElementsToDraw - 12 end
- end
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
-
- if UseMyElementNames == true then screenOutput = screenOutput .. [[Broken Name]]
- else screenOutput = screenOutput .. [[Broken Type]]
- end
-
- screenOutput = screenOutput .. [[DMG]]
- screenOutput = screenOutput .. [[T]]..ScrapTier..[[ SCRREPTIME]]
-
- AddClickArea("damage", {
- id = "SwitchScrapTier2",
- mode ="damage",
- x1 = 1570,
- x2 = 1690,
- y1 = 315,
- y2 = 360
- })
-
- local i = 0
- for j = 1 + (CurrentBrokenPage - 1) * DamagePageSize, brokenElementsToDraw + (CurrentBrokenPage - 1) * DamagePageSize, 1 do
- i = i + 1
- local DP = brokenElements[j]
- if UseMyElementNames == true then screenOutput = screenOutput .. [[]] .. string.format("%.30s", DP.name) .. [[]]
- else screenOutput = screenOutput .. [[]] .. string.format("%.30s", DP.type) .. [[]]
- end
- screenOutput = screenOutput .. [[]] .. GenerateCommaValue(string.format("%.0f", DP.missinghp), true) .. [[]] ..
- [[]] .. getScraps(DP.missinghp, true) .. [[]] ..
- [[]] .. getRepairTime(DP.missinghp, true) .. [[]] ..
- [[]]
- end
-
-
-
- if #brokenElements > DamagePageSize then
- screenOutput = screenOutput ..
- [[Page ]] .. CurrentBrokenPage .. " of " .. math.ceil(#brokenElements / DamagePageSize) .. [[]]
-
- if CurrentBrokenPage > 1 then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "BrokenPageUp",
- mode ="damage",
- x1 = 1665,
- x2 = 1865,
- y1 = 290 + (brokenElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (brokenElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("BrokenPageUp", "damage")
- end
-
- if CurrentBrokenPage < math.ceil(#brokenElements / DamagePageSize) then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "BrokenPageDown",
- mode ="damage",
- x1 = 980,
- x2 = 1180,
- y1 = 290 + (brokenElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (brokenElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("BrokenPageDown", "damage")
- end
- end
-
- end
-
- -- Draw summary
- if #damagedElements > 0 or #brokenElements > 0 then
- local dWidth = math.floor(1878/#elementsIdList*#damagedElements)
- local bWidth = math.floor(1878/#elementsIdList*#brokenElements)
- local hWidth = 1878-dWidth-bWidth+1
-
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
-
- if #damagedElements > 0 then
- screenOutput = screenOutput .. [[]]..#damagedElements..[[]]
- end
- if #healthyElements > 0 then
- screenOutput = screenOutput .. [[]]..#healthyElements..[[]]
- end
- if #brokenElements > 0 then
- screenOutput = screenOutput .. [[]]..#brokenElements..[[]]
- end
-
- screenOutput = screenOutput .. [[]]
-
- screenOutput = screenOutput .. [[]] ..
- GenerateCommaValue(string.format("%.0f", totalShipMaxHP - totalShipHP)) .. [[ HP damage in total ]] ..
- getScraps(totalShipMaxHP - totalShipHP, true) .. [[ T]]..ScrapTier..[[ scraps needed. ]] ..
- getRepairTime(totalShipMaxHP - totalShipHP, true) .. [[ projected repair time.]]
- else
- screenOutput = screenOutput .. GetElementLogo(812, 380, "ch", "ch", "ch") ..
- [[]] .. OkayCenterMessage .. [[]] ..
- [[]]..#healthyElements..[[ elements stand ]] .. GenerateCommaValue(string.format("%.0f", totalShipMaxHP)) .. [[ HP strong.]]
- end
-
- forceDamageRedraw = false
-
- return screenOutput
-end
-
-function ActionStopengines()
- ToggleHUD()
-end
-
-function ActionStrafeRight()
- if KeyCTRLPressed == true then
- if HUDShiftU < 4000 then
- HUDShiftU = HUDShiftU + 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- HudDeselectElement()
- end
-end
-
-function ActionStrafeLeft()
- if KeyCTRLPressed == true then
- if HUDShiftU >= 50 then
- HUDShiftU = HUDShiftU - 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- ToggleHUD()
- end
-end
-
-function ActionDown()
- if KeyCTRLPressed == true then
- if HUDShiftV < 4000 then
- HUDShiftV = HUDShiftV + 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- ChangeHudSelectedElement(1)
- end
-end
-
-function ActionUp()
- if KeyCTRLPressed == true then
- if HUDShiftV >= 50 then
- HUDShiftV = HUDShiftV - 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- ChangeHudSelectedElement(-1)
- end
-end
-
-function ActionOption1()
- ScrapTier = 1
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption2()
- ScrapTier = 2
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption3()
- ScrapTier = 3
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption4()
- ScrapTier = 4
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption8()
- HUDShiftU=0
- HUDShiftV=0
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption9()
- SaveToDatabank()
- SwitchScreens("off")
- unit.exit()
-end
diff --git a/src/DamageReport_3_00_UnitStart_2.lua b/src/DamageReport_3_00_UnitStart_2.lua
deleted file mode 100644
index f1ee927..0000000
--- a/src/DamageReport_3_00_UnitStart_2.lua
+++ /dev/null
@@ -1,2137 +0,0 @@
---[[
- Damage Report 3.0
- A LUA script for Dual Universe
-
- Created By Dorian GrayY.percent
- Ingame: DorianGray
- Discord: Dorian Gray#2623
-
- You can find/update this script on GitHub. Explanations, installation and usage information as well as screenshots can be found there too.
- GitHub: https://github.com/DorianTheGrey/DU-DamageReport
-
- GNU Public License 3.0. Use whatever you want, be so kind to leave credit.
-
- Credits & thanks:
- Thanks to NovaQuark for creating the MMO of the century.
- Thanks to Jericho, Dmentia and Archaegeo for learning a lot from their fine scripts.
- Thanks to TheBlacklist for testing and wonderful suggestions.
- SVG patterns by Hero Patterns.
- DU atlas data from Jayle Break.
-
-]]
-
---[[ 1. USER DEFINED VARIABLES ]]
-
-YourShipsName = "Enter here" --export Enter your ship name here if you want it displayed instead of the ship's ID. YOU NEED TO LEAVE THE QUOTATION MARKS.
-ShowWelcomeMessage = true --export Do you want the welcome message on the start screen with your name?
-AddSummertimeHour = false --export: Is summertime currently enabled in your location? (Adds one hour.)
-
---[[ 2. GLOBAL VARIABLES ]]
-
-UpdateDataInterval = 1.0 -- How often shall the data be updated? (Increase if running into CPU issues.)
-HighlightBlinkingInterval = 0.5 -- How fast shall highlight arrows of marked elements blink?
-
-ColorPrimary = "FF6700" -- Enter the hexcode of the main color to be used by all views.
-ColorSecondary = "FFFFFF" -- Enter the hexcode of the secondary color to be used by all views.
-ColorTertiary = "000000" -- Enter the hexcode of the tertiary color to be used by all views.
-ColorHealthy = "00FF00" -- Enter the hexcode of the 'healthy' color to be used by all views.
-ColorWarning = "FFFF00" -- Enter the hexcode of the 'warning' color to be used by all views.
-ColorCritical = "FF0000" -- Enter the hexcode of the 'critical' color to be used by all views.
-ColorBackground = "000000" -- Enter the hexcode of the background color to be used by all views.
-ColorBackgroundPattern = "4F4F4F" -- Enter the hexcode of the background color to be used by all views.
-ColorFuelAtmospheric = "004444" -- Enter the hexcode of the atmospheric fuel color.
-ColorFuelSpace = "444400" -- Enter the hexcode of the space fuel color.
-ColorFuelRocket = "440044" -- Enter the hexcode of the rocket fuel color.
-
-VERSION = 3.0
-DebugMode = false
-DebugRenderClickareas = true
-
-DBData = {}
-
-core = nil
-db = nil
-screens = {}
-dscreens = {}
-
-screenModes = {
- ["flight"] = { id="flight" },
- ["damage"] = { id="damage" },
- ["damageoutline"] = { id="damageoutline" },
- ["fuel"] = { id="fuel" },
- ["cargo"] = { id="cargo" },
- ["agg"] = { id="agg" },
- ["map"] = { id="map" },
- ["time"] = { id="time", activetoggle="true" },
- ["settings1"] = { id="settings1" },
- ["startup"] = { id="startup" }
-}
-
-backgroundModes = { "deathstar", "capsule", "rain", "signal", "hexagon", "diagonal", "diamond", "plus", "dots" }
-BackgroundMode ="deathstar"
-BackgroundSelected = 1
-BackgroundModeOpacity = 0.25
-
-SaveVars = { "dscreens", "YourShipsName", "AddSummertimeHour",
- "ColorPrimary", "ColorSecondary", "ColorTertiary",
- "ColorHealthy", "ColorWarning", "ColorCritical",
- "ColorBackground", "ColorBackgroundPattern",
- "UpdateDataInterval", "HighlightBlinkingInterval",
- "ScrapTier", "HUDMode", "SimulationMode", "DMGOStretch",
- "HUDShiftU", "HUDShiftV", "colorIDIndex", "colorIDTable",
- "SkillRepairToolEfficiency", "SkillRepairToolOptimization",
- "SkillAtmosphericFuelEfficiency", "SkillSpaceFuelEfficiency", "SkillRocketFuelEfficiency",
- "StatAtmosphericFuelTankHandling", "StatSpaceFuelTankHandling", "StatRocketFuelTankHandling",
- "BackgroundMode", "BackgroundSelected", "BackgroundModeOpacity" }
-
-HUDMode = false
-HUDShiftU = 0
-HUDShiftV = 0
-hudSelectedIndex = 0
-hudStartIndex = 1
-hudArrowSticker = {}
-highlightOn = false
-highlightID = 0
-highlightX = 0
-highlightY = 0
-highlightZ = 0
-
-SimulationMode = false
-OkayCenterMessage = "All systems nominal."
-CurrentDamagedPage = 1
-CurrentBrokenPage = 1
-DamagePageSize = 12
-ScrapTier = 1
-totalScraps = 0
-ScrapTierRepairTimes = { 10, 50, 250, 1250 }
-
-coreWorldOffset = 0
-totalShipHP = 0
-formerTotalShipHP = -1
-totalShipMaxHP = 0
-totalShipIntegrity = 100
-elementsId = {}
-elementsIdList = {}
-damagedElements = {}
-brokenElements = {}
-rE = {}
-healthyElements = {}
-typeElements = {}
-ElementCounter = 0
-UseMyElementNames = true
-dmgoElements = {}
-DMGOMaxElements = 250
-DMGOStretch = false
-ShipXmin = 99999999
-ShipXmax = -99999999
-ShipYmin = 99999999
-ShipYmax = -99999999
-ShipZmin = 99999999
-ShipZmax = -99999999
-
-totalShipMass = 0
-formerTotalShipMass = -1
-
-formerTime = -1
-
-FuelAtmosphericTanks = {}
-FuelSpaceTanks = {}
-FuelRocketTanks = {}
-FuelAtmosphericTotal = 0
-FuelSpaceTotal = 0
-FuelRocketTotal = 0
-FuelAtmosphericCurrent = 0
-FuelSpaceTotalCurrent = 0
-FuelRocketTotalCurrent = 0
-formerFuelAtmosphericTotal = -1
-formerFuelSpaceTotal = -1
-formerFuelRocketTotal = -1
-
-SkillRepairToolEfficiency = 0
-SkillRepairToolOptimization = 0
-
-SkillAtmosphericFuelEfficiency = 0
-SkillSpaceFuelEfficiency = 0
-SkillRocketFuelEfficiency = 0
-
-StatAtmosphericFuelTankHandling = 0
-StatSpaceFuelTankHandling = 0
-StatRocketFuelTankHandling = 0
-
-
-hexTable = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"}
-colorIDIndex = 1
-colorIDTable = {
- [1] = {
- id="ColorPrimary",
- desc="Main HUD Color",
- basec = "FF6700",
- newc = "FF6700"
- },
- [2] = {
- id="ColorSecondary",
- desc="Secondary HUD Color",
- basec = "FFFFFF",
- newc = "FFFFFF"
- },
- [3] = {
- id="ColorTertiary",
- desc="Tertiary HUD Color",
- basec = "000000",
- newc = "000000"
- },
- [4] = {
- id="ColorHealthy",
- desc="Color code for Healthy/Okay",
- basec = "00FF00",
- newc = "00FF00"
- },
- [5] = {
- id="ColorWarning",
- desc="Color code for Damaged/Warning",
- basec = "FFFF00",
- newc = "FFFF00"
- },
- [6] = {
- id="ColorCritical",
- desc="Color code for Broken/Critical",
- basec = "FF0000",
- newc = "FF0000"
- },
- [7] = {
- id="ColorBackground",
- desc="Background Color",
- basec = "000000",
- newc = "000000"
- },
- [8] = {
- id="ColorBackgroundPattern",
- desc="Background Pattern Color",
- basec = "4F4F4F",
- newc = "4F4F4F"
- },
- [9] = {
- id="ColorFuelAtmospheric",
- desc="Color for Atmo Fuel/Elements",
- basec = "004444",
- newc = "004444"
- },
- [10] = {
- id="ColorFuelSpace",
- desc="Color for Space Fuel/Elements",
- basec = "444400",
- newc = "444400"
- },
- [11] = {
- id="ColorFuelRocket",
- desc="Color for Rocket Fuel/Elements",
- basec = "440044",
- newc = "440044"
- }
-}
-
-
---[[ 3. PROCESSING FUNCTIONS ]]
-
-function InitiateSlots()
- for slot_name, slot in pairs(unit) do
- if type(slot) == "table" and type(slot.export) == "table" and
- slot.getElementClass then
- local elementClass = slot.getElementClass():lower()
- if elementClass:find("coreunit") then
- core = slot
- local coreHP = core.getMaxHitPoints()
- if coreHP > 10000 then
- coreWorldOffset = 128
- elseif coreHP > 1000 then
- coreWorldOffset = 64
- elseif coreHP > 150 then
- coreWorldOffset = 32
- else
- coreWorldOffset = 16
- end
- elseif elementClass == 'databankunit' then
- db = slot
- elseif elementClass == "screenunit" then
- local iScreenMode = "startup"
- screens[#screens + 1] = {
- element = slot,
- id = slot.getId(),
- mode = iScreenMode,
- submode = "",
- ClickAreas = {},
- refresh = true,
- active = false,
- fuelA = true,
- fuelS = true,
- fuelR = true,
- fuelIndex = 1
- }
- end
- end
- end
-end
-
-function LoadFromDatabank()
- if db == nil then
- return
- else
- for _, data in pairs(SaveVars) do
- if db.hasKey(data) then
- local jData = json.decode( db.getStringValue(data) )
- if jData ~= nil then
- if data == "YourShipsName" or data == "AddSummertimeHour" or data == "UpdateDataInterval" or data == "HighlightBlinkingInterval" then
- else
- _G[data] = jData
- end
- end
- end
- end
-
- for i,v in ipairs(screens) do
- for j,dv in ipairs(dscreens) do
- if screens[i].id == dscreens[j].id then
- screens[i].mode = dscreens[j].mode
- screens[i].submode = dscreens[j].submode
- screens[i].active = dscreens[j].active
- screens[i].refresh = true
- screens[i].fuelA = dscreens[j].fuelA
- screens[i].fuelS = dscreens[j].fuelS
- screens[i].fuelR = dscreens[j].fuelR
- screens[i].fuelIndex = dscreens[j].fuelIndex
- end
- end
- end
- end
-end
-
-function SaveToDatabank()
- if db == nil then
- return
- else
- dscreens = {}
- for i,screen in ipairs(screens) do
- dscreens[i] = {}
- dscreens[i].id = screen.id
- dscreens[i].mode = screen.mode
- dscreens[i].submode = screen.submode
- dscreens[i].active = screen.active
- dscreens[i].fuelA = screen.fuelA
- dscreens[i].fuelS = screen.fuelS
- dscreens[i].fuelR = screen.fuelR
- dscreens[i].fuelIndex = screen.fuelIndex
- end
-
- db.clear()
-
- for _, data in pairs(SaveVars) do
- if data == "YourShipsName" or data == "AddSummertimeHour" or data == "UpdateDataInterval" or data == "HighlightBlinkingInterval" then
- else
- db.setStringValue(data, json.encode(_G[data]))
- end
- end
-
- end
-end
-
-function InitiateScreens()
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- screens[i] = CreateClickAreasForScreen(screens[i])
- end
- end
-end
-
-function UpdateTypeData()
- FuelAtmosphericTanks = {}
- FuelSpaceTanks = {}
- FuelRocketTanks = {}
-
- FuelAtmosphericTotal = 0
- FuelAtmosphericCurrent = 0
- FuelSpaceTotal = 0
- FuelSpaceCurrent = 0
- FuelRocketCurrent = 0
- FuelRocketTotal = 0
-
- local weightAtmosphericFuel = 4
- local weightSpaceFuel = 6
- local weightRocketFuel = 0.8
-
- for i, id in ipairs(typeElements) do
- local idName = core.getElementNameById(id) or ""
- local idType = core.getElementTypeById(id) or ""
- -- local idTypeClean = idType:gsub("[%s%-]+", ""):lower()
- local idPos = core.getElementPositionById(id) or 0
- local idHP = core.getElementHitPointsById(id) or 0
- local idMaxHP = core.getElementMaxHitPointsById(id) or 0
- local idMass = core.getElementMassById(id) or 0
-
- local baseSize = ""
- local baseVol = 0
- local baseMass = 0
- local cMass = 0
- local cVol = 0
-
- if idType == "atmospheric fuel-tank" then
- if idMaxHP == 50 then
- baseSize = "XS"
- baseMass = 35.03
- baseVol = 100
- elseif idMaxHP == 163 then
- baseSize = "S"
- baseMass = 182.67
- baseVol = 400
- elseif idMaxHP == 1315 then
- baseSize = "M"
- baseMass = 988.67
- baseVol = 1600
- elseif idMaxHP == 10461 then
- baseSize = "L"
- baseMass = 5480
- baseVol = 12800
- end
- if StatAtmosphericFuelTankHandling > 0 then
- baseVol = 0.2 * StatAtmosphericFuelTankHandling * baseVol + baseVol
- end
- cMass = idMass - baseMass
- if cMass <=10 then cMass = 0 end
- cVol = string.format("%.0f", cMass / weightAtmosphericFuel)
- cPercent = string.format("%.1f", math.floor(100/baseVol * tonumber(cVol)))
- table.insert(FuelAtmosphericTanks, {
- type = 1,
- id = id,
- name = idName,
- maxhp = idMaxHP,
- hp = GetHPforElement(id),
- pos = idPos,
- size = baseSize,
- mass = baseMass,
- vol = baseVol,
- cvol = cVol,
- percent = cPercent
- })
- if idHP > 0 then
- FuelAtmosphericCurrent = FuelAtmosphericCurrent + cVol
- end
- FuelAtmosphericTotal = FuelAtmosphericTotal + baseVol
- elseif idType == "space fuel-tank" then
- if idMaxHP == 187 then
- baseSize = "S"
- baseMass = 182.67
- baseVol = 400
- elseif idMaxHP == 1496 then
- baseSize = "M"
- baseMass = 988.67
- baseVol = 1600
- elseif idMaxHP == 15933 then
- baseSize = "L"
- baseMass = 5480
- baseVol = 12800
- end
- if StatSpaceFuelTankHandling > 0 then
- baseVol = 0.2 * StatSpaceFuelTankHandling * baseVol + baseVol
- end
- cMass = idMass - baseMass
- if cMass <=10 then cMass = 0 end
- cVol = string.format("%.0f", cMass / weightSpaceFuel)
- cPercent = string.format("%.1f", (100/baseVol * tonumber(cVol)))
- table.insert(FuelSpaceTanks, {
- type = 2,
- id = id,
- name = idName,
- maxhp = idMaxHP,
- hp = GetHPforElement(id),
- pos = idPos,
- size = baseSize,
- mass = baseMass,
- vol = baseVol,
- cvol = cVol,
- percent = cPercent
- })
- if idHP > 0 then
- FuelSpaceCurrent = FuelSpaceCurrent + cVol
- end
- FuelSpaceTotal = FuelSpaceTotal + baseVol
- elseif idType == "rocket fuel-tank" then
- if idMaxHP == 366 then
- baseSize = "XS"
- baseMass = 173.42
- baseVol = 400
- elseif idMaxHP == 163 then
- baseSize = "S"
- baseMass = 886.72
- baseVol = 800
- elseif idMaxHP == 6231 then
- baseSize = "M"
- baseMass = 4720
- baseVol = 6400
- elseif idMaxHP == 10461 then
- baseSize = "L"
- baseMass = 25740
- baseVol = 50000
- end
- if StatRocketFuelTankHandling > 0 then
- baseVol = 0.2 * StatRocketFuelTankHandling * baseVol + baseVol
- end
- cMass = idMass - baseMass
- if cMass <=10 then cMass = 0 end
- cVol = string.format("%.0f", cMass / weightRocketFuel)
- cPercent = string.format("%.1f", (100/baseVol * tonumber(cVol)))
- table.insert(FuelRocketTanks, {
- type = 3,
- id = id,
- name = idName,
- maxhp = idMaxHP,
- hp = GetHPforElement(id),
- pos = idPos,
- size = baseSize,
- mass = baseMass,
- vol = baseVol,
- cvol = cVol,
- percent = cPercent
- })
- if idHP > 0 then
- FuelRocketCurrent = FuelRocketCurrent + cVol
- end
- FuelRocketTotal = FuelRocketTotal + baseVol
- end
-
- end
-
- if FuelAtmosphericCurrent ~= formerFuelAtmosphericCurrent then
- SetRefresh("fuel")
- formerFuelAtmosphericCurrent = FuelAtmosphericCurrent
- end
- if FuelSpaceCurrent ~= formerFuelSpaceCurrent then
- SetRefresh("fuel")
- formerFuelSpaceCurrent = FuelSpaceCurrent
- end
- if FuelRocketCurrent ~= formerFuelRocketCurrent then
- SetRefresh("fuel")
- formerFuelRocketCurrent = FuelRocketCurrent
- end
-
-end
-
-function UpdateDamageData(initial)
-
- initial = initial or false
-
- if SimulationActive == true then return end
-
- local formerTotalShipHP = totalShipHP
- totalShipHP = 0
- totalShipMaxHP = 0
- totalShipIntegrity = 100
- damagedElements = {}
- brokenElements = {}
- healthyElements = {}
- ElementCounter = 0
-
- elementsIdList = core.getElementIdList()
-
- for i, id in pairs(elementsIdList) do
-
- ElementCounter = ElementCounter + 1
-
- local idName = core.getElementNameById(id)
-
- local idType = core.getElementTypeById(id)
- -- local idTypeClean = idType:gsub("[%s%-]+", ""):lower()
- local idPos = core.getElementPositionById(id)
- local idHP = core.getElementHitPointsById(id)
- local idMaxHP = core.getElementMaxHitPointsById(id)
- -- local idMass = core.getElementMassById(id)
-
- if SimulationMode == true then
- SimulationActive = true
- local dice = math.random(0, 10)
- if dice < 2 and #brokenElements < 30 then
- idHP = 0
- elseif dice >= 2 and dice < 4 and #damagedElements < 30 then
- idHP = math.random(1, math.ceil(idMaxHP))
- else
- idHP = idMaxHP
- end
- end
-
- totalShipHP = totalShipHP + idHP
- totalShipMaxHP = totalShipMaxHP + idMaxHP
-
- if idMaxHP - idHP > constants.epsilon then
-
- if idHP > 0 then
- table.insert(damagedElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP - idHP,
- percent = math.ceil(100 / idMaxHP * idHP),
- pos = idPos
- })
- else
- table.insert(brokenElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP - idHP,
- percent = 0,
- pos = idPos
- })
- end
- else
- table.insert(healthyElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- pos = idPos
- })
- if id == highlightID then
- highlightID = 0
- highlightOn = false
- HideHighlight()
- hudSelectedIndex = 0
- end
- end
-
- if initial == true then
- if
- idType == "atmospheric fuel-tank" or
- idType == "space fuel-tank" or
- idType == "rocket fuel-tank"
- then
- table.insert(typeElements, id)
- end
- end
- end
-
- SortDamageTables()
-
- rE = {}
- if #brokenElements > 0 then
- for _,v in ipairs(brokenElements) do
- table.insert(rE, {id=v.id, missinghp=v.missinghp, hp=v.hp, name=v.name, type=v.type, pos=v.pos})
- end
- end
- if #damagedElements > 0 then
- for _,v in ipairs(damagedElements) do
- table.insert(rE, {id=v.id, missinghp=v.missinghp, hp=v.hp, name=v.name, type=v.type, pos=v.pos})
- end
- end
- if #rE > 0 then
- table.sort(rE, function(a,b) return a.missinghp>b.missinghp end)
- end
-
- totalShipIntegrity = string.format("%2.0f", 100 / totalShipMaxHP * totalShipHP)
-
- if formerTotalShipHP ~= totalShipHP then
- forceDamageRedraw = true
- formerTotalShipHP = totalShipHP
- else
- forceDamageRedraw = false
- end
-end
-
-function GetHPforElement(id)
- for i,v in ipairs(brokenElements) do
- if v.id == id then
- return 0
- end
- end
- for i,v in ipairs(damagedElements) do
- if v.id == id then
- return v.hp
- end
- end
- for i,v in ipairs(healthyElements) do
- if v.id == id then
- return v.maxhp
- end
- end
-end
-
-function UpdateClickArea(candidate, newEntry, mode)
- for i, screen in ipairs(screens) do
- for k, v in pairs(screens[i].ClickAreas) do
- if v.id == candidate and v.mode == mode then
- screens[i].ClickAreas[k] = newEntry
- end
- end
- end
-end
-
-function AddClickArea(mode, newEntry)
- for i, screen in ipairs(screens) do
- if screens[i].mode == mode then
- table.insert(screens[i].ClickAreas, newEntry)
- end
- end
-end
-
-function AddClickAreaForScreenID(screenid, newEntry)
- for i, screen in ipairs(screens) do
- if screens[i].id == screenid then
- table.insert(screens[i].ClickAreas, newEntry)
- end
- end
-end
-
-function DisableClickArea(candidate, mode)
- UpdateClickArea(candidate, {
- id = candidate,
- mode = mode,
- x1 = -1,
- x2 = -1,
- y1 = -1,
- y2 = -1
- })
-end
-
-function SetRefresh(mode, submode)
- mode = mode or "all"
- submode = submode or "all"
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- if screens[i].mode == mode or mode == "all" then
- if screens[i].submode == submode or submode =="all" then
- screens[i].refresh = true
- end
- end
- end
- end
-end
-
-function WipeClickAreasForScreen(screen)
- screen.ClickAreas = {}
- return screen
-end
-
-function CreateBaseClickAreas(screen)
- table.insert(screen.ClickAreas, {mode = "all", id = "ToggleHudMode", x1 = 1537, x2 = 1728, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "damage", x1 = 193, x2 = 384, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "damageoutline", x1 = 385, x2 = 576, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "fuel", x1 = 577, x2 = 768, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "flight", x1 = 769, x2 = 960, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "cargo", x1 = 961, x2 = 1152, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "agg", x1 = 1153, x2 = 1344, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "map", x1 = 1345, x2 = 1536, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "time", x1 = 0, x2 = 192, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "settings1", x1 = 1729, x2 = 1920, y1 = 1015, y2 = 1075} )
- return screen
-end
-
-function CreateClickAreasForScreen(screen)
-
- if screen == nil then return {} end
-
- if screen.mode == "flight" then
- elseif screen.mode == "damage" then
- table.insert( screen.ClickAreas, {mode = "damage", id = "ToggleElementLabel", x1 = 70, x2 = 425, y1 = 325, y2 = 355} )
- table.insert( screen.ClickAreas, {mode = "damage", id = "ToggleElementLabel2", x1 = 980, x2 = 1400, y1 = 325, y2 = 355} )
- elseif screen.mode == "damageoutline" then
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeView", param = "top", x1 = 60, x2 = 439, y1 = 150, y2 = 200} )
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeView", param = "side", x1 = 440, x2 = 824, y1 = 150, y2 = 200} )
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeView", param = "front", x1 = 825, x2 = 1215, y1 = 150, y2 = 200} )
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeStretch", x1 = 1530, x2 = 1580, y1 = 150, y2 = 200} )
- elseif screen.mode == "fuel" then
- elseif screen.mode == "cargo" then
- elseif screen.mode == "agg" then
- elseif screen.mode == "map" then
- elseif screen.mode == "time" then
- elseif screen.mode == "settings1" then
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ToggleBackground", x1 = 75, x2 = 860, y1 = 170, y2 = 215} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "PreviousBackground", x1 = 75, x2 = 460, y1 = 235, y2 = 285} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "NextBackground", x1 = 480, x2 = 860, y1 = 235, y2 = 285} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "DecreaseOpacity", x1 = 75, x2 = 460, y1 = 300, y2 = 350} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "IncreaseOpacity", x1 = 480, x2 = 860, y1 = 300, y2 = 350} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ResetColors", x1 = 75, x2 = 860, y1 = 370, y2 = 415} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "PreviousColorID", x1 = 90, x2 = 140, y1 = 500, y2 = 550} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "NextColorID", x1 = 795, x2 = 845, y1 = 500, y2 = 550} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="1", x1 = 210, x2 = 290, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="2", x1 = 300, x2 = 380, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="3", x1 = 385, x2 = 465, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="4", x1 = 470, x2 = 550, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="5", x1 = 560, x2 = 640, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="6", x1 = 645, x2 = 725, y1 = 655, y2 = 700} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="1", x1 = 210, x2 = 290, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="2", x1 = 300, x2 = 380, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="3", x1 = 385, x2 = 465, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="4", x1 = 470, x2 = 550, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="5", x1 = 560, x2 = 640, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="6", x1 = 645, x2 = 725, y1 = 740, y2 = 780} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ResetPosColor", x1 = 160, x2 = 340, y1 = 885, y2 = 935} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ApplyPosColor", x1 = 355, x2 = 780, y1 = 885, y2 = 935} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillRepairToolEfficiency", 0}, x1 = 1060, x2 = 1115, y1 = 260, y2 = 280} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillRepairToolEfficiency", 1}, x1 = 1215, x2 = 1295, y1 = 260, y2 = 280} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillRepairToolEfficiency", 2}, x1 = 1305, x2 = 1385, y1 = 260, y2 = 280} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillRepairToolEfficiency", 3}, x1 = 1390, x2 = 1470, y1 = 260, y2 = 280} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillRepairToolEfficiency", 4}, x1 = 1475, x2 = 1555, y1 = 260, y2 = 280} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillRepairToolEfficiency", 5}, x1 = 1565, x2 = 1645, y1 = 260, y2 = 280} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillRepairToolOptimization", 0}, x1 = 1060, x2 = 1115, y1 = 325, y2 = 345} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillRepairToolOptimization", 1}, x1 = 1215, x2 = 1295, y1 = 325, y2 = 345} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillRepairToolOptimization", 2}, x1 = 1305, x2 = 1385, y1 = 325, y2 = 345} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillRepairToolOptimization", 3}, x1 = 1390, x2 = 1470, y1 = 325, y2 = 345} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillRepairToolOptimization", 4}, x1 = 1475, x2 = 1555, y1 = 325, y2 = 345} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillRepairToolOptimization", 5}, x1 = 1565, x2 = 1645, y1 = 325, y2 = 345} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillAtmosphericFuelEfficiency", 0}, x1 = 1060, x2 = 1115, y1 = 390, y2 = 410} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillAtmosphericFuelEfficiency", 1}, x1 = 1215, x2 = 1295, y1 = 390, y2 = 410} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillAtmosphericFuelEfficiency", 2}, x1 = 1305, x2 = 1385, y1 = 390, y2 = 410} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillAtmosphericFuelEfficiency", 3}, x1 = 1390, x2 = 1470, y1 = 390, y2 = 410} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillAtmosphericFuelEfficiency", 4}, x1 = 1475, x2 = 1555, y1 = 390, y2 = 410} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillAtmosphericFuelEfficiency", 5}, x1 = 1565, x2 = 1645, y1 = 390, y2 = 410} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillSpaceFuelEfficiency", 0}, x1 = 1060, x2 = 1115, y1 = 460, y2 = 480} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillSpaceFuelEfficiency", 1}, x1 = 1215, x2 = 1295, y1 = 460, y2 = 480} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillSpaceFuelEfficiency", 2}, x1 = 1305, x2 = 1385, y1 = 460, y2 = 480} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillSpaceFuelEfficiency", 3}, x1 = 1390, x2 = 1470, y1 = 460, y2 = 480} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillSpaceFuelEfficiency", 4}, x1 = 1475, x2 = 1555, y1 = 460, y2 = 480} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillSpaceFuelEfficiency", 5}, x1 = 1565, x2 = 1645, y1 = 460, y2 = 480} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillRocketFuelEfficiency", 0}, x1 = 1060, x2 = 1115, y1 = 525, y2 = 545} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillRocketFuelEfficiency", 1}, x1 = 1215, x2 = 1295, y1 = 525, y2 = 545} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillRocketFuelEfficiency", 2}, x1 = 1305, x2 = 1385, y1 = 525, y2 = 545} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillRocketFuelEfficiency", 3}, x1 = 1390, x2 = 1470, y1 = 525, y2 = 545} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillRocketFuelEfficiency", 4}, x1 = 1475, x2 = 1555, y1 = 525, y2 = 545} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillRocketFuelEfficiency", 5}, x1 = 1565, x2 = 1645, y1 = 525, y2 = 545} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"StatAtmosphericFuelTankHandling", 0}, x1 = 1060, x2 = 1115, y1 = 590, y2 = 610} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"StatAtmosphericFuelTankHandling", 1}, x1 = 1215, x2 = 1295, y1 = 590, y2 = 610} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"StatAtmosphericFuelTankHandling", 2}, x1 = 1305, x2 = 1385, y1 = 590, y2 = 610} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"StatAtmosphericFuelTankHandling", 3}, x1 = 1390, x2 = 1470, y1 = 590, y2 = 610} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"StatAtmosphericFuelTankHandling", 4}, x1 = 1475, x2 = 1555, y1 = 590, y2 = 610} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"StatAtmosphericFuelTankHandling", 5}, x1 = 1565, x2 = 1645, y1 = 590, y2 = 610} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"StatSpaceFuelTankHandling", 0}, x1 = 1060, x2 = 1115, y1 = 660, y2 = 680} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"StatSpaceFuelTankHandling", 1}, x1 = 1215, x2 = 1295, y1 = 660, y2 = 680} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"StatSpaceFuelTankHandling", 2}, x1 = 1305, x2 = 1385, y1 = 660, y2 = 680} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"StatSpaceFuelTankHandling", 3}, x1 = 1390, x2 = 1470, y1 = 660, y2 = 680} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"StatSpaceFuelTankHandling", 4}, x1 = 1475, x2 = 1555, y1 = 660, y2 = 680} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"StatSpaceFuelTankHandling", 5}, x1 = 1565, x2 = 1645, y1 = 660, y2 = 680} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"StatRocketFuelTankHandling", 0}, x1 = 1060, x2 = 1115, y1 = 720, y2 = 740} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"StatRocketFuelTankHandling", 1}, x1 = 1215, x2 = 1295, y1 = 720, y2 = 740} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"StatRocketFuelTankHandling", 2}, x1 = 1305, x2 = 1385, y1 = 720, y2 = 740} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"StatRocketFuelTankHandling", 3}, x1 = 1390, x2 = 1470, y1 = 720, y2 = 740} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"StatRocketFuelTankHandling", 4}, x1 = 1475, x2 = 1555, y1 = 720, y2 = 740} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"StatRocketFuelTankHandling", 5}, x1 = 1565, x2 = 1645, y1 = 720, y2 = 740} )
-
-
-
- elseif screen.mode == "startup" then
- end
-
- screen = CreateBaseClickAreas(screen)
-
- return screen
-end
-
-function CheckClick(x, y, HitTarget)
- x = x*1920
- y = y*1120
- HitTarget = HitTarget or ""
- HitPayload = {}
- -- PrintConsole("Clicked: "..x.." / "..y)
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- if screens[i].active == true and screens[i].element.getMouseX() ~= -1 and screens[i].element.getMouseY() ~= -1 then
- if HitTarget == "" then
- for k, v in pairs(screens[i].ClickAreas) do
- if v ~=nil and x >= v.x1 and x <= v.x2 and y >= v.y1 and y <= v.y2 then
- HitTarget = v.id
- HitPayload = v
- break
- end
- end
- end
- if HitTarget == "ButtonPress" then
- if screens[i].mode == HitPayload.param then
- screens[i].mode = "startup"
- else
- screens[i].mode = HitPayload.param
- end
-
- if screens[i].mode == "damageoutline" then
- if screens[i].submode == "" then
- screens[i].submode = "top"
- end
- end
- screens[i].refresh = true
- screens[i].ClickAreas = {}
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "ToggleBackground" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundMode == "" then
- BackgroundSelected = 1
- BackgroundMode = backgroundModes[BackgroundSelected]
- else
- BackgroundSelected = 1
- BackgroundMode = ""
- end
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "PreviousBackground" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundMode == "" then
- BackgroundSelected = 1
- BackgroundMode = backgroundModes[BackgroundSelected]
- else
- if BackgroundSelected <= 1 then
- BackgroundSelected = #backgroundModes
- else
- BackgroundSelected = BackgroundSelected - 1
- end
- BackgroundMode = backgroundModes[BackgroundSelected]
- end
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "NextBackground" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundMode == "" then
- BackgroundSelected = 1
- BackgroundMode = backgroundModes[BackgroundSelected]
- else
- if BackgroundSelected >= #backgroundModes then
- BackgroundSelected = 1
- else
- BackgroundSelected = BackgroundSelected + 1
- end
- BackgroundMode = backgroundModes[BackgroundSelected]
- end
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "DecreaseOpacity" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundModeOpacity>0.1 then
- BackgroundModeOpacity = BackgroundModeOpacity - 0.05
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- end
- elseif HitTarget == "IncreaseOpacity" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundModeOpacity<1.0 then
- BackgroundModeOpacity = BackgroundModeOpacity + 0.05
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- end
- elseif HitTarget == "ResetColors" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- db.clear()
- ColorPrimary = "FF6700"
- ColorSecondary = "FFFFFF"
- ColorTertiary = "000000"
- ColorHealthy = "00FF00"
- ColorWarning = "FFFF00"
- ColorCritical = "FF0000"
- ColorBackground = "000000"
- ColorBackgroundPattern = "4f4f4f"
- BackgroundMode = "deathstar"
- BackgroundSelected = 1
- BackgroundModeOpacity = 0.25
- colorIDTable = {
- [1] = {
- id="ColorPrimary",
- desc="Main HUD Color",
- basec = "FF6700",
- newc = "FF6700"
- },
- [2] = {
- id="ColorSecondary",
- desc="Secondary HUD Color",
- basec = "FFFFFF",
- newc = "FFFFFF"
- },
- [3] = {
- id="ColorTertiary",
- desc="Tertiary HUD Color",
- basec = "000000",
- newc = "000000"
- },
- [4] = {
- id="ColorHealthy",
- desc="Color code for Healthy/Okay",
- basec = "00FF00",
- newc = "00FF00"
- },
- [5] = {
- id="ColorWarning",
- desc="Color code for Damaged/Warning",
- basec = "FFFF00",
- newc = "FFFF00"
- },
- [6] = {
- id="ColorCritical",
- desc="Color code for Broken/Critical",
- basec = "FF0000",
- newc = "FF0000"
- },
- [7] = {
- id="ColorBackground",
- desc="Background Color",
- basec = "000000",
- newc = "000000"
- },
- [8] = {
- id="ColorBackgroundPattern",
- desc="Background Pattern Color",
- basec = "4F4F4F",
- newc = "4F4F4F"
- },
- [9] = {
- id="ColorFuelAtmospheric",
- desc="Color for Atmo Fuel/Elements",
- basec = "004444",
- newc = "004444"
- },
- [10] = {
- id="ColorFuelSpace",
- desc="Color for Space Fuel/Elements",
- basec = "444400",
- newc = "444400"
- },
- [11] = {
- id="ColorFuelRocket",
- desc="Color for Rocket Fuel/Elements",
- basec = "440044",
- newc = "440044"
- }
- }
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "PreviousColorID" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- colorIDIndex = colorIDIndex - 1
- if colorIDIndex < 1 then colorIDIndex = #colorIDTable end
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "NextColorID" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- colorIDIndex = colorIDIndex + 1
- if colorIDIndex > #colorIDTable then colorIDIndex = 1 end
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "ColorPosUp" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- local s = tonumber(string.sub(colorIDTable[colorIDIndex].newc, HitPayload.param, HitPayload.param),16)
- s = s + 1
- if s > 15 then s = 0 end
- colorIDTable[colorIDIndex].newc = replace_char(HitPayload.param, colorIDTable[colorIDIndex].newc, hexTable[s+1])
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "ColorPosDown" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- local s = tonumber(string.sub(colorIDTable[colorIDIndex].newc, HitPayload.param, HitPayload.param),16)
- s = s - 1
- if s < 0 then s = 15 end
- colorIDTable[colorIDIndex].newc = replace_char(HitPayload.param, colorIDTable[colorIDIndex].newc, hexTable[s+1])
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "ResetPosColor" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- colorIDTable[colorIDIndex].newc = colorIDTable[colorIDIndex].basec
- _G[colorIDTable[colorIDIndex].id] = colorIDTable[colorIDIndex].basec
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "ApplyPosColor" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- _G[colorIDTable[colorIDIndex].id] = colorIDTable[colorIDIndex].newc
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "ChangeSkillPoint" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- _G[HitPayload.param[1]] = HitPayload.param[2]
- UpdateDamageData()
- UpdateTypeData()
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "DamagedPageDown" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentDamagedPage = CurrentDamagedPage + 1
- if CurrentDamagedPage > math.ceil(#damagedElements / DamagePageSize) then
- CurrentDamagedPage = math.ceil(#damagedElements / DamagePageSize)
- end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "DamagedPageUp" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentDamagedPage = CurrentDamagedPage - 1
- if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "BrokenPageDown" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentBrokenPage = CurrentBrokenPage + 1
- if CurrentBrokenPage > math.ceil(#brokenElements / DamagePageSize) then
- CurrentBrokenPage = math.ceil(#brokenElements / DamagePageSize)
- end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "BrokenPageUp" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentBrokenPage = CurrentBrokenPage - 1
- if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "DMGOChangeView" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- screens[i].submode = HitPayload.param
- UpdateViewDamageoutline(screens[i])
- SaveToDatabank()
- SetRefresh("damageoutline", screens[i].submode)
- RenderScreens("damageoutline", screens[i].submode)
- elseif HitTarget == "DMGOChangeStretch" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if DMGOStretch == true then
- DMGOStretch = false
- else
- DMGOStretch = true
- end
- UpdateViewDamageoutline(screens[i])
- SaveToDatabank()
- SetRefresh("damageoutline")
- RenderScreens("damageoutline")
- elseif HitTarget == "ToggleDisplayAtmosphere" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if screens[i].fuelA == true then
- screens[i].fuelA = false
- else
- screens[i].fuelA = true
- end
- screens[i].fuelIndex = 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "ToggleDisplaySpace" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if screens[i].fuelS == true then
- screens[i].fuelS = false
- else
- screens[i].fuelS = true
- end
- screens[i].fuelIndex = 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "ToggleDisplayRocket" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if screens[i].fuelR == true then
- screens[i].fuelR = false
- else
- screens[i].fuelR = true
- end
- screens[i].fuelIndex = 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "DecreaseFuelIndex" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- screens[i].fuelIndex = screens[i].fuelIndex - 1
- if screens[i].fuelIndex < 1 then screens[i].fuelIndex = 1 end
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "IncreaseFuelIndex" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- screens[i].fuelIndex = screens[i].fuelIndex + 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "ToggleHudMode" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if HUDMode == true then
- HUDMode = false
- forceDamageRedraw = true
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- else
- HUDMode = true
- forceDamageRedraw = true
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- end
- elseif HitTarget == "ToggleSimulation" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentDamagedPage = 1
- CurrentBrokenPage = 1
- if SimulationMode == true then
- SimulationMode = false
- SimulationActive = false
- UpdateDamageData()
- UpdateTypeData()
- forceDamageRedraw = true
- HudDeselectElement()
- SetRefresh("damage")
- SetRefresh("damageoutline")
- SetRefresh("settings1")
- SetRefresh("fuel")
- SaveToDatabank()
- RenderScreens()
- else
- SimulationMode = true
- SimulationActive = false
- UpdateDamageData()
- UpdateTypeData()
- forceDamageRedraw = true
- HudDeselectElement()
- SetRefresh("damage")
- SetRefresh("damageoutline")
- SetRefresh("settings1")
- SetRefresh("fuel")
- SaveToDatabank()
- RenderScreens()
- end
- elseif (HitTarget == "ToggleElementLabel" or HitTarget == "ToggleElementLabel2") and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if UseMyElementNames == true then
- UseMyElementNames = false
- SetRefresh("damage")
- RenderScreens("damage")
- else
- UseMyElementNames = true
- SetRefresh("damage")
- RenderScreens("damage")
- end
- elseif (HitTarget == "SwitchScrapTier" or HitTarget == "SwitchScrapTier2") and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- ScrapTier = ScrapTier + 1
- if ScrapTier > 4 then ScrapTier = 1 end
- SetRefresh("damage")
- RenderScreens("damage")
- end
-
-
- end
- end
- end
-end
-
---[[ 4. RENDERING FUNCTIONS ]]
-
-function GetContentFlight()
- local output = ""
- output = output .. GetHeader("Flight Data Report") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentDamage()
- local output = ""
- if SimulationMode == true then
- output = output .. GetHeader("Damage Report (Simulated damage)") .. [[]]
- else
- output = output .. GetHeader("Damage Report") .. [[]]
- end
- output = output .. GetContentDamageScreen()
- return output
-end
-
-function GetContentDamageoutline(screen)
- UpdateDataDamageoutline()
- UpdateViewDamageoutline(screen)
- local output = ""
- output = output .. GetHeader("Damage Ship Outline Report") ..
- GetDamageoutlineShip() ..
- [[]]
-
- if screen.submode=="top" then
- output = output ..
- [[
-
- Top View
-
- Side View
-
- Front View
- ]]
- elseif screen.submode=="side" then
- output = output ..
- [[
-
- Top View
-
- Side View
-
- Front View
- ]]
- elseif screen.submode=="front" then
- output = output ..
- [[
-
- Top View
-
- Side View
-
- Front View
- ]]
- else
- end
- output = output .. [[]]..#dmgoElements..[[ of ]]..ElementCounter..[[ shown]]
- output = output .. [[]]
- if DMGOStretch == true then
- output = output .. [[]]
- end
- output = output .. [[Stretch both axis]]
- return output
-end
-
-function GetContentFuel(screen)
- local FuelTypes = 0
- local output = ""
- local addHeadline = {}
-
- FuelDisplay = { screen.fuelA, screen.fuelS, screen.fuelR }
-
- if FuelDisplay[1] == true and #FuelAtmosphericTanks > 0 then
- table.insert(addHeadline, "Atmospheric")
- FuelTypes = FuelTypes + 1
- end
- if FuelDisplay[2] == true and #FuelSpaceTanks > 0 then
- table.insert(addHeadline, "Space")
- FuelTypes = FuelTypes + 1
- end
- if FuelDisplay[3] == true and #FuelRocketTanks > 0 then
- table.insert(addHeadline, "Rocket")
- FuelTypes = FuelTypes + 1
- end
-
- output = output .. GetHeader("Fuel Report ("..table.concat(addHeadline, ", ")..")") ..
- [[
- ]]
-
- local totalH = 150
- local counter = 0
- local tOffset = 0
-
- if FuelDisplay[1] == true and #FuelAtmosphericTanks > 0 then
-
- if FuelTypes == 1 then tOffset = 50
- elseif FuelTypes == 2 then tOffset = 6
- elseif FuelTypes == 3 then tOffset = 0
- end
-
- output = output .. [[
-
-
-
- ]]
-
- output = output ..
- [[]]..
- GenerateCommaValue(FuelAtmosphericCurrent, true)..
- [[ of ]]..GenerateCommaValue(FuelAtmosphericTotal, true)..
- [[ | Total Atmospheric Fuel in ]]..#FuelAtmosphericTanks..[[ tank]]..(#FuelAtmosphericTanks==1 and "" or "s")..[[ (]]..math.floor(100/FuelAtmosphericTotal*FuelAtmosphericCurrent)..[[%)]]
- counter = counter + 1
- end
-
- if FuelDisplay[2] == true and #FuelSpaceTanks > 0 then
-
- if FuelTypes == 1 then tOffset = 50
- elseif FuelTypes == 2 then tOffset = 6
- elseif FuelTypes == 3 then tOffset = 0
- end
-
- output = output .. [[
-
-
-
- ]]
-
- output = output ..
- [[]]..
- GenerateCommaValue(FuelSpaceCurrent, true)..
- [[ of ]]..GenerateCommaValue(FuelSpaceTotal, true)..
- [[ | Total Space Fuel in ]]..#FuelSpaceTanks..[[ tank]]..(#FuelSpaceTanks==1 and "" or "s")..[[ (]]..math.floor(100/FuelSpaceTotal*FuelSpaceCurrent)..[[%)]]
- counter = counter + 1
- end
-
- if FuelDisplay[3] == true and #FuelRocketTanks > 0 then
-
- if FuelTypes == 1 then tOffset = 50
- elseif FuelTypes == 2 then tOffset = 6
- elseif FuelTypes == 3 then tOffset = 0
- end
-
- output = output .. [[
-
-
-
- ]]
-
- output = output ..
- [[]]..
- GenerateCommaValue(FuelRocketCurrent, true)..
- [[ of ]]..GenerateCommaValue(FuelRocketTotal, true)..
- [[ | Total Rocket Fuel in ]]..#FuelRocketTanks..[[ tank]]..(#FuelRocketTanks==1 and "" or "s")..[[ (]]..math.floor(100/FuelRocketTotal*FuelRocketCurrent)..[[%)]]
- end
-
- output = output .. [[
-
-
-
- ]]
-
- local DisplayTable = {}
- if screen.fuelIndex == nil or screen.fuelIndex < 1 then
- screen.fuelIndex = 1
- end
-
- if FuelDisplay[1] == true then
- for _,v in ipairs(FuelAtmosphericTanks) do
- table.insert(DisplayTable, v)
- end
- end
- if FuelDisplay[2] == true then
- for _,v in ipairs(FuelSpaceTanks) do
- table.insert(DisplayTable, v)
- end
- end
- if FuelDisplay[3] == true then
- for _,v in ipairs(FuelRocketTanks) do
- table.insert(DisplayTable, v)
- end
- end
-
- table.sort(DisplayTable, function(a,b) return a.type
-
-
- ]]
- if tank.hp == 0 then
- output = output .. [[]]
- elseif tank.maxhp - tank.hp > constants.epsilon then
- output = output .. [[]]
- else
- output = output .. [[]]
- end
- if tank.hp == 0 then output = output .. [[]]..tank.size..[[]]
- else output = output .. [[]]..tank.size..[[]]
- end
-
- if tank.hp == 0 then
- output = output .. [[Broken]] ..
- [[0 of ]]..GenerateCommaValue(tank.vol)..[[]]
- elseif tonumber(tank.percent) < 10 then
- output = output .. [[]]..tank.percent..[[%]] ..
- [[]]..GenerateCommaValue(tank.cvol)..[[ of ]]..GenerateCommaValue(tank.vol)..[[]]
- elseif tonumber(tank.percent) < 30 then
- output = output .. [[]]..tank.percent..[[%]] ..
- [[]]..GenerateCommaValue(tank.cvol)..[[ of ]]..GenerateCommaValue(tank.vol)..[[]]
- else output =
- output .. [[]]..tank.percent..[[%]] ..
- [[]]..GenerateCommaValue(tank.cvol)..[[ of ]]..GenerateCommaValue(tank.vol)..[[]]
- end
-
- output = output ..[[]]..tank.name..[[]]
-
- output = output .. [[]]
-
- end
- end
-
-
-
- if #FuelAtmosphericTanks > 0 then
- output = output .. [[]]
- if FuelDisplay[1] == true then
- output = output .. [[]]
- end
- output = output .. [[ATM]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "ToggleDisplayAtmosphere", x1 = 50, x2 = 100, y1 = 270, y2 = 320} )
- end
-
- if #FuelSpaceTanks > 0 then
- output = output .. [[]]
- if FuelDisplay[2] == true then
- output = output .. [[]]
- end
- output = output .. [[SPC]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "ToggleDisplaySpace", x1 = 200, x2 = 250, y1 = 270, y2 = 320} )
- end
-
- if #FuelRocketTanks > 0 then
- output = output .. [[]]
- if FuelDisplay[3] == true then
- output = output .. [[]]
- end
- output = output .. [[RKT]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "ToggleDisplayRocket", x1 = 350, x2 = 400, y1 = 270, y2 = 320} )
- end
-
- if screen.fuelIndex > 1 then
- output = output .. [[
-
-
- ]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "DecreaseFuelIndex", x1 = 1470, x2 = 1670, y1 = 270, y2 = 320} )
- end
-
- if screen.fuelIndex+cCounter-1 < #DisplayTable then
- output = output .. [[
-
-
- ]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "IncreaseFuelIndex", x1 = 1680, x2 = 1880, y1 = 270, y2 = 320} )
- end
-
- if cCounter > 0 then
- output = output .. [[]]..
- #DisplayTable..
- [[ Tank]]..(#DisplayTable == 1 and "" or "s")..
- [[ (Showing ]]..screen.fuelIndex..[[ to ]]..(screen.fuelIndex+cCounter-1)..[[)]]
- end
-
- return output
-end
-
-function GetContentCargo()
- local output = ""
- output = output .. GetHeader("Cargo Report") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentAGG()
- local output = ""
- output = output .. GetHeader("Anti-Grav Control") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentMap()
- local output = ""
- output = output .. GetHeader("Map Overview") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentTime()
- local output = ""
- output = output .. GetHeader("Time") .. epochTime()
- output = output ..
- [[
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetContentSettings1()
- local output = ""
- output = output .. GetHeader("Settings") .. [[]]
- if BackgroundMode=="" then
- output = output ..[[Activate background]]
- else
- output = output ..[[Deactivate background (']]..BackgroundMode..[[', ]]..string.format("%.0f",BackgroundModeOpacity*100)..[[%)]]
- end
- output = output ..[[
-
- Previous background
-
- Next background
-
-
- Decrease Opacity
-
- Increase Opacity
- ]]
-
- output = output ..
- [[]] ..
- [[Reset background and all colors]]
-
- output = output ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Select and change any of the ]]..#colorIDTable..[[ HUD colors]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]]..colorIDTable[colorIDIndex].desc..[[]] ..
- [[]] ..
- [[Current color]] ..
- [[]] ..
-
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
-
- [[#]] ..
-
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,1,1)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,2,2)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,3,3)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,4,4)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,5,5)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,6,6)..[[]] ..
-
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
-
- [[]] ..
- [[]] ..
- [[New color]] ..
- [[]] ..
- [[Apply new color]] ..
- [[]] ..
- [[Reset]] ..
- [[]]
-
- output = output ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Enter your skills and placed element levels]]
-
- output = output .. [[]] ..
- [[Skill: Equipment Manager >> Repair Tool Efficiency:]]
- local lSkill = SkillRepairToolEfficiency
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
-
- output = output .. [[]] ..
- [[Skill: Equipment Manager >> Repair Tool Optimization:]]
- local lSkill = SkillRepairToolOptimization
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
-
- output = output .. [[]] ..
- [[Skill: Atmospheric Engine Pilot >> Atmospheric Fuel Efficiency:]]
- local lSkill = SkillAtmosphericFuelEfficiency
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
-
- output = output .. [[]] ..
- [[Skill: Space Engine Pilot >> Space Fuel Efficiency:]]
- local lSkill = SkillSpaceFuelEfficiency
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
-
- output = output .. [[]] ..
- [[Skill: Rocket Scientists >> Rocket Fuel Efficiency:]]
- local lSkill = SkillRocketFuelEfficiency
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
-
- output = output .. [[]] ..
- [[Stat: Level of Atmo Tanks (Atmospheric Fuel Tank Handling):]]
- local lSkill = StatAtmosphericFuelTankHandling
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
-
- output = output .. [[]] ..
- [[Stat: Level of Space Tanks (Space Fuel Tank Handling):]]
- local lSkill = StatSpaceFuelTankHandling
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
-
- output = output .. [[]] ..
- [[Stat: Level of Rocket Tanks (Rocket Fuel Tank Handling):]]
- local lSkill = StatRocketFuelTankHandling
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
-
- output = output .. [[]]
-
- if SimulationMode == true then
- output = output .. [[Simulating Damage to elements]]
- AddClickArea("settings1", { id = "ToggleSimulation", mode ="settings1", x1 = 940, x2 = 1850, y1 = 919, y2 = 969 })
- else
- output = output .. [[Simulate Damage to elements]]
- AddClickArea("settings1", { id = "ToggleSimulation", mode ="settings1", x1 = 940, x2 = 1850, y1 = 919, y2 = 969 })
- end
-
- return output
-end
-
-function GetContentStartup()
- local output = ""
- output = output .. GetElementLogo(812, 380, "f", "f", "f")
- if YourShipsName == "Enter here" then
- output = output .. [[Spaceship ID ]]..ShipID..[[]]
- else
- output = output .. [[]]..YourShipsName..[[]]
- end
- if ShowWelcomeMessage == true then output = output .. [[Greetings, Commander ]]..PlayerName..[[.]] end
- output = output .. [[Damage Report v]]..VERSION..[[, by Scion Interstellar, DorianGray - Discord: Dorian Gray#2623. Under GNU Public License 3.0.]]
- return output
-end
-
-function RenderScreen(screen, contentToRender)
- if contentToRender == nil then
- PrintConsole("ERROR: contentToRender is nil.")
- unit.exit()
- end
-
- CreateClickAreasForScreen(screen)
-
- local output =""
- output = output .. [[
-
-
- ]]
-
- output = output .. contentToRender
-
- if screen.mode == "startup" then
- output = output .. [[]]
- else
- output = output .. [[]]
- end
-
- output = output .. [[
-
- ]]
- output = output .. [[]]
-
- -- Center:
-
- --
- --
- --
- --
-
- local outputLength = string.len(output)
- -- PrintConsole("Render: "..screen.mode.." ("..outputLength.." chars)")
- screen.element.setSVG(output)
-end
-
-function RenderScreens(onlymode, onlysubmode)
-
- onlymode = onlymode or "all"
- onlysubmode = onlysubmode or "all"
-
- if screens ~= nil and #screens > 0 then
-
- local contentFlight = ""
- local contentDamage = ""
- local contentDamageoutlineTop = ""
- local contentDamageoutlineSide = ""
- local contentDamageoutlineFront = ""
- local contentFuel = ""
- local contentCargo = ""
- local contentAGG = ""
- local contentMap = ""
- local contentTime = ""
- local contentSettings1 = ""
- local contentStartup = ""
-
- for k,screen in pairs(screens) do
- if screen.refresh == true then
- local contentToRender = ""
-
- if screen.mode == "flight" and (onlymode =="flight" or onlymode =="all") then
- if contentFlight == "" then contentFlight = GetContentFlight() end
- contentToRender = contentFlight
- elseif screen.mode == "damage" and (onlymode =="damage" or onlymode =="all") then
- if contentDamage == "" then contentDamage = GetContentDamage() end
- contentToRender = contentDamage
- elseif screen.mode == "damageoutline" and (onlymode =="damageoutline" or onlymode =="all") then
- if screen.submode == "" then
- screen.submode = "top"
- screens[k].submode = "top"
- end
- if screen.submode == "top" and (onlysubmode == "top" or onlysubmode == "all") then
- if contentDamageoutlineTop == "" then contentDamageoutlineTop = GetContentDamageoutline(screen) end
- contentToRender = contentDamageoutlineTop
- end
- if screen.submode == "side" and (onlysubmode == "side" or onlysubmode == "all") then
- if contentDamageoutlineSide == "" then contentDamageoutlineSide = GetContentDamageoutline(screen) end
- contentToRender = contentDamageoutlineSide
- end
- if screen.submode == "front" and (onlysubmode == "front" or onlysubmode == "all") then
- if contentDamageoutlineFront == "" then contentDamageoutlineFront = GetContentDamageoutline(screen) end
- contentToRender = contentDamageoutlineFront
- end
- elseif screen.mode == "fuel" and (onlymode =="fuel" or onlymode =="all") then
- screen = WipeClickAreasForScreen(screens[k])
- contentToRender = GetContentFuel(screen)
- elseif screen.mode == "cargo" and (onlymode =="cargo" or onlymode =="all") then
- if contentCargo == "" then contentCargo = GetContentCargo() end
- contentToRender = contentCargo
- elseif screen.mode == "agg" and (onlymode =="agg" or onlymode =="all") then
- if contentAGG == "" then contentAGG = GetContentAGG() end
- contentToRender = contentAGG
- elseif screen.mode == "map" and (onlymode =="map" or onlymode =="all") then
- if contentMap == "" then contentMap = GetContentMap() end
- contentToRender = contentMap
- elseif screen.mode == "time" and (onlymode =="time" or onlymode =="all") then
- if contentTime == "" then contentTime = GetContentTime() end
- contentToRender = contentTime
- elseif screen.mode == "settings1" and (onlymode =="settings1" or onlymode =="all") then
- if contentSettings1 == "" then contentSettings1 = GetContentSettings1() end
- contentToRender = contentSettings1
- elseif screen.mode == "startup" and (onlymode =="startup" or onlymode =="all") then
- if contentStartup == "" then contentStartup = GetContentStartup() end
- contentToRender = contentStartup
- else
- contentToRender = "Invalid screen mode. ('"..screen.mode.."')"
- end
-
- if contentToRender ~= "" then
- RenderScreen(screen, contentToRender)
- else
- DrawCenteredText("ERROR: No contentToRender delivered for "..screen.mode)
- PrintConsole("ERROR: No contentToRender delivered for "..screen.mode)
- unit.exit()
- end
- screens[k].refresh = false
- end
- end
- end
-
- if HUDMode == true then
- system.setScreen(GetContentDamageHUDOutput())
- system.showScreen(1)
- else
- system.showScreen(0)
- end
-
-end
-
-function OnTickData(initial)
- if formerTime + 60 < system.getTime() then
- SetRefresh("time")
- end
- totalShipMass = core.getConstructMass()
- if formerTotalShipMass ~= totalShipMass then
- UpdateDamageData(true)
- UpdateTypeData()
- SetRefresh()
- formerTotalShipMass = totalShipMass
- else
- UpdateDamageData(initial)
- UpdateTypeData()
- end
- RenderScreens()
-end
-
---[[ 5. EXECUTION ]]
-
-unit.hide()
-ClearConsole()
-PrintConsole("DAMAGE REPORT v"..VERSION.." STARTED", true)
-InitiateSlots()
-LoadFromDatabank()
-SwitchScreens("on")
-InitiateScreens()
-
-if core == nil then
- PrintConsole("ERROR: Connect the core to the programming board.")
- unit.exit()
-else
- OperatorID = unit.getMasterPlayerId()
- OperatorData = database.getPlayer(OperatorID)
- PlayerName = OperatorData["name"]
- ShipID = core.getConstructId()
-end
-
-if screens == nil or #screens == 0 then
- HUDMode = true
-end
-
-OnTickData(true)
-
-unit.setTimer('UpdateData', UpdateDataInterval)
-unit.setTimer('UpdateHighlight', HighlightBlinkingInterval)
\ No newline at end of file
diff --git a/src/DamageReport_3_01_UnitStart_1.lua b/src/DamageReport_3_01_UnitStart_1.lua
deleted file mode 100644
index e8da06e..0000000
--- a/src/DamageReport_3_01_UnitStart_1.lua
+++ /dev/null
@@ -1,1277 +0,0 @@
---[[
- Damage Report 3.0
- A LUA script for Dual Universe
-
- Created By Dorian Gray
- Ingame: DorianGray
- Discord: Dorian Gray#2623
-
- You can find/update this script on GitHub. Explanations, installation and usage information as well as screenshots can be found there too.
- GitHub: https://github.com/DorianTheGrey/DU-DamageReport
-
- GNU Public License 3.0. Use whatever you want, be so kind to leave credit.
-
- Credits & thanks:
- Thanks to NovaQuark for creating the MMO of the century.
- Thanks to Jericho, Dmentia and Archaegeo for learning a lot from their fine scripts.
- Thanks to TheBlacklist for testing and wonderful suggestions.
- SVG patterns by Hero Patterns.
- DU atlas data from Jayle Break.
-
-]]
-
---[[ 1. HELPER FUNCTIONS ]]
-
-function GenerateCommaValue(amount, kify, postcomma)
- kify = kify or false
- postcomma = postcomma or 1
- local formatted = amount
- if kify == true then
- if string.len(amount)>=4 then
- formatted = string.format("%."..postcomma.."fk", amount/1000)
- else
- formatted = string.format("%."..postcomma.."f", amount)
- end
- else
- while true do
- formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
- if (k == 0) then break end
- end
- end
- return formatted
-end
-
-function PrintConsole(output, highlight)
- highlight = highlight or false
- if highlight then
- system.print(
- "------------------------------------------------------------------------")
- end
- system.print(output)
- if highlight then
- system.print(
- "------------------------------------------------------------------------")
- end
-end
-
-function DrawCenteredText(output)
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- screens[i].element.setCenteredText(output)
- end
- end
-end
-
-function ClearConsole()
- for i = 1, 10, 1 do
- PrintConsole()
- end
-end
-
-function SwitchScreens(state)
- state = state or "on"
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- if state == "on" then
- screens[i].element.clear()
- screens[i].element.activate()
- screens[i].active = true
- else
- screens[i].element.clear()
- screens[i].element.deactivate()
- screens[i].active = false
- end
- end
- end
-end
-
---[[ Convert seconds to string (by Jericho) ]]
-function GetSecondsString(seconds)
- local seconds = tonumber(seconds)
-
- if seconds == nil or seconds <= 0 then
- return "-";
- else
- days = string.format("%2.f", math.floor(seconds/(3600*24)));
- hours = string.format("%2.f", math.floor(seconds/3600 - (days*24)));
- mins = string.format("%2.f", math.floor(seconds/60 - (hours*60) - (days*24*60)));
- secs = string.format("%2.f", math.floor(seconds - hours*3600 - (days*24*60*60) - mins *60));
- str = ""
- if tonumber(days) > 0 then str = str .. days.."d " end
- if tonumber(hours) > 0 then str = str .. hours.."h " end
- if tonumber(mins) > 0 then str = str .. mins.."m " end
- if tonumber(secs) > 0 then str = str .. secs .."s" end
- return str
- end
-end
-
-function replace_char(pos, str, r)
- return str:sub(1, pos-1) .. r .. str:sub(pos+1)
-end
-
---[[ 2. RENDER HELPER FUNCTIONS ]]
-
---[[ epochTime function by Leodr (clock script), enhanced by Jericho (DU Industry script) ]]
-function epochTime()
- function rZ(a)
- if string.len(a) <= 1 then
- return "0" .. a
- else
- return a
- end
- end
- function dPoint(b)
- if not (b == math.floor(b)) then
- return true
- else
- return false
- end
- end
- function lYear(year)
- if not dPoint(year / 4) then
- if dPoint(year / 100) then
- return true
- else
- if not dPoint(year / 400) then
- return true
- else
- return false
- end
- end
- else
- return false
- end
- end
- local c = 5;
- local d = 3600;
- local e = 86400;
- local f = 31536000;
- local g = 31622400;
- local h = 2419200;
- local i = 2505600;
- local j = 2592000;
- local k = 2678400;
- local l = {4, 6, 9, 11}
- local m = {1, 3, 5, 7, 8, 10, 12}
- local n = 0;
- local o = 1506816000;
- local q = system.getTime()
- _G["formerTime"] = q
- if AddSummertimeHour == true then q = q + 3600 end
- now = math.floor(q + o)
- year = 1970;
- secs = 0;
- n = 0;
- while secs + g < now or secs + f < now do
- if lYear(year + 1) then
- if secs + g < now then
- secs = secs + g;
- year = year + 1;
- n = n + 366
- end
- else
- if secs + f < now then
- secs = secs + f;
- year = year + 1;
- n = n + 365
- end
- end
- end
- secondsRemaining = now - secs;
- monthSecs = 0;
- yearlYear = lYear(year)
- month = 1;
- while monthSecs + h < secondsRemaining or monthSecs + j < secondsRemaining or
- monthSecs + k < secondsRemaining do
- if month == 1 then
- if monthSecs + k < secondsRemaining then
- month = 2;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 2 then
- if not yearlYear then
- if monthSecs + h < secondsRemaining then
- month = 3;
- monthSecs = monthSecs + h;
- n = n + 28
- else
- break
- end
- else
- if monthSecs + i < secondsRemaining then
- month = 3;
- monthSecs = monthSecs + i;
- n = n + 29
- else
- break
- end
- end
- end
- if month == 3 then
- if monthSecs + k < secondsRemaining then
- month = 4;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 4 then
- if monthSecs + j < secondsRemaining then
- month = 5;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- if month == 5 then
- if monthSecs + k < secondsRemaining then
- month = 6;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 6 then
- if monthSecs + j < secondsRemaining then
- month = 7;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- if month == 7 then
- if monthSecs + k < secondsRemaining then
- month = 8;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 8 then
- if monthSecs + k < secondsRemaining then
- month = 9;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 9 then
- if monthSecs + j < secondsRemaining then
- month = 10;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- if month == 10 then
- if monthSecs + k < secondsRemaining then
- month = 11;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 11 then
- if monthSecs + j < secondsRemaining then
- month = 12;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- end
- day = 1;
- daySecs = 0;
- daySecsRemaining = secondsRemaining - monthSecs;
- while daySecs + e < daySecsRemaining do
- day = day + 1;
- daySecs = daySecs + e;
- n = n + 1
- end
- hour = 0;
- hourSecs = 0;
- hourSecsRemaining = daySecsRemaining - daySecs;
- while hourSecs + d < hourSecsRemaining do
- hour = hour + 1;
- hourSecs = hourSecs + d
- end
- minute = 0;
- minuteSecs = 0;
- minuteSecsRemaining = hourSecsRemaining - hourSecs;
- while minuteSecs + 60 < minuteSecsRemaining do
- minute = minute + 1;
- minuteSecs = minuteSecs + 60
- end
- second = math.floor(now % 60)
- year = rZ(year)
- month = rZ(month)
- day = rZ(day)
- hour = rZ(hour)
- minute = rZ(minute)
- second = rZ(second)
-
- return [[]]..hour..":".. minute..[[]]..
- [[]]..year.."/".. month.."/"..day..[[]]
-end
-
-
-function ToggleHUD()
- if HUDMode == true then
- HUDMode = false
- forceDamageRedraw = true
- hudSelectedIndex = 0
- highlightID = 0
- HideHighlight()
- SetRefresh()
- RenderScreens()
- else
- HUDMode = true
- forceDamageRedraw = true
- hudSelectedIndex = 0
- highlightID = 0
- HideHighlight()
- SetRefresh()
- RenderScreens()
- end
-end
-
-function HudDeselectElement()
- hudSelectedIndex = 0
- hudStartIndex = 1
- highlightID = 0
- HideHighlight()
- if HUDMode == true then
- SetRefresh("damage")
- SetRefresh("damageoutline")
- RenderScreens()
- end
-end
-
-function ChangeHudSelectedElement(step)
- if HUDMode == true and #rE > 0 then
-
- hudSelectedIndex = hudSelectedIndex + step
- if hudSelectedIndex < 1 then hudSelectedIndex = 1
- elseif hudSelectedIndex > #rE then hudSelectedIndex = #rE
- end
-
- if hudSelectedIndex > 9 then
- hudStartIndex = hudSelectedIndex-9
- end
- if hudSelectedIndex ~= 0 then
- highlightID = rE[hudSelectedIndex].id
- if highlightID ~=nil and highlightID ~= 0 then
- -- PrintConsole("CHSE: hudSelectedIndex: "..hudSelectedIndex.." / hudStartIndex: "..hudStartIndex.." / highlightID: "..highlightID)
- HideHighlight()
- elementPosition = vec3(rE[hudSelectedIndex].pos)
- highlightX = elementPosition.x - coreWorldOffset
- highlightY = elementPosition.y - coreWorldOffset
- highlightZ = elementPosition.z - coreWorldOffset
- highlightOn = true
- ShowHighlight()
- end
- end
-
- SetRefresh("damage")
- SetRefresh("damageoutline")
- RenderScreens()
-
- end
-end
-
-function HideHighlight()
- if #hudArrowSticker > 0 then
- for i in pairs(hudArrowSticker) do
- core.deleteSticker(hudArrowSticker[i])
- end
- hudArrowSticker = {}
- end
-end
-
-function ShowHighlight()
- if highlightOn == true and highlightID > 0 then
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX + 2, highlightY, highlightZ, "north"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY - 2, highlightZ, "east"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX - 2, highlightY, highlightZ, "south"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY + 2, highlightZ, "west"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY, highlightZ - 2, "up"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY, highlightZ + 2,"down"))
- end
-end
-
-function ToggleHighlight()
- if highlightOn == true then
- highlightOn = false
- HideHighlight()
- else
- highlightOn = true
- ShowHighlight()
- end
-end
-
-function SortDamageTables()
- table.sort(damagedElements, function(a, b) return a.missinghp > b.missinghp end)
- table.sort(brokenElements, function(a, b) return a.maxhp > b.maxhp end)
-end
-
-function getScraps(damage,commaval)
- commaval = commaval or false
- damage = damage - SkillRepairToolOptimization * 0.05 * damage
- local res = math.ceil( damage / ( 10 * 5^(ScrapTier-1) ) )
- if commaval ==true then
- return GenerateCommaValue(string.format("%.0f", res ), false)
- else
- return res
- end
-end
-
-function getRepairTime(damage,buildstring)
- buildstring = buildstring or false
- damage = damage - SkillRepairToolOptimization * 0.05 * damage
- local res = math.ceil(damage / ScrapTierRepairTimes[ScrapTier])
- res = res - ( SkillRepairToolEfficiency * 0.1 * res )
- if buildstring == true then
- return GetSecondsString(string.format("%.0f", res ) )
- else
- return res
- end
-end
-
-function UpdateDataDamageoutline()
-
- dmgoElements = {}
-
- for i,element in ipairs(brokenElements) do
- if #dmgoElements < DMGOMaxElements then
- local elementPosition = vec3(element.pos)
- local x = elementPosition.x - coreWorldOffset
- local y = elementPosition.y - coreWorldOffset
- local z = elementPosition.z - coreWorldOffset
- if x < ShipXmin then ShipXmin = x end
- if y < ShipYmin then ShipYmin = y end
- if z < ShipZmin then ShipZmin = z end
- if x > ShipXmax then ShipXmax = x end
- if y > ShipYmax then ShipYmax = y end
- if z > ShipZmax then ShipZmax = z end
- table.insert( dmgoElements, {
- id = element.id,
- type = "b",
- size = element.maxhp,
- x = x, y = y, z = z,
- xp = 0, yp = 0, zp = 0,
- u = 0, v = 0
- })
- end
- end
-
- if #dmgoElements < DMGOMaxElements then
- for i,element in ipairs(damagedElements) do
- if #dmgoElements < DMGOMaxElements then
- local elementPosition = vec3(element.pos)
- local x = elementPosition.x - coreWorldOffset
- local y = elementPosition.y - coreWorldOffset
- local z = elementPosition.z - coreWorldOffset
- if x < ShipXmin then ShipXmin = x end
- if y < ShipYmin then ShipYmin = y end
- if z < ShipZmin then ShipZmin = z end
- if x > ShipXmax then ShipXmax = x end
- if y > ShipYmax then ShipYmax = y end
- if z > ShipZmax then ShipZmax = z end
- table.insert( dmgoElements, {
- id = element.id,
- type = "d",
- size = element.maxhp,
- x = x, y = y, z = z,
- xp = 0, yp = 0, zp = 0,
- u = 0, v = 0
- })
- end
- end
- end
-
- if #dmgoElements < DMGOMaxElements then
- for i,element in ipairs(healthyElements) do
- if #dmgoElements < DMGOMaxElements then
- local elementPosition = vec3(element.pos)
- local x = elementPosition.x - coreWorldOffset
- local y = elementPosition.y - coreWorldOffset
- local z = elementPosition.z - coreWorldOffset
- if x < ShipXmin then ShipXmin = x end
- if y < ShipYmin then ShipYmin = y end
- if z < ShipZmin then ShipZmin = z end
- if x > ShipXmax then ShipXmax = x end
- if y > ShipYmax then ShipYmax = y end
- if z > ShipZmax then ShipZmax = z end
- table.insert( dmgoElements, {
- id = element.id,
- type = "h",
- size = element.maxhp,
- x = x, y = y, z = z,
- xp = 0, yp = 0, zp = 0,
- u = 0, v = 0
- })
- end
- end
- end
-
- ShipX = math.abs(ShipXmax-ShipXmin)
- ShipY = math.abs(ShipYmax-ShipYmin)
- ShipZ = math.abs(ShipZmax-ShipZmin)
-
- --[[
- PrintConsole(
- "ShipXmin: "..string.format("%.2f",ShipXmin)..
- " - ShipYmin: "..string.format("%.2f",ShipYmin)..
- " - ShipZmin: "..string.format("%.2f",ShipZmin)..
- " - ShipXmax: "..string.format("%.2f",ShipXmax)..
- " - ShipYmax: "..string.format("%.2f",ShipYmax)..
- " - ShipZmax: "..string.format("%.2f",ShipZmax)
- )
-
- PrintConsole(
- "ShipX: "..string.format("%.2f",ShipX)..
- " - ShipY: "..string.format("%.2f",ShipY)..
- " - ShipZ: "..string.format("%.2f",ShipZ)
- )
- ]]
-
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].xp = math.abs(100/(ShipXmax-ShipXmin)*(element.x-ShipXmin))
- dmgoElements[i].yp = math.abs(100/(ShipYmax-ShipYmin)*(element.y-ShipYmin))
- dmgoElements[i].zp = math.abs(100/(ShipZmax-ShipZmin)*(element.z-ShipZmin))
- -- PrintConsole(i..". "..element.id..": "..string.format("%.2f",element.x).."/"..string.format("%.2f",element.y).."/"..string.format("%.2f",element.z).." - XP: "..dmgoElements[i].xp.." - YP: "..dmgoElements[i].yp.." - ZP: "..dmgoElements[i].zp)
- end
-
-end
-
-function UpdateViewDamageoutline(screen)
- -- Full Width of virtual screen:
- -- UStart = 20
- -- VStart = 180
- -- UDim = 1880
- -- VDim = 840
- -- Adding frames:
- UFrame = 40
- VFrame = 40
-
- UStart = 20 + UFrame
- VStart = 180 + VFrame
- UDim = 1880 - 2*UFrame
- VDim = 840 - 2*VFrame
-
- if screen.submode == "top" then
- if DMGOStretch == false then
- local UFactor = UDim/(ShipYmax-ShipYmin)
- local VFactor = VDim/(ShipXmax-ShipXmin)
- if UFactor>=VFactor then
- local cFactor = UFactor/VFactor
- local newUDim = math.floor(UDim/cFactor)
- UStart = UStart+(UDim-newUDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100/cFactor*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*element.xp+VStart)
- end
- else
- local cFactor = VFactor/UFactor
- local newVDim = math.floor(VDim/cFactor)
- VStart = VStart+(VDim-newVDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100/cFactor*element.xp+VStart)
- end
- end
- else
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*element.xp+VStart)
- end
- end
-
-
- elseif screen.submode == "front" then
- if DMGOStretch == false then
- local UFactor = UDim/(ShipXmax-ShipXmin)
- local VFactor = VDim/(ShipZmax-ShipZmin)
- if UFactor>=VFactor then
- local cFactor = UFactor/VFactor
- local newUDim = math.floor(UDim/cFactor)
- UStart = UStart+(UDim-newUDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100/cFactor*element.xp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- else
- local cFactor = VFactor/UFactor
- local newVDim = math.floor(VDim/cFactor)
- VStart = VStart+(VDim-newVDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.xp+UStart)
- dmgoElements[i].v = math.floor(VDim/100/cFactor*(100-element.zp)+VStart)
- end
- end
- else
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.xp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- end
-
- elseif screen.submode == "side" then
- if DMGOStretch == false then
- local UFactor = UDim/(ShipYmax-ShipYmin)
- local VFactor = VDim/(ShipXmax-ShipZmin)
- if UFactor>=VFactor then
- local cFactor = UFactor/VFactor
- local newUDim = math.floor(UDim/cFactor)
- UStart = UStart+(UDim-newUDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100/cFactor*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- else
- local cFactor = VFactor/UFactor
- local newVDim = math.floor(VDim/cFactor)
- VStart = VStart+(VDim-newVDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100/cFactor*(100-element.zp)+VStart)
- end
- end
- else
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- end
- else
- DrawCenteredText("ERROR: non-existing DMGO mode set.")
- PrintConsole("ERROR: non-existing DMGO mode set.")
- unit.exit()
- end
-end
-
-function GetDamageoutlineShip()
- local output = ""
-
- for i,element in ipairs(dmgoElements) do
- local cclass = ""
- local size = 1
-
- if element.type == "h" then
- cclass ="ch"
- elseif element.type == "d" then
- cclass = "cw"
- else
- cclass = "cc"
- end
- if element.id == highlightID then
- cclass = "f2"
- end
-
- if element.size > 0 and element.size < 1000 then
- size = 5
- elseif element.size >= 1000 and element.size < 2000 then
- size = 8
- elseif element.size >= 2000 and element.size < 5000 then
- size = 12
- elseif element.size >= 5000 and element.size < 10000 then
- size = 15
- elseif element.size >= 10000 and element.size < 20000 then
- size = 20
- elseif element.size >= 20000 then
- size = 30
- end
- output = output .. [[]]
- if element.id == highlightID then
- output = output .. [[]]
- output = output .. [[]]
- end
- end
-
- return output
-end
-
-function GetContentClickareas(screen)
- local output = ""
- if screen ~= nil and screen.ClickAreas ~= nil and #screen.ClickAreas > 0 then
- for i,ca in ipairs(screen.ClickAreas) do
- output = output ..
- [[]]
- end
- end
- return output
-end
-
-function GetElement1(x, y, width, height)
- x = x or 0
- y = y or 0
- width = width or 600
- height = height or 600
- local output = ""
- output = output ..
- [[
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetElement2(x, y)
- x = x or 0
- y = y or 0
- local output = ""
- output = output .. [[]]
- return output
-end
-
-function GetElementLogo(x, y, primaryC, secondaryC, tertiaryC)
- x = x or 812
- y = y or 380
- primaryC = primaryC or "f"
- secondaryC = secondaryC or "f2"
- tertiaryC = tertiaryC or "f3"
- local output = ""
- output = output .. [[
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetHeader(headertext)
- headertext = headertext or "ERROR: UNDEFINED"
- local output = ""
- output = output ..
- [[
- ]]..headertext..[[]]
- return output
-end
-
-function GetContentBackground(candidate, bgcolor)
- bgColor = ColorBackgroundPattern
-
- local output = ""
-
- if candidate == "dots" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' viewBox='0 0 4 4'%3E%3Cpath fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' d='M1 3h1v1H1V3zm2-2h1v1H3V1z'%3E%3C/path%3E%3C/svg%3E");]]
- elseif candidate == "rain" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='12' height='16' viewBox='0 0 12 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 .99C4 .445 4.444 0 5 0c.552 0 1 .45 1 .99v4.02C6 5.555 5.556 6 5 6c-.552 0-1-.45-1-.99V.99zm6 8c0-.546.444-.99 1-.99.552 0 1 .45 1 .99v4.02c0 .546-.444.99-1 .99-.552 0-1-.45-1-.99V8.99z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E");]]
- elseif candidate == "plus" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "signal" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='84' height='48' viewBox='0 0 84 48' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h12v6H0V0zm28 8h12v6H28V8zm14-8h12v6H42V0zm14 0h12v6H56V0zm0 8h12v6H56V8zM42 8h12v6H42V8zm0 16h12v6H42v-6zm14-8h12v6H56v-6zm14 0h12v6H70v-6zm0-16h12v6H70V0zM28 32h12v6H28v-6zM14 16h12v6H14v-6zM0 24h12v6H0v-6zm0 8h12v6H0v-6zm14 0h12v6H14v-6zm14 8h12v6H28v-6zm-14 0h12v6H14v-6zm28 0h12v6H42v-6zm14-8h12v6H56v-6zm0-8h12v6H56v-6zm14 8h12v6H70v-6zm0 8h12v6H70v-6zM14 24h12v6H14v-6zm14-8h12v6H28v-6zM14 8h12v6H14V8zM0 8h12v6H0V8z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E");]]
- elseif candidate == "deathstar" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='105' viewBox='0 0 80 105'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M20 10a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm15 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zM20 75a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zm30-65a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm0 65a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zM35 10a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zM5 45a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zm60 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10z' /%3E%3C/g%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "diamond" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='32' viewBox='0 0 16 32'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath fill-rule='evenodd' d='M0 24h4v2H0v-2zm0 4h6v2H0v-2zm0-8h2v2H0v-2zM0 0h4v2H0V0zm0 4h2v2H0V4zm16 20h-6v2h6v-2zm0 4H8v2h8v-2zm0-8h-4v2h4v-2zm0-20h-6v2h6V0zm0 4h-4v2h4V4zm-2 12h2v2h-2v-2zm0-8h2v2h-2V8zM2 8h10v2H2V8zm0 8h10v2H2v-2zm-2-4h14v2H0v-2zm4-8h6v2H4V4zm0 16h6v2H4v-2zM6 0h2v2H6V0zm0 24h2v2H6v-2z'/%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "hexagon" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='49' viewBox='0 0 28 49'%3E%3Cg fill-rule='evenodd'%3E%3Cg id='hexagons' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='nonzero'%3E%3Cpath d='M13.99 9.25l13 7.5v15l-13 7.5L1 31.75v-15l12.99-7.5zM3 17.9v12.7l10.99 6.34 11-6.35V17.9l-11-6.34L3 17.9zM0 15l12.98-7.5V0h-2v6.35L0 12.69v2.3zm0 18.5L12.98 41v8h-2v-6.85L0 35.81v-2.3zM15 0v7.5L27.99 15H28v-2.31h-.01L17 6.35V0h-2zm0 49v-8l12.99-7.5H28v2.31h-.01L17 42.15V49h-2z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "capsule" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='32' height='26' viewBox='0 0 32 26' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M14 0v3.994C14 7.864 10.858 11 7 11c-3.866 0-7-3.138-7-7.006V0h2v4.005C2 6.765 4.24 9 7 9c2.756 0 5-2.236 5-4.995V0h2zm0 26v-5.994C14 16.138 10.866 13 7 13c-3.858 0-7 3.137-7 7.006V26h2v-6.005C2 17.235 4.244 15 7 15c2.76 0 5 2.236 5 4.995V26h2zm2-18.994C16 3.136 19.142 0 23 0c3.866 0 7 3.138 7 7.006v9.988C30 20.864 26.858 24 23 24c-3.866 0-7-3.138-7-7.006V7.006zm2-.01C18 4.235 20.244 2 23 2c2.76 0 5 2.236 5 4.995v10.01C28 19.765 25.756 22 23 22c-2.76 0-5-2.236-5-4.995V6.995z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E");]]
- elseif candidate == "diagonal" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='6' height='6' viewBox='0 0 6 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'%3E%3Cpath d='M5 0h1L0 6V5zM6 5v1H5z'/%3E%3C/g%3E%3C/svg%3E");]]
- end
- return output;
-end
-
-function GetContentDamageHUDOutput()
- local hudWidth = 300
- local hudHeight = 165
- if #damagedElements > 0 or #brokenElements > 0 then hudHeight = 510 end
- local output = ""
-
- output = output .. [[
-
- ]]
- output = output .. [[]] ..
- [[]] ..
- [[]] ..
- [[]]..(YourShipsName=="Enter here" and ("Ship ID "..ShipID) or YourShipsName) .. [[]] ..
- [[]]
- if #brokenElements > 0 then
- output = output .. [[]]
- elseif #damagedElements > 0 then
- output = output .. [[]]
- else
- output = output .. [[]]
- end
-
- if #damagedElements > 0 or #brokenElements > 0 then
-
- output = output .. [[Total Damage]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", totalShipMaxHP - totalShipHP))..[[]]
- output = output .. [[T]]..ScrapTier..[[ Scrap Needed]] ..
- [[]]..getScraps(totalShipMaxHP - totalShipHP, true)..[[]]
- output = output .. [[Repair Time]] ..
- [[]]..getRepairTime(totalShipMaxHP - totalShipHP, true)..[[]]
-
- output = output .. [[]] ..
- [[]] ..
- [[]]..#healthyElements..[[]] ..
- [[]] ..
- [[]]..#damagedElements..[[]] ..
- [[]] ..
- [[]]..#brokenElements..[[]]
- local j=0
-
- for currentIndex=hudStartIndex,hudStartIndex+9,1 do
- if rE[currentIndex] ~= nil then
- v = rE[currentIndex]
- if v.hp > 0 then
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- if v.id == highlightID then
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- end
- else
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- if v.id == highlightID then
- highlightX = elementPosition.x - coreWorldOffset
- highlightY = elementPosition.y - coreWorldOffset
- highlightZ = elementPosition.z - coreWorldOffset
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- end
- end
- j=j+1
- end
- end
- output = output ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Up/down arrows to highlight]] ..
- [[CTRL + arrows to move HUD]] ..
- [[Left arrow to toggle HUD Mode]] ..
- [[ALT+1-4 to set Scrap Tier]] ..
- [[ALT+8 to reset HUD position]] ..
- [[ALT+9 to shut script off]] ..
- [[]] ..
- [[]]
- else
- output = output ..
- [[]] .. OkayCenterMessage .. [[]] ..
- [[]]..#healthyElements..[[ elements / ]] .. GenerateCommaValue(string.format("%.0f", totalShipMaxHP)) .. [[ HP.]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Left arrow to toggle HUD Mode]] ..
- [[CTRL + arrows to move HUD]] ..
- [[ALT+8 to reset HUD position]] ..
- [[ALT+9 to shut script off]] ..
- [[]] ..
- [[]]
- end
- output = output .. [[]]
- return output
-end
-
-function GetContentDamageScreen()
-
- local screenOutput = ""
-
- -- Draw damage elements
- if #damagedElements > 0 then
- local damagedElementsToDraw = #damagedElements
- if damagedElementsToDraw > DamagePageSize then
- damagedElementsToDraw = DamagePageSize
- end
- if CurrentDamagedPage == math.ceil(#damagedElements / DamagePageSize) then
- damagedElementsToDraw = #damagedElements % DamagePageSize + 12
- if damagedElementsToDraw > 12 then damagedElementsToDraw = damagedElementsToDraw - 12 end
- end
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
-
- if UseMyElementNames == true then screenOutput = screenOutput .. [[Damaged Name]]
- else screenOutput = screenOutput .. [[Damaged Type]]
- end
-
- screenOutput = screenOutput .. [[HLTHDMG]]
- screenOutput = screenOutput .. [[T]]..ScrapTier..[[ SCRREPTIME]]
-
- AddClickArea("damage", {
- id = "SwitchScrapTier",
- mode ="damage",
- x1 = 650,
- x2 = 775,
- y1 = 315,
- y2 = 360
- })
-
- local i = 0
- for j = 1 + (CurrentDamagedPage - 1) * DamagePageSize, damagedElementsToDraw + (CurrentDamagedPage - 1) * DamagePageSize, 1 do
- i = i + 1
- local DP = damagedElements[j]
- if UseMyElementNames == true then screenOutput = screenOutput .. [[]] .. string.format("%.23s", DP.name) .. [[]]
- else screenOutput = screenOutput .. [[]] .. string.format("%.23s", DP.type) .. [[]]
- end
- screenOutput = screenOutput .. [[]] .. DP.percent .. [[%]] ..
- [[]] .. GenerateCommaValue(string.format("%.0f", DP.missinghp), true) .. [[]] ..
- [[]] .. getScraps(DP.missinghp, true) .. [[]] ..
- [[]] .. getRepairTime(DP.missinghp, true) .. [[]] ..
- [[]]
- end
-
- if #damagedElements > DamagePageSize then
- screenOutput = screenOutput ..
- [[Page ]] .. CurrentDamagedPage .. " of " .. math.ceil(#damagedElements / DamagePageSize) ..[[]]
-
- if CurrentDamagedPage < math.ceil(#damagedElements / DamagePageSize) then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "DamagedPageDown",
- mode ="damage",
- x1 = 65,
- x2 = 260,
- y1 = 290 + (damagedElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (damagedElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("DamagedPageDown","damage")
- end
-
- if CurrentDamagedPage > 1 then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "DamagedPageUp",
- mode ="damage",
- x1 = 750,
- x2 = 950,
- y1 = 290 + (damagedElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (damagedElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("DamagedPageUp","damage")
- end
- end
- end
-
- -- Draw broken elements
- if #brokenElements > 0 then
- local brokenElementsToDraw = #brokenElements
- if brokenElementsToDraw > DamagePageSize then
- brokenElementsToDraw = DamagePageSize
- end
- if CurrentBrokenPage == math.ceil(#brokenElements / DamagePageSize) then
- brokenElementsToDraw = #brokenElements % DamagePageSize + 12
- if brokenElementsToDraw > 12 then brokenElementsToDraw = brokenElementsToDraw - 12 end
- end
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
-
- if UseMyElementNames == true then screenOutput = screenOutput .. [[Broken Name]]
- else screenOutput = screenOutput .. [[Broken Type]]
- end
-
- screenOutput = screenOutput .. [[DMG]]
- screenOutput = screenOutput .. [[T]]..ScrapTier..[[ SCRREPTIME]]
-
- AddClickArea("damage", {
- id = "SwitchScrapTier2",
- mode ="damage",
- x1 = 1570,
- x2 = 1690,
- y1 = 315,
- y2 = 360
- })
-
- local i = 0
- for j = 1 + (CurrentBrokenPage - 1) * DamagePageSize, brokenElementsToDraw + (CurrentBrokenPage - 1) * DamagePageSize, 1 do
- i = i + 1
- local DP = brokenElements[j]
- if UseMyElementNames == true then screenOutput = screenOutput .. [[]] .. string.format("%.30s", DP.name) .. [[]]
- else screenOutput = screenOutput .. [[]] .. string.format("%.30s", DP.type) .. [[]]
- end
- screenOutput = screenOutput .. [[]] .. GenerateCommaValue(string.format("%.0f", DP.missinghp), true) .. [[]] ..
- [[]] .. getScraps(DP.missinghp, true) .. [[]] ..
- [[]] .. getRepairTime(DP.missinghp, true) .. [[]] ..
- [[]]
- end
-
-
-
- if #brokenElements > DamagePageSize then
- screenOutput = screenOutput ..
- [[Page ]] .. CurrentBrokenPage .. " of " .. math.ceil(#brokenElements / DamagePageSize) .. [[]]
-
- if CurrentBrokenPage > 1 then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "BrokenPageUp",
- mode ="damage",
- x1 = 1665,
- x2 = 1865,
- y1 = 290 + (brokenElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (brokenElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("BrokenPageUp", "damage")
- end
-
- if CurrentBrokenPage < math.ceil(#brokenElements / DamagePageSize) then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "BrokenPageDown",
- mode ="damage",
- x1 = 980,
- x2 = 1180,
- y1 = 290 + (brokenElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (brokenElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("BrokenPageDown", "damage")
- end
- end
-
- end
-
- -- Draw summary
- if #damagedElements > 0 or #brokenElements > 0 then
- local dWidth = math.floor(1878/#elementsIdList*#damagedElements)
- local bWidth = math.floor(1878/#elementsIdList*#brokenElements)
- local hWidth = 1878-dWidth-bWidth+1
-
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
-
- if #damagedElements > 0 then
- screenOutput = screenOutput .. [[]]..#damagedElements..[[]]
- end
- if #healthyElements > 0 then
- screenOutput = screenOutput .. [[]]..#healthyElements..[[]]
- end
- if #brokenElements > 0 then
- screenOutput = screenOutput .. [[]]..#brokenElements..[[]]
- end
-
- screenOutput = screenOutput .. [[]]
-
- screenOutput = screenOutput .. [[]] ..
- GenerateCommaValue(string.format("%.0f", totalShipMaxHP - totalShipHP)) .. [[ HP damage in total ]] ..
- getScraps(totalShipMaxHP - totalShipHP, true) .. [[ T]]..ScrapTier..[[ scraps needed. ]] ..
- getRepairTime(totalShipMaxHP - totalShipHP, true) .. [[ projected repair time.]]
- else
- screenOutput = screenOutput .. GetElementLogo(812, 380, "ch", "ch", "ch") ..
- [[]] .. OkayCenterMessage .. [[]] ..
- [[]]..#healthyElements..[[ elements stand ]] .. GenerateCommaValue(string.format("%.0f", totalShipMaxHP)) .. [[ HP strong.]]
- end
-
- forceDamageRedraw = false
-
- return screenOutput
-end
-
-function ActionStopengines()
- ToggleHUD()
-end
-
-function ActionStrafeRight()
- if KeyCTRLPressed == true then
- if HUDShiftU < 4000 then
- HUDShiftU = HUDShiftU + 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- HudDeselectElement()
- end
-end
-
-function ActionStrafeLeft()
- if KeyCTRLPressed == true then
- if HUDShiftU >= 50 then
- HUDShiftU = HUDShiftU - 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- ToggleHUD()
- end
-end
-
-function ActionDown()
- if KeyCTRLPressed == true then
- if HUDShiftV < 4000 then
- HUDShiftV = HUDShiftV + 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- ChangeHudSelectedElement(1)
- end
-end
-
-function ActionUp()
- if KeyCTRLPressed == true then
- if HUDShiftV >= 50 then
- HUDShiftV = HUDShiftV - 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- ChangeHudSelectedElement(-1)
- end
-end
-
-function ActionOption1()
- ScrapTier = 1
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption2()
- ScrapTier = 2
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption3()
- ScrapTier = 3
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption4()
- ScrapTier = 4
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption8()
- HUDShiftU=0
- HUDShiftV=0
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption9()
- SaveToDatabank()
- SwitchScreens("off")
- unit.exit()
-end
diff --git a/src/DamageReport_3_01_UnitStart_2.lua b/src/DamageReport_3_01_UnitStart_2.lua
deleted file mode 100644
index 16a077c..0000000
--- a/src/DamageReport_3_01_UnitStart_2.lua
+++ /dev/null
@@ -1,2148 +0,0 @@
---[[
- Damage Report 3.0
- A LUA script for Dual Universe
-
- Created By Dorian GrayY.percent
- Ingame: DorianGray
- Discord: Dorian Gray#2623
-
- You can find/update this script on GitHub. Explanations, installation and usage information as well as screenshots can be found there too.
- GitHub: https://github.com/DorianTheGrey/DU-DamageReport
-
- GNU Public License 3.0. Use whatever you want, be so kind to leave credit.
-
- Credits & thanks:
- Thanks to NovaQuark for creating the MMO of the century.
- Thanks to Jericho, Dmentia and Archaegeo for learning a lot from their fine scripts.
- Thanks to TheBlacklist for testing and wonderful suggestions.
- SVG patterns by Hero Patterns.
- DU atlas data from Jayle Break.
-
-]]
-
---[[ 1. USER DEFINED VARIABLES ]]
-
-YourShipsName = "Enter here" --export Enter your ship name here if you want it displayed instead of the ship's ID. YOU NEED TO LEAVE THE QUOTATION MARKS.
-ShowWelcomeMessage = true --export Do you want the welcome message on the start screen with your name?
-AddSummertimeHour = false --export: Is summertime currently enabled in your location? (Adds one hour.)
-
---[[ 2. GLOBAL VARIABLES ]]
-
-UpdateDataInterval = 1.0 -- How often shall the data be updated? (Increase if running into CPU issues.)
-HighlightBlinkingInterval = 0.5 -- How fast shall highlight arrows of marked elements blink?
-
-ColorPrimary = "FF6700" -- Enter the hexcode of the main color to be used by all views.
-ColorSecondary = "FFFFFF" -- Enter the hexcode of the secondary color to be used by all views.
-ColorTertiary = "000000" -- Enter the hexcode of the tertiary color to be used by all views.
-ColorHealthy = "00FF00" -- Enter the hexcode of the 'healthy' color to be used by all views.
-ColorWarning = "FFFF00" -- Enter the hexcode of the 'warning' color to be used by all views.
-ColorCritical = "FF0000" -- Enter the hexcode of the 'critical' color to be used by all views.
-ColorBackground = "000000" -- Enter the hexcode of the background color to be used by all views.
-ColorBackgroundPattern = "4F4F4F" -- Enter the hexcode of the background color to be used by all views.
-ColorFuelAtmospheric = "004444" -- Enter the hexcode of the atmospheric fuel color.
-ColorFuelSpace = "444400" -- Enter the hexcode of the space fuel color.
-ColorFuelRocket = "440044" -- Enter the hexcode of the rocket fuel color.
-
-VERSION = 3.0
-DebugMode = false
-DebugRenderClickareas = true
-
-DBData = {}
-
-core = nil
-db = nil
-screens = {}
-dscreens = {}
-
-screenModes = {
- ["flight"] = { id="flight" },
- ["damage"] = { id="damage" },
- ["damageoutline"] = { id="damageoutline" },
- ["fuel"] = { id="fuel" },
- ["cargo"] = { id="cargo" },
- ["agg"] = { id="agg" },
- ["map"] = { id="map" },
- ["time"] = { id="time", activetoggle="true" },
- ["settings1"] = { id="settings1" },
- ["startup"] = { id="startup" }
-}
-
-backgroundModes = { "deathstar", "capsule", "rain", "signal", "hexagon", "diagonal", "diamond", "plus", "dots" }
-BackgroundMode ="deathstar"
-BackgroundSelected = 1
-BackgroundModeOpacity = 0.25
-
-SaveVars = { "dscreens", "YourShipsName", "AddSummertimeHour",
- "ColorPrimary", "ColorSecondary", "ColorTertiary",
- "ColorHealthy", "ColorWarning", "ColorCritical",
- "ColorBackground", "ColorBackgroundPattern",
- "UpdateDataInterval", "HighlightBlinkingInterval",
- "ScrapTier", "HUDMode", "SimulationMode", "DMGOStretch",
- "HUDShiftU", "HUDShiftV", "colorIDIndex", "colorIDTable",
- "SkillRepairToolEfficiency", "SkillRepairToolOptimization",
- "SkillAtmosphericFuelEfficiency", "SkillSpaceFuelEfficiency", "SkillRocketFuelEfficiency",
- "StatAtmosphericFuelTankHandling", "StatSpaceFuelTankHandling", "StatRocketFuelTankHandling",
- "BackgroundMode", "BackgroundSelected", "BackgroundModeOpacity" }
-
-HUDMode = false
-HUDShiftU = 0
-HUDShiftV = 0
-hudSelectedIndex = 0
-hudStartIndex = 1
-hudArrowSticker = {}
-highlightOn = false
-highlightID = 0
-highlightX = 0
-highlightY = 0
-highlightZ = 0
-
-SimulationMode = false
-OkayCenterMessage = "All systems nominal."
-CurrentDamagedPage = 1
-CurrentBrokenPage = 1
-DamagePageSize = 12
-ScrapTier = 1
-totalScraps = 0
-ScrapTierRepairTimes = { 10, 50, 250, 1250 }
-
-coreWorldOffset = 0
-totalShipHP = 0
-formerTotalShipHP = -1
-totalShipMaxHP = 0
-totalShipIntegrity = 100
-elementsId = {}
-elementsIdList = {}
-damagedElements = {}
-brokenElements = {}
-rE = {}
-healthyElements = {}
-typeElements = {}
-ElementCounter = 0
-UseMyElementNames = true
-dmgoElements = {}
-DMGOMaxElements = 250
-DMGOStretch = false
-ShipXmin = 99999999
-ShipXmax = -99999999
-ShipYmin = 99999999
-ShipYmax = -99999999
-ShipZmin = 99999999
-ShipZmax = -99999999
-
-totalShipMass = 0
-formerTotalShipMass = -1
-
-formerTime = -1
-
-FuelAtmosphericTanks = {}
-FuelSpaceTanks = {}
-FuelRocketTanks = {}
-FuelAtmosphericTotal = 0
-FuelSpaceTotal = 0
-FuelRocketTotal = 0
-FuelAtmosphericCurrent = 0
-FuelSpaceTotalCurrent = 0
-FuelRocketTotalCurrent = 0
-formerFuelAtmosphericTotal = -1
-formerFuelSpaceTotal = -1
-formerFuelRocketTotal = -1
-
-SkillRepairToolEfficiency = 0
-SkillRepairToolOptimization = 0
-
-SkillAtmosphericFuelEfficiency = 0
-SkillSpaceFuelEfficiency = 0
-SkillRocketFuelEfficiency = 0
-
-StatAtmosphericFuelTankHandling = 0
-StatSpaceFuelTankHandling = 0
-StatRocketFuelTankHandling = 0
-
-
-hexTable = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"}
-colorIDIndex = 1
-colorIDTable = {
- [1] = {
- id="ColorPrimary",
- desc="Main HUD Color",
- basec = "FF6700",
- newc = "FF6700"
- },
- [2] = {
- id="ColorSecondary",
- desc="Secondary HUD Color",
- basec = "FFFFFF",
- newc = "FFFFFF"
- },
- [3] = {
- id="ColorTertiary",
- desc="Tertiary HUD Color",
- basec = "000000",
- newc = "000000"
- },
- [4] = {
- id="ColorHealthy",
- desc="Color code for Healthy/Okay",
- basec = "00FF00",
- newc = "00FF00"
- },
- [5] = {
- id="ColorWarning",
- desc="Color code for Damaged/Warning",
- basec = "FFFF00",
- newc = "FFFF00"
- },
- [6] = {
- id="ColorCritical",
- desc="Color code for Broken/Critical",
- basec = "FF0000",
- newc = "FF0000"
- },
- [7] = {
- id="ColorBackground",
- desc="Background Color",
- basec = "000000",
- newc = "000000"
- },
- [8] = {
- id="ColorBackgroundPattern",
- desc="Background Pattern Color",
- basec = "4F4F4F",
- newc = "4F4F4F"
- },
- [9] = {
- id="ColorFuelAtmospheric",
- desc="Color for Atmo Fuel/Elements",
- basec = "004444",
- newc = "004444"
- },
- [10] = {
- id="ColorFuelSpace",
- desc="Color for Space Fuel/Elements",
- basec = "444400",
- newc = "444400"
- },
- [11] = {
- id="ColorFuelRocket",
- desc="Color for Rocket Fuel/Elements",
- basec = "440044",
- newc = "440044"
- }
-}
-
-
---[[ 3. PROCESSING FUNCTIONS ]]
-
-function InitiateSlots()
- for slot_name, slot in pairs(unit) do
- if type(slot) == "table" and type(slot.export) == "table" and
- slot.getElementClass then
- local elementClass = slot.getElementClass():lower()
- if elementClass:find("coreunit") then
- core = slot
- local coreHP = core.getMaxHitPoints()
- if coreHP > 10000 then
- coreWorldOffset = 128
- elseif coreHP > 1000 then
- coreWorldOffset = 64
- elseif coreHP > 150 then
- coreWorldOffset = 32
- else
- coreWorldOffset = 16
- end
- elseif elementClass == 'databankunit' then
- db = slot
- elseif elementClass == "screenunit" then
- local iScreenMode = "startup"
- screens[#screens + 1] = {
- element = slot,
- id = slot.getId(),
- mode = iScreenMode,
- submode = "",
- ClickAreas = {},
- refresh = true,
- active = false,
- fuelA = true,
- fuelS = true,
- fuelR = true,
- fuelIndex = 1
- }
- end
- end
- end
-end
-
-function LoadFromDatabank()
- if db == nil then
- return
- else
- for _, data in pairs(SaveVars) do
- if db.hasKey(data) then
- local jData = json.decode( db.getStringValue(data) )
- if jData ~= nil then
- if data == "YourShipsName" or data == "AddSummertimeHour" or data == "UpdateDataInterval" or data == "HighlightBlinkingInterval" then
- else
- _G[data] = jData
- end
- end
- end
- end
-
- for i,v in ipairs(screens) do
- for j,dv in ipairs(dscreens) do
- if screens[i].id == dscreens[j].id then
- screens[i].mode = dscreens[j].mode
- screens[i].submode = dscreens[j].submode
- screens[i].active = dscreens[j].active
- screens[i].refresh = true
- screens[i].fuelA = dscreens[j].fuelA
- screens[i].fuelS = dscreens[j].fuelS
- screens[i].fuelR = dscreens[j].fuelR
- screens[i].fuelIndex = dscreens[j].fuelIndex
- end
- end
- end
- end
-end
-
-function SaveToDatabank()
- if db == nil then
- return
- else
- dscreens = {}
- for i,screen in ipairs(screens) do
- dscreens[i] = {}
- dscreens[i].id = screen.id
- dscreens[i].mode = screen.mode
- dscreens[i].submode = screen.submode
- dscreens[i].active = screen.active
- dscreens[i].fuelA = screen.fuelA
- dscreens[i].fuelS = screen.fuelS
- dscreens[i].fuelR = screen.fuelR
- dscreens[i].fuelIndex = screen.fuelIndex
- end
-
- db.clear()
-
- for _, data in pairs(SaveVars) do
- if data == "YourShipsName" or data == "AddSummertimeHour" or data == "UpdateDataInterval" or data == "HighlightBlinkingInterval" then
- else
- db.setStringValue(data, json.encode(_G[data]))
- end
- end
-
- end
-end
-
-function InitiateScreens()
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- screens[i] = CreateClickAreasForScreen(screens[i])
- end
- end
-end
-
-function UpdateTypeData()
- FuelAtmosphericTanks = {}
- FuelSpaceTanks = {}
- FuelRocketTanks = {}
-
- FuelAtmosphericTotal = 0
- FuelAtmosphericCurrent = 0
- FuelSpaceTotal = 0
- FuelSpaceCurrent = 0
- FuelRocketCurrent = 0
- FuelRocketTotal = 0
-
- local weightAtmosphericFuel = 4
- local weightSpaceFuel = 6
- local weightRocketFuel = 0.8
-
- for i, id in ipairs(typeElements) do
- local idName = core.getElementNameById(id) or ""
- local idType = core.getElementTypeById(id) or ""
- -- local idTypeClean = idType:gsub("[%s%-]+", ""):lower()
- local idPos = core.getElementPositionById(id) or 0
- local idHP = core.getElementHitPointsById(id) or 0
- local idMaxHP = core.getElementMaxHitPointsById(id) or 0
- local idMass = core.getElementMassById(id) or 0
-
- local baseSize = ""
- local baseVol = 0
- local baseMass = 0
- local cMass = 0
- local cVol = 0
-
- if idType == "atmospheric fuel-tank" then
- if idMaxHP > 10000 then
- baseSize = "L"
- baseMass = 5480
- baseVol = 12800
- elseif idMaxHP > 1300 then
- baseSize = "M"
- baseMass = 988.67
- baseVol = 1600
- elseif idMaxHP > 150 then
- baseSize = "S"
- baseMass = 182.67
- baseVol = 400
- else
- baseSize = "XS"
- baseMass = 35.03
- baseVol = 100
- end
- if StatAtmosphericFuelTankHandling > 0 then
- baseVol = 0.2 * StatAtmosphericFuelTankHandling * baseVol + baseVol
- end
- cMass = idMass - baseMass
- if cMass <=10 then cMass = 0 end
- cVol = string.format("%.0f", cMass / weightAtmosphericFuel)
- cPercent = string.format("%.1f", math.floor(100/baseVol * tonumber(cVol)))
- table.insert(FuelAtmosphericTanks, {
- type = 1,
- id = id,
- name = idName,
- maxhp = idMaxHP,
- hp = GetHPforElement(id),
- pos = idPos,
- size = baseSize,
- mass = baseMass,
- vol = baseVol,
- cvol = cVol,
- percent = cPercent
- })
- if idHP > 0 then
- FuelAtmosphericCurrent = FuelAtmosphericCurrent + cVol
- end
- FuelAtmosphericTotal = FuelAtmosphericTotal + baseVol
- elseif idType == "space fuel-tank" then
- if idMaxHP > 10000 then
- baseSize = "L"
- baseMass = 5480
- baseVol = 12800
- elseif idMaxHP > 1300 then
- baseSize = "M"
- baseMass = 988.67
- baseVol = 1600
- else
- baseSize = "S"
- baseMass = 182.67
- baseVol = 400
- end
- if StatSpaceFuelTankHandling > 0 then
- baseVol = 0.2 * StatSpaceFuelTankHandling * baseVol + baseVol
- end
- cMass = idMass - baseMass
- if cMass <=10 then cMass = 0 end
- cVol = string.format("%.0f", cMass / weightSpaceFuel)
- cPercent = string.format("%.1f", (100/baseVol * tonumber(cVol)))
- table.insert(FuelSpaceTanks, {
- type = 2,
- id = id,
- name = idName,
- maxhp = idMaxHP,
- hp = GetHPforElement(id),
- pos = idPos,
- size = baseSize,
- mass = baseMass,
- vol = baseVol,
- cvol = cVol,
- percent = cPercent
- })
- if idHP > 0 then
- FuelSpaceCurrent = FuelSpaceCurrent + cVol
- end
- FuelSpaceTotal = FuelSpaceTotal + baseVol
- elseif idType == "rocket fuel-tank" then
- if idMaxHP > 65000 then
- baseSize = "L"
- baseMass = 25740
- baseVol = 50000
- elseif idMaxHP > 6000 then
- baseSize = "M"
- baseMass = 4720
- baseVol = 6400
- elseif idMaxHP == 700 then
- baseSize = "S"
- baseMass = 886.72
- baseVol = 800
- else
- baseSize = "XS"
- baseMass = 173.42
- baseVol = 400
- end
- if StatRocketFuelTankHandling > 0 then
- baseVol = 0.2 * StatRocketFuelTankHandling * baseVol + baseVol
- end
- cMass = idMass - baseMass
- if cMass <=10 then cMass = 0 end
- cVol = string.format("%.0f", cMass / weightRocketFuel)
- cPercent = string.format("%.1f", (100/baseVol * tonumber(cVol)))
- table.insert(FuelRocketTanks, {
- type = 3,
- id = id,
- name = idName,
- maxhp = idMaxHP,
- hp = GetHPforElement(id),
- pos = idPos,
- size = baseSize,
- mass = baseMass,
- vol = baseVol,
- cvol = cVol,
- percent = cPercent
- })
- if idHP > 0 then
- FuelRocketCurrent = FuelRocketCurrent + cVol
- end
- FuelRocketTotal = FuelRocketTotal + baseVol
- end
-
- end
-
- if FuelAtmosphericCurrent ~= formerFuelAtmosphericCurrent then
- SetRefresh("fuel")
- formerFuelAtmosphericCurrent = FuelAtmosphericCurrent
- end
- if FuelSpaceCurrent ~= formerFuelSpaceCurrent then
- SetRefresh("fuel")
- formerFuelSpaceCurrent = FuelSpaceCurrent
- end
- if FuelRocketCurrent ~= formerFuelRocketCurrent then
- SetRefresh("fuel")
- formerFuelRocketCurrent = FuelRocketCurrent
- end
-
-end
-
-function UpdateDamageData(initial)
-
- initial = initial or false
-
- if SimulationActive == true then return end
-
- local formerTotalShipHP = totalShipHP
- totalShipHP = 0
- totalShipMaxHP = 0
- totalShipIntegrity = 100
- damagedElements = {}
- brokenElements = {}
- healthyElements = {}
- ElementCounter = 0
-
- elementsIdList = core.getElementIdList()
-
- for i, id in pairs(elementsIdList) do
-
- ElementCounter = ElementCounter + 1
-
- local idName = core.getElementNameById(id)
-
- local idType = core.getElementTypeById(id)
- -- local idTypeClean = idType:gsub("[%s%-]+", ""):lower()
- local idPos = core.getElementPositionById(id)
- local idHP = core.getElementHitPointsById(id)
- local idMaxHP = core.getElementMaxHitPointsById(id)
- -- local idMass = core.getElementMassById(id)
-
- if SimulationMode == true then
- SimulationActive = true
- local dice = math.random(0, 10)
- if dice < 2 and #brokenElements < 30 then
- idHP = 0
- elseif dice >= 2 and dice < 4 and #damagedElements < 30 then
- idHP = math.random(1, math.ceil(idMaxHP))
- else
- idHP = idMaxHP
- end
- end
-
- totalShipHP = totalShipHP + idHP
- totalShipMaxHP = totalShipMaxHP + idMaxHP
-
- if idMaxHP - idHP > constants.epsilon then
-
- if idHP > 0 then
- table.insert(damagedElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP - idHP,
- percent = math.ceil(100 / idMaxHP * idHP),
- pos = idPos
- })
- else
- table.insert(brokenElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP - idHP,
- percent = 0,
- pos = idPos
- })
- end
- else
- table.insert(healthyElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- pos = idPos
- })
- if id == highlightID then
- highlightID = 0
- highlightOn = false
- HideHighlight()
- hudSelectedIndex = 0
- end
- end
-
- if initial == true then
- if
- idType == "atmospheric fuel-tank" or
- idType == "space fuel-tank" or
- idType == "rocket fuel-tank"
- then
- table.insert(typeElements, id)
- end
- end
- end
-
- SortDamageTables()
-
- rE = {}
- if #brokenElements > 0 then
- for _,v in ipairs(brokenElements) do
- table.insert(rE, {id=v.id, missinghp=v.missinghp, hp=v.hp, name=v.name, type=v.type, pos=v.pos})
- end
- end
- if #damagedElements > 0 then
- for _,v in ipairs(damagedElements) do
- table.insert(rE, {id=v.id, missinghp=v.missinghp, hp=v.hp, name=v.name, type=v.type, pos=v.pos})
- end
- end
- if #rE > 0 then
- table.sort(rE, function(a,b) return a.missinghp>b.missinghp end)
- end
-
- totalShipIntegrity = string.format("%2.0f", 100 / totalShipMaxHP * totalShipHP)
-
- if formerTotalShipHP ~= totalShipHP then
- forceDamageRedraw = true
- formerTotalShipHP = totalShipHP
- else
- forceDamageRedraw = false
- end
-end
-
-function GetHPforElement(id)
- for i,v in ipairs(brokenElements) do
- if v.id == id then
- return 0
- end
- end
- for i,v in ipairs(damagedElements) do
- if v.id == id then
- return v.hp
- end
- end
- for i,v in ipairs(healthyElements) do
- if v.id == id then
- return v.maxhp
- end
- end
-end
-
-function UpdateClickArea(candidate, newEntry, mode)
- for i, screen in ipairs(screens) do
- for k, v in pairs(screens[i].ClickAreas) do
- if v.id == candidate and v.mode == mode then
- screens[i].ClickAreas[k] = newEntry
- end
- end
- end
-end
-
-function AddClickArea(mode, newEntry)
- for i, screen in ipairs(screens) do
- if screens[i].mode == mode then
- table.insert(screens[i].ClickAreas, newEntry)
- end
- end
-end
-
-function AddClickAreaForScreenID(screenid, newEntry)
- for i, screen in ipairs(screens) do
- if screens[i].id == screenid then
- table.insert(screens[i].ClickAreas, newEntry)
- end
- end
-end
-
-function DisableClickArea(candidate, mode)
- UpdateClickArea(candidate, {
- id = candidate,
- mode = mode,
- x1 = -1,
- x2 = -1,
- y1 = -1,
- y2 = -1
- })
-end
-
-function SetRefresh(mode, submode)
- mode = mode or "all"
- submode = submode or "all"
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- if screens[i].mode == mode or mode == "all" then
- if screens[i].submode == submode or submode =="all" then
- screens[i].refresh = true
- end
- end
- end
- end
-end
-
-function WipeClickAreasForScreen(screen)
- screen.ClickAreas = {}
- return screen
-end
-
-function CreateBaseClickAreas(screen)
- table.insert(screen.ClickAreas, {mode = "all", id = "ToggleHudMode", x1 = 1537, x2 = 1728, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "damage", x1 = 193, x2 = 384, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "damageoutline", x1 = 385, x2 = 576, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "fuel", x1 = 577, x2 = 768, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "flight", x1 = 769, x2 = 960, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "cargo", x1 = 961, x2 = 1152, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "agg", x1 = 1153, x2 = 1344, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "map", x1 = 1345, x2 = 1536, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "time", x1 = 0, x2 = 192, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "settings1", x1 = 1729, x2 = 1920, y1 = 1015, y2 = 1075} )
- return screen
-end
-
-function CreateClickAreasForScreen(screen)
-
- if screen == nil then return {} end
-
- if screen.mode == "flight" then
- elseif screen.mode == "damage" then
- table.insert( screen.ClickAreas, {mode = "damage", id = "ToggleElementLabel", x1 = 70, x2 = 425, y1 = 325, y2 = 355} )
- table.insert( screen.ClickAreas, {mode = "damage", id = "ToggleElementLabel2", x1 = 980, x2 = 1400, y1 = 325, y2 = 355} )
- elseif screen.mode == "damageoutline" then
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeView", param = "top", x1 = 60, x2 = 439, y1 = 150, y2 = 200} )
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeView", param = "side", x1 = 440, x2 = 824, y1 = 150, y2 = 200} )
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeView", param = "front", x1 = 825, x2 = 1215, y1 = 150, y2 = 200} )
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeStretch", x1 = 1530, x2 = 1580, y1 = 150, y2 = 200} )
- elseif screen.mode == "fuel" then
- elseif screen.mode == "cargo" then
- elseif screen.mode == "agg" then
- elseif screen.mode == "map" then
- elseif screen.mode == "time" then
- elseif screen.mode == "settings1" then
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ToggleBackground", x1 = 75, x2 = 860, y1 = 170, y2 = 215} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "PreviousBackground", x1 = 75, x2 = 460, y1 = 235, y2 = 285} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "NextBackground", x1 = 480, x2 = 860, y1 = 235, y2 = 285} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "DecreaseOpacity", x1 = 75, x2 = 460, y1 = 300, y2 = 350} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "IncreaseOpacity", x1 = 480, x2 = 860, y1 = 300, y2 = 350} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ResetColors", x1 = 75, x2 = 860, y1 = 370, y2 = 415} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "PreviousColorID", x1 = 90, x2 = 140, y1 = 500, y2 = 550} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "NextColorID", x1 = 795, x2 = 845, y1 = 500, y2 = 550} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="1", x1 = 210, x2 = 290, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="2", x1 = 300, x2 = 380, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="3", x1 = 385, x2 = 465, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="4", x1 = 470, x2 = 550, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="5", x1 = 560, x2 = 640, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="6", x1 = 645, x2 = 725, y1 = 655, y2 = 700} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="1", x1 = 210, x2 = 290, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="2", x1 = 300, x2 = 380, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="3", x1 = 385, x2 = 465, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="4", x1 = 470, x2 = 550, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="5", x1 = 560, x2 = 640, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="6", x1 = 645, x2 = 725, y1 = 740, y2 = 780} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ResetPosColor", x1 = 160, x2 = 340, y1 = 885, y2 = 935} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ApplyPosColor", x1 = 355, x2 = 780, y1 = 885, y2 = 935} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillRepairToolEfficiency", 0}, x1 = 1060, x2 = 1115, y1 = 260, y2 = 280} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillRepairToolEfficiency", 1}, x1 = 1215, x2 = 1295, y1 = 260, y2 = 280} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillRepairToolEfficiency", 2}, x1 = 1305, x2 = 1385, y1 = 260, y2 = 280} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillRepairToolEfficiency", 3}, x1 = 1390, x2 = 1470, y1 = 260, y2 = 280} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillRepairToolEfficiency", 4}, x1 = 1475, x2 = 1555, y1 = 260, y2 = 280} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillRepairToolEfficiency", 5}, x1 = 1565, x2 = 1645, y1 = 260, y2 = 280} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillRepairToolOptimization", 0}, x1 = 1060, x2 = 1115, y1 = 325, y2 = 345} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillRepairToolOptimization", 1}, x1 = 1215, x2 = 1295, y1 = 325, y2 = 345} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillRepairToolOptimization", 2}, x1 = 1305, x2 = 1385, y1 = 325, y2 = 345} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillRepairToolOptimization", 3}, x1 = 1390, x2 = 1470, y1 = 325, y2 = 345} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillRepairToolOptimization", 4}, x1 = 1475, x2 = 1555, y1 = 325, y2 = 345} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillRepairToolOptimization", 5}, x1 = 1565, x2 = 1645, y1 = 325, y2 = 345} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillAtmosphericFuelEfficiency", 0}, x1 = 1060, x2 = 1115, y1 = 390, y2 = 410} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillAtmosphericFuelEfficiency", 1}, x1 = 1215, x2 = 1295, y1 = 390, y2 = 410} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillAtmosphericFuelEfficiency", 2}, x1 = 1305, x2 = 1385, y1 = 390, y2 = 410} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillAtmosphericFuelEfficiency", 3}, x1 = 1390, x2 = 1470, y1 = 390, y2 = 410} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillAtmosphericFuelEfficiency", 4}, x1 = 1475, x2 = 1555, y1 = 390, y2 = 410} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillAtmosphericFuelEfficiency", 5}, x1 = 1565, x2 = 1645, y1 = 390, y2 = 410} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillSpaceFuelEfficiency", 0}, x1 = 1060, x2 = 1115, y1 = 460, y2 = 480} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillSpaceFuelEfficiency", 1}, x1 = 1215, x2 = 1295, y1 = 460, y2 = 480} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillSpaceFuelEfficiency", 2}, x1 = 1305, x2 = 1385, y1 = 460, y2 = 480} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillSpaceFuelEfficiency", 3}, x1 = 1390, x2 = 1470, y1 = 460, y2 = 480} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillSpaceFuelEfficiency", 4}, x1 = 1475, x2 = 1555, y1 = 460, y2 = 480} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillSpaceFuelEfficiency", 5}, x1 = 1565, x2 = 1645, y1 = 460, y2 = 480} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillRocketFuelEfficiency", 0}, x1 = 1060, x2 = 1115, y1 = 525, y2 = 545} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillRocketFuelEfficiency", 1}, x1 = 1215, x2 = 1295, y1 = 525, y2 = 545} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillRocketFuelEfficiency", 2}, x1 = 1305, x2 = 1385, y1 = 525, y2 = 545} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillRocketFuelEfficiency", 3}, x1 = 1390, x2 = 1470, y1 = 525, y2 = 545} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillRocketFuelEfficiency", 4}, x1 = 1475, x2 = 1555, y1 = 525, y2 = 545} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"SkillRocketFuelEfficiency", 5}, x1 = 1565, x2 = 1645, y1 = 525, y2 = 545} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"StatAtmosphericFuelTankHandling", 0}, x1 = 1060, x2 = 1115, y1 = 590, y2 = 610} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"StatAtmosphericFuelTankHandling", 1}, x1 = 1215, x2 = 1295, y1 = 590, y2 = 610} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"StatAtmosphericFuelTankHandling", 2}, x1 = 1305, x2 = 1385, y1 = 590, y2 = 610} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"StatAtmosphericFuelTankHandling", 3}, x1 = 1390, x2 = 1470, y1 = 590, y2 = 610} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"StatAtmosphericFuelTankHandling", 4}, x1 = 1475, x2 = 1555, y1 = 590, y2 = 610} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"StatAtmosphericFuelTankHandling", 5}, x1 = 1565, x2 = 1645, y1 = 590, y2 = 610} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"StatSpaceFuelTankHandling", 0}, x1 = 1060, x2 = 1115, y1 = 660, y2 = 680} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"StatSpaceFuelTankHandling", 1}, x1 = 1215, x2 = 1295, y1 = 660, y2 = 680} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"StatSpaceFuelTankHandling", 2}, x1 = 1305, x2 = 1385, y1 = 660, y2 = 680} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"StatSpaceFuelTankHandling", 3}, x1 = 1390, x2 = 1470, y1 = 660, y2 = 680} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"StatSpaceFuelTankHandling", 4}, x1 = 1475, x2 = 1555, y1 = 660, y2 = 680} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"StatSpaceFuelTankHandling", 5}, x1 = 1565, x2 = 1645, y1 = 660, y2 = 680} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"StatRocketFuelTankHandling", 0}, x1 = 1060, x2 = 1115, y1 = 720, y2 = 740} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"StatRocketFuelTankHandling", 1}, x1 = 1215, x2 = 1295, y1 = 720, y2 = 740} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"StatRocketFuelTankHandling", 2}, x1 = 1305, x2 = 1385, y1 = 720, y2 = 740} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"StatRocketFuelTankHandling", 3}, x1 = 1390, x2 = 1470, y1 = 720, y2 = 740} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"StatRocketFuelTankHandling", 4}, x1 = 1475, x2 = 1555, y1 = 720, y2 = 740} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ChangeSkillPoint", param={"StatRocketFuelTankHandling", 5}, x1 = 1565, x2 = 1645, y1 = 720, y2 = 740} )
-
-
-
- elseif screen.mode == "startup" then
- end
-
- screen = CreateBaseClickAreas(screen)
-
- return screen
-end
-
-function CheckClick(x, y, HitTarget)
- x = x*1920
- y = y*1120
- HitTarget = HitTarget or ""
- HitPayload = {}
- -- PrintConsole("Clicked: "..x.." / "..y)
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- if screens[i].active == true and screens[i].element.getMouseX() ~= -1 and screens[i].element.getMouseY() ~= -1 then
- if HitTarget == "" then
- for k, v in pairs(screens[i].ClickAreas) do
- if v ~=nil and x >= v.x1 and x <= v.x2 and y >= v.y1 and y <= v.y2 then
- HitTarget = v.id
- HitPayload = v
- break
- end
- end
- end
- if HitTarget == "ButtonPress" then
- if screens[i].mode == HitPayload.param then
- screens[i].mode = "startup"
- else
- screens[i].mode = HitPayload.param
- end
-
- if screens[i].mode == "damageoutline" then
- if screens[i].submode == "" then
- screens[i].submode = "top"
- end
- end
- screens[i].refresh = true
- screens[i].ClickAreas = {}
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "ToggleBackground" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundMode == "" then
- BackgroundSelected = 1
- BackgroundMode = backgroundModes[BackgroundSelected]
- else
- BackgroundSelected = 1
- BackgroundMode = ""
- end
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "PreviousBackground" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundMode == "" then
- BackgroundSelected = 1
- BackgroundMode = backgroundModes[BackgroundSelected]
- else
- if BackgroundSelected <= 1 then
- BackgroundSelected = #backgroundModes
- else
- BackgroundSelected = BackgroundSelected - 1
- end
- BackgroundMode = backgroundModes[BackgroundSelected]
- end
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "NextBackground" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundMode == "" then
- BackgroundSelected = 1
- BackgroundMode = backgroundModes[BackgroundSelected]
- else
- if BackgroundSelected >= #backgroundModes then
- BackgroundSelected = 1
- else
- BackgroundSelected = BackgroundSelected + 1
- end
- BackgroundMode = backgroundModes[BackgroundSelected]
- end
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "DecreaseOpacity" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundModeOpacity>0.1 then
- BackgroundModeOpacity = BackgroundModeOpacity - 0.05
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- end
- elseif HitTarget == "IncreaseOpacity" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundModeOpacity<1.0 then
- BackgroundModeOpacity = BackgroundModeOpacity + 0.05
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- end
- elseif HitTarget == "ResetColors" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- db.clear()
- ColorPrimary = "FF6700"
- ColorSecondary = "FFFFFF"
- ColorTertiary = "000000"
- ColorHealthy = "00FF00"
- ColorWarning = "FFFF00"
- ColorCritical = "FF0000"
- ColorBackground = "000000"
- ColorBackgroundPattern = "4f4f4f"
- BackgroundMode = "deathstar"
- BackgroundSelected = 1
- BackgroundModeOpacity = 0.25
- colorIDTable = {
- [1] = {
- id="ColorPrimary",
- desc="Main HUD Color",
- basec = "FF6700",
- newc = "FF6700"
- },
- [2] = {
- id="ColorSecondary",
- desc="Secondary HUD Color",
- basec = "FFFFFF",
- newc = "FFFFFF"
- },
- [3] = {
- id="ColorTertiary",
- desc="Tertiary HUD Color",
- basec = "000000",
- newc = "000000"
- },
- [4] = {
- id="ColorHealthy",
- desc="Color code for Healthy/Okay",
- basec = "00FF00",
- newc = "00FF00"
- },
- [5] = {
- id="ColorWarning",
- desc="Color code for Damaged/Warning",
- basec = "FFFF00",
- newc = "FFFF00"
- },
- [6] = {
- id="ColorCritical",
- desc="Color code for Broken/Critical",
- basec = "FF0000",
- newc = "FF0000"
- },
- [7] = {
- id="ColorBackground",
- desc="Background Color",
- basec = "000000",
- newc = "000000"
- },
- [8] = {
- id="ColorBackgroundPattern",
- desc="Background Pattern Color",
- basec = "4F4F4F",
- newc = "4F4F4F"
- },
- [9] = {
- id="ColorFuelAtmospheric",
- desc="Color for Atmo Fuel/Elements",
- basec = "004444",
- newc = "004444"
- },
- [10] = {
- id="ColorFuelSpace",
- desc="Color for Space Fuel/Elements",
- basec = "444400",
- newc = "444400"
- },
- [11] = {
- id="ColorFuelRocket",
- desc="Color for Rocket Fuel/Elements",
- basec = "440044",
- newc = "440044"
- }
- }
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "PreviousColorID" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- colorIDIndex = colorIDIndex - 1
- if colorIDIndex < 1 then colorIDIndex = #colorIDTable end
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "NextColorID" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- colorIDIndex = colorIDIndex + 1
- if colorIDIndex > #colorIDTable then colorIDIndex = 1 end
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "ColorPosUp" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- local s = tonumber(string.sub(colorIDTable[colorIDIndex].newc, HitPayload.param, HitPayload.param),16)
- s = s + 1
- if s > 15 then s = 0 end
- colorIDTable[colorIDIndex].newc = replace_char(HitPayload.param, colorIDTable[colorIDIndex].newc, hexTable[s+1])
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "ColorPosDown" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- local s = tonumber(string.sub(colorIDTable[colorIDIndex].newc, HitPayload.param, HitPayload.param),16)
- s = s - 1
- if s < 0 then s = 15 end
- colorIDTable[colorIDIndex].newc = replace_char(HitPayload.param, colorIDTable[colorIDIndex].newc, hexTable[s+1])
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "ResetPosColor" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- colorIDTable[colorIDIndex].newc = colorIDTable[colorIDIndex].basec
- _G[colorIDTable[colorIDIndex].id] = colorIDTable[colorIDIndex].basec
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "ApplyPosColor" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- _G[colorIDTable[colorIDIndex].id] = colorIDTable[colorIDIndex].newc
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "ChangeSkillPoint" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- _G[HitPayload.param[1]] = HitPayload.param[2]
- UpdateDamageData()
- UpdateTypeData()
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "DamagedPageDown" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentDamagedPage = CurrentDamagedPage + 1
- if CurrentDamagedPage > math.ceil(#damagedElements / DamagePageSize) then
- CurrentDamagedPage = math.ceil(#damagedElements / DamagePageSize)
- end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "DamagedPageUp" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentDamagedPage = CurrentDamagedPage - 1
- if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "BrokenPageDown" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentBrokenPage = CurrentBrokenPage + 1
- if CurrentBrokenPage > math.ceil(#brokenElements / DamagePageSize) then
- CurrentBrokenPage = math.ceil(#brokenElements / DamagePageSize)
- end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "BrokenPageUp" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentBrokenPage = CurrentBrokenPage - 1
- if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "DMGOChangeView" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- screens[i].submode = HitPayload.param
- UpdateViewDamageoutline(screens[i])
- SaveToDatabank()
- SetRefresh("damageoutline", screens[i].submode)
- RenderScreens("damageoutline", screens[i].submode)
- elseif HitTarget == "DMGOChangeStretch" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if DMGOStretch == true then
- DMGOStretch = false
- else
- DMGOStretch = true
- end
- UpdateViewDamageoutline(screens[i])
- SaveToDatabank()
- SetRefresh("damageoutline")
- RenderScreens("damageoutline")
- elseif HitTarget == "ToggleDisplayAtmosphere" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if screens[i].fuelA == true then
- screens[i].fuelA = false
- else
- screens[i].fuelA = true
- end
- screens[i].fuelIndex = 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "ToggleDisplaySpace" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if screens[i].fuelS == true then
- screens[i].fuelS = false
- else
- screens[i].fuelS = true
- end
- screens[i].fuelIndex = 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "ToggleDisplayRocket" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if screens[i].fuelR == true then
- screens[i].fuelR = false
- else
- screens[i].fuelR = true
- end
- screens[i].fuelIndex = 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "DecreaseFuelIndex" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- screens[i].fuelIndex = screens[i].fuelIndex - 1
- if screens[i].fuelIndex < 1 then screens[i].fuelIndex = 1 end
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "IncreaseFuelIndex" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- screens[i].fuelIndex = screens[i].fuelIndex + 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "ToggleHudMode" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if HUDMode == true then
- HUDMode = false
- forceDamageRedraw = true
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- else
- HUDMode = true
- forceDamageRedraw = true
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- end
- elseif HitTarget == "ToggleSimulation" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentDamagedPage = 1
- CurrentBrokenPage = 1
- if SimulationMode == true then
- SimulationMode = false
- SimulationActive = false
- UpdateDamageData()
- UpdateTypeData()
- forceDamageRedraw = true
- HudDeselectElement()
- SetRefresh("damage")
- SetRefresh("damageoutline")
- SetRefresh("settings1")
- SetRefresh("fuel")
- SaveToDatabank()
- RenderScreens()
- else
- SimulationMode = true
- SimulationActive = false
- UpdateDamageData()
- UpdateTypeData()
- forceDamageRedraw = true
- HudDeselectElement()
- SetRefresh("damage")
- SetRefresh("damageoutline")
- SetRefresh("settings1")
- SetRefresh("fuel")
- SaveToDatabank()
- RenderScreens()
- end
- elseif (HitTarget == "ToggleElementLabel" or HitTarget == "ToggleElementLabel2") and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if UseMyElementNames == true then
- UseMyElementNames = false
- SetRefresh("damage")
- RenderScreens("damage")
- else
- UseMyElementNames = true
- SetRefresh("damage")
- RenderScreens("damage")
- end
- elseif (HitTarget == "SwitchScrapTier" or HitTarget == "SwitchScrapTier2") and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- ScrapTier = ScrapTier + 1
- if ScrapTier > 4 then ScrapTier = 1 end
- SetRefresh("damage")
- RenderScreens("damage")
- end
-
-
- end
- end
- end
-end
-
---[[ 4. RENDERING FUNCTIONS ]]
-
-function GetContentFlight()
- local output = ""
- output = output .. GetHeader("Flight Data Report") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentDamage()
- local output = ""
- if SimulationMode == true then
- output = output .. GetHeader("Damage Report (Simulated damage)") .. [[]]
- else
- output = output .. GetHeader("Damage Report") .. [[]]
- end
- output = output .. GetContentDamageScreen()
- return output
-end
-
-function GetContentDamageoutline(screen)
- UpdateDataDamageoutline()
- UpdateViewDamageoutline(screen)
- local output = ""
- output = output .. GetHeader("Damage Ship Outline Report") ..
- GetDamageoutlineShip() ..
- [[]]
-
- if screen.submode=="top" then
- output = output ..
- [[
-
- Top View
-
- Side View
-
- Front View
- ]]
- elseif screen.submode=="side" then
- output = output ..
- [[
-
- Top View
-
- Side View
-
- Front View
- ]]
- elseif screen.submode=="front" then
- output = output ..
- [[
-
- Top View
-
- Side View
-
- Front View
- ]]
- else
- end
- output = output .. [[]]..#dmgoElements..[[ of ]]..ElementCounter..[[ shown]]
- output = output .. [[]]
- if DMGOStretch == true then
- output = output .. [[]]
- end
- output = output .. [[Stretch both axis]]
- return output
-end
-
-function GetContentFuel(screen)
-
- if #FuelAtmosphericTanks < 1 and #FuelSpaceTanks < 1 and #FuelRocketTanks < 1 then return "" end
-
- local FuelTypes = 0
- local output = ""
- local addHeadline = {}
-
- FuelDisplay = { screen.fuelA, screen.fuelS, screen.fuelR }
-
- if FuelDisplay[1] == true and #FuelAtmosphericTanks > 0 then
- table.insert(addHeadline, "Atmospheric")
- FuelTypes = FuelTypes + 1
- end
- if FuelDisplay[2] == true and #FuelSpaceTanks > 0 then
- table.insert(addHeadline, "Space")
- FuelTypes = FuelTypes + 1
- end
- if FuelDisplay[3] == true and #FuelRocketTanks > 0 then
- table.insert(addHeadline, "Rocket")
- FuelTypes = FuelTypes + 1
- end
-
- output = output .. GetHeader("Fuel Report ("..table.concat(addHeadline, ", ")..")") ..
- [[
- ]]
-
- local totalH = 150
- local counter = 0
- local tOffset = 0
-
- if FuelDisplay[1] == true and #FuelAtmosphericTanks > 0 then
-
- if FuelTypes == 1 then tOffset = 50
- elseif FuelTypes == 2 then tOffset = 6
- elseif FuelTypes == 3 then tOffset = 0
- end
-
- output = output .. [[
-
-
-
- ]]
-
- output = output ..
- [[]]..
- GenerateCommaValue(FuelAtmosphericCurrent, true)..
- [[ of ]]..GenerateCommaValue(FuelAtmosphericTotal, true)..
- [[ | Total Atmospheric Fuel in ]]..#FuelAtmosphericTanks..[[ tank]]..(#FuelAtmosphericTanks==1 and "" or "s")..[[ (]]..math.floor(100/FuelAtmosphericTotal*FuelAtmosphericCurrent)..[[%)]]
- counter = counter + 1
- end
-
- if FuelDisplay[2] == true and #FuelSpaceTanks > 0 then
-
- if FuelTypes == 1 then tOffset = 50
- elseif FuelTypes == 2 then tOffset = 6
- elseif FuelTypes == 3 then tOffset = 0
- end
-
- output = output .. [[
-
-
-
- ]]
-
- output = output ..
- [[]]..
- GenerateCommaValue(FuelSpaceCurrent, true)..
- [[ of ]]..GenerateCommaValue(FuelSpaceTotal, true)..
- [[ | Total Space Fuel in ]]..#FuelSpaceTanks..[[ tank]]..(#FuelSpaceTanks==1 and "" or "s")..[[ (]]..math.floor(100/FuelSpaceTotal*FuelSpaceCurrent)..[[%)]]
- counter = counter + 1
- end
-
- if FuelDisplay[3] == true and #FuelRocketTanks > 0 then
-
- if FuelTypes == 1 then tOffset = 50
- elseif FuelTypes == 2 then tOffset = 6
- elseif FuelTypes == 3 then tOffset = 0
- end
-
- output = output .. [[
-
-
-
- ]]
-
- output = output ..
- [[]]..
- GenerateCommaValue(FuelRocketCurrent, true)..
- [[ of ]]..GenerateCommaValue(FuelRocketTotal, true)..
- [[ | Total Rocket Fuel in ]]..#FuelRocketTanks..[[ tank]]..(#FuelRocketTanks==1 and "" or "s")..[[ (]]..math.floor(100/FuelRocketTotal*FuelRocketCurrent)..[[%)]]
- end
-
- output = output .. [[
-
-
-
- ]]
-
- local DisplayTable = {}
- if screen.fuelIndex == nil or screen.fuelIndex < 1 then
- screen.fuelIndex = 1
- end
-
- if FuelDisplay[1] == true then
- for _,v in ipairs(FuelAtmosphericTanks) do
- table.insert(DisplayTable, v)
- end
- end
- if FuelDisplay[2] == true then
- for _,v in ipairs(FuelSpaceTanks) do
- table.insert(DisplayTable, v)
- end
- end
- if FuelDisplay[3] == true then
- for _,v in ipairs(FuelRocketTanks) do
- table.insert(DisplayTable, v)
- end
- end
-
- table.sort(DisplayTable, function(a,b) return a.type
-
-
- ]]
- if tank.hp == 0 then
- output = output .. [[]]
- elseif tank.maxhp - tank.hp > constants.epsilon then
- output = output .. [[]]
- else
- output = output .. [[]]
- end
- if tank.hp == 0 then output = output .. [[]]..tank.size..[[]]
- else output = output .. [[]]..tank.size..[[]]
- end
-
- if tank.hp == 0 then
- output = output .. [[Broken]] ..
- [[0 of ]]..GenerateCommaValue(tank.vol)..[[]]
- elseif tonumber(tank.percent) < 10 then
- output = output .. [[]]..tank.percent..[[%]] ..
- [[]]..GenerateCommaValue(tank.cvol)..[[ of ]]..GenerateCommaValue(tank.vol)..[[]]
- elseif tonumber(tank.percent) < 30 then
- output = output .. [[]]..tank.percent..[[%]] ..
- [[]]..GenerateCommaValue(tank.cvol)..[[ of ]]..GenerateCommaValue(tank.vol)..[[]]
- else output =
- output .. [[]]..tank.percent..[[%]] ..
- [[]]..GenerateCommaValue(tank.cvol)..[[ of ]]..GenerateCommaValue(tank.vol)..[[]]
- end
-
- output = output ..[[]]..tank.name..[[]]
-
- output = output .. [[]]
-
- end
- end
-
-
-
- if #FuelAtmosphericTanks > 0 then
- output = output .. [[]]
- if FuelDisplay[1] == true then
- output = output .. [[]]
- end
- output = output .. [[ATM]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "ToggleDisplayAtmosphere", x1 = 50, x2 = 100, y1 = 270, y2 = 320} )
- end
-
- if #FuelSpaceTanks > 0 then
- output = output .. [[]]
- if FuelDisplay[2] == true then
- output = output .. [[]]
- end
- output = output .. [[SPC]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "ToggleDisplaySpace", x1 = 200, x2 = 250, y1 = 270, y2 = 320} )
- end
-
- if #FuelRocketTanks > 0 then
- output = output .. [[]]
- if FuelDisplay[3] == true then
- output = output .. [[]]
- end
- output = output .. [[RKT]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "ToggleDisplayRocket", x1 = 350, x2 = 400, y1 = 270, y2 = 320} )
- end
-
- if screen.fuelIndex > 1 then
- output = output .. [[
-
-
- ]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "DecreaseFuelIndex", x1 = 1470, x2 = 1670, y1 = 270, y2 = 320} )
- end
-
- if screen.fuelIndex+cCounter-1 < #DisplayTable then
- output = output .. [[
-
-
- ]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "IncreaseFuelIndex", x1 = 1680, x2 = 1880, y1 = 270, y2 = 320} )
- end
-
- if cCounter > 0 then
- output = output .. [[]]..
- #DisplayTable..
- [[ Tank]]..(#DisplayTable == 1 and "" or "s")..
- [[ (Showing ]]..screen.fuelIndex..[[ to ]]..(screen.fuelIndex+cCounter-1)..[[)]]
- end
-
- return output
-end
-
-function GetContentCargo()
- local output = ""
- output = output .. GetHeader("Cargo Report") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentAGG()
- local output = ""
- output = output .. GetHeader("Anti-Grav Control") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentMap()
- local output = ""
- output = output .. GetHeader("Map Overview") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentTime()
- local output = ""
- output = output .. GetHeader("Time") .. epochTime()
- output = output ..
- [[
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetContentSettings1()
- local output = ""
- output = output .. GetHeader("Settings") .. [[]]
- if BackgroundMode=="" then
- output = output ..[[Activate background]]
- else
- output = output ..[[Deactivate background (']]..BackgroundMode..[[', ]]..string.format("%.0f",BackgroundModeOpacity*100)..[[%)]]
- end
- output = output ..[[
-
- Previous background
-
- Next background
-
-
- Decrease Opacity
-
- Increase Opacity
- ]]
-
- output = output ..
- [[]] ..
- [[Reset background and all colors]]
-
- output = output ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Select and change any of the ]]..#colorIDTable..[[ HUD colors]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]]..colorIDTable[colorIDIndex].desc..[[]] ..
- [[]] ..
- [[Current color]] ..
- [[]] ..
-
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
-
- [[#]] ..
-
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,1,1)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,2,2)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,3,3)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,4,4)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,5,5)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,6,6)..[[]] ..
-
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
-
- [[]] ..
- [[]] ..
- [[New color]] ..
- [[]] ..
- [[Apply new color]] ..
- [[]] ..
- [[Reset]] ..
- [[]]
-
- output = output ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Enter your skills and placed element levels]]
-
- output = output .. [[]] ..
- [[Skill: Equipment Manager >> Repair Tool Efficiency:]]
- local lSkill = SkillRepairToolEfficiency
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
-
- output = output .. [[]] ..
- [[Skill: Equipment Manager >> Repair Tool Optimization:]]
- local lSkill = SkillRepairToolOptimization
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
-
- output = output .. [[]] ..
- [[Skill: Atmospheric Engine Pilot >> Atmospheric Fuel Efficiency:]]
- local lSkill = SkillAtmosphericFuelEfficiency
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
-
- output = output .. [[]] ..
- [[Skill: Space Engine Pilot >> Space Fuel Efficiency:]]
- local lSkill = SkillSpaceFuelEfficiency
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
-
- output = output .. [[]] ..
- [[Skill: Rocket Scientists >> Rocket Fuel Efficiency:]]
- local lSkill = SkillRocketFuelEfficiency
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
-
- output = output .. [[]] ..
- [[Stat: Level of Atmo Tanks (Atmospheric Fuel Tank Handling):]]
- local lSkill = StatAtmosphericFuelTankHandling
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
-
- output = output .. [[]] ..
- [[Stat: Level of Space Tanks (Space Fuel Tank Handling):]]
- local lSkill = StatSpaceFuelTankHandling
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
-
- output = output .. [[]] ..
- [[Stat: Level of Rocket Tanks (Rocket Fuel Tank Handling):]]
- local lSkill = StatRocketFuelTankHandling
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
- output = output .. [[]]
-
- output = output .. [[]]
-
- if SimulationMode == true then
- output = output .. [[Simulating Damage to elements]]
- AddClickArea("settings1", { id = "ToggleSimulation", mode ="settings1", x1 = 940, x2 = 1850, y1 = 919, y2 = 969 })
- else
- output = output .. [[Simulate Damage to elements]]
- AddClickArea("settings1", { id = "ToggleSimulation", mode ="settings1", x1 = 940, x2 = 1850, y1 = 919, y2 = 969 })
- end
-
- return output
-end
-
-function GetContentStartup()
- local output = ""
- output = output .. GetElementLogo(812, 380, "f", "f", "f")
- if YourShipsName == "Enter here" then
- output = output .. [[Spaceship ID ]]..ShipID..[[]]
- else
- output = output .. [[]]..YourShipsName..[[]]
- end
- if ShowWelcomeMessage == true then output = output .. [[Greetings, Commander ]]..PlayerName..[[.]] end
- output = output .. [[Damage Report v]]..VERSION..[[, by Scion Interstellar, DorianGray - Discord: Dorian Gray#2623. Under GNU Public License 3.0.]]
- return output
-end
-
-function RenderScreen(screen, contentToRender)
- if contentToRender == nil then
- PrintConsole("ERROR: contentToRender is nil.")
- unit.exit()
- end
-
- CreateClickAreasForScreen(screen)
-
- local output =""
- output = output .. [[
-
-
- ]]
-
- output = output .. contentToRender
-
- if screen.mode == "startup" then
- output = output .. [[]]
- else
- output = output .. [[]]
- end
-
- output = output .. [[
-
- ]]
- output = output .. [[]]
-
- -- Center:
-
- --
- --
- --
- --
-
- local outputLength = string.len(output)
- -- PrintConsole("Render: "..screen.mode.." ("..outputLength.." chars)")
- screen.element.setSVG(output)
-end
-
-function RenderScreens(onlymode, onlysubmode)
-
- onlymode = onlymode or "all"
- onlysubmode = onlysubmode or "all"
-
- if screens ~= nil and #screens > 0 then
-
- local contentFlight = ""
- local contentDamage = ""
- local contentDamageoutlineTop = ""
- local contentDamageoutlineSide = ""
- local contentDamageoutlineFront = ""
- local contentFuel = ""
- local contentCargo = ""
- local contentAGG = ""
- local contentMap = ""
- local contentTime = ""
- local contentSettings1 = ""
- local contentStartup = ""
-
- for k,screen in pairs(screens) do
- if screen.refresh == true then
- local contentToRender = ""
-
- if screen.mode == "flight" and (onlymode =="flight" or onlymode =="all") then
- if contentFlight == "" then contentFlight = GetContentFlight() end
- contentToRender = contentFlight
- elseif screen.mode == "damage" and (onlymode =="damage" or onlymode =="all") then
- if contentDamage == "" then contentDamage = GetContentDamage() end
- contentToRender = contentDamage
- elseif screen.mode == "damageoutline" and (onlymode =="damageoutline" or onlymode =="all") then
- if screen.submode == "" then
- screen.submode = "top"
- screens[k].submode = "top"
- end
- if screen.submode == "top" and (onlysubmode == "top" or onlysubmode == "all") then
- if contentDamageoutlineTop == "" then contentDamageoutlineTop = GetContentDamageoutline(screen) end
- contentToRender = contentDamageoutlineTop
- end
- if screen.submode == "side" and (onlysubmode == "side" or onlysubmode == "all") then
- if contentDamageoutlineSide == "" then contentDamageoutlineSide = GetContentDamageoutline(screen) end
- contentToRender = contentDamageoutlineSide
- end
- if screen.submode == "front" and (onlysubmode == "front" or onlysubmode == "all") then
- if contentDamageoutlineFront == "" then contentDamageoutlineFront = GetContentDamageoutline(screen) end
- contentToRender = contentDamageoutlineFront
- end
- elseif screen.mode == "fuel" and (onlymode =="fuel" or onlymode =="all") then
- screen = WipeClickAreasForScreen(screens[k])
- contentToRender = GetContentFuel(screen)
- elseif screen.mode == "cargo" and (onlymode =="cargo" or onlymode =="all") then
- if contentCargo == "" then contentCargo = GetContentCargo() end
- contentToRender = contentCargo
- elseif screen.mode == "agg" and (onlymode =="agg" or onlymode =="all") then
- if contentAGG == "" then contentAGG = GetContentAGG() end
- contentToRender = contentAGG
- elseif screen.mode == "map" and (onlymode =="map" or onlymode =="all") then
- if contentMap == "" then contentMap = GetContentMap() end
- contentToRender = contentMap
- elseif screen.mode == "time" and (onlymode =="time" or onlymode =="all") then
- if contentTime == "" then contentTime = GetContentTime() end
- contentToRender = contentTime
- elseif screen.mode == "settings1" and (onlymode =="settings1" or onlymode =="all") then
- if contentSettings1 == "" then contentSettings1 = GetContentSettings1() end
- contentToRender = contentSettings1
- elseif screen.mode == "startup" and (onlymode =="startup" or onlymode =="all") then
- if contentStartup == "" then contentStartup = GetContentStartup() end
- contentToRender = contentStartup
- else
- contentToRender = "Invalid screen mode. ('"..screen.mode.."')"
- end
-
- if contentToRender ~= "" then
- RenderScreen(screen, contentToRender)
- else
- DrawCenteredText("ERROR: No contentToRender delivered for "..screen.mode)
- PrintConsole("ERROR: No contentToRender delivered for "..screen.mode)
- unit.exit()
- end
- screens[k].refresh = false
- end
- end
- end
-
- if HUDMode == true then
- system.setScreen(GetContentDamageHUDOutput())
- system.showScreen(1)
- else
- system.showScreen(0)
- end
-
-end
-
-function OnTickData(initial)
- if formerTime + 60 < system.getTime() then
- SetRefresh("time")
- end
- totalShipMass = core.getConstructMass()
- if formerTotalShipMass ~= totalShipMass then
- UpdateDamageData(true)
- UpdateTypeData()
- SetRefresh()
- formerTotalShipMass = totalShipMass
- else
- UpdateDamageData(initial)
- UpdateTypeData()
- end
- RenderScreens()
-end
-
---[[ 5. EXECUTION ]]
-
-unit.hide()
-ClearConsole()
-PrintConsole("DAMAGE REPORT v"..VERSION.." STARTED", true)
-InitiateSlots()
-LoadFromDatabank()
-SwitchScreens("on")
-InitiateScreens()
-
-if core == nil then
- PrintConsole("ERROR: Connect the core to the programming board.")
- unit.exit()
-else
- OperatorID = unit.getMasterPlayerId()
- OperatorData = database.getPlayer(OperatorID)
- PlayerName = OperatorData["name"]
- ShipID = core.getConstructId()
-end
-
-if screens == nil or #screens == 0 then
- HUDMode = true
-end
-
-OnTickData(true)
-
-unit.setTimer('UpdateData', UpdateDataInterval)
-unit.setTimer('UpdateHighlight', HighlightBlinkingInterval)
\ No newline at end of file
diff --git a/src/DamageReport_3_02_UnitStart_1.lua b/src/DamageReport_3_02_UnitStart_1.lua
deleted file mode 100644
index 95a875a..0000000
--- a/src/DamageReport_3_02_UnitStart_1.lua
+++ /dev/null
@@ -1,1277 +0,0 @@
---[[
- Damage Report 3.02
- A LUA script for Dual Universe
-
- Created By Dorian Gray
- Ingame: DorianGray
- Discord: Dorian Gray#2623
-
- You can find/update this script on GitHub. Explanations, installation and usage information as well as screenshots can be found there too.
- GitHub: https://github.com/DorianTheGrey/DU-DamageReport
-
- GNU Public License 3.0. Use whatever you want, be so kind to leave credit.
-
- Credits & thanks:
- Thanks to NovaQuark for creating the MMO of the century.
- Thanks to Jericho, Dmentia and Archaegeo for learning a lot from their fine scripts.
- Thanks to TheBlacklist for testing and wonderful suggestions.
- SVG patterns by Hero Patterns.
- DU atlas data from Jayle Break.
-
-]]
-
---[[ 1. HELPER FUNCTIONS ]]
-
-function GenerateCommaValue(amount, kify, postcomma)
- kify = kify or false
- postcomma = postcomma or 1
- local formatted = amount
- if kify == true then
- if string.len(amount)>=4 then
- formatted = string.format("%."..postcomma.."fk", amount/1000)
- else
- formatted = string.format("%."..postcomma.."f", amount)
- end
- else
- while true do
- formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
- if (k == 0) then break end
- end
- end
- return formatted
-end
-
-function PrintConsole(output, highlight)
- highlight = highlight or false
- if highlight then
- system.print(
- "------------------------------------------------------------------------")
- end
- system.print(output)
- if highlight then
- system.print(
- "------------------------------------------------------------------------")
- end
-end
-
-function DrawCenteredText(output)
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- screens[i].element.setCenteredText(output)
- end
- end
-end
-
-function ClearConsole()
- for i = 1, 10, 1 do
- PrintConsole()
- end
-end
-
-function SwitchScreens(state)
- state = state or "on"
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- if state == "on" then
- screens[i].element.clear()
- screens[i].element.activate()
- screens[i].active = true
- else
- screens[i].element.clear()
- screens[i].element.deactivate()
- screens[i].active = false
- end
- end
- end
-end
-
---[[ Convert seconds to string (by Jericho) ]]
-function GetSecondsString(seconds)
- local seconds = tonumber(seconds)
-
- if seconds == nil or seconds <= 0 then
- return "-";
- else
- days = string.format("%2.f", math.floor(seconds/(3600*24)));
- hours = string.format("%2.f", math.floor(seconds/3600 - (days*24)));
- mins = string.format("%2.f", math.floor(seconds/60 - (hours*60) - (days*24*60)));
- secs = string.format("%2.f", math.floor(seconds - hours*3600 - (days*24*60*60) - mins *60));
- str = ""
- if tonumber(days) > 0 then str = str .. days.."d " end
- if tonumber(hours) > 0 then str = str .. hours.."h " end
- if tonumber(mins) > 0 then str = str .. mins.."m " end
- if tonumber(secs) > 0 then str = str .. secs .."s" end
- return str
- end
-end
-
-function replace_char(pos, str, r)
- return str:sub(1, pos-1) .. r .. str:sub(pos+1)
-end
-
---[[ 2. RENDER HELPER FUNCTIONS ]]
-
---[[ epochTime function by Leodr (clock script), enhanced by Jericho (DU Industry script) ]]
-function epochTime()
- function rZ(a)
- if string.len(a) <= 1 then
- return "0" .. a
- else
- return a
- end
- end
- function dPoint(b)
- if not (b == math.floor(b)) then
- return true
- else
- return false
- end
- end
- function lYear(year)
- if not dPoint(year / 4) then
- if dPoint(year / 100) then
- return true
- else
- if not dPoint(year / 400) then
- return true
- else
- return false
- end
- end
- else
- return false
- end
- end
- local c = 5;
- local d = 3600;
- local e = 86400;
- local f = 31536000;
- local g = 31622400;
- local h = 2419200;
- local i = 2505600;
- local j = 2592000;
- local k = 2678400;
- local l = {4, 6, 9, 11}
- local m = {1, 3, 5, 7, 8, 10, 12}
- local n = 0;
- local o = 1506816000;
- local q = system.getTime()
- _G["formerTime"] = q
- if AddSummertimeHour == true then q = q + 3600 end
- now = math.floor(q + o)
- year = 1970;
- secs = 0;
- n = 0;
- while secs + g < now or secs + f < now do
- if lYear(year + 1) then
- if secs + g < now then
- secs = secs + g;
- year = year + 1;
- n = n + 366
- end
- else
- if secs + f < now then
- secs = secs + f;
- year = year + 1;
- n = n + 365
- end
- end
- end
- secondsRemaining = now - secs;
- monthSecs = 0;
- yearlYear = lYear(year)
- month = 1;
- while monthSecs + h < secondsRemaining or monthSecs + j < secondsRemaining or
- monthSecs + k < secondsRemaining do
- if month == 1 then
- if monthSecs + k < secondsRemaining then
- month = 2;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 2 then
- if not yearlYear then
- if monthSecs + h < secondsRemaining then
- month = 3;
- monthSecs = monthSecs + h;
- n = n + 28
- else
- break
- end
- else
- if monthSecs + i < secondsRemaining then
- month = 3;
- monthSecs = monthSecs + i;
- n = n + 29
- else
- break
- end
- end
- end
- if month == 3 then
- if monthSecs + k < secondsRemaining then
- month = 4;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 4 then
- if monthSecs + j < secondsRemaining then
- month = 5;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- if month == 5 then
- if monthSecs + k < secondsRemaining then
- month = 6;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 6 then
- if monthSecs + j < secondsRemaining then
- month = 7;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- if month == 7 then
- if monthSecs + k < secondsRemaining then
- month = 8;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 8 then
- if monthSecs + k < secondsRemaining then
- month = 9;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 9 then
- if monthSecs + j < secondsRemaining then
- month = 10;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- if month == 10 then
- if monthSecs + k < secondsRemaining then
- month = 11;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 11 then
- if monthSecs + j < secondsRemaining then
- month = 12;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- end
- day = 1;
- daySecs = 0;
- daySecsRemaining = secondsRemaining - monthSecs;
- while daySecs + e < daySecsRemaining do
- day = day + 1;
- daySecs = daySecs + e;
- n = n + 1
- end
- hour = 0;
- hourSecs = 0;
- hourSecsRemaining = daySecsRemaining - daySecs;
- while hourSecs + d < hourSecsRemaining do
- hour = hour + 1;
- hourSecs = hourSecs + d
- end
- minute = 0;
- minuteSecs = 0;
- minuteSecsRemaining = hourSecsRemaining - hourSecs;
- while minuteSecs + 60 < minuteSecsRemaining do
- minute = minute + 1;
- minuteSecs = minuteSecs + 60
- end
- second = math.floor(now % 60)
- year = rZ(year)
- month = rZ(month)
- day = rZ(day)
- hour = rZ(hour)
- minute = rZ(minute)
- second = rZ(second)
-
- return [[]]..hour..":".. minute..[[]]..
- [[]]..year.."/".. month.."/"..day..[[]]
-end
-
-
-function ToggleHUD()
- if HUDMode == true then
- HUDMode = false
- forceDamageRedraw = true
- hudSelectedIndex = 0
- highlightID = 0
- HideHighlight()
- SetRefresh()
- RenderScreens()
- else
- HUDMode = true
- forceDamageRedraw = true
- hudSelectedIndex = 0
- highlightID = 0
- HideHighlight()
- SetRefresh()
- RenderScreens()
- end
-end
-
-function HudDeselectElement()
- hudSelectedIndex = 0
- hudStartIndex = 1
- highlightID = 0
- HideHighlight()
- if HUDMode == true then
- SetRefresh("damage")
- SetRefresh("damageoutline")
- RenderScreens()
- end
-end
-
-function ChangeHudSelectedElement(step)
- if HUDMode == true and #rE > 0 then
-
- hudSelectedIndex = hudSelectedIndex + step
- if hudSelectedIndex < 1 then hudSelectedIndex = 1
- elseif hudSelectedIndex > #rE then hudSelectedIndex = #rE
- end
-
- if hudSelectedIndex > 9 then
- hudStartIndex = hudSelectedIndex-9
- end
- if hudSelectedIndex ~= 0 then
- highlightID = rE[hudSelectedIndex].id
- if highlightID ~=nil and highlightID ~= 0 then
- -- PrintConsole("CHSE: hudSelectedIndex: "..hudSelectedIndex.." / hudStartIndex: "..hudStartIndex.." / highlightID: "..highlightID)
- HideHighlight()
- elementPosition = vec3(rE[hudSelectedIndex].pos)
- highlightX = elementPosition.x - coreWorldOffset
- highlightY = elementPosition.y - coreWorldOffset
- highlightZ = elementPosition.z - coreWorldOffset
- highlightOn = true
- ShowHighlight()
- end
- end
-
- SetRefresh("damage")
- SetRefresh("damageoutline")
- RenderScreens()
-
- end
-end
-
-function HideHighlight()
- if #hudArrowSticker > 0 then
- for i in pairs(hudArrowSticker) do
- core.deleteSticker(hudArrowSticker[i])
- end
- hudArrowSticker = {}
- end
-end
-
-function ShowHighlight()
- if highlightOn == true and highlightID > 0 then
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX + 2, highlightY, highlightZ, "north"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY - 2, highlightZ, "east"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX - 2, highlightY, highlightZ, "south"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY + 2, highlightZ, "west"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY, highlightZ - 2, "up"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY, highlightZ + 2,"down"))
- end
-end
-
-function ToggleHighlight()
- if highlightOn == true then
- highlightOn = false
- HideHighlight()
- else
- highlightOn = true
- ShowHighlight()
- end
-end
-
-function SortDamageTables()
- table.sort(damagedElements, function(a, b) return a.missinghp > b.missinghp end)
- table.sort(brokenElements, function(a, b) return a.maxhp > b.maxhp end)
-end
-
-function getScraps(damage,commaval)
- commaval = commaval or false
- damage = damage - SkillRepairToolOptimization * 0.05 * damage
- local res = math.ceil( damage / ( 10 * 5^(ScrapTier-1) ) )
- if commaval ==true then
- return GenerateCommaValue(string.format("%.0f", res ), false)
- else
- return res
- end
-end
-
-function getRepairTime(damage,buildstring)
- buildstring = buildstring or false
- damage = damage - SkillRepairToolOptimization * 0.05 * damage
- local res = math.ceil(damage / ScrapTierRepairTimes[ScrapTier])
- res = res - ( SkillRepairToolEfficiency * 0.1 * res )
- if buildstring == true then
- return GetSecondsString(string.format("%.0f", res ) )
- else
- return res
- end
-end
-
-function UpdateDataDamageoutline()
-
- dmgoElements = {}
-
- for i,element in ipairs(brokenElements) do
- if #dmgoElements < DMGOMaxElements then
- local elementPosition = vec3(element.pos)
- local x = elementPosition.x - coreWorldOffset
- local y = elementPosition.y - coreWorldOffset
- local z = elementPosition.z - coreWorldOffset
- if x < ShipXmin then ShipXmin = x end
- if y < ShipYmin then ShipYmin = y end
- if z < ShipZmin then ShipZmin = z end
- if x > ShipXmax then ShipXmax = x end
- if y > ShipYmax then ShipYmax = y end
- if z > ShipZmax then ShipZmax = z end
- table.insert( dmgoElements, {
- id = element.id,
- type = "b",
- size = element.maxhp,
- x = x, y = y, z = z,
- xp = 0, yp = 0, zp = 0,
- u = 0, v = 0
- })
- end
- end
-
- if #dmgoElements < DMGOMaxElements then
- for i,element in ipairs(damagedElements) do
- if #dmgoElements < DMGOMaxElements then
- local elementPosition = vec3(element.pos)
- local x = elementPosition.x - coreWorldOffset
- local y = elementPosition.y - coreWorldOffset
- local z = elementPosition.z - coreWorldOffset
- if x < ShipXmin then ShipXmin = x end
- if y < ShipYmin then ShipYmin = y end
- if z < ShipZmin then ShipZmin = z end
- if x > ShipXmax then ShipXmax = x end
- if y > ShipYmax then ShipYmax = y end
- if z > ShipZmax then ShipZmax = z end
- table.insert( dmgoElements, {
- id = element.id,
- type = "d",
- size = element.maxhp,
- x = x, y = y, z = z,
- xp = 0, yp = 0, zp = 0,
- u = 0, v = 0
- })
- end
- end
- end
-
- if #dmgoElements < DMGOMaxElements then
- for i,element in ipairs(healthyElements) do
- if #dmgoElements < DMGOMaxElements then
- local elementPosition = vec3(element.pos)
- local x = elementPosition.x - coreWorldOffset
- local y = elementPosition.y - coreWorldOffset
- local z = elementPosition.z - coreWorldOffset
- if x < ShipXmin then ShipXmin = x end
- if y < ShipYmin then ShipYmin = y end
- if z < ShipZmin then ShipZmin = z end
- if x > ShipXmax then ShipXmax = x end
- if y > ShipYmax then ShipYmax = y end
- if z > ShipZmax then ShipZmax = z end
- table.insert( dmgoElements, {
- id = element.id,
- type = "h",
- size = element.maxhp,
- x = x, y = y, z = z,
- xp = 0, yp = 0, zp = 0,
- u = 0, v = 0
- })
- end
- end
- end
-
- ShipX = math.abs(ShipXmax-ShipXmin)
- ShipY = math.abs(ShipYmax-ShipYmin)
- ShipZ = math.abs(ShipZmax-ShipZmin)
-
- --[[
- PrintConsole(
- "ShipXmin: "..string.format("%.2f",ShipXmin)..
- " - ShipYmin: "..string.format("%.2f",ShipYmin)..
- " - ShipZmin: "..string.format("%.2f",ShipZmin)..
- " - ShipXmax: "..string.format("%.2f",ShipXmax)..
- " - ShipYmax: "..string.format("%.2f",ShipYmax)..
- " - ShipZmax: "..string.format("%.2f",ShipZmax)
- )
-
- PrintConsole(
- "ShipX: "..string.format("%.2f",ShipX)..
- " - ShipY: "..string.format("%.2f",ShipY)..
- " - ShipZ: "..string.format("%.2f",ShipZ)
- )
- ]]
-
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].xp = math.abs(100/(ShipXmax-ShipXmin)*(element.x-ShipXmin))
- dmgoElements[i].yp = math.abs(100/(ShipYmax-ShipYmin)*(element.y-ShipYmin))
- dmgoElements[i].zp = math.abs(100/(ShipZmax-ShipZmin)*(element.z-ShipZmin))
- -- PrintConsole(i..". "..element.id..": "..string.format("%.2f",element.x).."/"..string.format("%.2f",element.y).."/"..string.format("%.2f",element.z).." - XP: "..dmgoElements[i].xp.." - YP: "..dmgoElements[i].yp.." - ZP: "..dmgoElements[i].zp)
- end
-
-end
-
-function UpdateViewDamageoutline(screen)
- -- Full Width of virtual screen:
- -- UStart = 20
- -- VStart = 180
- -- UDim = 1880
- -- VDim = 840
- -- Adding frames:
- UFrame = 40
- VFrame = 40
-
- UStart = 20 + UFrame
- VStart = 180 + VFrame
- UDim = 1880 - 2*UFrame
- VDim = 840 - 2*VFrame
-
- if screen.submode == "top" then
- if DMGOStretch == false then
- local UFactor = UDim/(ShipYmax-ShipYmin)
- local VFactor = VDim/(ShipXmax-ShipXmin)
- if UFactor>=VFactor then
- local cFactor = UFactor/VFactor
- local newUDim = math.floor(UDim/cFactor)
- UStart = UStart+(UDim-newUDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100/cFactor*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*element.xp+VStart)
- end
- else
- local cFactor = VFactor/UFactor
- local newVDim = math.floor(VDim/cFactor)
- VStart = VStart+(VDim-newVDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100/cFactor*element.xp+VStart)
- end
- end
- else
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*element.xp+VStart)
- end
- end
-
-
- elseif screen.submode == "front" then
- if DMGOStretch == false then
- local UFactor = UDim/(ShipXmax-ShipXmin)
- local VFactor = VDim/(ShipZmax-ShipZmin)
- if UFactor>=VFactor then
- local cFactor = UFactor/VFactor
- local newUDim = math.floor(UDim/cFactor)
- UStart = UStart+(UDim-newUDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100/cFactor*element.xp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- else
- local cFactor = VFactor/UFactor
- local newVDim = math.floor(VDim/cFactor)
- VStart = VStart+(VDim-newVDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.xp+UStart)
- dmgoElements[i].v = math.floor(VDim/100/cFactor*(100-element.zp)+VStart)
- end
- end
- else
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.xp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- end
-
- elseif screen.submode == "side" then
- if DMGOStretch == false then
- local UFactor = UDim/(ShipYmax-ShipYmin)
- local VFactor = VDim/(ShipXmax-ShipZmin)
- if UFactor>=VFactor then
- local cFactor = UFactor/VFactor
- local newUDim = math.floor(UDim/cFactor)
- UStart = UStart+(UDim-newUDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100/cFactor*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- else
- local cFactor = VFactor/UFactor
- local newVDim = math.floor(VDim/cFactor)
- VStart = VStart+(VDim-newVDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100/cFactor*(100-element.zp)+VStart)
- end
- end
- else
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- end
- else
- DrawCenteredText("ERROR: non-existing DMGO mode set.")
- PrintConsole("ERROR: non-existing DMGO mode set.")
- unit.exit()
- end
-end
-
-function GetDamageoutlineShip()
- local output = ""
-
- for i,element in ipairs(dmgoElements) do
- local cclass = ""
- local size = 1
-
- if element.type == "h" then
- cclass ="ch"
- elseif element.type == "d" then
- cclass = "cw"
- else
- cclass = "cc"
- end
- if element.id == highlightID then
- cclass = "f2"
- end
-
- if element.size > 0 and element.size < 1000 then
- size = 5
- elseif element.size >= 1000 and element.size < 2000 then
- size = 8
- elseif element.size >= 2000 and element.size < 5000 then
- size = 12
- elseif element.size >= 5000 and element.size < 10000 then
- size = 15
- elseif element.size >= 10000 and element.size < 20000 then
- size = 20
- elseif element.size >= 20000 then
- size = 30
- end
- output = output .. [[]]
- if element.id == highlightID then
- output = output .. [[]]
- output = output .. [[]]
- end
- end
-
- return output
-end
-
-function GetContentClickareas(screen)
- local output = ""
- if screen ~= nil and screen.ClickAreas ~= nil and #screen.ClickAreas > 0 then
- for i,ca in ipairs(screen.ClickAreas) do
- output = output ..
- [[]]
- end
- end
- return output
-end
-
-function GetElement1(x, y, width, height)
- x = x or 0
- y = y or 0
- width = width or 600
- height = height or 600
- local output = ""
- output = output ..
- [[
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetElement2(x, y)
- x = x or 0
- y = y or 0
- local output = ""
- output = output .. [[]]
- return output
-end
-
-function GetElementLogo(x, y, primaryC, secondaryC, tertiaryC)
- x = x or 812
- y = y or 380
- primaryC = primaryC or "f"
- secondaryC = secondaryC or "f2"
- tertiaryC = tertiaryC or "f3"
- local output = ""
- output = output .. [[
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetHeader(headertext)
- headertext = headertext or "ERROR: UNDEFINED"
- local output = ""
- output = output ..
- [[
- ]]..headertext..[[]]
- return output
-end
-
-function GetContentBackground(candidate, bgcolor)
- bgColor = ColorBackgroundPattern
-
- local output = ""
-
- if candidate == "dots" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' viewBox='0 0 4 4'%3E%3Cpath fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' d='M1 3h1v1H1V3zm2-2h1v1H3V1z'%3E%3C/path%3E%3C/svg%3E");]]
- elseif candidate == "rain" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='12' height='16' viewBox='0 0 12 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 .99C4 .445 4.444 0 5 0c.552 0 1 .45 1 .99v4.02C6 5.555 5.556 6 5 6c-.552 0-1-.45-1-.99V.99zm6 8c0-.546.444-.99 1-.99.552 0 1 .45 1 .99v4.02c0 .546-.444.99-1 .99-.552 0-1-.45-1-.99V8.99z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E");]]
- elseif candidate == "plus" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "signal" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='84' height='48' viewBox='0 0 84 48' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h12v6H0V0zm28 8h12v6H28V8zm14-8h12v6H42V0zm14 0h12v6H56V0zm0 8h12v6H56V8zM42 8h12v6H42V8zm0 16h12v6H42v-6zm14-8h12v6H56v-6zm14 0h12v6H70v-6zm0-16h12v6H70V0zM28 32h12v6H28v-6zM14 16h12v6H14v-6zM0 24h12v6H0v-6zm0 8h12v6H0v-6zm14 0h12v6H14v-6zm14 8h12v6H28v-6zm-14 0h12v6H14v-6zm28 0h12v6H42v-6zm14-8h12v6H56v-6zm0-8h12v6H56v-6zm14 8h12v6H70v-6zm0 8h12v6H70v-6zM14 24h12v6H14v-6zm14-8h12v6H28v-6zM14 8h12v6H14V8zM0 8h12v6H0V8z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E");]]
- elseif candidate == "deathstar" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='105' viewBox='0 0 80 105'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M20 10a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm15 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zM20 75a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zm30-65a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm0 65a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zM35 10a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zM5 45a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zm60 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10z' /%3E%3C/g%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "diamond" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='32' viewBox='0 0 16 32'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath fill-rule='evenodd' d='M0 24h4v2H0v-2zm0 4h6v2H0v-2zm0-8h2v2H0v-2zM0 0h4v2H0V0zm0 4h2v2H0V4zm16 20h-6v2h6v-2zm0 4H8v2h8v-2zm0-8h-4v2h4v-2zm0-20h-6v2h6V0zm0 4h-4v2h4V4zm-2 12h2v2h-2v-2zm0-8h2v2h-2V8zM2 8h10v2H2V8zm0 8h10v2H2v-2zm-2-4h14v2H0v-2zm4-8h6v2H4V4zm0 16h6v2H4v-2zM6 0h2v2H6V0zm0 24h2v2H6v-2z'/%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "hexagon" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='49' viewBox='0 0 28 49'%3E%3Cg fill-rule='evenodd'%3E%3Cg id='hexagons' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='nonzero'%3E%3Cpath d='M13.99 9.25l13 7.5v15l-13 7.5L1 31.75v-15l12.99-7.5zM3 17.9v12.7l10.99 6.34 11-6.35V17.9l-11-6.34L3 17.9zM0 15l12.98-7.5V0h-2v6.35L0 12.69v2.3zm0 18.5L12.98 41v8h-2v-6.85L0 35.81v-2.3zM15 0v7.5L27.99 15H28v-2.31h-.01L17 6.35V0h-2zm0 49v-8l12.99-7.5H28v2.31h-.01L17 42.15V49h-2z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "capsule" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='32' height='26' viewBox='0 0 32 26' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M14 0v3.994C14 7.864 10.858 11 7 11c-3.866 0-7-3.138-7-7.006V0h2v4.005C2 6.765 4.24 9 7 9c2.756 0 5-2.236 5-4.995V0h2zm0 26v-5.994C14 16.138 10.866 13 7 13c-3.858 0-7 3.137-7 7.006V26h2v-6.005C2 17.235 4.244 15 7 15c2.76 0 5 2.236 5 4.995V26h2zm2-18.994C16 3.136 19.142 0 23 0c3.866 0 7 3.138 7 7.006v9.988C30 20.864 26.858 24 23 24c-3.866 0-7-3.138-7-7.006V7.006zm2-.01C18 4.235 20.244 2 23 2c2.76 0 5 2.236 5 4.995v10.01C28 19.765 25.756 22 23 22c-2.76 0-5-2.236-5-4.995V6.995z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E");]]
- elseif candidate == "diagonal" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='6' height='6' viewBox='0 0 6 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'%3E%3Cpath d='M5 0h1L0 6V5zM6 5v1H5z'/%3E%3C/g%3E%3C/svg%3E");]]
- end
- return output;
-end
-
-function GetContentDamageHUDOutput()
- local hudWidth = 300
- local hudHeight = 165
- if #damagedElements > 0 or #brokenElements > 0 then hudHeight = 510 end
- local output = ""
-
- output = output .. [[
-
- ]]
- output = output .. [[]] ..
- [[]] ..
- [[]] ..
- [[]]..(YourShipsName=="Enter here" and ("Ship ID "..ShipID) or YourShipsName) .. [[]] ..
- [[]]
- if #brokenElements > 0 then
- output = output .. [[]]
- elseif #damagedElements > 0 then
- output = output .. [[]]
- else
- output = output .. [[]]
- end
-
- if #damagedElements > 0 or #brokenElements > 0 then
-
- output = output .. [[Total Damage]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", totalShipMaxHP - totalShipHP))..[[]]
- output = output .. [[T]]..ScrapTier..[[ Scrap Needed]] ..
- [[]]..getScraps(totalShipMaxHP - totalShipHP, true)..[[]]
- output = output .. [[Repair Time]] ..
- [[]]..getRepairTime(totalShipMaxHP - totalShipHP, true)..[[]]
-
- output = output .. [[]] ..
- [[]] ..
- [[]]..#healthyElements..[[]] ..
- [[]] ..
- [[]]..#damagedElements..[[]] ..
- [[]] ..
- [[]]..#brokenElements..[[]]
- local j=0
-
- for currentIndex=hudStartIndex,hudStartIndex+9,1 do
- if rE[currentIndex] ~= nil then
- v = rE[currentIndex]
- if v.hp > 0 then
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- if v.id == highlightID then
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- end
- else
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- if v.id == highlightID then
- highlightX = elementPosition.x - coreWorldOffset
- highlightY = elementPosition.y - coreWorldOffset
- highlightZ = elementPosition.z - coreWorldOffset
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- end
- end
- j=j+1
- end
- end
- output = output ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Up/down arrows to highlight]] ..
- [[CTRL + arrows to move HUD]] ..
- [[Left arrow to toggle HUD Mode]] ..
- [[ALT+1-4 to set Scrap Tier]] ..
- [[ALT+8 to reset HUD position]] ..
- [[ALT+9 to shut script off]] ..
- [[]] ..
- [[]]
- else
- output = output ..
- [[]] .. OkayCenterMessage .. [[]] ..
- [[]]..#healthyElements..[[ elements / ]] .. GenerateCommaValue(string.format("%.0f", totalShipMaxHP)) .. [[ HP.]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Left arrow to toggle HUD Mode]] ..
- [[CTRL + arrows to move HUD]] ..
- [[ALT+8 to reset HUD position]] ..
- [[ALT+9 to shut script off]] ..
- [[]] ..
- [[]]
- end
- output = output .. [[]]
- return output
-end
-
-function GetContentDamageScreen()
-
- local screenOutput = ""
-
- -- Draw damage elements
- if #damagedElements > 0 then
- local damagedElementsToDraw = #damagedElements
- if damagedElementsToDraw > DamagePageSize then
- damagedElementsToDraw = DamagePageSize
- end
- if CurrentDamagedPage == math.ceil(#damagedElements / DamagePageSize) then
- damagedElementsToDraw = #damagedElements % DamagePageSize + 12
- if damagedElementsToDraw > 12 then damagedElementsToDraw = damagedElementsToDraw - 12 end
- end
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
-
- if UseMyElementNames == true then screenOutput = screenOutput .. [[Damaged Name]]
- else screenOutput = screenOutput .. [[Damaged Type]]
- end
-
- screenOutput = screenOutput .. [[HLTHDMG]]
- screenOutput = screenOutput .. [[T]]..ScrapTier..[[ SCRREPTIME]]
-
- AddClickArea("damage", {
- id = "SwitchScrapTier",
- mode ="damage",
- x1 = 650,
- x2 = 775,
- y1 = 315,
- y2 = 360
- })
-
- local i = 0
- for j = 1 + (CurrentDamagedPage - 1) * DamagePageSize, damagedElementsToDraw + (CurrentDamagedPage - 1) * DamagePageSize, 1 do
- i = i + 1
- local DP = damagedElements[j]
- if UseMyElementNames == true then screenOutput = screenOutput .. [[]] .. string.format("%.23s", DP.name) .. [[]]
- else screenOutput = screenOutput .. [[]] .. string.format("%.23s", DP.type) .. [[]]
- end
- screenOutput = screenOutput .. [[]] .. DP.percent .. [[%]] ..
- [[]] .. GenerateCommaValue(string.format("%.0f", DP.missinghp), true) .. [[]] ..
- [[]] .. getScraps(DP.missinghp, true) .. [[]] ..
- [[]] .. getRepairTime(DP.missinghp, true) .. [[]] ..
- [[]]
- end
-
- if #damagedElements > DamagePageSize then
- screenOutput = screenOutput ..
- [[Page ]] .. CurrentDamagedPage .. " of " .. math.ceil(#damagedElements / DamagePageSize) ..[[]]
-
- if CurrentDamagedPage < math.ceil(#damagedElements / DamagePageSize) then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "DamagedPageDown",
- mode ="damage",
- x1 = 65,
- x2 = 260,
- y1 = 290 + (damagedElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (damagedElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("DamagedPageDown","damage")
- end
-
- if CurrentDamagedPage > 1 then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "DamagedPageUp",
- mode ="damage",
- x1 = 750,
- x2 = 950,
- y1 = 290 + (damagedElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (damagedElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("DamagedPageUp","damage")
- end
- end
- end
-
- -- Draw broken elements
- if #brokenElements > 0 then
- local brokenElementsToDraw = #brokenElements
- if brokenElementsToDraw > DamagePageSize then
- brokenElementsToDraw = DamagePageSize
- end
- if CurrentBrokenPage == math.ceil(#brokenElements / DamagePageSize) then
- brokenElementsToDraw = #brokenElements % DamagePageSize + 12
- if brokenElementsToDraw > 12 then brokenElementsToDraw = brokenElementsToDraw - 12 end
- end
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
-
- if UseMyElementNames == true then screenOutput = screenOutput .. [[Broken Name]]
- else screenOutput = screenOutput .. [[Broken Type]]
- end
-
- screenOutput = screenOutput .. [[DMG]]
- screenOutput = screenOutput .. [[T]]..ScrapTier..[[ SCRREPTIME]]
-
- AddClickArea("damage", {
- id = "SwitchScrapTier2",
- mode ="damage",
- x1 = 1570,
- x2 = 1690,
- y1 = 315,
- y2 = 360
- })
-
- local i = 0
- for j = 1 + (CurrentBrokenPage - 1) * DamagePageSize, brokenElementsToDraw + (CurrentBrokenPage - 1) * DamagePageSize, 1 do
- i = i + 1
- local DP = brokenElements[j]
- if UseMyElementNames == true then screenOutput = screenOutput .. [[]] .. string.format("%.30s", DP.name) .. [[]]
- else screenOutput = screenOutput .. [[]] .. string.format("%.30s", DP.type) .. [[]]
- end
- screenOutput = screenOutput .. [[]] .. GenerateCommaValue(string.format("%.0f", DP.missinghp), true) .. [[]] ..
- [[]] .. getScraps(DP.missinghp, true) .. [[]] ..
- [[]] .. getRepairTime(DP.missinghp, true) .. [[]] ..
- [[]]
- end
-
-
-
- if #brokenElements > DamagePageSize then
- screenOutput = screenOutput ..
- [[Page ]] .. CurrentBrokenPage .. " of " .. math.ceil(#brokenElements / DamagePageSize) .. [[]]
-
- if CurrentBrokenPage > 1 then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "BrokenPageUp",
- mode ="damage",
- x1 = 1665,
- x2 = 1865,
- y1 = 290 + (brokenElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (brokenElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("BrokenPageUp", "damage")
- end
-
- if CurrentBrokenPage < math.ceil(#brokenElements / DamagePageSize) then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "BrokenPageDown",
- mode ="damage",
- x1 = 980,
- x2 = 1180,
- y1 = 290 + (brokenElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (brokenElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("BrokenPageDown", "damage")
- end
- end
-
- end
-
- -- Draw summary
- if #damagedElements > 0 or #brokenElements > 0 then
- local dWidth = math.floor(1878/#elementsIdList*#damagedElements)
- local bWidth = math.floor(1878/#elementsIdList*#brokenElements)
- local hWidth = 1878-dWidth-bWidth+1
-
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
-
- if #damagedElements > 0 then
- screenOutput = screenOutput .. [[]]..#damagedElements..[[]]
- end
- if #healthyElements > 0 then
- screenOutput = screenOutput .. [[]]..#healthyElements..[[]]
- end
- if #brokenElements > 0 then
- screenOutput = screenOutput .. [[]]..#brokenElements..[[]]
- end
-
- screenOutput = screenOutput .. [[]]
-
- screenOutput = screenOutput .. [[]] ..
- GenerateCommaValue(string.format("%.0f", totalShipMaxHP - totalShipHP)) .. [[ HP damage in total ]] ..
- getScraps(totalShipMaxHP - totalShipHP, true) .. [[ T]]..ScrapTier..[[ scraps needed. ]] ..
- getRepairTime(totalShipMaxHP - totalShipHP, true) .. [[ projected repair time.]]
- else
- screenOutput = screenOutput .. GetElementLogo(812, 380, "ch", "ch", "ch") ..
- [[]] .. OkayCenterMessage .. [[]] ..
- [[]]..#healthyElements..[[ elements stand ]] .. GenerateCommaValue(string.format("%.0f", totalShipMaxHP)) .. [[ HP strong.]]
- end
-
- forceDamageRedraw = false
-
- return screenOutput
-end
-
-function ActionStopengines()
- ToggleHUD()
-end
-
-function ActionStrafeRight()
- if KeyCTRLPressed == true then
- if HUDShiftU < 4000 then
- HUDShiftU = HUDShiftU + 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- HudDeselectElement()
- end
-end
-
-function ActionStrafeLeft()
- if KeyCTRLPressed == true then
- if HUDShiftU >= 50 then
- HUDShiftU = HUDShiftU - 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- ToggleHUD()
- end
-end
-
-function ActionDown()
- if KeyCTRLPressed == true then
- if HUDShiftV < 4000 then
- HUDShiftV = HUDShiftV + 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- ChangeHudSelectedElement(1)
- end
-end
-
-function ActionUp()
- if KeyCTRLPressed == true then
- if HUDShiftV >= 50 then
- HUDShiftV = HUDShiftV - 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- ChangeHudSelectedElement(-1)
- end
-end
-
-function ActionOption1()
- ScrapTier = 1
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption2()
- ScrapTier = 2
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption3()
- ScrapTier = 3
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption4()
- ScrapTier = 4
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption8()
- HUDShiftU=0
- HUDShiftV=0
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption9()
- SaveToDatabank()
- SwitchScreens("off")
- unit.exit()
-end
diff --git a/src/DamageReport_3_02_UnitStart_2.lua b/src/DamageReport_3_02_UnitStart_2.lua
deleted file mode 100644
index 0200de8..0000000
--- a/src/DamageReport_3_02_UnitStart_2.lua
+++ /dev/null
@@ -1,2030 +0,0 @@
---[[
- Damage Report 3.02
- A LUA script for Dual Universe
-
- Created By Dorian Gray
- Ingame: DorianGray
- Discord: Dorian Gray#2623
-
- You can find/update this script on GitHub. Explanations, installation and usage information as well as screenshots can be found there too.
- GitHub: https://github.com/DorianTheGrey/DU-DamageReport
-
- GNU Public License 3.0. Use whatever you want, be so kind to leave credit.
-
- Credits & thanks:
- Thanks to NovaQuark for creating the MMO of the century.
- Thanks to Jericho, Dmentia and Archaegeo for learning a lot from their fine scripts.
- Thanks to TheBlacklist for testing and wonderful suggestions.
- SVG patterns by Hero Patterns.
- DU atlas data from Jayle Break.
-
-]]
-
---[[ 1. USER DEFINED VARIABLES ]]
-
-YourShipsName = "Enter here" --export Enter your ship name here if you want it displayed instead of the ship's ID. YOU NEED TO LEAVE THE QUOTATION MARKS.
-
-SkillRepairToolEfficiency = 0 --export Enter (0-5) your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency"
-SkillRepairToolOptimization = 0 --export Enter your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Optimization"
-
--- SkillAtmosphericFuelEfficiency = 0 --export Enter (0-5) your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency"
--- SkillSpaceFuelEfficiency = 0 --export Enter (0-5) your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency"
--- SkillRocketFuelEfficiency = 0 --export Enter (0-5) your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency"
-
-StatAtmosphericFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED ATMOSPHERIC FUEL TANKS (from the builders talent "Piloting -> Atmospheric Flight Technician -> Atmospheric Fuel-Tank Handling")
-StatSpaceFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL SPACE TANKS (from the builders talent "Piloting -> Atmospheric Engine Technician -> Space Fuel-Tank Handling")
-StatRocketFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL ROCKET TANKS (from the builders talent "Piloting -> Rocket Scientist -> Rocket Booster Fuel Tank Handling")
-StatFuelTankOptimization = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL TANKS "from the builders talent Mining and Inventory -> Stock Control -> Fuel Tank Optimization"
-
-ShowWelcomeMessage = true --export Do you want the welcome message on the start screen with your name?
-AddSummertimeHour = false --export: Is summertime currently enabled in your location? (Adds one hour.)
-
---[[ 2. GLOBAL VARIABLES ]]
-
-UpdateDataInterval = 1.0 -- How often shall the data be updated? (Increase if running into CPU issues.)
-HighlightBlinkingInterval = 0.5 -- How fast shall highlight arrows of marked elements blink?
-
-ColorPrimary = "FF6700" -- Enter the hexcode of the main color to be used by all views.
-ColorSecondary = "FFFFFF" -- Enter the hexcode of the secondary color to be used by all views.
-ColorTertiary = "000000" -- Enter the hexcode of the tertiary color to be used by all views.
-ColorHealthy = "00FF00" -- Enter the hexcode of the 'healthy' color to be used by all views.
-ColorWarning = "FFFF00" -- Enter the hexcode of the 'warning' color to be used by all views.
-ColorCritical = "FF0000" -- Enter the hexcode of the 'critical' color to be used by all views.
-ColorBackground = "000000" -- Enter the hexcode of the background color to be used by all views.
-ColorBackgroundPattern = "4F4F4F" -- Enter the hexcode of the background color to be used by all views.
-ColorFuelAtmospheric = "004444" -- Enter the hexcode of the atmospheric fuel color.
-ColorFuelSpace = "444400" -- Enter the hexcode of the space fuel color.
-ColorFuelRocket = "440044" -- Enter the hexcode of the rocket fuel color.
-
-VERSION = 3.02
-DebugMode = false
-DebugRenderClickareas = true
-
-DBData = {}
-
-core = nil
-db = nil
-screens = {}
-dscreens = {}
-
-Warnings = {}
-
-screenModes = {
- ["flight"] = { id="flight" },
- ["damage"] = { id="damage" },
- ["damageoutline"] = { id="damageoutline" },
- ["fuel"] = { id="fuel" },
- ["cargo"] = { id="cargo" },
- ["agg"] = { id="agg" },
- ["map"] = { id="map" },
- ["time"] = { id="time", activetoggle="true" },
- ["settings1"] = { id="settings1" },
- ["startup"] = { id="startup" }
-}
-
-backgroundModes = { "deathstar", "capsule", "rain", "signal", "hexagon", "diagonal", "diamond", "plus", "dots" }
-BackgroundMode ="deathstar"
-BackgroundSelected = 1
-BackgroundModeOpacity = 0.25
-
-SaveVars = { "dscreens",
- "ColorPrimary", "ColorSecondary", "ColorTertiary",
- "ColorHealthy", "ColorWarning", "ColorCritical",
- "ColorBackground", "ColorBackgroundPattern",
- "ScrapTier", "HUDMode", "SimulationMode", "DMGOStretch",
- "HUDShiftU", "HUDShiftV", "colorIDIndex", "colorIDTable",
- "BackgroundMode", "BackgroundSelected", "BackgroundModeOpacity" }
-
-HUDMode = false
-HUDShiftU = 0
-HUDShiftV = 0
-hudSelectedIndex = 0
-hudStartIndex = 1
-hudArrowSticker = {}
-highlightOn = false
-highlightID = 0
-highlightX = 0
-highlightY = 0
-highlightZ = 0
-
-SimulationMode = false
-OkayCenterMessage = "All systems nominal."
-CurrentDamagedPage = 1
-CurrentBrokenPage = 1
-DamagePageSize = 12
-ScrapTier = 1
-totalScraps = 0
-ScrapTierRepairTimes = { 10, 50, 250, 1250 }
-
-coreWorldOffset = 0
-totalShipHP = 0
-formerTotalShipHP = -1
-totalShipMaxHP = 0
-totalShipIntegrity = 100
-elementsId = {}
-elementsIdList = {}
-damagedElements = {}
-brokenElements = {}
-rE = {}
-healthyElements = {}
-typeElements = {}
-ElementCounter = 0
-UseMyElementNames = true
-dmgoElements = {}
-DMGOMaxElements = 250
-DMGOStretch = false
-ShipXmin = 99999999
-ShipXmax = -99999999
-ShipYmin = 99999999
-ShipYmax = -99999999
-ShipZmin = 99999999
-ShipZmax = -99999999
-
-totalShipMass = 0
-formerTotalShipMass = -1
-
-formerTime = -1
-
-FuelAtmosphericTanks = {}
-FuelSpaceTanks = {}
-FuelRocketTanks = {}
-FuelAtmosphericTotal = 0
-FuelSpaceTotal = 0
-FuelRocketTotal = 0
-FuelAtmosphericCurrent = 0
-FuelSpaceTotalCurrent = 0
-FuelRocketTotalCurrent = 0
-formerFuelAtmosphericTotal = -1
-formerFuelSpaceTotal = -1
-formerFuelRocketTotal = -1
-
-hexTable = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"}
-colorIDIndex = 1
-colorIDTable = {
- [1] = {
- id="ColorPrimary",
- desc="Main HUD Color",
- basec = "FF6700",
- newc = "FF6700"
- },
- [2] = {
- id="ColorSecondary",
- desc="Secondary HUD Color",
- basec = "FFFFFF",
- newc = "FFFFFF"
- },
- [3] = {
- id="ColorTertiary",
- desc="Tertiary HUD Color",
- basec = "000000",
- newc = "000000"
- },
- [4] = {
- id="ColorHealthy",
- desc="Color code for Healthy/Okay",
- basec = "00FF00",
- newc = "00FF00"
- },
- [5] = {
- id="ColorWarning",
- desc="Color code for Damaged/Warning",
- basec = "FFFF00",
- newc = "FFFF00"
- },
- [6] = {
- id="ColorCritical",
- desc="Color code for Broken/Critical",
- basec = "FF0000",
- newc = "FF0000"
- },
- [7] = {
- id="ColorBackground",
- desc="Background Color",
- basec = "000000",
- newc = "000000"
- },
- [8] = {
- id="ColorBackgroundPattern",
- desc="Background Pattern Color",
- basec = "4F4F4F",
- newc = "4F4F4F"
- },
- [9] = {
- id="ColorFuelAtmospheric",
- desc="Color for Atmo Fuel/Elements",
- basec = "004444",
- newc = "004444"
- },
- [10] = {
- id="ColorFuelSpace",
- desc="Color for Space Fuel/Elements",
- basec = "444400",
- newc = "444400"
- },
- [11] = {
- id="ColorFuelRocket",
- desc="Color for Rocket Fuel/Elements",
- basec = "440044",
- newc = "440044"
- }
-}
-
-
---[[ 3. PROCESSING FUNCTIONS ]]
-
-function InitiateSlots()
- for slot_name, slot in pairs(unit) do
- if type(slot) == "table" and type(slot.export) == "table" and
- slot.getElementClass then
- local elementClass = slot.getElementClass():lower()
- if elementClass:find("coreunit") then
- core = slot
- local coreHP = core.getMaxHitPoints()
- if coreHP > 10000 then
- coreWorldOffset = 128
- elseif coreHP > 1000 then
- coreWorldOffset = 64
- elseif coreHP > 150 then
- coreWorldOffset = 32
- else
- coreWorldOffset = 16
- end
- elseif elementClass == 'databankunit' then
- db = slot
- elseif elementClass == "screenunit" then
- local iScreenMode = "startup"
- screens[#screens + 1] = {
- element = slot,
- id = slot.getId(),
- mode = iScreenMode,
- submode = "",
- ClickAreas = {},
- refresh = true,
- active = false,
- fuelA = true,
- fuelS = true,
- fuelR = true,
- fuelIndex = 1
- }
- end
- end
- end
-end
-
-function LoadFromDatabank()
- if db == nil then
- return
- else
- for _, data in pairs(SaveVars) do
- if db.hasKey(data) then
- local jData = json.decode( db.getStringValue(data) )
- if jData ~= nil then
- if data == "YourShipsName" or data == "AddSummertimeHour" or data == "UpdateDataInterval" or data == "HighlightBlinkingInterval" or
- data == "SkillRepairToolEfficiency" or data == "SkillRepairToolOptimization" or data == "SkillAtmosphericFuelEfficiency" or
- data == "SkillSpaceFuelEfficiency" or data == "SkillRocketFuelEfficiency" or data == "StatAtmosphericFuelTankHandling" or
- data == "StatSpaceFuelTankHandling" or data == "StatRocketFuelTankHandling"
- then
- -- Nada
- else
- _G[data] = jData
- end
- end
- end
- end
-
- for i,v in ipairs(screens) do
- for j,dv in ipairs(dscreens) do
- if screens[i].id == dscreens[j].id then
- screens[i].mode = dscreens[j].mode
- screens[i].submode = dscreens[j].submode
- screens[i].active = dscreens[j].active
- screens[i].refresh = true
- screens[i].fuelA = dscreens[j].fuelA
- screens[i].fuelS = dscreens[j].fuelS
- screens[i].fuelR = dscreens[j].fuelR
- screens[i].fuelIndex = dscreens[j].fuelIndex
- end
- end
- end
- end
-end
-
-function SaveToDatabank()
- if db == nil then
- return
- else
- dscreens = {}
- for i,screen in ipairs(screens) do
- dscreens[i] = {}
- dscreens[i].id = screen.id
- dscreens[i].mode = screen.mode
- dscreens[i].submode = screen.submode
- dscreens[i].active = screen.active
- dscreens[i].fuelA = screen.fuelA
- dscreens[i].fuelS = screen.fuelS
- dscreens[i].fuelR = screen.fuelR
- dscreens[i].fuelIndex = screen.fuelIndex
- end
-
- db.clear()
-
- for _, data in pairs(SaveVars) do
- db.setStringValue(data, json.encode(_G[data]))
- end
-
- end
-end
-
-function InitiateScreens()
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- screens[i] = CreateClickAreasForScreen(screens[i])
- end
- end
-end
-
-function UpdateTypeData()
- FuelAtmosphericTanks = {}
- FuelSpaceTanks = {}
- FuelRocketTanks = {}
-
- FuelAtmosphericTotal = 0
- FuelAtmosphericCurrent = 0
- FuelSpaceTotal = 0
- FuelSpaceCurrent = 0
- FuelRocketCurrent = 0
- FuelRocketTotal = 0
-
- local weightAtmosphericFuel = 4
- local weightSpaceFuel = 6
- local weightRocketFuel = 0.8
-
- if StatFuelTankOptimization > 0 then
- weightAtmosphericFuel = weightAtmosphericFuel - 0.09 * StatFuelTankOptimization * weightAtmosphericFuel
- weightSpaceFuel = weightSpaceFuel - 0.09 * StatFuelTankOptimization * weightSpaceFuel
- weightRocketFuel = weightRocketFuel - 0.09 * StatFuelTankOptimization * weightRocketFuel
- end
-
- for i, id in ipairs(typeElements) do
- local idName = core.getElementNameById(id) or ""
- local idType = core.getElementTypeById(id) or ""
- -- local idTypeClean = idType:gsub("[%s%-]+", ""):lower()
- local idPos = core.getElementPositionById(id) or 0
- local idHP = core.getElementHitPointsById(id) or 0
- local idMaxHP = core.getElementMaxHitPointsById(id) or 0
- local idMass = core.getElementMassById(id) or 0
-
- local baseSize = ""
- local baseVol = 0
- local baseMass = 0
- local cMass = 0
- local cVol = 0
-
- if idType == "atmospheric fuel-tank" then
- if idMaxHP > 10000 then
- baseSize = "L"
- baseMass = 5480
- baseVol = 12800
- elseif idMaxHP > 1300 then
- baseSize = "M"
- baseMass = 988.67
- baseVol = 1600
- elseif idMaxHP > 150 then
- baseSize = "S"
- baseMass = 182.67
- baseVol = 400
- else
- baseSize = "XS"
- baseMass = 35.03
- baseVol = 100
- end
- if StatAtmosphericFuelTankHandling > 0 then
- baseVol = 0.2 * StatAtmosphericFuelTankHandling * baseVol + baseVol
- end
- cMass = idMass - baseMass
- if cMass <=10 then cMass = 0 end
- cVol = string.format("%.0f", cMass / weightAtmosphericFuel)
- cPercent = string.format("%.1f", math.floor(100/baseVol * tonumber(cVol)))
- table.insert(FuelAtmosphericTanks, {
- type = 1,
- id = id,
- name = idName,
- maxhp = idMaxHP,
- hp = GetHPforElement(id),
- pos = idPos,
- size = baseSize,
- mass = baseMass,
- vol = baseVol,
- cvol = cVol,
- percent = cPercent
- })
- if idHP > 0 then
- FuelAtmosphericCurrent = FuelAtmosphericCurrent + cVol
- end
- FuelAtmosphericTotal = FuelAtmosphericTotal + baseVol
- elseif idType == "space fuel-tank" then
- if idMaxHP > 10000 then
- baseSize = "L"
- baseMass = 5480
- baseVol = 12800
- elseif idMaxHP > 1300 then
- baseSize = "M"
- baseMass = 988.67
- baseVol = 1600
- else
- baseSize = "S"
- baseMass = 182.67
- baseVol = 400
- end
- if StatSpaceFuelTankHandling > 0 then
- baseVol = 0.2 * StatSpaceFuelTankHandling * baseVol + baseVol
- end
- cMass = idMass - baseMass
- if cMass <=10 then cMass = 0 end
- cVol = string.format("%.0f", cMass / weightSpaceFuel)
- cPercent = string.format("%.1f", (100/baseVol * tonumber(cVol)))
- table.insert(FuelSpaceTanks, {
- type = 2,
- id = id,
- name = idName,
- maxhp = idMaxHP,
- hp = GetHPforElement(id),
- pos = idPos,
- size = baseSize,
- mass = baseMass,
- vol = baseVol,
- cvol = cVol,
- percent = cPercent
- })
- if idHP > 0 then
- FuelSpaceCurrent = FuelSpaceCurrent + cVol
- end
- FuelSpaceTotal = FuelSpaceTotal + baseVol
- elseif idType == "rocket fuel-tank" then
- if idMaxHP > 65000 then
- baseSize = "L"
- baseMass = 25740
- baseVol = 50000
- elseif idMaxHP > 6000 then
- baseSize = "M"
- baseMass = 4720
- baseVol = 6400
- elseif idMaxHP > 700 then
- baseSize = "S"
- baseMass = 886.72
- baseVol = 800
- else
- baseSize = "XS"
- baseMass = 173.42
- baseVol = 400
- end
- if StatRocketFuelTankHandling > 0 then
- baseVol = 0.2 * StatRocketFuelTankHandling * baseVol + baseVol
- end
- cMass = idMass - baseMass
- if cMass <=10 then cMass = 0 end
- cVol = string.format("%.0f", cMass / weightRocketFuel)
- cPercent = string.format("%.1f", (100/baseVol * tonumber(cVol)))
- table.insert(FuelRocketTanks, {
- type = 3,
- id = id,
- name = idName,
- maxhp = idMaxHP,
- hp = GetHPforElement(id),
- pos = idPos,
- size = baseSize,
- mass = baseMass,
- vol = baseVol,
- cvol = cVol,
- percent = cPercent
- })
- if idHP > 0 then
- FuelRocketCurrent = FuelRocketCurrent + cVol
- end
- FuelRocketTotal = FuelRocketTotal + baseVol
- end
-
- end
-
- if FuelAtmosphericCurrent ~= formerFuelAtmosphericCurrent then
- SetRefresh("fuel")
- formerFuelAtmosphericCurrent = FuelAtmosphericCurrent
- end
- if FuelSpaceCurrent ~= formerFuelSpaceCurrent then
- SetRefresh("fuel")
- formerFuelSpaceCurrent = FuelSpaceCurrent
- end
- if FuelRocketCurrent ~= formerFuelRocketCurrent then
- SetRefresh("fuel")
- formerFuelRocketCurrent = FuelRocketCurrent
- end
-
-end
-
-function UpdateDamageData(initial)
-
- initial = initial or false
-
- if SimulationActive == true then return end
-
- local formerTotalShipHP = totalShipHP
- totalShipHP = 0
- totalShipMaxHP = 0
- totalShipIntegrity = 100
- damagedElements = {}
- brokenElements = {}
- healthyElements = {}
- ElementCounter = 0
-
- elementsIdList = core.getElementIdList()
-
- for i, id in pairs(elementsIdList) do
-
- ElementCounter = ElementCounter + 1
-
- local idName = core.getElementNameById(id)
-
- local idType = core.getElementTypeById(id)
- -- local idTypeClean = idType:gsub("[%s%-]+", ""):lower()
- local idPos = core.getElementPositionById(id)
- local idHP = core.getElementHitPointsById(id)
- local idMaxHP = core.getElementMaxHitPointsById(id)
- -- local idMass = core.getElementMassById(id)
-
- if SimulationMode == true then
- SimulationActive = true
- local dice = math.random(0, 10)
- if dice < 2 and #brokenElements < 30 then
- idHP = 0
- elseif dice >= 2 and dice < 4 and #damagedElements < 30 then
- idHP = math.random(1, math.ceil(idMaxHP))
- else
- idHP = idMaxHP
- end
- end
-
- totalShipHP = totalShipHP + idHP
- totalShipMaxHP = totalShipMaxHP + idMaxHP
-
- if idMaxHP - idHP > constants.epsilon then
-
- if idHP > 0 then
- table.insert(damagedElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP - idHP,
- percent = math.ceil(100 / idMaxHP * idHP),
- pos = idPos
- })
- else
- table.insert(brokenElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP - idHP,
- percent = 0,
- pos = idPos
- })
- end
- else
- table.insert(healthyElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- pos = idPos
- })
- if id == highlightID then
- highlightID = 0
- highlightOn = false
- HideHighlight()
- hudSelectedIndex = 0
- end
- end
-
- if initial == true then
- if
- idType == "atmospheric fuel-tank" or
- idType == "space fuel-tank" or
- idType == "rocket fuel-tank"
- then
- table.insert(typeElements, id)
- end
- end
- end
-
- SortDamageTables()
-
- rE = {}
- if #brokenElements > 0 then
- for _,v in ipairs(brokenElements) do
- table.insert(rE, {id=v.id, missinghp=v.missinghp, hp=v.hp, name=v.name, type=v.type, pos=v.pos})
- end
- end
- if #damagedElements > 0 then
- for _,v in ipairs(damagedElements) do
- table.insert(rE, {id=v.id, missinghp=v.missinghp, hp=v.hp, name=v.name, type=v.type, pos=v.pos})
- end
- end
- if #rE > 0 then
- table.sort(rE, function(a,b) return a.missinghp>b.missinghp end)
- end
-
- totalShipIntegrity = string.format("%2.0f", 100 / totalShipMaxHP * totalShipHP)
-
- if formerTotalShipHP ~= totalShipHP then
- forceDamageRedraw = true
- formerTotalShipHP = totalShipHP
- else
- forceDamageRedraw = false
- end
-end
-
-function GetHPforElement(id)
- for i,v in ipairs(brokenElements) do
- if v.id == id then
- return 0
- end
- end
- for i,v in ipairs(damagedElements) do
- if v.id == id then
- return v.hp
- end
- end
- for i,v in ipairs(healthyElements) do
- if v.id == id then
- return v.maxhp
- end
- end
-end
-
-function UpdateClickArea(candidate, newEntry, mode)
- for i, screen in ipairs(screens) do
- for k, v in pairs(screens[i].ClickAreas) do
- if v.id == candidate and v.mode == mode then
- screens[i].ClickAreas[k] = newEntry
- end
- end
- end
-end
-
-function AddClickArea(mode, newEntry)
- for i, screen in ipairs(screens) do
- if screens[i].mode == mode then
- table.insert(screens[i].ClickAreas, newEntry)
- end
- end
-end
-
-function AddClickAreaForScreenID(screenid, newEntry)
- for i, screen in ipairs(screens) do
- if screens[i].id == screenid then
- table.insert(screens[i].ClickAreas, newEntry)
- end
- end
-end
-
-function DisableClickArea(candidate, mode)
- UpdateClickArea(candidate, {
- id = candidate,
- mode = mode,
- x1 = -1,
- x2 = -1,
- y1 = -1,
- y2 = -1
- })
-end
-
-function SetRefresh(mode, submode)
- mode = mode or "all"
- submode = submode or "all"
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- if screens[i].mode == mode or mode == "all" then
- if screens[i].submode == submode or submode =="all" then
- screens[i].refresh = true
- end
- end
- end
- end
-end
-
-function WipeClickAreasForScreen(screen)
- screen.ClickAreas = {}
- return screen
-end
-
-function CreateBaseClickAreas(screen)
- table.insert(screen.ClickAreas, {mode = "all", id = "ToggleHudMode", x1 = 1537, x2 = 1728, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "damage", x1 = 193, x2 = 384, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "damageoutline", x1 = 385, x2 = 576, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "fuel", x1 = 577, x2 = 768, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "flight", x1 = 769, x2 = 960, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "cargo", x1 = 961, x2 = 1152, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "agg", x1 = 1153, x2 = 1344, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "map", x1 = 1345, x2 = 1536, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "time", x1 = 0, x2 = 192, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "settings1", x1 = 1729, x2 = 1920, y1 = 1015, y2 = 1075} )
- return screen
-end
-
-function CreateClickAreasForScreen(screen)
-
- if screen == nil then return {} end
-
- if screen.mode == "flight" then
- elseif screen.mode == "damage" then
- table.insert( screen.ClickAreas, {mode = "damage", id = "ToggleElementLabel", x1 = 70, x2 = 425, y1 = 325, y2 = 355} )
- table.insert( screen.ClickAreas, {mode = "damage", id = "ToggleElementLabel2", x1 = 980, x2 = 1400, y1 = 325, y2 = 355} )
- elseif screen.mode == "damageoutline" then
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeView", param = "top", x1 = 60, x2 = 439, y1 = 150, y2 = 200} )
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeView", param = "side", x1 = 440, x2 = 824, y1 = 150, y2 = 200} )
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeView", param = "front", x1 = 825, x2 = 1215, y1 = 150, y2 = 200} )
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeStretch", x1 = 1530, x2 = 1580, y1 = 150, y2 = 200} )
- elseif screen.mode == "fuel" then
- elseif screen.mode == "cargo" then
- elseif screen.mode == "agg" then
- elseif screen.mode == "map" then
- elseif screen.mode == "time" then
- elseif screen.mode == "settings1" then
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ToggleBackground", x1 = 75, x2 = 860, y1 = 170, y2 = 215} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "PreviousBackground", x1 = 75, x2 = 460, y1 = 235, y2 = 285} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "NextBackground", x1 = 480, x2 = 860, y1 = 235, y2 = 285} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "DecreaseOpacity", x1 = 75, x2 = 460, y1 = 300, y2 = 350} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "IncreaseOpacity", x1 = 480, x2 = 860, y1 = 300, y2 = 350} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ResetColors", x1 = 75, x2 = 860, y1 = 370, y2 = 415} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "PreviousColorID", x1 = 90, x2 = 140, y1 = 500, y2 = 550} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "NextColorID", x1 = 795, x2 = 845, y1 = 500, y2 = 550} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="1", x1 = 210, x2 = 290, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="2", x1 = 300, x2 = 380, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="3", x1 = 385, x2 = 465, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="4", x1 = 470, x2 = 550, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="5", x1 = 560, x2 = 640, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="6", x1 = 645, x2 = 725, y1 = 655, y2 = 700} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="1", x1 = 210, x2 = 290, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="2", x1 = 300, x2 = 380, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="3", x1 = 385, x2 = 465, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="4", x1 = 470, x2 = 550, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="5", x1 = 560, x2 = 640, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="6", x1 = 645, x2 = 725, y1 = 740, y2 = 780} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ResetPosColor", x1 = 160, x2 = 340, y1 = 885, y2 = 935} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ApplyPosColor", x1 = 355, x2 = 780, y1 = 885, y2 = 935} )
-
- elseif screen.mode == "startup" then
- end
-
- screen = CreateBaseClickAreas(screen)
-
- return screen
-end
-
-function CheckClick(x, y, HitTarget)
- x = x*1920
- y = y*1120
- HitTarget = HitTarget or ""
- HitPayload = {}
- -- PrintConsole("Clicked: "..x.." / "..y)
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- if screens[i].active == true and screens[i].element.getMouseX() ~= -1 and screens[i].element.getMouseY() ~= -1 then
- if HitTarget == "" then
- for k, v in pairs(screens[i].ClickAreas) do
- if v ~=nil and x >= v.x1 and x <= v.x2 and y >= v.y1 and y <= v.y2 then
- HitTarget = v.id
- HitPayload = v
- break
- end
- end
- end
- if HitTarget == "ButtonPress" then
- if screens[i].mode == HitPayload.param then
- screens[i].mode = "startup"
- else
- screens[i].mode = HitPayload.param
- end
-
- if screens[i].mode == "damageoutline" then
- if screens[i].submode == "" then
- screens[i].submode = "top"
- end
- end
- screens[i].refresh = true
- screens[i].ClickAreas = {}
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "ToggleBackground" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundMode == "" then
- BackgroundSelected = 1
- BackgroundMode = backgroundModes[BackgroundSelected]
- else
- BackgroundSelected = 1
- BackgroundMode = ""
- end
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "PreviousBackground" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundMode == "" then
- BackgroundSelected = 1
- BackgroundMode = backgroundModes[BackgroundSelected]
- else
- if BackgroundSelected <= 1 then
- BackgroundSelected = #backgroundModes
- else
- BackgroundSelected = BackgroundSelected - 1
- end
- BackgroundMode = backgroundModes[BackgroundSelected]
- end
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "NextBackground" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundMode == "" then
- BackgroundSelected = 1
- BackgroundMode = backgroundModes[BackgroundSelected]
- else
- if BackgroundSelected >= #backgroundModes then
- BackgroundSelected = 1
- else
- BackgroundSelected = BackgroundSelected + 1
- end
- BackgroundMode = backgroundModes[BackgroundSelected]
- end
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "DecreaseOpacity" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundModeOpacity>0.1 then
- BackgroundModeOpacity = BackgroundModeOpacity - 0.05
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- end
- elseif HitTarget == "IncreaseOpacity" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundModeOpacity<1.0 then
- BackgroundModeOpacity = BackgroundModeOpacity + 0.05
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- end
- elseif HitTarget == "ResetColors" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- db.clear()
- ColorPrimary = "FF6700"
- ColorSecondary = "FFFFFF"
- ColorTertiary = "000000"
- ColorHealthy = "00FF00"
- ColorWarning = "FFFF00"
- ColorCritical = "FF0000"
- ColorBackground = "000000"
- ColorBackgroundPattern = "4f4f4f"
- BackgroundMode = "deathstar"
- BackgroundSelected = 1
- BackgroundModeOpacity = 0.25
- colorIDTable = {
- [1] = {
- id="ColorPrimary",
- desc="Main HUD Color",
- basec = "FF6700",
- newc = "FF6700"
- },
- [2] = {
- id="ColorSecondary",
- desc="Secondary HUD Color",
- basec = "FFFFFF",
- newc = "FFFFFF"
- },
- [3] = {
- id="ColorTertiary",
- desc="Tertiary HUD Color",
- basec = "000000",
- newc = "000000"
- },
- [4] = {
- id="ColorHealthy",
- desc="Color code for Healthy/Okay",
- basec = "00FF00",
- newc = "00FF00"
- },
- [5] = {
- id="ColorWarning",
- desc="Color code for Damaged/Warning",
- basec = "FFFF00",
- newc = "FFFF00"
- },
- [6] = {
- id="ColorCritical",
- desc="Color code for Broken/Critical",
- basec = "FF0000",
- newc = "FF0000"
- },
- [7] = {
- id="ColorBackground",
- desc="Background Color",
- basec = "000000",
- newc = "000000"
- },
- [8] = {
- id="ColorBackgroundPattern",
- desc="Background Pattern Color",
- basec = "4F4F4F",
- newc = "4F4F4F"
- },
- [9] = {
- id="ColorFuelAtmospheric",
- desc="Color for Atmo Fuel/Elements",
- basec = "004444",
- newc = "004444"
- },
- [10] = {
- id="ColorFuelSpace",
- desc="Color for Space Fuel/Elements",
- basec = "444400",
- newc = "444400"
- },
- [11] = {
- id="ColorFuelRocket",
- desc="Color for Rocket Fuel/Elements",
- basec = "440044",
- newc = "440044"
- }
- }
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "PreviousColorID" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- colorIDIndex = colorIDIndex - 1
- if colorIDIndex < 1 then colorIDIndex = #colorIDTable end
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "NextColorID" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- colorIDIndex = colorIDIndex + 1
- if colorIDIndex > #colorIDTable then colorIDIndex = 1 end
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "ColorPosUp" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- local s = tonumber(string.sub(colorIDTable[colorIDIndex].newc, HitPayload.param, HitPayload.param),16)
- s = s + 1
- if s > 15 then s = 0 end
- colorIDTable[colorIDIndex].newc = replace_char(HitPayload.param, colorIDTable[colorIDIndex].newc, hexTable[s+1])
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "ColorPosDown" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- local s = tonumber(string.sub(colorIDTable[colorIDIndex].newc, HitPayload.param, HitPayload.param),16)
- s = s - 1
- if s < 0 then s = 15 end
- colorIDTable[colorIDIndex].newc = replace_char(HitPayload.param, colorIDTable[colorIDIndex].newc, hexTable[s+1])
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "ResetPosColor" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- colorIDTable[colorIDIndex].newc = colorIDTable[colorIDIndex].basec
- _G[colorIDTable[colorIDIndex].id] = colorIDTable[colorIDIndex].basec
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "ApplyPosColor" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- _G[colorIDTable[colorIDIndex].id] = colorIDTable[colorIDIndex].newc
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "DamagedPageDown" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentDamagedPage = CurrentDamagedPage + 1
- if CurrentDamagedPage > math.ceil(#damagedElements / DamagePageSize) then
- CurrentDamagedPage = math.ceil(#damagedElements / DamagePageSize)
- end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "DamagedPageUp" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentDamagedPage = CurrentDamagedPage - 1
- if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "BrokenPageDown" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentBrokenPage = CurrentBrokenPage + 1
- if CurrentBrokenPage > math.ceil(#brokenElements / DamagePageSize) then
- CurrentBrokenPage = math.ceil(#brokenElements / DamagePageSize)
- end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "BrokenPageUp" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentBrokenPage = CurrentBrokenPage - 1
- if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "DMGOChangeView" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- screens[i].submode = HitPayload.param
- UpdateViewDamageoutline(screens[i])
- SaveToDatabank()
- SetRefresh("damageoutline", screens[i].submode)
- RenderScreens("damageoutline", screens[i].submode)
- elseif HitTarget == "DMGOChangeStretch" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if DMGOStretch == true then
- DMGOStretch = false
- else
- DMGOStretch = true
- end
- UpdateViewDamageoutline(screens[i])
- SaveToDatabank()
- SetRefresh("damageoutline")
- RenderScreens("damageoutline")
- elseif HitTarget == "ToggleDisplayAtmosphere" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if screens[i].fuelA == true then
- screens[i].fuelA = false
- else
- screens[i].fuelA = true
- end
- screens[i].fuelIndex = 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "ToggleDisplaySpace" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if screens[i].fuelS == true then
- screens[i].fuelS = false
- else
- screens[i].fuelS = true
- end
- screens[i].fuelIndex = 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "ToggleDisplayRocket" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if screens[i].fuelR == true then
- screens[i].fuelR = false
- else
- screens[i].fuelR = true
- end
- screens[i].fuelIndex = 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "DecreaseFuelIndex" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- screens[i].fuelIndex = screens[i].fuelIndex - 1
- if screens[i].fuelIndex < 1 then screens[i].fuelIndex = 1 end
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "IncreaseFuelIndex" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- screens[i].fuelIndex = screens[i].fuelIndex + 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "ToggleHudMode" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if HUDMode == true then
- HUDMode = false
- forceDamageRedraw = true
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- else
- HUDMode = true
- forceDamageRedraw = true
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- end
- elseif HitTarget == "ToggleSimulation" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentDamagedPage = 1
- CurrentBrokenPage = 1
- if SimulationMode == true then
- SimulationMode = false
- SimulationActive = false
- UpdateDamageData()
- UpdateTypeData()
- forceDamageRedraw = true
- HudDeselectElement()
- SetRefresh("damage")
- SetRefresh("damageoutline")
- SetRefresh("settings1")
- SetRefresh("fuel")
- SaveToDatabank()
- RenderScreens()
- else
- SimulationMode = true
- SimulationActive = false
- UpdateDamageData()
- UpdateTypeData()
- forceDamageRedraw = true
- HudDeselectElement()
- SetRefresh("damage")
- SetRefresh("damageoutline")
- SetRefresh("settings1")
- SetRefresh("fuel")
- SaveToDatabank()
- RenderScreens()
- end
- elseif (HitTarget == "ToggleElementLabel" or HitTarget == "ToggleElementLabel2") and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if UseMyElementNames == true then
- UseMyElementNames = false
- SetRefresh("damage")
- RenderScreens("damage")
- else
- UseMyElementNames = true
- SetRefresh("damage")
- RenderScreens("damage")
- end
- elseif (HitTarget == "SwitchScrapTier" or HitTarget == "SwitchScrapTier2") and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- ScrapTier = ScrapTier + 1
- if ScrapTier > 4 then ScrapTier = 1 end
- SetRefresh("damage")
- RenderScreens("damage")
- end
-
-
- end
- end
- end
-end
-
---[[ 4. RENDERING FUNCTIONS ]]
-
-function GetContentFlight()
- local output = ""
- output = output .. GetHeader("Flight Data Report") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentDamage()
- local output = ""
- if SimulationMode == true then
- output = output .. GetHeader("Damage Report (Simulated damage)") .. [[]]
- else
- output = output .. GetHeader("Damage Report") .. [[]]
- end
- output = output .. GetContentDamageScreen()
- return output
-end
-
-function GetContentDamageoutline(screen)
- UpdateDataDamageoutline()
- UpdateViewDamageoutline(screen)
- local output = ""
- output = output .. GetHeader("Damage Ship Outline Report") ..
- GetDamageoutlineShip() ..
- [[]]
-
- if screen.submode=="top" then
- output = output ..
- [[
-
- Top View
-
- Side View
-
- Front View
- ]]
- elseif screen.submode=="side" then
- output = output ..
- [[
-
- Top View
-
- Side View
-
- Front View
- ]]
- elseif screen.submode=="front" then
- output = output ..
- [[
-
- Top View
-
- Side View
-
- Front View
- ]]
- else
- end
- output = output .. [[]]..#dmgoElements..[[ of ]]..ElementCounter..[[ shown]]
- output = output .. [[]]
- if DMGOStretch == true then
- output = output .. [[]]
- end
- output = output .. [[Stretch both axis]]
- return output
-end
-
-function GetContentFuel(screen)
-
- if #FuelAtmosphericTanks < 1 and #FuelSpaceTanks < 1 and #FuelRocketTanks < 1 then return "" end
-
- local FuelTypes = 0
- local output = ""
- local addHeadline = {}
-
- FuelDisplay = { screen.fuelA, screen.fuelS, screen.fuelR }
-
- if FuelDisplay[1] == true and #FuelAtmosphericTanks > 0 then
- table.insert(addHeadline, "Atmospheric")
- FuelTypes = FuelTypes + 1
- end
- if FuelDisplay[2] == true and #FuelSpaceTanks > 0 then
- table.insert(addHeadline, "Space")
- FuelTypes = FuelTypes + 1
- end
- if FuelDisplay[3] == true and #FuelRocketTanks > 0 then
- table.insert(addHeadline, "Rocket")
- FuelTypes = FuelTypes + 1
- end
-
- output = output .. GetHeader("Fuel Report ("..table.concat(addHeadline, ", ")..")") ..
- [[
- ]]
-
- local totalH = 150
- local counter = 0
- local tOffset = 0
-
- if FuelDisplay[1] == true and #FuelAtmosphericTanks > 0 then
-
- if FuelTypes == 1 then tOffset = 50
- elseif FuelTypes == 2 then tOffset = 6
- elseif FuelTypes == 3 then tOffset = 0
- end
-
- output = output .. [[
-
-
-
- ]]
-
- output = output ..
- [[]]..
- GenerateCommaValue(FuelAtmosphericCurrent, true)..
- [[ of ]]..GenerateCommaValue(FuelAtmosphericTotal, true)..
- [[ | Total Atmospheric Fuel in ]]..#FuelAtmosphericTanks..[[ tank]]..(#FuelAtmosphericTanks==1 and "" or "s")..[[ (]]..math.floor(100/FuelAtmosphericTotal*FuelAtmosphericCurrent)..[[%)]]
- counter = counter + 1
- end
-
- if FuelDisplay[2] == true and #FuelSpaceTanks > 0 then
-
- if FuelTypes == 1 then tOffset = 50
- elseif FuelTypes == 2 then tOffset = 6
- elseif FuelTypes == 3 then tOffset = 0
- end
-
- output = output .. [[
-
-
-
- ]]
-
- output = output ..
- [[]]..
- GenerateCommaValue(FuelSpaceCurrent, true)..
- [[ of ]]..GenerateCommaValue(FuelSpaceTotal, true)..
- [[ | Total Space Fuel in ]]..#FuelSpaceTanks..[[ tank]]..(#FuelSpaceTanks==1 and "" or "s")..[[ (]]..math.floor(100/FuelSpaceTotal*FuelSpaceCurrent)..[[%)]]
- counter = counter + 1
- end
-
- if FuelDisplay[3] == true and #FuelRocketTanks > 0 then
-
- if FuelTypes == 1 then tOffset = 50
- elseif FuelTypes == 2 then tOffset = 6
- elseif FuelTypes == 3 then tOffset = 0
- end
-
- output = output .. [[
-
-
-
- ]]
-
- output = output ..
- [[]]..
- GenerateCommaValue(FuelRocketCurrent, true)..
- [[ of ]]..GenerateCommaValue(FuelRocketTotal, true)..
- [[ | Total Rocket Fuel in ]]..#FuelRocketTanks..[[ tank]]..(#FuelRocketTanks==1 and "" or "s")..[[ (]]..math.floor(100/FuelRocketTotal*FuelRocketCurrent)..[[%)]]
- end
-
- output = output .. [[
-
-
-
- ]]
-
- local DisplayTable = {}
- if screen.fuelIndex == nil or screen.fuelIndex < 1 then
- screen.fuelIndex = 1
- end
-
- if FuelDisplay[1] == true then
- for _,v in ipairs(FuelAtmosphericTanks) do
- table.insert(DisplayTable, v)
- end
- end
- if FuelDisplay[2] == true then
- for _,v in ipairs(FuelSpaceTanks) do
- table.insert(DisplayTable, v)
- end
- end
- if FuelDisplay[3] == true then
- for _,v in ipairs(FuelRocketTanks) do
- table.insert(DisplayTable, v)
- end
- end
-
- table.sort(DisplayTable, function(a,b) return a.type
-
-
- ]]
- if tank.hp == 0 then
- output = output .. [[]]
- elseif tank.maxhp - tank.hp > constants.epsilon then
- output = output .. [[]]
- else
- output = output .. [[]]
- end
- if tank.hp == 0 then output = output .. [[]]..tank.size..[[]]
- else output = output .. [[]]..tank.size..[[]]
- end
-
- if tank.hp == 0 then
- output = output .. [[Broken]] ..
- [[0 of ]]..GenerateCommaValue(tank.vol)..[[]]
- elseif tonumber(tank.percent) < 10 then
- output = output .. [[]]..tank.percent..[[%]] ..
- [[]]..GenerateCommaValue(tank.cvol)..[[ of ]]..GenerateCommaValue(tank.vol)..[[]]
- elseif tonumber(tank.percent) < 30 then
- output = output .. [[]]..tank.percent..[[%]] ..
- [[]]..GenerateCommaValue(tank.cvol)..[[ of ]]..GenerateCommaValue(tank.vol)..[[]]
- else output =
- output .. [[]]..tank.percent..[[%]] ..
- [[]]..GenerateCommaValue(tank.cvol)..[[ of ]]..GenerateCommaValue(tank.vol)..[[]]
- end
-
- output = output ..[[]]..tank.name..[[]]
-
- output = output .. [[]]
-
- end
- end
-
-
-
- if #FuelAtmosphericTanks > 0 then
- output = output .. [[]]
- if FuelDisplay[1] == true then
- output = output .. [[]]
- end
- output = output .. [[ATM]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "ToggleDisplayAtmosphere", x1 = 50, x2 = 100, y1 = 270, y2 = 320} )
- end
-
- if #FuelSpaceTanks > 0 then
- output = output .. [[]]
- if FuelDisplay[2] == true then
- output = output .. [[]]
- end
- output = output .. [[SPC]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "ToggleDisplaySpace", x1 = 200, x2 = 250, y1 = 270, y2 = 320} )
- end
-
- if #FuelRocketTanks > 0 then
- output = output .. [[]]
- if FuelDisplay[3] == true then
- output = output .. [[]]
- end
- output = output .. [[RKT]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "ToggleDisplayRocket", x1 = 350, x2 = 400, y1 = 270, y2 = 320} )
- end
-
- if screen.fuelIndex > 1 then
- output = output .. [[
-
-
- ]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "DecreaseFuelIndex", x1 = 1470, x2 = 1670, y1 = 270, y2 = 320} )
- end
-
- if screen.fuelIndex+cCounter-1 < #DisplayTable then
- output = output .. [[
-
-
- ]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "IncreaseFuelIndex", x1 = 1680, x2 = 1880, y1 = 270, y2 = 320} )
- end
-
- if cCounter > 0 then
- output = output .. [[]]..
- #DisplayTable..
- [[ Tank]]..(#DisplayTable == 1 and "" or "s")..
- [[ (Showing ]]..screen.fuelIndex..[[ to ]]..(screen.fuelIndex+cCounter-1)..[[)]]
- end
-
- return output
-end
-
-function GetContentCargo()
- local output = ""
- output = output .. GetHeader("Cargo Report") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentAGG()
- local output = ""
- output = output .. GetHeader("Anti-Grav Control") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentMap()
- local output = ""
- output = output .. GetHeader("Map Overview") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentTime()
- local output = ""
- output = output .. GetHeader("Time") .. epochTime()
- output = output ..
- [[
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetContentSettings1()
- local output = ""
- output = output .. GetHeader("Settings") .. [[]]
- if BackgroundMode=="" then
- output = output ..[[Activate background]]
- else
- output = output ..[[Deactivate background (']]..BackgroundMode..[[', ]]..string.format("%.0f",BackgroundModeOpacity*100)..[[%)]]
- end
- output = output ..[[
-
- Previous background
-
- Next background
-
-
- Decrease Opacity
-
- Increase Opacity
- ]]
-
- output = output ..
- [[]] ..
- [[Reset background and all colors]]
-
- output = output ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Select and change any of the ]]..#colorIDTable..[[ HUD colors]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]]..colorIDTable[colorIDIndex].desc..[[]] ..
- [[]] ..
- [[Current color]] ..
- [[]] ..
-
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
-
- [[#]] ..
-
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,1,1)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,2,2)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,3,3)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,4,4)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,5,5)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,6,6)..[[]] ..
-
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
-
- [[]] ..
- [[]] ..
- [[New color]] ..
- [[]] ..
- [[Apply new color]] ..
- [[]] ..
- [[Reset]] ..
- [[]]
-
- output = output ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Explanation / Hints]] ..
- [[Coming soon.]]
-
-
- output = output .. [[]]
-
- if SimulationMode == true then
- output = output .. [[Simulating Damage to elements]]
- AddClickArea("settings1", { id = "ToggleSimulation", mode ="settings1", x1 = 940, x2 = 1850, y1 = 919, y2 = 969 })
- else
- output = output .. [[Simulate Damage to elements]]
- AddClickArea("settings1", { id = "ToggleSimulation", mode ="settings1", x1 = 940, x2 = 1850, y1 = 919, y2 = 969 })
- end
-
- return output
-end
-
-function GetContentStartup()
- local output = ""
- output = output .. GetElementLogo(812, 380, "f", "f", "f")
- if YourShipsName == "Enter here" then
- output = output .. [[Spaceship ID ]]..ShipID..[[]]
- else
- output = output .. [[]]..YourShipsName..[[]]
- end
- if ShowWelcomeMessage == true then output = output .. [[Greetings, Commander ]]..PlayerName..[[.]] end
- if #Warnings > 0 then
- output = output .. [[Warning: ]]..(table.concat(Warnings, " "))..[[]]
- end
- output = output .. [[Damage Report v]]..VERSION..[[, by Scion Interstellar, DorianGray - Discord: Dorian Gray#2623. Under GNU Public License 3.0.]]
- return output
-end
-
-function RenderScreen(screen, contentToRender)
- if contentToRender == nil then
- PrintConsole("ERROR: contentToRender is nil.")
- unit.exit()
- end
-
- CreateClickAreasForScreen(screen)
-
- local output =""
- output = output .. [[
-
-
- ]]
-
- output = output .. contentToRender
-
- if screen.mode == "startup" then
- output = output .. [[]]
- else
- output = output .. [[]]
- end
-
- output = output .. [[
-
- ]]
- output = output .. [[]]
-
- -- Center:
-
- --
- --
- --
- --
-
- local outputLength = string.len(output)
- -- PrintConsole("Render: "..screen.mode.." ("..outputLength.." chars)")
- screen.element.setSVG(output)
-end
-
-function RenderScreens(onlymode, onlysubmode)
-
- onlymode = onlymode or "all"
- onlysubmode = onlysubmode or "all"
-
- if screens ~= nil and #screens > 0 then
-
- local contentFlight = ""
- local contentDamage = ""
- local contentDamageoutlineTop = ""
- local contentDamageoutlineSide = ""
- local contentDamageoutlineFront = ""
- local contentFuel = ""
- local contentCargo = ""
- local contentAGG = ""
- local contentMap = ""
- local contentTime = ""
- local contentSettings1 = ""
- local contentStartup = ""
-
- for k,screen in pairs(screens) do
- if screen.refresh == true then
- local contentToRender = ""
-
- if screen.mode == "flight" and (onlymode =="flight" or onlymode =="all") then
- if contentFlight == "" then contentFlight = GetContentFlight() end
- contentToRender = contentFlight
- elseif screen.mode == "damage" and (onlymode =="damage" or onlymode =="all") then
- if contentDamage == "" then contentDamage = GetContentDamage() end
- contentToRender = contentDamage
- elseif screen.mode == "damageoutline" and (onlymode =="damageoutline" or onlymode =="all") then
- if screen.submode == "" then
- screen.submode = "top"
- screens[k].submode = "top"
- end
- if screen.submode == "top" and (onlysubmode == "top" or onlysubmode == "all") then
- if contentDamageoutlineTop == "" then contentDamageoutlineTop = GetContentDamageoutline(screen) end
- contentToRender = contentDamageoutlineTop
- end
- if screen.submode == "side" and (onlysubmode == "side" or onlysubmode == "all") then
- if contentDamageoutlineSide == "" then contentDamageoutlineSide = GetContentDamageoutline(screen) end
- contentToRender = contentDamageoutlineSide
- end
- if screen.submode == "front" and (onlysubmode == "front" or onlysubmode == "all") then
- if contentDamageoutlineFront == "" then contentDamageoutlineFront = GetContentDamageoutline(screen) end
- contentToRender = contentDamageoutlineFront
- end
- elseif screen.mode == "fuel" and (onlymode =="fuel" or onlymode =="all") then
- screen = WipeClickAreasForScreen(screens[k])
- contentToRender = GetContentFuel(screen)
- elseif screen.mode == "cargo" and (onlymode =="cargo" or onlymode =="all") then
- if contentCargo == "" then contentCargo = GetContentCargo() end
- contentToRender = contentCargo
- elseif screen.mode == "agg" and (onlymode =="agg" or onlymode =="all") then
- if contentAGG == "" then contentAGG = GetContentAGG() end
- contentToRender = contentAGG
- elseif screen.mode == "map" and (onlymode =="map" or onlymode =="all") then
- if contentMap == "" then contentMap = GetContentMap() end
- contentToRender = contentMap
- elseif screen.mode == "time" and (onlymode =="time" or onlymode =="all") then
- if contentTime == "" then contentTime = GetContentTime() end
- contentToRender = contentTime
- elseif screen.mode == "settings1" and (onlymode =="settings1" or onlymode =="all") then
- if contentSettings1 == "" then contentSettings1 = GetContentSettings1() end
- contentToRender = contentSettings1
- elseif screen.mode == "startup" and (onlymode =="startup" or onlymode =="all") then
- if contentStartup == "" then contentStartup = GetContentStartup() end
- contentToRender = contentStartup
- else
- contentToRender = "Invalid screen mode. ('"..screen.mode.."')"
- end
-
- if contentToRender ~= "" then
- RenderScreen(screen, contentToRender)
- else
- DrawCenteredText("ERROR: No contentToRender delivered for "..screen.mode)
- PrintConsole("ERROR: No contentToRender delivered for "..screen.mode)
- unit.exit()
- end
- screens[k].refresh = false
- end
- end
- end
-
- if HUDMode == true then
- system.setScreen(GetContentDamageHUDOutput())
- system.showScreen(1)
- else
- system.showScreen(0)
- end
-
-end
-
-function OnTickData(initial)
- if formerTime + 60 < system.getTime() then
- SetRefresh("time")
- end
- totalShipMass = core.getConstructMass()
- if formerTotalShipMass ~= totalShipMass then
- UpdateDamageData(true)
- UpdateTypeData()
- SetRefresh()
- formerTotalShipMass = totalShipMass
- else
- UpdateDamageData(initial)
- UpdateTypeData()
- end
- RenderScreens()
-end
-
---[[ 5. EXECUTION ]]
-
-unit.hide()
-ClearConsole()
-PrintConsole("DAMAGE REPORT v"..VERSION.." STARTED", true)
-InitiateSlots()
-LoadFromDatabank()
-SwitchScreens("on")
-InitiateScreens()
-
-if core == nil then
- PrintConsole("ERROR: Connect the core to the programming board.")
- unit.exit()
-else
- OperatorID = unit.getMasterPlayerId()
- OperatorData = database.getPlayer(OperatorID)
- PlayerName = OperatorData["name"]
- ShipID = core.getConstructId()
-end
-
-if db == nil then
- table.insert(Warnings, "No databank connected, won't save/load settings.")
-end
-
-if YourShipsName == "Enter here" then
- table.insert(Warnings, "No ship name set in LUA settings.")
-end
-
-if SkillRepairToolEfficiency == 0 and SkillRepairToolOptimization == 0 and StatFuelTankOptimization == 0 and
- StatAtmosphericFuelTankHandling == 0 and StatSpaceFuelTankHandling == 0 and StatRocketFuelTankHandling ==0 then
- table.insert(Warnings, "No talents/stats set in LUA settings.")
-end
-
-if SkillRepairToolEfficiency < 0 or SkillRepairToolOptimization < 0 or StatFuelTankOptimization < 0 or
- StatAtmosphericFuelTankHandling < 0 or StatSpaceFuelTankHandling < 0 or StatRocketFuelTankHandling < 0 or
- SkillRepairToolEfficiency > 5 or SkillRepairToolOptimization > 5 or StatFuelTankOptimization > 5 or
- StatAtmosphericFuelTankHandling > 5 or StatSpaceFuelTankHandling > 5 or StatRocketFuelTankHandling > 5 then
- PrintConsole("ERROR: Talents/stats can only range from 0 to 5. Please set correctly in LUA settings and reactivate script.")
- unit.exit()
-end
-
-if screens == nil or #screens == 0 then
- HUDMode = true
- PrintConsole("Warning: No screens connected. Entering HUD mode only.")
-end
-
-OnTickData(true)
-
-unit.setTimer('UpdateData', UpdateDataInterval)
-unit.setTimer('UpdateHighlight', HighlightBlinkingInterval)
\ No newline at end of file
diff --git a/src/DamageReport_3_03_UnitStart_1.lua b/src/DamageReport_3_03_UnitStart_1.lua
deleted file mode 100644
index 8b67c41..0000000
--- a/src/DamageReport_3_03_UnitStart_1.lua
+++ /dev/null
@@ -1,1277 +0,0 @@
---[[
- Damage Report 3.04
- A LUA script for Dual Universe
-
- Created By Dorian Gray
- Ingame: DorianGray
- Discord: Dorian Gray#2623
-
- You can find/update this script on GitHub. Explanations, installation and usage information as well as screenshots can be found there too.
- GitHub: https://github.com/DorianTheGrey/DU-DamageReport
-
- GNU Public License 3.0. Use whatever you want, be so kind to leave credit.
-
- Credits & thanks:
- Thanks to NovaQuark for creating the MMO of the century.
- Thanks to Jericho, Dmentia and Archaegeo for learning a lot from their fine scripts.
- Thanks to TheBlacklist for testing and wonderful suggestions.
- SVG patterns by Hero Patterns.
- DU atlas data from Jayle Break.
-
-]]
-
---[[ 1. HELPER FUNCTIONS ]]
-
-function GenerateCommaValue(amount, kify, postcomma)
- kify = kify or false
- postcomma = postcomma or 1
- local formatted = amount
- if kify == true then
- if string.len(amount)>=4 then
- formatted = string.format("%."..postcomma.."fk", amount/1000)
- else
- formatted = string.format("%."..postcomma.."f", amount)
- end
- else
- while true do
- formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
- if (k == 0) then break end
- end
- end
- return formatted
-end
-
-function PrintConsole(output, highlight)
- highlight = highlight or false
- if highlight then
- system.print(
- "------------------------------------------------------------------------")
- end
- system.print(output)
- if highlight then
- system.print(
- "------------------------------------------------------------------------")
- end
-end
-
-function DrawCenteredText(output)
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- screens[i].element.setCenteredText(output)
- end
- end
-end
-
-function ClearConsole()
- for i = 1, 10, 1 do
- PrintConsole()
- end
-end
-
-function SwitchScreens(state)
- state = state or "on"
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- if state == "on" then
- screens[i].element.clear()
- screens[i].element.activate()
- screens[i].active = true
- else
- screens[i].element.clear()
- screens[i].element.deactivate()
- screens[i].active = false
- end
- end
- end
-end
-
---[[ Convert seconds to string (by Jericho) ]]
-function GetSecondsString(seconds)
- local seconds = tonumber(seconds)
-
- if seconds == nil or seconds <= 0 then
- return "-";
- else
- days = string.format("%2.f", math.floor(seconds/(3600*24)));
- hours = string.format("%2.f", math.floor(seconds/3600 - (days*24)));
- mins = string.format("%2.f", math.floor(seconds/60 - (hours*60) - (days*24*60)));
- secs = string.format("%2.f", math.floor(seconds - hours*3600 - (days*24*60*60) - mins *60));
- str = ""
- if tonumber(days) > 0 then str = str .. days.."d " end
- if tonumber(hours) > 0 then str = str .. hours.."h " end
- if tonumber(mins) > 0 then str = str .. mins.."m " end
- if tonumber(secs) > 0 then str = str .. secs .."s" end
- return str
- end
-end
-
-function replace_char(pos, str, r)
- return str:sub(1, pos-1) .. r .. str:sub(pos+1)
-end
-
---[[ 2. RENDER HELPER FUNCTIONS ]]
-
---[[ epochTime function by Leodr (clock script), enhanced by Jericho (DU Industry script) ]]
-function epochTime()
- function rZ(a)
- if string.len(a) <= 1 then
- return "0" .. a
- else
- return a
- end
- end
- function dPoint(b)
- if not (b == math.floor(b)) then
- return true
- else
- return false
- end
- end
- function lYear(year)
- if not dPoint(year / 4) then
- if dPoint(year / 100) then
- return true
- else
- if not dPoint(year / 400) then
- return true
- else
- return false
- end
- end
- else
- return false
- end
- end
- local c = 5;
- local d = 3600;
- local e = 86400;
- local f = 31536000;
- local g = 31622400;
- local h = 2419200;
- local i = 2505600;
- local j = 2592000;
- local k = 2678400;
- local l = {4, 6, 9, 11}
- local m = {1, 3, 5, 7, 8, 10, 12}
- local n = 0;
- local o = 1506816000;
- local q = system.getTime()
- _G["formerTime"] = q
- if AddSummertimeHour == true then q = q + 3600 end
- now = math.floor(q + o)
- year = 1970;
- secs = 0;
- n = 0;
- while secs + g < now or secs + f < now do
- if lYear(year + 1) then
- if secs + g < now then
- secs = secs + g;
- year = year + 1;
- n = n + 366
- end
- else
- if secs + f < now then
- secs = secs + f;
- year = year + 1;
- n = n + 365
- end
- end
- end
- secondsRemaining = now - secs;
- monthSecs = 0;
- yearlYear = lYear(year)
- month = 1;
- while monthSecs + h < secondsRemaining or monthSecs + j < secondsRemaining or
- monthSecs + k < secondsRemaining do
- if month == 1 then
- if monthSecs + k < secondsRemaining then
- month = 2;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 2 then
- if not yearlYear then
- if monthSecs + h < secondsRemaining then
- month = 3;
- monthSecs = monthSecs + h;
- n = n + 28
- else
- break
- end
- else
- if monthSecs + i < secondsRemaining then
- month = 3;
- monthSecs = monthSecs + i;
- n = n + 29
- else
- break
- end
- end
- end
- if month == 3 then
- if monthSecs + k < secondsRemaining then
- month = 4;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 4 then
- if monthSecs + j < secondsRemaining then
- month = 5;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- if month == 5 then
- if monthSecs + k < secondsRemaining then
- month = 6;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 6 then
- if monthSecs + j < secondsRemaining then
- month = 7;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- if month == 7 then
- if monthSecs + k < secondsRemaining then
- month = 8;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 8 then
- if monthSecs + k < secondsRemaining then
- month = 9;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 9 then
- if monthSecs + j < secondsRemaining then
- month = 10;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- if month == 10 then
- if monthSecs + k < secondsRemaining then
- month = 11;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 11 then
- if monthSecs + j < secondsRemaining then
- month = 12;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- end
- day = 1;
- daySecs = 0;
- daySecsRemaining = secondsRemaining - monthSecs;
- while daySecs + e < daySecsRemaining do
- day = day + 1;
- daySecs = daySecs + e;
- n = n + 1
- end
- hour = 0;
- hourSecs = 0;
- hourSecsRemaining = daySecsRemaining - daySecs;
- while hourSecs + d < hourSecsRemaining do
- hour = hour + 1;
- hourSecs = hourSecs + d
- end
- minute = 0;
- minuteSecs = 0;
- minuteSecsRemaining = hourSecsRemaining - hourSecs;
- while minuteSecs + 60 < minuteSecsRemaining do
- minute = minute + 1;
- minuteSecs = minuteSecs + 60
- end
- second = math.floor(now % 60)
- year = rZ(year)
- month = rZ(month)
- day = rZ(day)
- hour = rZ(hour)
- minute = rZ(minute)
- second = rZ(second)
-
- return [[]]..hour..":".. minute..[[]]..
- [[]]..year.."/".. month.."/"..day..[[]]
-end
-
-
-function ToggleHUD()
- if HUDMode == true then
- HUDMode = false
- forceDamageRedraw = true
- hudSelectedIndex = 0
- highlightID = 0
- HideHighlight()
- SetRefresh()
- RenderScreens()
- else
- HUDMode = true
- forceDamageRedraw = true
- hudSelectedIndex = 0
- highlightID = 0
- HideHighlight()
- SetRefresh()
- RenderScreens()
- end
-end
-
-function HudDeselectElement()
- hudSelectedIndex = 0
- hudStartIndex = 1
- highlightID = 0
- HideHighlight()
- if HUDMode == true then
- SetRefresh("damage")
- SetRefresh("damageoutline")
- RenderScreens()
- end
-end
-
-function ChangeHudSelectedElement(step)
- if HUDMode == true and #rE > 0 then
-
- hudSelectedIndex = hudSelectedIndex + step
- if hudSelectedIndex < 1 then hudSelectedIndex = 1
- elseif hudSelectedIndex > #rE then hudSelectedIndex = #rE
- end
-
- if hudSelectedIndex > 9 then
- hudStartIndex = hudSelectedIndex-9
- end
- if hudSelectedIndex ~= 0 then
- highlightID = rE[hudSelectedIndex].id
- if highlightID ~=nil and highlightID ~= 0 then
- -- PrintConsole("CHSE: hudSelectedIndex: "..hudSelectedIndex.." / hudStartIndex: "..hudStartIndex.." / highlightID: "..highlightID)
- HideHighlight()
- elementPosition = vec3(rE[hudSelectedIndex].pos)
- highlightX = elementPosition.x - coreWorldOffset
- highlightY = elementPosition.y - coreWorldOffset
- highlightZ = elementPosition.z - coreWorldOffset
- highlightOn = true
- ShowHighlight()
- end
- end
-
- SetRefresh("damage")
- SetRefresh("damageoutline")
- RenderScreens()
-
- end
-end
-
-function HideHighlight()
- if #hudArrowSticker > 0 then
- for i in pairs(hudArrowSticker) do
- core.deleteSticker(hudArrowSticker[i])
- end
- hudArrowSticker = {}
- end
-end
-
-function ShowHighlight()
- if highlightOn == true and highlightID > 0 then
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX + 2, highlightY, highlightZ, "north"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY - 2, highlightZ, "east"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX - 2, highlightY, highlightZ, "south"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY + 2, highlightZ, "west"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY, highlightZ - 2, "up"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY, highlightZ + 2,"down"))
- end
-end
-
-function ToggleHighlight()
- if highlightOn == true then
- highlightOn = false
- HideHighlight()
- else
- highlightOn = true
- ShowHighlight()
- end
-end
-
-function SortDamageTables()
- table.sort(damagedElements, function(a, b) return a.missinghp > b.missinghp end)
- table.sort(brokenElements, function(a, b) return a.maxhp > b.maxhp end)
-end
-
-function getScraps(damage,commaval)
- commaval = commaval or false
- damage = damage - SkillRepairToolOptimization * 0.05 * damage
- local res = math.ceil( damage / ( 10 * 5^(ScrapTier-1) ) )
- if commaval ==true then
- return GenerateCommaValue(string.format("%.0f", res ), false)
- else
- return res
- end
-end
-
-function getRepairTime(damage,buildstring)
- buildstring = buildstring or false
- damage = damage - SkillRepairToolOptimization * 0.05 * damage
- local res = math.ceil(damage / ScrapTierRepairTimes[ScrapTier])
- res = res - ( SkillRepairToolEfficiency * 0.1 * res )
- if buildstring == true then
- return GetSecondsString(string.format("%.0f", res ) )
- else
- return res
- end
-end
-
-function UpdateDataDamageoutline()
-
- dmgoElements = {}
-
- for i,element in ipairs(brokenElements) do
- if #dmgoElements < DMGOMaxElements then
- local elementPosition = vec3(element.pos)
- local x = elementPosition.x - coreWorldOffset
- local y = elementPosition.y - coreWorldOffset
- local z = elementPosition.z - coreWorldOffset
- if x < ShipXmin then ShipXmin = x end
- if y < ShipYmin then ShipYmin = y end
- if z < ShipZmin then ShipZmin = z end
- if x > ShipXmax then ShipXmax = x end
- if y > ShipYmax then ShipYmax = y end
- if z > ShipZmax then ShipZmax = z end
- table.insert( dmgoElements, {
- id = element.id,
- type = "b",
- size = element.maxhp,
- x = x, y = y, z = z,
- xp = 0, yp = 0, zp = 0,
- u = 0, v = 0
- })
- end
- end
-
- if #dmgoElements < DMGOMaxElements then
- for i,element in ipairs(damagedElements) do
- if #dmgoElements < DMGOMaxElements then
- local elementPosition = vec3(element.pos)
- local x = elementPosition.x - coreWorldOffset
- local y = elementPosition.y - coreWorldOffset
- local z = elementPosition.z - coreWorldOffset
- if x < ShipXmin then ShipXmin = x end
- if y < ShipYmin then ShipYmin = y end
- if z < ShipZmin then ShipZmin = z end
- if x > ShipXmax then ShipXmax = x end
- if y > ShipYmax then ShipYmax = y end
- if z > ShipZmax then ShipZmax = z end
- table.insert( dmgoElements, {
- id = element.id,
- type = "d",
- size = element.maxhp,
- x = x, y = y, z = z,
- xp = 0, yp = 0, zp = 0,
- u = 0, v = 0
- })
- end
- end
- end
-
- if #dmgoElements < DMGOMaxElements then
- for i,element in ipairs(healthyElements) do
- if #dmgoElements < DMGOMaxElements then
- local elementPosition = vec3(element.pos)
- local x = elementPosition.x - coreWorldOffset
- local y = elementPosition.y - coreWorldOffset
- local z = elementPosition.z - coreWorldOffset
- if x < ShipXmin then ShipXmin = x end
- if y < ShipYmin then ShipYmin = y end
- if z < ShipZmin then ShipZmin = z end
- if x > ShipXmax then ShipXmax = x end
- if y > ShipYmax then ShipYmax = y end
- if z > ShipZmax then ShipZmax = z end
- table.insert( dmgoElements, {
- id = element.id,
- type = "h",
- size = element.maxhp,
- x = x, y = y, z = z,
- xp = 0, yp = 0, zp = 0,
- u = 0, v = 0
- })
- end
- end
- end
-
- ShipX = math.abs(ShipXmax-ShipXmin)
- ShipY = math.abs(ShipYmax-ShipYmin)
- ShipZ = math.abs(ShipZmax-ShipZmin)
-
- --[[
- PrintConsole(
- "ShipXmin: "..string.format("%.2f",ShipXmin)..
- " - ShipYmin: "..string.format("%.2f",ShipYmin)..
- " - ShipZmin: "..string.format("%.2f",ShipZmin)..
- " - ShipXmax: "..string.format("%.2f",ShipXmax)..
- " - ShipYmax: "..string.format("%.2f",ShipYmax)..
- " - ShipZmax: "..string.format("%.2f",ShipZmax)
- )
-
- PrintConsole(
- "ShipX: "..string.format("%.2f",ShipX)..
- " - ShipY: "..string.format("%.2f",ShipY)..
- " - ShipZ: "..string.format("%.2f",ShipZ)
- )
- ]]
-
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].xp = math.abs(100/(ShipXmax-ShipXmin)*(element.x-ShipXmin))
- dmgoElements[i].yp = math.abs(100/(ShipYmax-ShipYmin)*(element.y-ShipYmin))
- dmgoElements[i].zp = math.abs(100/(ShipZmax-ShipZmin)*(element.z-ShipZmin))
- -- PrintConsole(i..". "..element.id..": "..string.format("%.2f",element.x).."/"..string.format("%.2f",element.y).."/"..string.format("%.2f",element.z).." - XP: "..dmgoElements[i].xp.." - YP: "..dmgoElements[i].yp.." - ZP: "..dmgoElements[i].zp)
- end
-
-end
-
-function UpdateViewDamageoutline(screen)
- -- Full Width of virtual screen:
- -- UStart = 20
- -- VStart = 180
- -- UDim = 1880
- -- VDim = 840
- -- Adding frames:
- UFrame = 40
- VFrame = 40
-
- UStart = 20 + UFrame
- VStart = 180 + VFrame
- UDim = 1880 - 2*UFrame
- VDim = 840 - 2*VFrame
-
- if screen.submode == "top" then
- if DMGOStretch == false then
- local UFactor = UDim/(ShipYmax-ShipYmin)
- local VFactor = VDim/(ShipXmax-ShipXmin)
- if UFactor>=VFactor then
- local cFactor = UFactor/VFactor
- local newUDim = math.floor(UDim/cFactor)
- UStart = UStart+(UDim-newUDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100/cFactor*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*element.xp+VStart)
- end
- else
- local cFactor = VFactor/UFactor
- local newVDim = math.floor(VDim/cFactor)
- VStart = VStart+(VDim-newVDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100/cFactor*element.xp+VStart)
- end
- end
- else
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*element.xp+VStart)
- end
- end
-
-
- elseif screen.submode == "front" then
- if DMGOStretch == false then
- local UFactor = UDim/(ShipXmax-ShipXmin)
- local VFactor = VDim/(ShipZmax-ShipZmin)
- if UFactor>=VFactor then
- local cFactor = UFactor/VFactor
- local newUDim = math.floor(UDim/cFactor)
- UStart = UStart+(UDim-newUDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100/cFactor*element.xp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- else
- local cFactor = VFactor/UFactor
- local newVDim = math.floor(VDim/cFactor)
- VStart = VStart+(VDim-newVDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.xp+UStart)
- dmgoElements[i].v = math.floor(VDim/100/cFactor*(100-element.zp)+VStart)
- end
- end
- else
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.xp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- end
-
- elseif screen.submode == "side" then
- if DMGOStretch == false then
- local UFactor = UDim/(ShipYmax-ShipYmin)
- local VFactor = VDim/(ShipXmax-ShipZmin)
- if UFactor>=VFactor then
- local cFactor = UFactor/VFactor
- local newUDim = math.floor(UDim/cFactor)
- UStart = UStart+(UDim-newUDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100/cFactor*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- else
- local cFactor = VFactor/UFactor
- local newVDim = math.floor(VDim/cFactor)
- VStart = VStart+(VDim-newVDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100/cFactor*(100-element.zp)+VStart)
- end
- end
- else
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- end
- else
- DrawCenteredText("ERROR: non-existing DMGO mode set.")
- PrintConsole("ERROR: non-existing DMGO mode set.")
- unit.exit()
- end
-end
-
-function GetDamageoutlineShip()
- local output = ""
-
- for i,element in ipairs(dmgoElements) do
- local cclass = ""
- local size = 1
-
- if element.type == "h" then
- cclass ="ch"
- elseif element.type == "d" then
- cclass = "cw"
- else
- cclass = "cc"
- end
- if element.id == highlightID then
- cclass = "f2"
- end
-
- if element.size > 0 and element.size < 1000 then
- size = 5
- elseif element.size >= 1000 and element.size < 2000 then
- size = 8
- elseif element.size >= 2000 and element.size < 5000 then
- size = 12
- elseif element.size >= 5000 and element.size < 10000 then
- size = 15
- elseif element.size >= 10000 and element.size < 20000 then
- size = 20
- elseif element.size >= 20000 then
- size = 30
- end
- output = output .. [[]]
- if element.id == highlightID then
- output = output .. [[]]
- output = output .. [[]]
- end
- end
-
- return output
-end
-
-function GetContentClickareas(screen)
- local output = ""
- if screen ~= nil and screen.ClickAreas ~= nil and #screen.ClickAreas > 0 then
- for i,ca in ipairs(screen.ClickAreas) do
- output = output ..
- [[]]
- end
- end
- return output
-end
-
-function GetElement1(x, y, width, height)
- x = x or 0
- y = y or 0
- width = width or 600
- height = height or 600
- local output = ""
- output = output ..
- [[
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetElement2(x, y)
- x = x or 0
- y = y or 0
- local output = ""
- output = output .. [[]]
- return output
-end
-
-function GetElementLogo(x, y, primaryC, secondaryC, tertiaryC)
- x = x or 812
- y = y or 380
- primaryC = primaryC or "f"
- secondaryC = secondaryC or "f2"
- tertiaryC = tertiaryC or "f3"
- local output = ""
- output = output .. [[
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetHeader(headertext)
- headertext = headertext or "ERROR: UNDEFINED"
- local output = ""
- output = output ..
- [[
- ]]..headertext..[[]]
- return output
-end
-
-function GetContentBackground(candidate, bgcolor)
- bgColor = ColorBackgroundPattern
-
- local output = ""
-
- if candidate == "dots" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' viewBox='0 0 4 4'%3E%3Cpath fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' d='M1 3h1v1H1V3zm2-2h1v1H3V1z'%3E%3C/path%3E%3C/svg%3E");]]
- elseif candidate == "rain" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='12' height='16' viewBox='0 0 12 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 .99C4 .445 4.444 0 5 0c.552 0 1 .45 1 .99v4.02C6 5.555 5.556 6 5 6c-.552 0-1-.45-1-.99V.99zm6 8c0-.546.444-.99 1-.99.552 0 1 .45 1 .99v4.02c0 .546-.444.99-1 .99-.552 0-1-.45-1-.99V8.99z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E");]]
- elseif candidate == "plus" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "signal" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='84' height='48' viewBox='0 0 84 48' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h12v6H0V0zm28 8h12v6H28V8zm14-8h12v6H42V0zm14 0h12v6H56V0zm0 8h12v6H56V8zM42 8h12v6H42V8zm0 16h12v6H42v-6zm14-8h12v6H56v-6zm14 0h12v6H70v-6zm0-16h12v6H70V0zM28 32h12v6H28v-6zM14 16h12v6H14v-6zM0 24h12v6H0v-6zm0 8h12v6H0v-6zm14 0h12v6H14v-6zm14 8h12v6H28v-6zm-14 0h12v6H14v-6zm28 0h12v6H42v-6zm14-8h12v6H56v-6zm0-8h12v6H56v-6zm14 8h12v6H70v-6zm0 8h12v6H70v-6zM14 24h12v6H14v-6zm14-8h12v6H28v-6zM14 8h12v6H14V8zM0 8h12v6H0V8z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E");]]
- elseif candidate == "deathstar" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='105' viewBox='0 0 80 105'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M20 10a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm15 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zM20 75a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zm30-65a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm0 65a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zM35 10a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zM5 45a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zm60 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10z' /%3E%3C/g%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "diamond" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='32' viewBox='0 0 16 32'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath fill-rule='evenodd' d='M0 24h4v2H0v-2zm0 4h6v2H0v-2zm0-8h2v2H0v-2zM0 0h4v2H0V0zm0 4h2v2H0V4zm16 20h-6v2h6v-2zm0 4H8v2h8v-2zm0-8h-4v2h4v-2zm0-20h-6v2h6V0zm0 4h-4v2h4V4zm-2 12h2v2h-2v-2zm0-8h2v2h-2V8zM2 8h10v2H2V8zm0 8h10v2H2v-2zm-2-4h14v2H0v-2zm4-8h6v2H4V4zm0 16h6v2H4v-2zM6 0h2v2H6V0zm0 24h2v2H6v-2z'/%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "hexagon" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='49' viewBox='0 0 28 49'%3E%3Cg fill-rule='evenodd'%3E%3Cg id='hexagons' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='nonzero'%3E%3Cpath d='M13.99 9.25l13 7.5v15l-13 7.5L1 31.75v-15l12.99-7.5zM3 17.9v12.7l10.99 6.34 11-6.35V17.9l-11-6.34L3 17.9zM0 15l12.98-7.5V0h-2v6.35L0 12.69v2.3zm0 18.5L12.98 41v8h-2v-6.85L0 35.81v-2.3zM15 0v7.5L27.99 15H28v-2.31h-.01L17 6.35V0h-2zm0 49v-8l12.99-7.5H28v2.31h-.01L17 42.15V49h-2z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "capsule" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='32' height='26' viewBox='0 0 32 26' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M14 0v3.994C14 7.864 10.858 11 7 11c-3.866 0-7-3.138-7-7.006V0h2v4.005C2 6.765 4.24 9 7 9c2.756 0 5-2.236 5-4.995V0h2zm0 26v-5.994C14 16.138 10.866 13 7 13c-3.858 0-7 3.137-7 7.006V26h2v-6.005C2 17.235 4.244 15 7 15c2.76 0 5 2.236 5 4.995V26h2zm2-18.994C16 3.136 19.142 0 23 0c3.866 0 7 3.138 7 7.006v9.988C30 20.864 26.858 24 23 24c-3.866 0-7-3.138-7-7.006V7.006zm2-.01C18 4.235 20.244 2 23 2c2.76 0 5 2.236 5 4.995v10.01C28 19.765 25.756 22 23 22c-2.76 0-5-2.236-5-4.995V6.995z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E");]]
- elseif candidate == "diagonal" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='6' height='6' viewBox='0 0 6 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'%3E%3Cpath d='M5 0h1L0 6V5zM6 5v1H5z'/%3E%3C/g%3E%3C/svg%3E");]]
- end
- return output;
-end
-
-function GetContentDamageHUDOutput()
- local hudWidth = 300
- local hudHeight = 165
- if #damagedElements > 0 or #brokenElements > 0 then hudHeight = 510 end
- local output = ""
-
- output = output .. [[
-
- ]]
- output = output .. [[]] ..
- [[]] ..
- [[]] ..
- [[]]..(YourShipsName=="Enter here" and ("Ship ID "..ShipID) or YourShipsName) .. [[]] ..
- [[]]
- if #brokenElements > 0 then
- output = output .. [[]]
- elseif #damagedElements > 0 then
- output = output .. [[]]
- else
- output = output .. [[]]
- end
-
- if #damagedElements > 0 or #brokenElements > 0 then
-
- output = output .. [[Total Damage]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", totalShipMaxHP - totalShipHP))..[[]]
- output = output .. [[T]]..ScrapTier..[[ Scrap Needed]] ..
- [[]]..getScraps(totalShipMaxHP - totalShipHP, true)..[[]]
- output = output .. [[Repair Time]] ..
- [[]]..getRepairTime(totalShipMaxHP - totalShipHP, true)..[[]]
-
- output = output .. [[]] ..
- [[]] ..
- [[]]..#healthyElements..[[]] ..
- [[]] ..
- [[]]..#damagedElements..[[]] ..
- [[]] ..
- [[]]..#brokenElements..[[]]
- local j=0
-
- for currentIndex=hudStartIndex,hudStartIndex+9,1 do
- if rE[currentIndex] ~= nil then
- v = rE[currentIndex]
- if v.hp > 0 then
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- if v.id == highlightID then
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- end
- else
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- if v.id == highlightID then
- highlightX = elementPosition.x - coreWorldOffset
- highlightY = elementPosition.y - coreWorldOffset
- highlightZ = elementPosition.z - coreWorldOffset
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- end
- end
- j=j+1
- end
- end
- output = output ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Up/down arrows to highlight]] ..
- [[CTRL + arrows to move HUD]] ..
- [[Left arrow to toggle HUD Mode]] ..
- [[ALT+1-4 to set Scrap Tier]] ..
- [[ALT+8 to reset HUD position]] ..
- [[ALT+9 to shut script off]] ..
- [[]] ..
- [[]]
- else
- output = output ..
- [[]] .. OkayCenterMessage .. [[]] ..
- [[]]..#healthyElements..[[ elements / ]] .. GenerateCommaValue(string.format("%.0f", totalShipMaxHP)) .. [[ HP.]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Left arrow to toggle HUD Mode]] ..
- [[CTRL + arrows to move HUD]] ..
- [[ALT+8 to reset HUD position]] ..
- [[ALT+9 to shut script off]] ..
- [[]] ..
- [[]]
- end
- output = output .. [[]]
- return output
-end
-
-function GetContentDamageScreen()
-
- local screenOutput = ""
-
- -- Draw damage elements
- if #damagedElements > 0 then
- local damagedElementsToDraw = #damagedElements
- if damagedElementsToDraw > DamagePageSize then
- damagedElementsToDraw = DamagePageSize
- end
- if CurrentDamagedPage == math.ceil(#damagedElements / DamagePageSize) then
- damagedElementsToDraw = #damagedElements % DamagePageSize + 12
- if damagedElementsToDraw > 12 then damagedElementsToDraw = damagedElementsToDraw - 12 end
- end
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
-
- if UseMyElementNames == true then screenOutput = screenOutput .. [[Damaged Name]]
- else screenOutput = screenOutput .. [[Damaged Type]]
- end
-
- screenOutput = screenOutput .. [[HLTHDMG]]
- screenOutput = screenOutput .. [[T]]..ScrapTier..[[ SCRREPTIME]]
-
- AddClickArea("damage", {
- id = "SwitchScrapTier",
- mode ="damage",
- x1 = 650,
- x2 = 775,
- y1 = 315,
- y2 = 360
- })
-
- local i = 0
- for j = 1 + (CurrentDamagedPage - 1) * DamagePageSize, damagedElementsToDraw + (CurrentDamagedPage - 1) * DamagePageSize, 1 do
- i = i + 1
- local DP = damagedElements[j]
- if UseMyElementNames == true then screenOutput = screenOutput .. [[]] .. string.format("%.23s", DP.name) .. [[]]
- else screenOutput = screenOutput .. [[]] .. string.format("%.23s", DP.type) .. [[]]
- end
- screenOutput = screenOutput .. [[]] .. DP.percent .. [[%]] ..
- [[]] .. GenerateCommaValue(string.format("%.0f", DP.missinghp), true) .. [[]] ..
- [[]] .. getScraps(DP.missinghp, true) .. [[]] ..
- [[]] .. getRepairTime(DP.missinghp, true) .. [[]] ..
- [[]]
- end
-
- if #damagedElements > DamagePageSize then
- screenOutput = screenOutput ..
- [[Page ]] .. CurrentDamagedPage .. " of " .. math.ceil(#damagedElements / DamagePageSize) ..[[]]
-
- if CurrentDamagedPage < math.ceil(#damagedElements / DamagePageSize) then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "DamagedPageDown",
- mode ="damage",
- x1 = 65,
- x2 = 260,
- y1 = 290 + (damagedElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (damagedElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("DamagedPageDown","damage")
- end
-
- if CurrentDamagedPage > 1 then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "DamagedPageUp",
- mode ="damage",
- x1 = 750,
- x2 = 950,
- y1 = 290 + (damagedElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (damagedElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("DamagedPageUp","damage")
- end
- end
- end
-
- -- Draw broken elements
- if #brokenElements > 0 then
- local brokenElementsToDraw = #brokenElements
- if brokenElementsToDraw > DamagePageSize then
- brokenElementsToDraw = DamagePageSize
- end
- if CurrentBrokenPage == math.ceil(#brokenElements / DamagePageSize) then
- brokenElementsToDraw = #brokenElements % DamagePageSize + 12
- if brokenElementsToDraw > 12 then brokenElementsToDraw = brokenElementsToDraw - 12 end
- end
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
-
- if UseMyElementNames == true then screenOutput = screenOutput .. [[Broken Name]]
- else screenOutput = screenOutput .. [[Broken Type]]
- end
-
- screenOutput = screenOutput .. [[DMG]]
- screenOutput = screenOutput .. [[T]]..ScrapTier..[[ SCRREPTIME]]
-
- AddClickArea("damage", {
- id = "SwitchScrapTier2",
- mode ="damage",
- x1 = 1570,
- x2 = 1690,
- y1 = 315,
- y2 = 360
- })
-
- local i = 0
- for j = 1 + (CurrentBrokenPage - 1) * DamagePageSize, brokenElementsToDraw + (CurrentBrokenPage - 1) * DamagePageSize, 1 do
- i = i + 1
- local DP = brokenElements[j]
- if UseMyElementNames == true then screenOutput = screenOutput .. [[]] .. string.format("%.30s", DP.name) .. [[]]
- else screenOutput = screenOutput .. [[]] .. string.format("%.30s", DP.type) .. [[]]
- end
- screenOutput = screenOutput .. [[]] .. GenerateCommaValue(string.format("%.0f", DP.missinghp), true) .. [[]] ..
- [[]] .. getScraps(DP.missinghp, true) .. [[]] ..
- [[]] .. getRepairTime(DP.missinghp, true) .. [[]] ..
- [[]]
- end
-
-
-
- if #brokenElements > DamagePageSize then
- screenOutput = screenOutput ..
- [[Page ]] .. CurrentBrokenPage .. " of " .. math.ceil(#brokenElements / DamagePageSize) .. [[]]
-
- if CurrentBrokenPage > 1 then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "BrokenPageUp",
- mode ="damage",
- x1 = 1665,
- x2 = 1865,
- y1 = 290 + (brokenElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (brokenElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("BrokenPageUp", "damage")
- end
-
- if CurrentBrokenPage < math.ceil(#brokenElements / DamagePageSize) then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "BrokenPageDown",
- mode ="damage",
- x1 = 980,
- x2 = 1180,
- y1 = 290 + (brokenElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (brokenElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("BrokenPageDown", "damage")
- end
- end
-
- end
-
- -- Draw summary
- if #damagedElements > 0 or #brokenElements > 0 then
- local dWidth = math.floor(1878/#elementsIdList*#damagedElements)
- local bWidth = math.floor(1878/#elementsIdList*#brokenElements)
- local hWidth = 1878-dWidth-bWidth+1
-
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
-
- if #damagedElements > 0 then
- screenOutput = screenOutput .. [[]]..#damagedElements..[[]]
- end
- if #healthyElements > 0 then
- screenOutput = screenOutput .. [[]]..#healthyElements..[[]]
- end
- if #brokenElements > 0 then
- screenOutput = screenOutput .. [[]]..#brokenElements..[[]]
- end
-
- screenOutput = screenOutput .. [[]]
-
- screenOutput = screenOutput .. [[]] ..
- GenerateCommaValue(string.format("%.0f", totalShipMaxHP - totalShipHP)) .. [[ HP damage in total ]] ..
- getScraps(totalShipMaxHP - totalShipHP, true) .. [[ T]]..ScrapTier..[[ scraps needed. ]] ..
- getRepairTime(totalShipMaxHP - totalShipHP, true) .. [[ projected repair time.]]
- else
- screenOutput = screenOutput .. GetElementLogo(812, 380, "ch", "ch", "ch") ..
- [[]] .. OkayCenterMessage .. [[]] ..
- [[]]..#healthyElements..[[ elements stand ]] .. GenerateCommaValue(string.format("%.0f", totalShipMaxHP)) .. [[ HP strong.]]
- end
-
- forceDamageRedraw = false
-
- return screenOutput
-end
-
-function ActionStopengines()
- ToggleHUD()
-end
-
-function ActionStrafeRight()
- if KeyCTRLPressed == true then
- if HUDShiftU < 4000 then
- HUDShiftU = HUDShiftU + 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- HudDeselectElement()
- end
-end
-
-function ActionStrafeLeft()
- if KeyCTRLPressed == true then
- if HUDShiftU >= 50 then
- HUDShiftU = HUDShiftU - 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- ToggleHUD()
- end
-end
-
-function ActionDown()
- if KeyCTRLPressed == true then
- if HUDShiftV < 4000 then
- HUDShiftV = HUDShiftV + 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- ChangeHudSelectedElement(1)
- end
-end
-
-function ActionUp()
- if KeyCTRLPressed == true then
- if HUDShiftV >= 50 then
- HUDShiftV = HUDShiftV - 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- ChangeHudSelectedElement(-1)
- end
-end
-
-function ActionOption1()
- ScrapTier = 1
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption2()
- ScrapTier = 2
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption3()
- ScrapTier = 3
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption4()
- ScrapTier = 4
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption8()
- HUDShiftU=0
- HUDShiftV=0
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption9()
- SaveToDatabank()
- SwitchScreens("off")
- unit.exit()
-end
diff --git a/src/DamageReport_3_03_UnitStart_2.lua b/src/DamageReport_3_03_UnitStart_2.lua
deleted file mode 100644
index 1b48589..0000000
--- a/src/DamageReport_3_03_UnitStart_2.lua
+++ /dev/null
@@ -1,2041 +0,0 @@
---[[
- Damage Report 3.04
- A LUA script for Dual Universe
-
- Created By Dorian Gray
- Ingame: DorianGray
- Discord: Dorian Gray#2623
-
- You can find/update this script on GitHub. Explanations, installation and usage information as well as screenshots can be found there too.
- GitHub: https://github.com/DorianTheGrey/DU-DamageReport
-
- GNU Public License 3.0. Use whatever you want, be so kind to leave credit.
-
- Credits & thanks:
- Thanks to NovaQuark for creating the MMO of the century.
- Thanks to Jericho, Dmentia and Archaegeo for learning a lot from their fine scripts.
- Thanks to TheBlacklist for testing and wonderful suggestions.
- SVG patterns by Hero Patterns.
- DU atlas data from Jayle Break.
-
-]]
-
---[[ 1. USER DEFINED VARIABLES ]]
-
-YourShipsName = "Enter here" --export Enter your ship name here if you want it displayed instead of the ship's ID. YOU NEED TO LEAVE THE QUOTATION MARKS.
-
-SkillRepairToolEfficiency = 0 --export Enter (0-5) your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency"
-SkillRepairToolOptimization = 0 --export Enter your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Optimization"
-
--- SkillAtmosphericFuelEfficiency = 0 --export Enter (0-5) your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency"
--- SkillSpaceFuelEfficiency = 0 --export Enter (0-5) your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency"
--- SkillRocketFuelEfficiency = 0 --export Enter (0-5) your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency"
-
-StatAtmosphericFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED ATMOSPHERIC FUEL TANKS (from the builders talent "Piloting -> Atmospheric Flight Technician -> Atmospheric Fuel-Tank Handling")
-StatSpaceFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL SPACE TANKS (from the builders talent "Piloting -> Atmospheric Engine Technician -> Space Fuel-Tank Handling")
-StatRocketFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL ROCKET TANKS (from the builders talent "Piloting -> Rocket Scientist -> Rocket Booster Fuel Tank Handling")
-StatFuelTankOptimization = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL TANKS "from the builders talent Mining and Inventory -> Stock Control -> Fuel Tank Optimization"
-
-ShowWelcomeMessage = true --export Do you want the welcome message on the start screen with your name?
-AddSummertimeHour = false --export: Is summertime currently enabled in your location? (Adds one hour.)
-
---[[ 2. GLOBAL VARIABLES ]]
-
-UpdateDataInterval = 1.0 -- How often shall the data be updated? (Increase if running into CPU issues.)
-HighlightBlinkingInterval = 0.5 -- How fast shall highlight arrows of marked elements blink?
-
-ColorPrimary = "FF6700" -- Enter the hexcode of the main color to be used by all views.
-ColorSecondary = "FFFFFF" -- Enter the hexcode of the secondary color to be used by all views.
-ColorTertiary = "000000" -- Enter the hexcode of the tertiary color to be used by all views.
-ColorHealthy = "00FF00" -- Enter the hexcode of the 'healthy' color to be used by all views.
-ColorWarning = "FFFF00" -- Enter the hexcode of the 'warning' color to be used by all views.
-ColorCritical = "FF0000" -- Enter the hexcode of the 'critical' color to be used by all views.
-ColorBackground = "000000" -- Enter the hexcode of the background color to be used by all views.
-ColorBackgroundPattern = "4F4F4F" -- Enter the hexcode of the background color to be used by all views.
-ColorFuelAtmospheric = "004444" -- Enter the hexcode of the atmospheric fuel color.
-ColorFuelSpace = "444400" -- Enter the hexcode of the space fuel color.
-ColorFuelRocket = "440044" -- Enter the hexcode of the rocket fuel color.
-
-VERSION = 3.04
-DebugMode = false
-DebugRenderClickareas = true
-
-DBData = {}
-
-core = nil
-db = nil
-screens = {}
-dscreens = {}
-
-Warnings = {}
-
-screenModes = {
- ["flight"] = { id="flight" },
- ["damage"] = { id="damage" },
- ["damageoutline"] = { id="damageoutline" },
- ["fuel"] = { id="fuel" },
- ["cargo"] = { id="cargo" },
- ["agg"] = { id="agg" },
- ["map"] = { id="map" },
- ["time"] = { id="time", activetoggle="true" },
- ["settings1"] = { id="settings1" },
- ["startup"] = { id="startup" }
-}
-
-backgroundModes = { "deathstar", "capsule", "rain", "signal", "hexagon", "diagonal", "diamond", "plus", "dots" }
-BackgroundMode ="deathstar"
-BackgroundSelected = 1
-BackgroundModeOpacity = 0.25
-
-SaveVars = { "dscreens",
- "ColorPrimary", "ColorSecondary", "ColorTertiary",
- "ColorHealthy", "ColorWarning", "ColorCritical",
- "ColorBackground", "ColorBackgroundPattern",
- "ScrapTier", "HUDMode", "SimulationMode", "DMGOStretch",
- "HUDShiftU", "HUDShiftV", "colorIDIndex", "colorIDTable",
- "BackgroundMode", "BackgroundSelected", "BackgroundModeOpacity" }
-
-HUDMode = false
-HUDShiftU = 0
-HUDShiftV = 0
-hudSelectedIndex = 0
-hudStartIndex = 1
-hudArrowSticker = {}
-highlightOn = false
-highlightID = 0
-highlightX = 0
-highlightY = 0
-highlightZ = 0
-
-SimulationMode = false
-OkayCenterMessage = "All systems nominal."
-CurrentDamagedPage = 1
-CurrentBrokenPage = 1
-DamagePageSize = 12
-ScrapTier = 1
-totalScraps = 0
-ScrapTierRepairTimes = { 10, 50, 250, 1250 }
-
-coreWorldOffset = 0
-totalShipHP = 0
-formerTotalShipHP = -1
-totalShipMaxHP = 0
-totalShipIntegrity = 100
-elementsId = {}
-elementsIdList = {}
-damagedElements = {}
-brokenElements = {}
-rE = {}
-healthyElements = {}
-typeElements = {}
-ElementCounter = 0
-UseMyElementNames = true
-dmgoElements = {}
-DMGOMaxElements = 250
-DMGOStretch = false
-ShipXmin = 99999999
-ShipXmax = -99999999
-ShipYmin = 99999999
-ShipYmax = -99999999
-ShipZmin = 99999999
-ShipZmax = -99999999
-
-totalShipMass = 0
-formerTotalShipMass = -1
-
-formerTime = -1
-
-FuelAtmosphericTanks = {}
-FuelSpaceTanks = {}
-FuelRocketTanks = {}
-FuelAtmosphericTotal = 0
-FuelSpaceTotal = 0
-FuelRocketTotal = 0
-FuelAtmosphericCurrent = 0
-FuelSpaceTotalCurrent = 0
-FuelRocketTotalCurrent = 0
-formerFuelAtmosphericTotal = -1
-formerFuelSpaceTotal = -1
-formerFuelRocketTotal = -1
-
-hexTable = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"}
-colorIDIndex = 1
-colorIDTable = {
- [1] = {
- id="ColorPrimary",
- desc="Main HUD Color",
- basec = "FF6700",
- newc = "FF6700"
- },
- [2] = {
- id="ColorSecondary",
- desc="Secondary HUD Color",
- basec = "FFFFFF",
- newc = "FFFFFF"
- },
- [3] = {
- id="ColorTertiary",
- desc="Tertiary HUD Color",
- basec = "000000",
- newc = "000000"
- },
- [4] = {
- id="ColorHealthy",
- desc="Color code for Healthy/Okay",
- basec = "00FF00",
- newc = "00FF00"
- },
- [5] = {
- id="ColorWarning",
- desc="Color code for Damaged/Warning",
- basec = "FFFF00",
- newc = "FFFF00"
- },
- [6] = {
- id="ColorCritical",
- desc="Color code for Broken/Critical",
- basec = "FF0000",
- newc = "FF0000"
- },
- [7] = {
- id="ColorBackground",
- desc="Background Color",
- basec = "000000",
- newc = "000000"
- },
- [8] = {
- id="ColorBackgroundPattern",
- desc="Background Pattern Color",
- basec = "4F4F4F",
- newc = "4F4F4F"
- },
- [9] = {
- id="ColorFuelAtmospheric",
- desc="Color for Atmo Fuel/Elements",
- basec = "004444",
- newc = "004444"
- },
- [10] = {
- id="ColorFuelSpace",
- desc="Color for Space Fuel/Elements",
- basec = "444400",
- newc = "444400"
- },
- [11] = {
- id="ColorFuelRocket",
- desc="Color for Rocket Fuel/Elements",
- basec = "440044",
- newc = "440044"
- }
-}
-
-
---[[ 3. PROCESSING FUNCTIONS ]]
-
-function InitiateSlots()
- for slot_name, slot in pairs(unit) do
- if type(slot) == "table" and type(slot.export) == "table" and
- slot.getElementClass then
- local elementClass = slot.getElementClass():lower()
- if elementClass:find("coreunit") then
- core = slot
- local coreHP = core.getMaxHitPoints()
- if coreHP > 10000 then
- coreWorldOffset = 128
- elseif coreHP > 1000 then
- coreWorldOffset = 64
- elseif coreHP > 150 then
- coreWorldOffset = 32
- else
- coreWorldOffset = 16
- end
- elseif elementClass == 'databankunit' then
- db = slot
- elseif elementClass == "screenunit" then
- local iScreenMode = "startup"
- screens[#screens + 1] = {
- element = slot,
- id = slot.getId(),
- mode = iScreenMode,
- submode = "",
- ClickAreas = {},
- refresh = true,
- active = false,
- fuelA = true,
- fuelS = true,
- fuelR = true,
- fuelIndex = 1
- }
- end
- end
- end
-end
-
-function LoadFromDatabank()
- if db == nil then
- return
- else
- for _, data in pairs(SaveVars) do
- if db.hasKey(data) then
- local jData = json.decode( db.getStringValue(data) )
- if jData ~= nil then
- if data == "YourShipsName" or data == "AddSummertimeHour" or data == "UpdateDataInterval" or data == "HighlightBlinkingInterval" or
- data == "SkillRepairToolEfficiency" or data == "SkillRepairToolOptimization" or data == "SkillAtmosphericFuelEfficiency" or
- data == "SkillSpaceFuelEfficiency" or data == "SkillRocketFuelEfficiency" or data == "StatAtmosphericFuelTankHandling" or
- data == "StatSpaceFuelTankHandling" or data == "StatRocketFuelTankHandling"
- then
- -- Nada
- else
- _G[data] = jData
- end
- end
- end
- end
-
- for i,v in ipairs(screens) do
- for j,dv in ipairs(dscreens) do
- if screens[i].id == dscreens[j].id then
- screens[i].mode = dscreens[j].mode
- screens[i].submode = dscreens[j].submode
- screens[i].active = dscreens[j].active
- screens[i].refresh = true
- screens[i].fuelA = dscreens[j].fuelA
- screens[i].fuelS = dscreens[j].fuelS
- screens[i].fuelR = dscreens[j].fuelR
- screens[i].fuelIndex = dscreens[j].fuelIndex
- end
- end
- end
- end
-end
-
-function SaveToDatabank()
- if db == nil then
- return
- else
- dscreens = {}
- for i,screen in ipairs(screens) do
- dscreens[i] = {}
- dscreens[i].id = screen.id
- dscreens[i].mode = screen.mode
- dscreens[i].submode = screen.submode
- dscreens[i].active = screen.active
- dscreens[i].fuelA = screen.fuelA
- dscreens[i].fuelS = screen.fuelS
- dscreens[i].fuelR = screen.fuelR
- dscreens[i].fuelIndex = screen.fuelIndex
- end
-
- db.clear()
-
- for _, data in pairs(SaveVars) do
- db.setStringValue(data, json.encode(_G[data]))
- end
-
- end
-end
-
-function InitiateScreens()
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- screens[i] = CreateClickAreasForScreen(screens[i])
- end
- end
-end
-
-function UpdateTypeData()
- FuelAtmosphericTanks = {}
- FuelSpaceTanks = {}
- FuelRocketTanks = {}
-
- FuelAtmosphericTotal = 0
- FuelAtmosphericCurrent = 0
- FuelSpaceTotal = 0
- FuelSpaceCurrent = 0
- FuelRocketCurrent = 0
- FuelRocketTotal = 0
-
- local weightAtmosphericFuel = 4
- local weightSpaceFuel = 6
- local weightRocketFuel = 0.8
-
- -- (FuelMass * (1-.05 * ) * (1-.05 * )
-
- if StatFuelTankOptimization > 0 then
- weightAtmosphericFuel = weightAtmosphericFuel - 0.05 * StatFuelTankOptimization * weightAtmosphericFuel
- weightSpaceFuel = weightSpaceFuel - 0.05 * StatFuelTankOptimization * weightSpaceFuel
- weightRocketFuel = weightRocketFuel - 0.05 * StatFuelTankOptimization * weightRocketFuel
- end
-
- for i, id in ipairs(typeElements) do
- local idName = core.getElementNameById(id) or ""
- local idType = core.getElementTypeById(id) or ""
- -- local idTypeClean = idType:gsub("[%s%-]+", ""):lower()
- local idPos = core.getElementPositionById(id) or 0
- local idHP = core.getElementHitPointsById(id) or 0
- local idMaxHP = core.getElementMaxHitPointsById(id) or 0
- local idMass = core.getElementMassById(id) or 0
-
- local baseSize = ""
- local baseVol = 0
- local baseMass = 0
- local cMass = 0
- local cVol = 0
-
- if idType == "atmospheric fuel-tank" then
- if idMaxHP > 10000 then
- baseSize = "L"
- baseMass = 5480
- baseVol = 12800
- elseif idMaxHP > 1300 then
- baseSize = "M"
- baseMass = 988.67
- baseVol = 1600
- elseif idMaxHP > 150 then
- baseSize = "S"
- baseMass = 182.67
- baseVol = 400
- else
- baseSize = "XS"
- baseMass = 35.03
- baseVol = 100
- end
- if StatAtmosphericFuelTankHandling > 0 then
- baseVol = 0.2 * StatAtmosphericFuelTankHandling * baseVol + baseVol
- end
- if StatFuelTankOptimization > 0 then
- baseMass = baseMass - 0.05 * StatFuelTankOptimization * baseMass
- end
- cMass = idMass - baseMass
- if cMass <=10 then cMass = 0 end
- cVol = string.format("%.0f", cMass / weightAtmosphericFuel)
- cPercent = string.format("%.1f", math.floor(100/baseVol * tonumber(cVol)))
- table.insert(FuelAtmosphericTanks, {
- type = 1,
- id = id,
- name = idName,
- maxhp = idMaxHP,
- hp = GetHPforElement(id),
- pos = idPos,
- size = baseSize,
- mass = baseMass,
- vol = baseVol,
- cvol = cVol,
- percent = cPercent
- })
- if idHP > 0 then
- FuelAtmosphericCurrent = FuelAtmosphericCurrent + cVol
- end
- FuelAtmosphericTotal = FuelAtmosphericTotal + baseVol
- elseif idType == "space fuel-tank" then
- if idMaxHP > 10000 then
- baseSize = "L"
- baseMass = 5480
- baseVol = 12800
- elseif idMaxHP > 1300 then
- baseSize = "M"
- baseMass = 988.67
- baseVol = 1600
- else
- baseSize = "S"
- baseMass = 182.67
- baseVol = 400
- end
- if StatSpaceFuelTankHandling > 0 then
- baseVol = 0.2 * StatSpaceFuelTankHandling * baseVol + baseVol
- end
- if StatFuelTankOptimization > 0 then
- baseMass = baseMass - 0.05 * StatFuelTankOptimization * baseMass
- end
- cMass = idMass - baseMass
- if cMass <=10 then cMass = 0 end
- cVol = string.format("%.0f", cMass / weightSpaceFuel)
- cPercent = string.format("%.1f", (100/baseVol * tonumber(cVol)))
- table.insert(FuelSpaceTanks, {
- type = 2,
- id = id,
- name = idName,
- maxhp = idMaxHP,
- hp = GetHPforElement(id),
- pos = idPos,
- size = baseSize,
- mass = baseMass,
- vol = baseVol,
- cvol = cVol,
- percent = cPercent
- })
- if idHP > 0 then
- FuelSpaceCurrent = FuelSpaceCurrent + cVol
- end
- FuelSpaceTotal = FuelSpaceTotal + baseVol
- elseif idType == "rocket fuel-tank" then
- if idMaxHP > 65000 then
- baseSize = "L"
- baseMass = 25740
- baseVol = 50000
- elseif idMaxHP > 6000 then
- baseSize = "M"
- baseMass = 4720
- baseVol = 6400
- elseif idMaxHP > 700 then
- baseSize = "S"
- baseMass = 886.72
- baseVol = 800
- else
- baseSize = "XS"
- baseMass = 173.42
- baseVol = 400
- end
- if StatRocketFuelTankHandling > 0 then
- baseVol = 0.2 * StatRocketFuelTankHandling * baseVol + baseVol
- end
- if StatFuelTankOptimization > 0 then
- baseMass = baseMass - 0.05 * StatFuelTankOptimization * baseMass
- end
- cMass = idMass - baseMass
- if cMass <=10 then cMass = 0 end
- cVol = string.format("%.0f", cMass / weightRocketFuel)
- cPercent = string.format("%.1f", (100/baseVol * tonumber(cVol)))
- table.insert(FuelRocketTanks, {
- type = 3,
- id = id,
- name = idName,
- maxhp = idMaxHP,
- hp = GetHPforElement(id),
- pos = idPos,
- size = baseSize,
- mass = baseMass,
- vol = baseVol,
- cvol = cVol,
- percent = cPercent
- })
- if idHP > 0 then
- FuelRocketCurrent = FuelRocketCurrent + cVol
- end
- FuelRocketTotal = FuelRocketTotal + baseVol
- end
-
- end
-
- if FuelAtmosphericCurrent ~= formerFuelAtmosphericCurrent then
- SetRefresh("fuel")
- formerFuelAtmosphericCurrent = FuelAtmosphericCurrent
- end
- if FuelSpaceCurrent ~= formerFuelSpaceCurrent then
- SetRefresh("fuel")
- formerFuelSpaceCurrent = FuelSpaceCurrent
- end
- if FuelRocketCurrent ~= formerFuelRocketCurrent then
- SetRefresh("fuel")
- formerFuelRocketCurrent = FuelRocketCurrent
- end
-
-end
-
-function UpdateDamageData(initial)
-
- initial = initial or false
-
- if SimulationActive == true then return end
-
- local formerTotalShipHP = totalShipHP
- totalShipHP = 0
- totalShipMaxHP = 0
- totalShipIntegrity = 100
- damagedElements = {}
- brokenElements = {}
- healthyElements = {}
- ElementCounter = 0
-
- elementsIdList = core.getElementIdList()
-
- for i, id in pairs(elementsIdList) do
-
- ElementCounter = ElementCounter + 1
-
- local idName = core.getElementNameById(id)
-
- local idType = core.getElementTypeById(id)
- -- local idTypeClean = idType:gsub("[%s%-]+", ""):lower()
- local idPos = core.getElementPositionById(id)
- local idHP = core.getElementHitPointsById(id)
- local idMaxHP = core.getElementMaxHitPointsById(id)
- -- local idMass = core.getElementMassById(id)
-
- if SimulationMode == true then
- SimulationActive = true
- local dice = math.random(0, 10)
- if dice < 2 and #brokenElements < 30 then
- idHP = 0
- elseif dice >= 2 and dice < 4 and #damagedElements < 30 then
- idHP = math.random(1, math.ceil(idMaxHP))
- else
- idHP = idMaxHP
- end
- end
-
- totalShipHP = totalShipHP + idHP
- totalShipMaxHP = totalShipMaxHP + idMaxHP
-
- if idMaxHP - idHP > constants.epsilon then
-
- if idHP > 0 then
- table.insert(damagedElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP - idHP,
- percent = math.ceil(100 / idMaxHP * idHP),
- pos = idPos
- })
- else
- table.insert(brokenElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP - idHP,
- percent = 0,
- pos = idPos
- })
- end
- else
- table.insert(healthyElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- pos = idPos
- })
- if id == highlightID then
- highlightID = 0
- highlightOn = false
- HideHighlight()
- hudSelectedIndex = 0
- end
- end
-
- if initial == true then
- if
- idType == "atmospheric fuel-tank" or
- idType == "space fuel-tank" or
- idType == "rocket fuel-tank"
- then
- table.insert(typeElements, id)
- end
- end
- end
-
- SortDamageTables()
-
- rE = {}
- if #brokenElements > 0 then
- for _,v in ipairs(brokenElements) do
- table.insert(rE, {id=v.id, missinghp=v.missinghp, hp=v.hp, name=v.name, type=v.type, pos=v.pos})
- end
- end
- if #damagedElements > 0 then
- for _,v in ipairs(damagedElements) do
- table.insert(rE, {id=v.id, missinghp=v.missinghp, hp=v.hp, name=v.name, type=v.type, pos=v.pos})
- end
- end
- if #rE > 0 then
- table.sort(rE, function(a,b) return a.missinghp>b.missinghp end)
- end
-
- totalShipIntegrity = string.format("%2.0f", 100 / totalShipMaxHP * totalShipHP)
-
- if formerTotalShipHP ~= totalShipHP then
- forceDamageRedraw = true
- formerTotalShipHP = totalShipHP
- else
- forceDamageRedraw = false
- end
-end
-
-function GetHPforElement(id)
- for i,v in ipairs(brokenElements) do
- if v.id == id then
- return 0
- end
- end
- for i,v in ipairs(damagedElements) do
- if v.id == id then
- return v.hp
- end
- end
- for i,v in ipairs(healthyElements) do
- if v.id == id then
- return v.maxhp
- end
- end
-end
-
-function UpdateClickArea(candidate, newEntry, mode)
- for i, screen in ipairs(screens) do
- for k, v in pairs(screens[i].ClickAreas) do
- if v.id == candidate and v.mode == mode then
- screens[i].ClickAreas[k] = newEntry
- end
- end
- end
-end
-
-function AddClickArea(mode, newEntry)
- for i, screen in ipairs(screens) do
- if screens[i].mode == mode then
- table.insert(screens[i].ClickAreas, newEntry)
- end
- end
-end
-
-function AddClickAreaForScreenID(screenid, newEntry)
- for i, screen in ipairs(screens) do
- if screens[i].id == screenid then
- table.insert(screens[i].ClickAreas, newEntry)
- end
- end
-end
-
-function DisableClickArea(candidate, mode)
- UpdateClickArea(candidate, {
- id = candidate,
- mode = mode,
- x1 = -1,
- x2 = -1,
- y1 = -1,
- y2 = -1
- })
-end
-
-function SetRefresh(mode, submode)
- mode = mode or "all"
- submode = submode or "all"
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- if screens[i].mode == mode or mode == "all" then
- if screens[i].submode == submode or submode =="all" then
- screens[i].refresh = true
- end
- end
- end
- end
-end
-
-function WipeClickAreasForScreen(screen)
- screen.ClickAreas = {}
- return screen
-end
-
-function CreateBaseClickAreas(screen)
- table.insert(screen.ClickAreas, {mode = "all", id = "ToggleHudMode", x1 = 1537, x2 = 1728, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "damage", x1 = 193, x2 = 384, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "damageoutline", x1 = 385, x2 = 576, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "fuel", x1 = 577, x2 = 768, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "flight", x1 = 769, x2 = 960, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "cargo", x1 = 961, x2 = 1152, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "agg", x1 = 1153, x2 = 1344, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "map", x1 = 1345, x2 = 1536, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "time", x1 = 0, x2 = 192, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "settings1", x1 = 1729, x2 = 1920, y1 = 1015, y2 = 1075} )
- return screen
-end
-
-function CreateClickAreasForScreen(screen)
-
- if screen == nil then return {} end
-
- if screen.mode == "flight" then
- elseif screen.mode == "damage" then
- table.insert( screen.ClickAreas, {mode = "damage", id = "ToggleElementLabel", x1 = 70, x2 = 425, y1 = 325, y2 = 355} )
- table.insert( screen.ClickAreas, {mode = "damage", id = "ToggleElementLabel2", x1 = 980, x2 = 1400, y1 = 325, y2 = 355} )
- elseif screen.mode == "damageoutline" then
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeView", param = "top", x1 = 60, x2 = 439, y1 = 150, y2 = 200} )
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeView", param = "side", x1 = 440, x2 = 824, y1 = 150, y2 = 200} )
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeView", param = "front", x1 = 825, x2 = 1215, y1 = 150, y2 = 200} )
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeStretch", x1 = 1530, x2 = 1580, y1 = 150, y2 = 200} )
- elseif screen.mode == "fuel" then
- elseif screen.mode == "cargo" then
- elseif screen.mode == "agg" then
- elseif screen.mode == "map" then
- elseif screen.mode == "time" then
- elseif screen.mode == "settings1" then
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ToggleBackground", x1 = 75, x2 = 860, y1 = 170, y2 = 215} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "PreviousBackground", x1 = 75, x2 = 460, y1 = 235, y2 = 285} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "NextBackground", x1 = 480, x2 = 860, y1 = 235, y2 = 285} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "DecreaseOpacity", x1 = 75, x2 = 460, y1 = 300, y2 = 350} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "IncreaseOpacity", x1 = 480, x2 = 860, y1 = 300, y2 = 350} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ResetColors", x1 = 75, x2 = 860, y1 = 370, y2 = 415} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "PreviousColorID", x1 = 90, x2 = 140, y1 = 500, y2 = 550} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "NextColorID", x1 = 795, x2 = 845, y1 = 500, y2 = 550} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="1", x1 = 210, x2 = 290, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="2", x1 = 300, x2 = 380, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="3", x1 = 385, x2 = 465, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="4", x1 = 470, x2 = 550, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="5", x1 = 560, x2 = 640, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="6", x1 = 645, x2 = 725, y1 = 655, y2 = 700} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="1", x1 = 210, x2 = 290, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="2", x1 = 300, x2 = 380, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="3", x1 = 385, x2 = 465, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="4", x1 = 470, x2 = 550, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="5", x1 = 560, x2 = 640, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="6", x1 = 645, x2 = 725, y1 = 740, y2 = 780} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ResetPosColor", x1 = 160, x2 = 340, y1 = 885, y2 = 935} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ApplyPosColor", x1 = 355, x2 = 780, y1 = 885, y2 = 935} )
-
- elseif screen.mode == "startup" then
- end
-
- screen = CreateBaseClickAreas(screen)
-
- return screen
-end
-
-function CheckClick(x, y, HitTarget)
- x = x*1920
- y = y*1120
- HitTarget = HitTarget or ""
- HitPayload = {}
- -- PrintConsole("Clicked: "..x.." / "..y)
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- if screens[i].active == true and screens[i].element.getMouseX() ~= -1 and screens[i].element.getMouseY() ~= -1 then
- if HitTarget == "" then
- for k, v in pairs(screens[i].ClickAreas) do
- if v ~=nil and x >= v.x1 and x <= v.x2 and y >= v.y1 and y <= v.y2 then
- HitTarget = v.id
- HitPayload = v
- break
- end
- end
- end
- if HitTarget == "ButtonPress" then
- if screens[i].mode == HitPayload.param then
- screens[i].mode = "startup"
- else
- screens[i].mode = HitPayload.param
- end
-
- if screens[i].mode == "damageoutline" then
- if screens[i].submode == "" then
- screens[i].submode = "top"
- end
- end
- screens[i].refresh = true
- screens[i].ClickAreas = {}
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "ToggleBackground" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundMode == "" then
- BackgroundSelected = 1
- BackgroundMode = backgroundModes[BackgroundSelected]
- else
- BackgroundSelected = 1
- BackgroundMode = ""
- end
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "PreviousBackground" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundMode == "" then
- BackgroundSelected = 1
- BackgroundMode = backgroundModes[BackgroundSelected]
- else
- if BackgroundSelected <= 1 then
- BackgroundSelected = #backgroundModes
- else
- BackgroundSelected = BackgroundSelected - 1
- end
- BackgroundMode = backgroundModes[BackgroundSelected]
- end
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "NextBackground" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundMode == "" then
- BackgroundSelected = 1
- BackgroundMode = backgroundModes[BackgroundSelected]
- else
- if BackgroundSelected >= #backgroundModes then
- BackgroundSelected = 1
- else
- BackgroundSelected = BackgroundSelected + 1
- end
- BackgroundMode = backgroundModes[BackgroundSelected]
- end
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "DecreaseOpacity" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundModeOpacity>0.1 then
- BackgroundModeOpacity = BackgroundModeOpacity - 0.05
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- end
- elseif HitTarget == "IncreaseOpacity" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundModeOpacity<1.0 then
- BackgroundModeOpacity = BackgroundModeOpacity + 0.05
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- end
- elseif HitTarget == "ResetColors" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- db.clear()
- ColorPrimary = "FF6700"
- ColorSecondary = "FFFFFF"
- ColorTertiary = "000000"
- ColorHealthy = "00FF00"
- ColorWarning = "FFFF00"
- ColorCritical = "FF0000"
- ColorBackground = "000000"
- ColorBackgroundPattern = "4f4f4f"
- BackgroundMode = "deathstar"
- BackgroundSelected = 1
- BackgroundModeOpacity = 0.25
- colorIDTable = {
- [1] = {
- id="ColorPrimary",
- desc="Main HUD Color",
- basec = "FF6700",
- newc = "FF6700"
- },
- [2] = {
- id="ColorSecondary",
- desc="Secondary HUD Color",
- basec = "FFFFFF",
- newc = "FFFFFF"
- },
- [3] = {
- id="ColorTertiary",
- desc="Tertiary HUD Color",
- basec = "000000",
- newc = "000000"
- },
- [4] = {
- id="ColorHealthy",
- desc="Color code for Healthy/Okay",
- basec = "00FF00",
- newc = "00FF00"
- },
- [5] = {
- id="ColorWarning",
- desc="Color code for Damaged/Warning",
- basec = "FFFF00",
- newc = "FFFF00"
- },
- [6] = {
- id="ColorCritical",
- desc="Color code for Broken/Critical",
- basec = "FF0000",
- newc = "FF0000"
- },
- [7] = {
- id="ColorBackground",
- desc="Background Color",
- basec = "000000",
- newc = "000000"
- },
- [8] = {
- id="ColorBackgroundPattern",
- desc="Background Pattern Color",
- basec = "4F4F4F",
- newc = "4F4F4F"
- },
- [9] = {
- id="ColorFuelAtmospheric",
- desc="Color for Atmo Fuel/Elements",
- basec = "004444",
- newc = "004444"
- },
- [10] = {
- id="ColorFuelSpace",
- desc="Color for Space Fuel/Elements",
- basec = "444400",
- newc = "444400"
- },
- [11] = {
- id="ColorFuelRocket",
- desc="Color for Rocket Fuel/Elements",
- basec = "440044",
- newc = "440044"
- }
- }
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "PreviousColorID" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- colorIDIndex = colorIDIndex - 1
- if colorIDIndex < 1 then colorIDIndex = #colorIDTable end
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "NextColorID" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- colorIDIndex = colorIDIndex + 1
- if colorIDIndex > #colorIDTable then colorIDIndex = 1 end
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "ColorPosUp" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- local s = tonumber(string.sub(colorIDTable[colorIDIndex].newc, HitPayload.param, HitPayload.param),16)
- s = s + 1
- if s > 15 then s = 0 end
- colorIDTable[colorIDIndex].newc = replace_char(HitPayload.param, colorIDTable[colorIDIndex].newc, hexTable[s+1])
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "ColorPosDown" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- local s = tonumber(string.sub(colorIDTable[colorIDIndex].newc, HitPayload.param, HitPayload.param),16)
- s = s - 1
- if s < 0 then s = 15 end
- colorIDTable[colorIDIndex].newc = replace_char(HitPayload.param, colorIDTable[colorIDIndex].newc, hexTable[s+1])
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "ResetPosColor" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- colorIDTable[colorIDIndex].newc = colorIDTable[colorIDIndex].basec
- _G[colorIDTable[colorIDIndex].id] = colorIDTable[colorIDIndex].basec
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "ApplyPosColor" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- _G[colorIDTable[colorIDIndex].id] = colorIDTable[colorIDIndex].newc
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "DamagedPageDown" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentDamagedPage = CurrentDamagedPage + 1
- if CurrentDamagedPage > math.ceil(#damagedElements / DamagePageSize) then
- CurrentDamagedPage = math.ceil(#damagedElements / DamagePageSize)
- end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "DamagedPageUp" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentDamagedPage = CurrentDamagedPage - 1
- if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "BrokenPageDown" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentBrokenPage = CurrentBrokenPage + 1
- if CurrentBrokenPage > math.ceil(#brokenElements / DamagePageSize) then
- CurrentBrokenPage = math.ceil(#brokenElements / DamagePageSize)
- end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "BrokenPageUp" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentBrokenPage = CurrentBrokenPage - 1
- if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "DMGOChangeView" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- screens[i].submode = HitPayload.param
- UpdateViewDamageoutline(screens[i])
- SaveToDatabank()
- SetRefresh("damageoutline", screens[i].submode)
- RenderScreens("damageoutline", screens[i].submode)
- elseif HitTarget == "DMGOChangeStretch" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if DMGOStretch == true then
- DMGOStretch = false
- else
- DMGOStretch = true
- end
- UpdateViewDamageoutline(screens[i])
- SaveToDatabank()
- SetRefresh("damageoutline")
- RenderScreens("damageoutline")
- elseif HitTarget == "ToggleDisplayAtmosphere" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if screens[i].fuelA == true then
- screens[i].fuelA = false
- else
- screens[i].fuelA = true
- end
- screens[i].fuelIndex = 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "ToggleDisplaySpace" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if screens[i].fuelS == true then
- screens[i].fuelS = false
- else
- screens[i].fuelS = true
- end
- screens[i].fuelIndex = 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "ToggleDisplayRocket" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if screens[i].fuelR == true then
- screens[i].fuelR = false
- else
- screens[i].fuelR = true
- end
- screens[i].fuelIndex = 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "DecreaseFuelIndex" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- screens[i].fuelIndex = screens[i].fuelIndex - 1
- if screens[i].fuelIndex < 1 then screens[i].fuelIndex = 1 end
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "IncreaseFuelIndex" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- screens[i].fuelIndex = screens[i].fuelIndex + 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "ToggleHudMode" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if HUDMode == true then
- HUDMode = false
- forceDamageRedraw = true
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- else
- HUDMode = true
- forceDamageRedraw = true
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- end
- elseif HitTarget == "ToggleSimulation" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentDamagedPage = 1
- CurrentBrokenPage = 1
- if SimulationMode == true then
- SimulationMode = false
- SimulationActive = false
- UpdateDamageData()
- UpdateTypeData()
- forceDamageRedraw = true
- HudDeselectElement()
- SetRefresh("damage")
- SetRefresh("damageoutline")
- SetRefresh("settings1")
- SetRefresh("fuel")
- SaveToDatabank()
- RenderScreens()
- else
- SimulationMode = true
- SimulationActive = false
- UpdateDamageData()
- UpdateTypeData()
- forceDamageRedraw = true
- HudDeselectElement()
- SetRefresh("damage")
- SetRefresh("damageoutline")
- SetRefresh("settings1")
- SetRefresh("fuel")
- SaveToDatabank()
- RenderScreens()
- end
- elseif (HitTarget == "ToggleElementLabel" or HitTarget == "ToggleElementLabel2") and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if UseMyElementNames == true then
- UseMyElementNames = false
- SetRefresh("damage")
- RenderScreens("damage")
- else
- UseMyElementNames = true
- SetRefresh("damage")
- RenderScreens("damage")
- end
- elseif (HitTarget == "SwitchScrapTier" or HitTarget == "SwitchScrapTier2") and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- ScrapTier = ScrapTier + 1
- if ScrapTier > 4 then ScrapTier = 1 end
- SetRefresh("damage")
- RenderScreens("damage")
- end
-
-
- end
- end
- end
-end
-
---[[ 4. RENDERING FUNCTIONS ]]
-
-function GetContentFlight()
- local output = ""
- output = output .. GetHeader("Flight Data Report") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentDamage()
- local output = ""
- if SimulationMode == true then
- output = output .. GetHeader("Damage Report (Simulated damage)") .. [[]]
- else
- output = output .. GetHeader("Damage Report") .. [[]]
- end
- output = output .. GetContentDamageScreen()
- return output
-end
-
-function GetContentDamageoutline(screen)
- UpdateDataDamageoutline()
- UpdateViewDamageoutline(screen)
- local output = ""
- output = output .. GetHeader("Damage Ship Outline Report") ..
- GetDamageoutlineShip() ..
- [[]]
-
- if screen.submode=="top" then
- output = output ..
- [[
-
- Top View
-
- Side View
-
- Front View
- ]]
- elseif screen.submode=="side" then
- output = output ..
- [[
-
- Top View
-
- Side View
-
- Front View
- ]]
- elseif screen.submode=="front" then
- output = output ..
- [[
-
- Top View
-
- Side View
-
- Front View
- ]]
- else
- end
- output = output .. [[]]..#dmgoElements..[[ of ]]..ElementCounter..[[ shown]]
- output = output .. [[]]
- if DMGOStretch == true then
- output = output .. [[]]
- end
- output = output .. [[Stretch both axis]]
- return output
-end
-
-function GetContentFuel(screen)
-
- if #FuelAtmosphericTanks < 1 and #FuelSpaceTanks < 1 and #FuelRocketTanks < 1 then return "" end
-
- local FuelTypes = 0
- local output = ""
- local addHeadline = {}
-
- FuelDisplay = { screen.fuelA, screen.fuelS, screen.fuelR }
-
- if FuelDisplay[1] == true and #FuelAtmosphericTanks > 0 then
- table.insert(addHeadline, "Atmospheric")
- FuelTypes = FuelTypes + 1
- end
- if FuelDisplay[2] == true and #FuelSpaceTanks > 0 then
- table.insert(addHeadline, "Space")
- FuelTypes = FuelTypes + 1
- end
- if FuelDisplay[3] == true and #FuelRocketTanks > 0 then
- table.insert(addHeadline, "Rocket")
- FuelTypes = FuelTypes + 1
- end
-
- output = output .. GetHeader("Fuel Report ("..table.concat(addHeadline, ", ")..")") ..
- [[
- ]]
-
- local totalH = 150
- local counter = 0
- local tOffset = 0
-
- if FuelDisplay[1] == true and #FuelAtmosphericTanks > 0 then
-
- if FuelTypes == 1 then tOffset = 50
- elseif FuelTypes == 2 then tOffset = 6
- elseif FuelTypes == 3 then tOffset = 0
- end
-
- output = output .. [[
-
-
-
- ]]
-
- output = output ..
- [[]]..
- GenerateCommaValue(FuelAtmosphericCurrent, true)..
- [[ of ]]..GenerateCommaValue(FuelAtmosphericTotal, true)..
- [[ | Total Atmospheric Fuel in ]]..#FuelAtmosphericTanks..[[ tank]]..(#FuelAtmosphericTanks==1 and "" or "s")..[[ (]]..math.floor(100/FuelAtmosphericTotal*FuelAtmosphericCurrent)..[[%)]]
- counter = counter + 1
- end
-
- if FuelDisplay[2] == true and #FuelSpaceTanks > 0 then
-
- if FuelTypes == 1 then tOffset = 50
- elseif FuelTypes == 2 then tOffset = 6
- elseif FuelTypes == 3 then tOffset = 0
- end
-
- output = output .. [[
-
-
-
- ]]
-
- output = output ..
- [[]]..
- GenerateCommaValue(FuelSpaceCurrent, true)..
- [[ of ]]..GenerateCommaValue(FuelSpaceTotal, true)..
- [[ | Total Space Fuel in ]]..#FuelSpaceTanks..[[ tank]]..(#FuelSpaceTanks==1 and "" or "s")..[[ (]]..math.floor(100/FuelSpaceTotal*FuelSpaceCurrent)..[[%)]]
- counter = counter + 1
- end
-
- if FuelDisplay[3] == true and #FuelRocketTanks > 0 then
-
- if FuelTypes == 1 then tOffset = 50
- elseif FuelTypes == 2 then tOffset = 6
- elseif FuelTypes == 3 then tOffset = 0
- end
-
- output = output .. [[
-
-
-
- ]]
-
- output = output ..
- [[]]..
- GenerateCommaValue(FuelRocketCurrent, true)..
- [[ of ]]..GenerateCommaValue(FuelRocketTotal, true)..
- [[ | Total Rocket Fuel in ]]..#FuelRocketTanks..[[ tank]]..(#FuelRocketTanks==1 and "" or "s")..[[ (]]..math.floor(100/FuelRocketTotal*FuelRocketCurrent)..[[%)]]
- end
-
- output = output .. [[
-
-
-
- ]]
-
- local DisplayTable = {}
- if screen.fuelIndex == nil or screen.fuelIndex < 1 then
- screen.fuelIndex = 1
- end
-
- if FuelDisplay[1] == true then
- for _,v in ipairs(FuelAtmosphericTanks) do
- table.insert(DisplayTable, v)
- end
- end
- if FuelDisplay[2] == true then
- for _,v in ipairs(FuelSpaceTanks) do
- table.insert(DisplayTable, v)
- end
- end
- if FuelDisplay[3] == true then
- for _,v in ipairs(FuelRocketTanks) do
- table.insert(DisplayTable, v)
- end
- end
-
- table.sort(DisplayTable, function(a,b) return a.type
-
-
- ]]
- if tank.hp == 0 then
- output = output .. [[]]
- elseif tank.maxhp - tank.hp > constants.epsilon then
- output = output .. [[]]
- else
- output = output .. [[]]
- end
- if tank.hp == 0 then output = output .. [[]]..tank.size..[[]]
- else output = output .. [[]]..tank.size..[[]]
- end
-
- if tank.hp == 0 then
- output = output .. [[Broken]] ..
- [[0 of ]]..GenerateCommaValue(tank.vol)..[[]]
- elseif tonumber(tank.percent) < 10 then
- output = output .. [[]]..tank.percent..[[%]] ..
- [[]]..GenerateCommaValue(tank.cvol)..[[ of ]]..GenerateCommaValue(tank.vol)..[[]]
- elseif tonumber(tank.percent) < 30 then
- output = output .. [[]]..tank.percent..[[%]] ..
- [[]]..GenerateCommaValue(tank.cvol)..[[ of ]]..GenerateCommaValue(tank.vol)..[[]]
- else output =
- output .. [[]]..tank.percent..[[%]] ..
- [[]]..GenerateCommaValue(tank.cvol)..[[ of ]]..GenerateCommaValue(tank.vol)..[[]]
- end
-
- output = output ..[[]]..tank.name..[[]]
-
- output = output .. [[]]
-
- end
- end
-
-
-
- if #FuelAtmosphericTanks > 0 then
- output = output .. [[]]
- if FuelDisplay[1] == true then
- output = output .. [[]]
- end
- output = output .. [[ATM]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "ToggleDisplayAtmosphere", x1 = 50, x2 = 100, y1 = 270, y2 = 320} )
- end
-
- if #FuelSpaceTanks > 0 then
- output = output .. [[]]
- if FuelDisplay[2] == true then
- output = output .. [[]]
- end
- output = output .. [[SPC]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "ToggleDisplaySpace", x1 = 200, x2 = 250, y1 = 270, y2 = 320} )
- end
-
- if #FuelRocketTanks > 0 then
- output = output .. [[]]
- if FuelDisplay[3] == true then
- output = output .. [[]]
- end
- output = output .. [[RKT]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "ToggleDisplayRocket", x1 = 350, x2 = 400, y1 = 270, y2 = 320} )
- end
-
- if screen.fuelIndex > 1 then
- output = output .. [[
-
-
- ]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "DecreaseFuelIndex", x1 = 1470, x2 = 1670, y1 = 270, y2 = 320} )
- end
-
- if screen.fuelIndex+cCounter-1 < #DisplayTable then
- output = output .. [[
-
-
- ]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "IncreaseFuelIndex", x1 = 1680, x2 = 1880, y1 = 270, y2 = 320} )
- end
-
- if cCounter > 0 then
- output = output .. [[]]..
- #DisplayTable..
- [[ Tank]]..(#DisplayTable == 1 and "" or "s")..
- [[ (Showing ]]..screen.fuelIndex..[[ to ]]..(screen.fuelIndex+cCounter-1)..[[)]]
- end
-
- return output
-end
-
-function GetContentCargo()
- local output = ""
- output = output .. GetHeader("Cargo Report") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentAGG()
- local output = ""
- output = output .. GetHeader("Anti-Grav Control") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentMap()
- local output = ""
- output = output .. GetHeader("Map Overview") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentTime()
- local output = ""
- output = output .. GetHeader("Time") .. epochTime()
- output = output ..
- [[
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetContentSettings1()
- local output = ""
- output = output .. GetHeader("Settings") .. [[]]
- if BackgroundMode=="" then
- output = output ..[[Activate background]]
- else
- output = output ..[[Deactivate background (']]..BackgroundMode..[[', ]]..string.format("%.0f",BackgroundModeOpacity*100)..[[%)]]
- end
- output = output ..[[
-
- Previous background
-
- Next background
-
-
- Decrease Opacity
-
- Increase Opacity
- ]]
-
- output = output ..
- [[]] ..
- [[Reset background and all colors]]
-
- output = output ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Select and change any of the ]]..#colorIDTable..[[ HUD colors]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]]..colorIDTable[colorIDIndex].desc..[[]] ..
- [[]] ..
- [[Current color]] ..
- [[]] ..
-
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
-
- [[#]] ..
-
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,1,1)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,2,2)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,3,3)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,4,4)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,5,5)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,6,6)..[[]] ..
-
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
-
- [[]] ..
- [[]] ..
- [[New color]] ..
- [[]] ..
- [[Apply new color]] ..
- [[]] ..
- [[Reset]] ..
- [[]]
-
- output = output ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Explanation / Hints]] ..
- [[Coming soon.]]
-
-
- output = output .. [[]]
-
- if SimulationMode == true then
- output = output .. [[Simulating Damage to elements]]
- AddClickArea("settings1", { id = "ToggleSimulation", mode ="settings1", x1 = 940, x2 = 1850, y1 = 919, y2 = 969 })
- else
- output = output .. [[Simulate Damage to elements]]
- AddClickArea("settings1", { id = "ToggleSimulation", mode ="settings1", x1 = 940, x2 = 1850, y1 = 919, y2 = 969 })
- end
-
- return output
-end
-
-function GetContentStartup()
- local output = ""
- output = output .. GetElementLogo(812, 380, "f", "f", "f")
- if YourShipsName == "Enter here" then
- output = output .. [[Spaceship ID ]]..ShipID..[[]]
- else
- output = output .. [[]]..YourShipsName..[[]]
- end
- if ShowWelcomeMessage == true then output = output .. [[Greetings, Commander ]]..PlayerName..[[.]] end
- if #Warnings > 0 then
- output = output .. [[Warning: ]]..(table.concat(Warnings, " "))..[[]]
- end
- output = output .. [[Damage Report v]]..VERSION..[[, by Scion Interstellar, DorianGray - Discord: Dorian Gray#2623. Under GNU Public License 3.0.]]
- return output
-end
-
-function RenderScreen(screen, contentToRender)
- if contentToRender == nil then
- PrintConsole("ERROR: contentToRender is nil.")
- unit.exit()
- end
-
- CreateClickAreasForScreen(screen)
-
- local output =""
- output = output .. [[
-
-
- ]]
-
- output = output .. contentToRender
-
- if screen.mode == "startup" then
- output = output .. [[]]
- else
- output = output .. [[]]
- end
-
- output = output .. [[
-
- ]]
- output = output .. [[]]
-
- -- Center:
-
- --
- --
- --
- --
-
- local outputLength = string.len(output)
- -- PrintConsole("Render: "..screen.mode.." ("..outputLength.." chars)")
- screen.element.setSVG(output)
-end
-
-function RenderScreens(onlymode, onlysubmode)
-
- onlymode = onlymode or "all"
- onlysubmode = onlysubmode or "all"
-
- if screens ~= nil and #screens > 0 then
-
- local contentFlight = ""
- local contentDamage = ""
- local contentDamageoutlineTop = ""
- local contentDamageoutlineSide = ""
- local contentDamageoutlineFront = ""
- local contentFuel = ""
- local contentCargo = ""
- local contentAGG = ""
- local contentMap = ""
- local contentTime = ""
- local contentSettings1 = ""
- local contentStartup = ""
-
- for k,screen in pairs(screens) do
- if screen.refresh == true then
- local contentToRender = ""
-
- if screen.mode == "flight" and (onlymode =="flight" or onlymode =="all") then
- if contentFlight == "" then contentFlight = GetContentFlight() end
- contentToRender = contentFlight
- elseif screen.mode == "damage" and (onlymode =="damage" or onlymode =="all") then
- if contentDamage == "" then contentDamage = GetContentDamage() end
- contentToRender = contentDamage
- elseif screen.mode == "damageoutline" and (onlymode =="damageoutline" or onlymode =="all") then
- if screen.submode == "" then
- screen.submode = "top"
- screens[k].submode = "top"
- end
- if screen.submode == "top" and (onlysubmode == "top" or onlysubmode == "all") then
- if contentDamageoutlineTop == "" then contentDamageoutlineTop = GetContentDamageoutline(screen) end
- contentToRender = contentDamageoutlineTop
- end
- if screen.submode == "side" and (onlysubmode == "side" or onlysubmode == "all") then
- if contentDamageoutlineSide == "" then contentDamageoutlineSide = GetContentDamageoutline(screen) end
- contentToRender = contentDamageoutlineSide
- end
- if screen.submode == "front" and (onlysubmode == "front" or onlysubmode == "all") then
- if contentDamageoutlineFront == "" then contentDamageoutlineFront = GetContentDamageoutline(screen) end
- contentToRender = contentDamageoutlineFront
- end
- elseif screen.mode == "fuel" and (onlymode =="fuel" or onlymode =="all") then
- screen = WipeClickAreasForScreen(screens[k])
- contentToRender = GetContentFuel(screen)
- elseif screen.mode == "cargo" and (onlymode =="cargo" or onlymode =="all") then
- if contentCargo == "" then contentCargo = GetContentCargo() end
- contentToRender = contentCargo
- elseif screen.mode == "agg" and (onlymode =="agg" or onlymode =="all") then
- if contentAGG == "" then contentAGG = GetContentAGG() end
- contentToRender = contentAGG
- elseif screen.mode == "map" and (onlymode =="map" or onlymode =="all") then
- if contentMap == "" then contentMap = GetContentMap() end
- contentToRender = contentMap
- elseif screen.mode == "time" and (onlymode =="time" or onlymode =="all") then
- if contentTime == "" then contentTime = GetContentTime() end
- contentToRender = contentTime
- elseif screen.mode == "settings1" and (onlymode =="settings1" or onlymode =="all") then
- if contentSettings1 == "" then contentSettings1 = GetContentSettings1() end
- contentToRender = contentSettings1
- elseif screen.mode == "startup" and (onlymode =="startup" or onlymode =="all") then
- if contentStartup == "" then contentStartup = GetContentStartup() end
- contentToRender = contentStartup
- else
- contentToRender = "Invalid screen mode. ('"..screen.mode.."')"
- end
-
- if contentToRender ~= "" then
- RenderScreen(screen, contentToRender)
- else
- DrawCenteredText("ERROR: No contentToRender delivered for "..screen.mode)
- PrintConsole("ERROR: No contentToRender delivered for "..screen.mode)
- unit.exit()
- end
- screens[k].refresh = false
- end
- end
- end
-
- if HUDMode == true then
- system.setScreen(GetContentDamageHUDOutput())
- system.showScreen(1)
- else
- system.showScreen(0)
- end
-
-end
-
-function OnTickData(initial)
- if formerTime + 60 < system.getTime() then
- SetRefresh("time")
- end
- totalShipMass = core.getConstructMass()
- if formerTotalShipMass ~= totalShipMass then
- UpdateDamageData(true)
- UpdateTypeData()
- SetRefresh()
- formerTotalShipMass = totalShipMass
- else
- UpdateDamageData(initial)
- UpdateTypeData()
- end
- RenderScreens()
-end
-
---[[ 5. EXECUTION ]]
-
-unit.hide()
-ClearConsole()
-PrintConsole("DAMAGE REPORT v"..VERSION.." STARTED", true)
-InitiateSlots()
-LoadFromDatabank()
-SwitchScreens("on")
-InitiateScreens()
-
-if core == nil then
- PrintConsole("ERROR: Connect the core to the programming board.")
- unit.exit()
-else
- OperatorID = unit.getMasterPlayerId()
- OperatorData = database.getPlayer(OperatorID)
- PlayerName = OperatorData["name"]
- ShipID = core.getConstructId()
-end
-
-if db == nil then
- table.insert(Warnings, "No databank connected, won't save/load settings.")
-end
-
-if YourShipsName == "Enter here" then
- table.insert(Warnings, "No ship name set in LUA settings.")
-end
-
-if SkillRepairToolEfficiency == 0 and SkillRepairToolOptimization == 0 and StatFuelTankOptimization == 0 and
- StatAtmosphericFuelTankHandling == 0 and StatSpaceFuelTankHandling == 0 and StatRocketFuelTankHandling ==0 then
- table.insert(Warnings, "No talents/stats set in LUA settings.")
-end
-
-if SkillRepairToolEfficiency < 0 or SkillRepairToolOptimization < 0 or StatFuelTankOptimization < 0 or
- StatAtmosphericFuelTankHandling < 0 or StatSpaceFuelTankHandling < 0 or StatRocketFuelTankHandling < 0 or
- SkillRepairToolEfficiency > 5 or SkillRepairToolOptimization > 5 or StatFuelTankOptimization > 5 or
- StatAtmosphericFuelTankHandling > 5 or StatSpaceFuelTankHandling > 5 or StatRocketFuelTankHandling > 5 then
- PrintConsole("ERROR: Talents/stats can only range from 0 to 5. Please set correctly in LUA settings and reactivate script.")
- unit.exit()
-end
-
-if screens == nil or #screens == 0 then
- HUDMode = true
- PrintConsole("Warning: No screens connected. Entering HUD mode only.")
-end
-
-OnTickData(true)
-
-unit.setTimer('UpdateData', UpdateDataInterval)
-unit.setTimer('UpdateHighlight', HighlightBlinkingInterval)
\ No newline at end of file
diff --git a/src/DamageReport_3_04_UnitStart_1.lua b/src/DamageReport_3_04_UnitStart_1.lua
deleted file mode 100644
index 8b67c41..0000000
--- a/src/DamageReport_3_04_UnitStart_1.lua
+++ /dev/null
@@ -1,1277 +0,0 @@
---[[
- Damage Report 3.04
- A LUA script for Dual Universe
-
- Created By Dorian Gray
- Ingame: DorianGray
- Discord: Dorian Gray#2623
-
- You can find/update this script on GitHub. Explanations, installation and usage information as well as screenshots can be found there too.
- GitHub: https://github.com/DorianTheGrey/DU-DamageReport
-
- GNU Public License 3.0. Use whatever you want, be so kind to leave credit.
-
- Credits & thanks:
- Thanks to NovaQuark for creating the MMO of the century.
- Thanks to Jericho, Dmentia and Archaegeo for learning a lot from their fine scripts.
- Thanks to TheBlacklist for testing and wonderful suggestions.
- SVG patterns by Hero Patterns.
- DU atlas data from Jayle Break.
-
-]]
-
---[[ 1. HELPER FUNCTIONS ]]
-
-function GenerateCommaValue(amount, kify, postcomma)
- kify = kify or false
- postcomma = postcomma or 1
- local formatted = amount
- if kify == true then
- if string.len(amount)>=4 then
- formatted = string.format("%."..postcomma.."fk", amount/1000)
- else
- formatted = string.format("%."..postcomma.."f", amount)
- end
- else
- while true do
- formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
- if (k == 0) then break end
- end
- end
- return formatted
-end
-
-function PrintConsole(output, highlight)
- highlight = highlight or false
- if highlight then
- system.print(
- "------------------------------------------------------------------------")
- end
- system.print(output)
- if highlight then
- system.print(
- "------------------------------------------------------------------------")
- end
-end
-
-function DrawCenteredText(output)
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- screens[i].element.setCenteredText(output)
- end
- end
-end
-
-function ClearConsole()
- for i = 1, 10, 1 do
- PrintConsole()
- end
-end
-
-function SwitchScreens(state)
- state = state or "on"
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- if state == "on" then
- screens[i].element.clear()
- screens[i].element.activate()
- screens[i].active = true
- else
- screens[i].element.clear()
- screens[i].element.deactivate()
- screens[i].active = false
- end
- end
- end
-end
-
---[[ Convert seconds to string (by Jericho) ]]
-function GetSecondsString(seconds)
- local seconds = tonumber(seconds)
-
- if seconds == nil or seconds <= 0 then
- return "-";
- else
- days = string.format("%2.f", math.floor(seconds/(3600*24)));
- hours = string.format("%2.f", math.floor(seconds/3600 - (days*24)));
- mins = string.format("%2.f", math.floor(seconds/60 - (hours*60) - (days*24*60)));
- secs = string.format("%2.f", math.floor(seconds - hours*3600 - (days*24*60*60) - mins *60));
- str = ""
- if tonumber(days) > 0 then str = str .. days.."d " end
- if tonumber(hours) > 0 then str = str .. hours.."h " end
- if tonumber(mins) > 0 then str = str .. mins.."m " end
- if tonumber(secs) > 0 then str = str .. secs .."s" end
- return str
- end
-end
-
-function replace_char(pos, str, r)
- return str:sub(1, pos-1) .. r .. str:sub(pos+1)
-end
-
---[[ 2. RENDER HELPER FUNCTIONS ]]
-
---[[ epochTime function by Leodr (clock script), enhanced by Jericho (DU Industry script) ]]
-function epochTime()
- function rZ(a)
- if string.len(a) <= 1 then
- return "0" .. a
- else
- return a
- end
- end
- function dPoint(b)
- if not (b == math.floor(b)) then
- return true
- else
- return false
- end
- end
- function lYear(year)
- if not dPoint(year / 4) then
- if dPoint(year / 100) then
- return true
- else
- if not dPoint(year / 400) then
- return true
- else
- return false
- end
- end
- else
- return false
- end
- end
- local c = 5;
- local d = 3600;
- local e = 86400;
- local f = 31536000;
- local g = 31622400;
- local h = 2419200;
- local i = 2505600;
- local j = 2592000;
- local k = 2678400;
- local l = {4, 6, 9, 11}
- local m = {1, 3, 5, 7, 8, 10, 12}
- local n = 0;
- local o = 1506816000;
- local q = system.getTime()
- _G["formerTime"] = q
- if AddSummertimeHour == true then q = q + 3600 end
- now = math.floor(q + o)
- year = 1970;
- secs = 0;
- n = 0;
- while secs + g < now or secs + f < now do
- if lYear(year + 1) then
- if secs + g < now then
- secs = secs + g;
- year = year + 1;
- n = n + 366
- end
- else
- if secs + f < now then
- secs = secs + f;
- year = year + 1;
- n = n + 365
- end
- end
- end
- secondsRemaining = now - secs;
- monthSecs = 0;
- yearlYear = lYear(year)
- month = 1;
- while monthSecs + h < secondsRemaining or monthSecs + j < secondsRemaining or
- monthSecs + k < secondsRemaining do
- if month == 1 then
- if monthSecs + k < secondsRemaining then
- month = 2;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 2 then
- if not yearlYear then
- if monthSecs + h < secondsRemaining then
- month = 3;
- monthSecs = monthSecs + h;
- n = n + 28
- else
- break
- end
- else
- if monthSecs + i < secondsRemaining then
- month = 3;
- monthSecs = monthSecs + i;
- n = n + 29
- else
- break
- end
- end
- end
- if month == 3 then
- if monthSecs + k < secondsRemaining then
- month = 4;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 4 then
- if monthSecs + j < secondsRemaining then
- month = 5;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- if month == 5 then
- if monthSecs + k < secondsRemaining then
- month = 6;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 6 then
- if monthSecs + j < secondsRemaining then
- month = 7;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- if month == 7 then
- if monthSecs + k < secondsRemaining then
- month = 8;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 8 then
- if monthSecs + k < secondsRemaining then
- month = 9;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 9 then
- if monthSecs + j < secondsRemaining then
- month = 10;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- if month == 10 then
- if monthSecs + k < secondsRemaining then
- month = 11;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 11 then
- if monthSecs + j < secondsRemaining then
- month = 12;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- end
- day = 1;
- daySecs = 0;
- daySecsRemaining = secondsRemaining - monthSecs;
- while daySecs + e < daySecsRemaining do
- day = day + 1;
- daySecs = daySecs + e;
- n = n + 1
- end
- hour = 0;
- hourSecs = 0;
- hourSecsRemaining = daySecsRemaining - daySecs;
- while hourSecs + d < hourSecsRemaining do
- hour = hour + 1;
- hourSecs = hourSecs + d
- end
- minute = 0;
- minuteSecs = 0;
- minuteSecsRemaining = hourSecsRemaining - hourSecs;
- while minuteSecs + 60 < minuteSecsRemaining do
- minute = minute + 1;
- minuteSecs = minuteSecs + 60
- end
- second = math.floor(now % 60)
- year = rZ(year)
- month = rZ(month)
- day = rZ(day)
- hour = rZ(hour)
- minute = rZ(minute)
- second = rZ(second)
-
- return [[]]..hour..":".. minute..[[]]..
- [[]]..year.."/".. month.."/"..day..[[]]
-end
-
-
-function ToggleHUD()
- if HUDMode == true then
- HUDMode = false
- forceDamageRedraw = true
- hudSelectedIndex = 0
- highlightID = 0
- HideHighlight()
- SetRefresh()
- RenderScreens()
- else
- HUDMode = true
- forceDamageRedraw = true
- hudSelectedIndex = 0
- highlightID = 0
- HideHighlight()
- SetRefresh()
- RenderScreens()
- end
-end
-
-function HudDeselectElement()
- hudSelectedIndex = 0
- hudStartIndex = 1
- highlightID = 0
- HideHighlight()
- if HUDMode == true then
- SetRefresh("damage")
- SetRefresh("damageoutline")
- RenderScreens()
- end
-end
-
-function ChangeHudSelectedElement(step)
- if HUDMode == true and #rE > 0 then
-
- hudSelectedIndex = hudSelectedIndex + step
- if hudSelectedIndex < 1 then hudSelectedIndex = 1
- elseif hudSelectedIndex > #rE then hudSelectedIndex = #rE
- end
-
- if hudSelectedIndex > 9 then
- hudStartIndex = hudSelectedIndex-9
- end
- if hudSelectedIndex ~= 0 then
- highlightID = rE[hudSelectedIndex].id
- if highlightID ~=nil and highlightID ~= 0 then
- -- PrintConsole("CHSE: hudSelectedIndex: "..hudSelectedIndex.." / hudStartIndex: "..hudStartIndex.." / highlightID: "..highlightID)
- HideHighlight()
- elementPosition = vec3(rE[hudSelectedIndex].pos)
- highlightX = elementPosition.x - coreWorldOffset
- highlightY = elementPosition.y - coreWorldOffset
- highlightZ = elementPosition.z - coreWorldOffset
- highlightOn = true
- ShowHighlight()
- end
- end
-
- SetRefresh("damage")
- SetRefresh("damageoutline")
- RenderScreens()
-
- end
-end
-
-function HideHighlight()
- if #hudArrowSticker > 0 then
- for i in pairs(hudArrowSticker) do
- core.deleteSticker(hudArrowSticker[i])
- end
- hudArrowSticker = {}
- end
-end
-
-function ShowHighlight()
- if highlightOn == true and highlightID > 0 then
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX + 2, highlightY, highlightZ, "north"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY - 2, highlightZ, "east"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX - 2, highlightY, highlightZ, "south"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY + 2, highlightZ, "west"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY, highlightZ - 2, "up"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY, highlightZ + 2,"down"))
- end
-end
-
-function ToggleHighlight()
- if highlightOn == true then
- highlightOn = false
- HideHighlight()
- else
- highlightOn = true
- ShowHighlight()
- end
-end
-
-function SortDamageTables()
- table.sort(damagedElements, function(a, b) return a.missinghp > b.missinghp end)
- table.sort(brokenElements, function(a, b) return a.maxhp > b.maxhp end)
-end
-
-function getScraps(damage,commaval)
- commaval = commaval or false
- damage = damage - SkillRepairToolOptimization * 0.05 * damage
- local res = math.ceil( damage / ( 10 * 5^(ScrapTier-1) ) )
- if commaval ==true then
- return GenerateCommaValue(string.format("%.0f", res ), false)
- else
- return res
- end
-end
-
-function getRepairTime(damage,buildstring)
- buildstring = buildstring or false
- damage = damage - SkillRepairToolOptimization * 0.05 * damage
- local res = math.ceil(damage / ScrapTierRepairTimes[ScrapTier])
- res = res - ( SkillRepairToolEfficiency * 0.1 * res )
- if buildstring == true then
- return GetSecondsString(string.format("%.0f", res ) )
- else
- return res
- end
-end
-
-function UpdateDataDamageoutline()
-
- dmgoElements = {}
-
- for i,element in ipairs(brokenElements) do
- if #dmgoElements < DMGOMaxElements then
- local elementPosition = vec3(element.pos)
- local x = elementPosition.x - coreWorldOffset
- local y = elementPosition.y - coreWorldOffset
- local z = elementPosition.z - coreWorldOffset
- if x < ShipXmin then ShipXmin = x end
- if y < ShipYmin then ShipYmin = y end
- if z < ShipZmin then ShipZmin = z end
- if x > ShipXmax then ShipXmax = x end
- if y > ShipYmax then ShipYmax = y end
- if z > ShipZmax then ShipZmax = z end
- table.insert( dmgoElements, {
- id = element.id,
- type = "b",
- size = element.maxhp,
- x = x, y = y, z = z,
- xp = 0, yp = 0, zp = 0,
- u = 0, v = 0
- })
- end
- end
-
- if #dmgoElements < DMGOMaxElements then
- for i,element in ipairs(damagedElements) do
- if #dmgoElements < DMGOMaxElements then
- local elementPosition = vec3(element.pos)
- local x = elementPosition.x - coreWorldOffset
- local y = elementPosition.y - coreWorldOffset
- local z = elementPosition.z - coreWorldOffset
- if x < ShipXmin then ShipXmin = x end
- if y < ShipYmin then ShipYmin = y end
- if z < ShipZmin then ShipZmin = z end
- if x > ShipXmax then ShipXmax = x end
- if y > ShipYmax then ShipYmax = y end
- if z > ShipZmax then ShipZmax = z end
- table.insert( dmgoElements, {
- id = element.id,
- type = "d",
- size = element.maxhp,
- x = x, y = y, z = z,
- xp = 0, yp = 0, zp = 0,
- u = 0, v = 0
- })
- end
- end
- end
-
- if #dmgoElements < DMGOMaxElements then
- for i,element in ipairs(healthyElements) do
- if #dmgoElements < DMGOMaxElements then
- local elementPosition = vec3(element.pos)
- local x = elementPosition.x - coreWorldOffset
- local y = elementPosition.y - coreWorldOffset
- local z = elementPosition.z - coreWorldOffset
- if x < ShipXmin then ShipXmin = x end
- if y < ShipYmin then ShipYmin = y end
- if z < ShipZmin then ShipZmin = z end
- if x > ShipXmax then ShipXmax = x end
- if y > ShipYmax then ShipYmax = y end
- if z > ShipZmax then ShipZmax = z end
- table.insert( dmgoElements, {
- id = element.id,
- type = "h",
- size = element.maxhp,
- x = x, y = y, z = z,
- xp = 0, yp = 0, zp = 0,
- u = 0, v = 0
- })
- end
- end
- end
-
- ShipX = math.abs(ShipXmax-ShipXmin)
- ShipY = math.abs(ShipYmax-ShipYmin)
- ShipZ = math.abs(ShipZmax-ShipZmin)
-
- --[[
- PrintConsole(
- "ShipXmin: "..string.format("%.2f",ShipXmin)..
- " - ShipYmin: "..string.format("%.2f",ShipYmin)..
- " - ShipZmin: "..string.format("%.2f",ShipZmin)..
- " - ShipXmax: "..string.format("%.2f",ShipXmax)..
- " - ShipYmax: "..string.format("%.2f",ShipYmax)..
- " - ShipZmax: "..string.format("%.2f",ShipZmax)
- )
-
- PrintConsole(
- "ShipX: "..string.format("%.2f",ShipX)..
- " - ShipY: "..string.format("%.2f",ShipY)..
- " - ShipZ: "..string.format("%.2f",ShipZ)
- )
- ]]
-
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].xp = math.abs(100/(ShipXmax-ShipXmin)*(element.x-ShipXmin))
- dmgoElements[i].yp = math.abs(100/(ShipYmax-ShipYmin)*(element.y-ShipYmin))
- dmgoElements[i].zp = math.abs(100/(ShipZmax-ShipZmin)*(element.z-ShipZmin))
- -- PrintConsole(i..". "..element.id..": "..string.format("%.2f",element.x).."/"..string.format("%.2f",element.y).."/"..string.format("%.2f",element.z).." - XP: "..dmgoElements[i].xp.." - YP: "..dmgoElements[i].yp.." - ZP: "..dmgoElements[i].zp)
- end
-
-end
-
-function UpdateViewDamageoutline(screen)
- -- Full Width of virtual screen:
- -- UStart = 20
- -- VStart = 180
- -- UDim = 1880
- -- VDim = 840
- -- Adding frames:
- UFrame = 40
- VFrame = 40
-
- UStart = 20 + UFrame
- VStart = 180 + VFrame
- UDim = 1880 - 2*UFrame
- VDim = 840 - 2*VFrame
-
- if screen.submode == "top" then
- if DMGOStretch == false then
- local UFactor = UDim/(ShipYmax-ShipYmin)
- local VFactor = VDim/(ShipXmax-ShipXmin)
- if UFactor>=VFactor then
- local cFactor = UFactor/VFactor
- local newUDim = math.floor(UDim/cFactor)
- UStart = UStart+(UDim-newUDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100/cFactor*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*element.xp+VStart)
- end
- else
- local cFactor = VFactor/UFactor
- local newVDim = math.floor(VDim/cFactor)
- VStart = VStart+(VDim-newVDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100/cFactor*element.xp+VStart)
- end
- end
- else
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*element.xp+VStart)
- end
- end
-
-
- elseif screen.submode == "front" then
- if DMGOStretch == false then
- local UFactor = UDim/(ShipXmax-ShipXmin)
- local VFactor = VDim/(ShipZmax-ShipZmin)
- if UFactor>=VFactor then
- local cFactor = UFactor/VFactor
- local newUDim = math.floor(UDim/cFactor)
- UStart = UStart+(UDim-newUDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100/cFactor*element.xp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- else
- local cFactor = VFactor/UFactor
- local newVDim = math.floor(VDim/cFactor)
- VStart = VStart+(VDim-newVDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.xp+UStart)
- dmgoElements[i].v = math.floor(VDim/100/cFactor*(100-element.zp)+VStart)
- end
- end
- else
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.xp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- end
-
- elseif screen.submode == "side" then
- if DMGOStretch == false then
- local UFactor = UDim/(ShipYmax-ShipYmin)
- local VFactor = VDim/(ShipXmax-ShipZmin)
- if UFactor>=VFactor then
- local cFactor = UFactor/VFactor
- local newUDim = math.floor(UDim/cFactor)
- UStart = UStart+(UDim-newUDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100/cFactor*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- else
- local cFactor = VFactor/UFactor
- local newVDim = math.floor(VDim/cFactor)
- VStart = VStart+(VDim-newVDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100/cFactor*(100-element.zp)+VStart)
- end
- end
- else
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- end
- else
- DrawCenteredText("ERROR: non-existing DMGO mode set.")
- PrintConsole("ERROR: non-existing DMGO mode set.")
- unit.exit()
- end
-end
-
-function GetDamageoutlineShip()
- local output = ""
-
- for i,element in ipairs(dmgoElements) do
- local cclass = ""
- local size = 1
-
- if element.type == "h" then
- cclass ="ch"
- elseif element.type == "d" then
- cclass = "cw"
- else
- cclass = "cc"
- end
- if element.id == highlightID then
- cclass = "f2"
- end
-
- if element.size > 0 and element.size < 1000 then
- size = 5
- elseif element.size >= 1000 and element.size < 2000 then
- size = 8
- elseif element.size >= 2000 and element.size < 5000 then
- size = 12
- elseif element.size >= 5000 and element.size < 10000 then
- size = 15
- elseif element.size >= 10000 and element.size < 20000 then
- size = 20
- elseif element.size >= 20000 then
- size = 30
- end
- output = output .. [[]]
- if element.id == highlightID then
- output = output .. [[]]
- output = output .. [[]]
- end
- end
-
- return output
-end
-
-function GetContentClickareas(screen)
- local output = ""
- if screen ~= nil and screen.ClickAreas ~= nil and #screen.ClickAreas > 0 then
- for i,ca in ipairs(screen.ClickAreas) do
- output = output ..
- [[]]
- end
- end
- return output
-end
-
-function GetElement1(x, y, width, height)
- x = x or 0
- y = y or 0
- width = width or 600
- height = height or 600
- local output = ""
- output = output ..
- [[
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetElement2(x, y)
- x = x or 0
- y = y or 0
- local output = ""
- output = output .. [[]]
- return output
-end
-
-function GetElementLogo(x, y, primaryC, secondaryC, tertiaryC)
- x = x or 812
- y = y or 380
- primaryC = primaryC or "f"
- secondaryC = secondaryC or "f2"
- tertiaryC = tertiaryC or "f3"
- local output = ""
- output = output .. [[
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetHeader(headertext)
- headertext = headertext or "ERROR: UNDEFINED"
- local output = ""
- output = output ..
- [[
- ]]..headertext..[[]]
- return output
-end
-
-function GetContentBackground(candidate, bgcolor)
- bgColor = ColorBackgroundPattern
-
- local output = ""
-
- if candidate == "dots" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' viewBox='0 0 4 4'%3E%3Cpath fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' d='M1 3h1v1H1V3zm2-2h1v1H3V1z'%3E%3C/path%3E%3C/svg%3E");]]
- elseif candidate == "rain" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='12' height='16' viewBox='0 0 12 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 .99C4 .445 4.444 0 5 0c.552 0 1 .45 1 .99v4.02C6 5.555 5.556 6 5 6c-.552 0-1-.45-1-.99V.99zm6 8c0-.546.444-.99 1-.99.552 0 1 .45 1 .99v4.02c0 .546-.444.99-1 .99-.552 0-1-.45-1-.99V8.99z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E");]]
- elseif candidate == "plus" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "signal" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='84' height='48' viewBox='0 0 84 48' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h12v6H0V0zm28 8h12v6H28V8zm14-8h12v6H42V0zm14 0h12v6H56V0zm0 8h12v6H56V8zM42 8h12v6H42V8zm0 16h12v6H42v-6zm14-8h12v6H56v-6zm14 0h12v6H70v-6zm0-16h12v6H70V0zM28 32h12v6H28v-6zM14 16h12v6H14v-6zM0 24h12v6H0v-6zm0 8h12v6H0v-6zm14 0h12v6H14v-6zm14 8h12v6H28v-6zm-14 0h12v6H14v-6zm28 0h12v6H42v-6zm14-8h12v6H56v-6zm0-8h12v6H56v-6zm14 8h12v6H70v-6zm0 8h12v6H70v-6zM14 24h12v6H14v-6zm14-8h12v6H28v-6zM14 8h12v6H14V8zM0 8h12v6H0V8z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E");]]
- elseif candidate == "deathstar" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='105' viewBox='0 0 80 105'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M20 10a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm15 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zM20 75a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zm30-65a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm0 65a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zM35 10a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zM5 45a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zm60 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10z' /%3E%3C/g%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "diamond" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='32' viewBox='0 0 16 32'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath fill-rule='evenodd' d='M0 24h4v2H0v-2zm0 4h6v2H0v-2zm0-8h2v2H0v-2zM0 0h4v2H0V0zm0 4h2v2H0V4zm16 20h-6v2h6v-2zm0 4H8v2h8v-2zm0-8h-4v2h4v-2zm0-20h-6v2h6V0zm0 4h-4v2h4V4zm-2 12h2v2h-2v-2zm0-8h2v2h-2V8zM2 8h10v2H2V8zm0 8h10v2H2v-2zm-2-4h14v2H0v-2zm4-8h6v2H4V4zm0 16h6v2H4v-2zM6 0h2v2H6V0zm0 24h2v2H6v-2z'/%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "hexagon" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='49' viewBox='0 0 28 49'%3E%3Cg fill-rule='evenodd'%3E%3Cg id='hexagons' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='nonzero'%3E%3Cpath d='M13.99 9.25l13 7.5v15l-13 7.5L1 31.75v-15l12.99-7.5zM3 17.9v12.7l10.99 6.34 11-6.35V17.9l-11-6.34L3 17.9zM0 15l12.98-7.5V0h-2v6.35L0 12.69v2.3zm0 18.5L12.98 41v8h-2v-6.85L0 35.81v-2.3zM15 0v7.5L27.99 15H28v-2.31h-.01L17 6.35V0h-2zm0 49v-8l12.99-7.5H28v2.31h-.01L17 42.15V49h-2z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "capsule" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='32' height='26' viewBox='0 0 32 26' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M14 0v3.994C14 7.864 10.858 11 7 11c-3.866 0-7-3.138-7-7.006V0h2v4.005C2 6.765 4.24 9 7 9c2.756 0 5-2.236 5-4.995V0h2zm0 26v-5.994C14 16.138 10.866 13 7 13c-3.858 0-7 3.137-7 7.006V26h2v-6.005C2 17.235 4.244 15 7 15c2.76 0 5 2.236 5 4.995V26h2zm2-18.994C16 3.136 19.142 0 23 0c3.866 0 7 3.138 7 7.006v9.988C30 20.864 26.858 24 23 24c-3.866 0-7-3.138-7-7.006V7.006zm2-.01C18 4.235 20.244 2 23 2c2.76 0 5 2.236 5 4.995v10.01C28 19.765 25.756 22 23 22c-2.76 0-5-2.236-5-4.995V6.995z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E");]]
- elseif candidate == "diagonal" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='6' height='6' viewBox='0 0 6 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'%3E%3Cpath d='M5 0h1L0 6V5zM6 5v1H5z'/%3E%3C/g%3E%3C/svg%3E");]]
- end
- return output;
-end
-
-function GetContentDamageHUDOutput()
- local hudWidth = 300
- local hudHeight = 165
- if #damagedElements > 0 or #brokenElements > 0 then hudHeight = 510 end
- local output = ""
-
- output = output .. [[
-
- ]]
- output = output .. [[]] ..
- [[]] ..
- [[]] ..
- [[]]..(YourShipsName=="Enter here" and ("Ship ID "..ShipID) or YourShipsName) .. [[]] ..
- [[]]
- if #brokenElements > 0 then
- output = output .. [[]]
- elseif #damagedElements > 0 then
- output = output .. [[]]
- else
- output = output .. [[]]
- end
-
- if #damagedElements > 0 or #brokenElements > 0 then
-
- output = output .. [[Total Damage]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", totalShipMaxHP - totalShipHP))..[[]]
- output = output .. [[T]]..ScrapTier..[[ Scrap Needed]] ..
- [[]]..getScraps(totalShipMaxHP - totalShipHP, true)..[[]]
- output = output .. [[Repair Time]] ..
- [[]]..getRepairTime(totalShipMaxHP - totalShipHP, true)..[[]]
-
- output = output .. [[]] ..
- [[]] ..
- [[]]..#healthyElements..[[]] ..
- [[]] ..
- [[]]..#damagedElements..[[]] ..
- [[]] ..
- [[]]..#brokenElements..[[]]
- local j=0
-
- for currentIndex=hudStartIndex,hudStartIndex+9,1 do
- if rE[currentIndex] ~= nil then
- v = rE[currentIndex]
- if v.hp > 0 then
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- if v.id == highlightID then
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- end
- else
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- if v.id == highlightID then
- highlightX = elementPosition.x - coreWorldOffset
- highlightY = elementPosition.y - coreWorldOffset
- highlightZ = elementPosition.z - coreWorldOffset
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- end
- end
- j=j+1
- end
- end
- output = output ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Up/down arrows to highlight]] ..
- [[CTRL + arrows to move HUD]] ..
- [[Left arrow to toggle HUD Mode]] ..
- [[ALT+1-4 to set Scrap Tier]] ..
- [[ALT+8 to reset HUD position]] ..
- [[ALT+9 to shut script off]] ..
- [[]] ..
- [[]]
- else
- output = output ..
- [[]] .. OkayCenterMessage .. [[]] ..
- [[]]..#healthyElements..[[ elements / ]] .. GenerateCommaValue(string.format("%.0f", totalShipMaxHP)) .. [[ HP.]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Left arrow to toggle HUD Mode]] ..
- [[CTRL + arrows to move HUD]] ..
- [[ALT+8 to reset HUD position]] ..
- [[ALT+9 to shut script off]] ..
- [[]] ..
- [[]]
- end
- output = output .. [[]]
- return output
-end
-
-function GetContentDamageScreen()
-
- local screenOutput = ""
-
- -- Draw damage elements
- if #damagedElements > 0 then
- local damagedElementsToDraw = #damagedElements
- if damagedElementsToDraw > DamagePageSize then
- damagedElementsToDraw = DamagePageSize
- end
- if CurrentDamagedPage == math.ceil(#damagedElements / DamagePageSize) then
- damagedElementsToDraw = #damagedElements % DamagePageSize + 12
- if damagedElementsToDraw > 12 then damagedElementsToDraw = damagedElementsToDraw - 12 end
- end
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
-
- if UseMyElementNames == true then screenOutput = screenOutput .. [[Damaged Name]]
- else screenOutput = screenOutput .. [[Damaged Type]]
- end
-
- screenOutput = screenOutput .. [[HLTHDMG]]
- screenOutput = screenOutput .. [[T]]..ScrapTier..[[ SCRREPTIME]]
-
- AddClickArea("damage", {
- id = "SwitchScrapTier",
- mode ="damage",
- x1 = 650,
- x2 = 775,
- y1 = 315,
- y2 = 360
- })
-
- local i = 0
- for j = 1 + (CurrentDamagedPage - 1) * DamagePageSize, damagedElementsToDraw + (CurrentDamagedPage - 1) * DamagePageSize, 1 do
- i = i + 1
- local DP = damagedElements[j]
- if UseMyElementNames == true then screenOutput = screenOutput .. [[]] .. string.format("%.23s", DP.name) .. [[]]
- else screenOutput = screenOutput .. [[]] .. string.format("%.23s", DP.type) .. [[]]
- end
- screenOutput = screenOutput .. [[]] .. DP.percent .. [[%]] ..
- [[]] .. GenerateCommaValue(string.format("%.0f", DP.missinghp), true) .. [[]] ..
- [[]] .. getScraps(DP.missinghp, true) .. [[]] ..
- [[]] .. getRepairTime(DP.missinghp, true) .. [[]] ..
- [[]]
- end
-
- if #damagedElements > DamagePageSize then
- screenOutput = screenOutput ..
- [[Page ]] .. CurrentDamagedPage .. " of " .. math.ceil(#damagedElements / DamagePageSize) ..[[]]
-
- if CurrentDamagedPage < math.ceil(#damagedElements / DamagePageSize) then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "DamagedPageDown",
- mode ="damage",
- x1 = 65,
- x2 = 260,
- y1 = 290 + (damagedElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (damagedElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("DamagedPageDown","damage")
- end
-
- if CurrentDamagedPage > 1 then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "DamagedPageUp",
- mode ="damage",
- x1 = 750,
- x2 = 950,
- y1 = 290 + (damagedElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (damagedElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("DamagedPageUp","damage")
- end
- end
- end
-
- -- Draw broken elements
- if #brokenElements > 0 then
- local brokenElementsToDraw = #brokenElements
- if brokenElementsToDraw > DamagePageSize then
- brokenElementsToDraw = DamagePageSize
- end
- if CurrentBrokenPage == math.ceil(#brokenElements / DamagePageSize) then
- brokenElementsToDraw = #brokenElements % DamagePageSize + 12
- if brokenElementsToDraw > 12 then brokenElementsToDraw = brokenElementsToDraw - 12 end
- end
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
-
- if UseMyElementNames == true then screenOutput = screenOutput .. [[Broken Name]]
- else screenOutput = screenOutput .. [[Broken Type]]
- end
-
- screenOutput = screenOutput .. [[DMG]]
- screenOutput = screenOutput .. [[T]]..ScrapTier..[[ SCRREPTIME]]
-
- AddClickArea("damage", {
- id = "SwitchScrapTier2",
- mode ="damage",
- x1 = 1570,
- x2 = 1690,
- y1 = 315,
- y2 = 360
- })
-
- local i = 0
- for j = 1 + (CurrentBrokenPage - 1) * DamagePageSize, brokenElementsToDraw + (CurrentBrokenPage - 1) * DamagePageSize, 1 do
- i = i + 1
- local DP = brokenElements[j]
- if UseMyElementNames == true then screenOutput = screenOutput .. [[]] .. string.format("%.30s", DP.name) .. [[]]
- else screenOutput = screenOutput .. [[]] .. string.format("%.30s", DP.type) .. [[]]
- end
- screenOutput = screenOutput .. [[]] .. GenerateCommaValue(string.format("%.0f", DP.missinghp), true) .. [[]] ..
- [[]] .. getScraps(DP.missinghp, true) .. [[]] ..
- [[]] .. getRepairTime(DP.missinghp, true) .. [[]] ..
- [[]]
- end
-
-
-
- if #brokenElements > DamagePageSize then
- screenOutput = screenOutput ..
- [[Page ]] .. CurrentBrokenPage .. " of " .. math.ceil(#brokenElements / DamagePageSize) .. [[]]
-
- if CurrentBrokenPage > 1 then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "BrokenPageUp",
- mode ="damage",
- x1 = 1665,
- x2 = 1865,
- y1 = 290 + (brokenElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (brokenElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("BrokenPageUp", "damage")
- end
-
- if CurrentBrokenPage < math.ceil(#brokenElements / DamagePageSize) then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "BrokenPageDown",
- mode ="damage",
- x1 = 980,
- x2 = 1180,
- y1 = 290 + (brokenElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (brokenElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("BrokenPageDown", "damage")
- end
- end
-
- end
-
- -- Draw summary
- if #damagedElements > 0 or #brokenElements > 0 then
- local dWidth = math.floor(1878/#elementsIdList*#damagedElements)
- local bWidth = math.floor(1878/#elementsIdList*#brokenElements)
- local hWidth = 1878-dWidth-bWidth+1
-
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
-
- if #damagedElements > 0 then
- screenOutput = screenOutput .. [[]]..#damagedElements..[[]]
- end
- if #healthyElements > 0 then
- screenOutput = screenOutput .. [[]]..#healthyElements..[[]]
- end
- if #brokenElements > 0 then
- screenOutput = screenOutput .. [[]]..#brokenElements..[[]]
- end
-
- screenOutput = screenOutput .. [[]]
-
- screenOutput = screenOutput .. [[]] ..
- GenerateCommaValue(string.format("%.0f", totalShipMaxHP - totalShipHP)) .. [[ HP damage in total ]] ..
- getScraps(totalShipMaxHP - totalShipHP, true) .. [[ T]]..ScrapTier..[[ scraps needed. ]] ..
- getRepairTime(totalShipMaxHP - totalShipHP, true) .. [[ projected repair time.]]
- else
- screenOutput = screenOutput .. GetElementLogo(812, 380, "ch", "ch", "ch") ..
- [[]] .. OkayCenterMessage .. [[]] ..
- [[]]..#healthyElements..[[ elements stand ]] .. GenerateCommaValue(string.format("%.0f", totalShipMaxHP)) .. [[ HP strong.]]
- end
-
- forceDamageRedraw = false
-
- return screenOutput
-end
-
-function ActionStopengines()
- ToggleHUD()
-end
-
-function ActionStrafeRight()
- if KeyCTRLPressed == true then
- if HUDShiftU < 4000 then
- HUDShiftU = HUDShiftU + 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- HudDeselectElement()
- end
-end
-
-function ActionStrafeLeft()
- if KeyCTRLPressed == true then
- if HUDShiftU >= 50 then
- HUDShiftU = HUDShiftU - 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- ToggleHUD()
- end
-end
-
-function ActionDown()
- if KeyCTRLPressed == true then
- if HUDShiftV < 4000 then
- HUDShiftV = HUDShiftV + 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- ChangeHudSelectedElement(1)
- end
-end
-
-function ActionUp()
- if KeyCTRLPressed == true then
- if HUDShiftV >= 50 then
- HUDShiftV = HUDShiftV - 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- ChangeHudSelectedElement(-1)
- end
-end
-
-function ActionOption1()
- ScrapTier = 1
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption2()
- ScrapTier = 2
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption3()
- ScrapTier = 3
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption4()
- ScrapTier = 4
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption8()
- HUDShiftU=0
- HUDShiftV=0
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption9()
- SaveToDatabank()
- SwitchScreens("off")
- unit.exit()
-end
diff --git a/src/DamageReport_3_04_UnitStart_2.lua b/src/DamageReport_3_04_UnitStart_2.lua
deleted file mode 100644
index 07d2ccc..0000000
--- a/src/DamageReport_3_04_UnitStart_2.lua
+++ /dev/null
@@ -1,2041 +0,0 @@
---[[
- Damage Report 3.04
- A LUA script for Dual Universe
-
- Created By Dorian Gray
- Ingame: DorianGray
- Discord: Dorian Gray#2623
-
- You can find/update this script on GitHub. Explanations, installation and usage information as well as screenshots can be found there too.
- GitHub: https://github.com/DorianTheGrey/DU-DamageReport
-
- GNU Public License 3.0. Use whatever you want, be so kind to leave credit.
-
- Credits & thanks:
- Thanks to NovaQuark for creating the MMO of the century.
- Thanks to Jericho, Dmentia and Archaegeo for learning a lot from their fine scripts.
- Thanks to TheBlacklist for testing and wonderful suggestions.
- SVG patterns by Hero Patterns.
- DU atlas data from Jayle Break.
-
-]]
-
---[[ 1. USER DEFINED VARIABLES ]]
-
-YourShipsName = "Enter here" --export Enter your ship name here if you want it displayed instead of the ship's ID. YOU NEED TO LEAVE THE QUOTATION MARKS.
-
-SkillRepairToolEfficiency = 0 --export Enter (0-5) your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency"
-SkillRepairToolOptimization = 0 --export Enter your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Optimization"
-
--- SkillAtmosphericFuelEfficiency = 0 --export Enter (0-5) your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency"
--- SkillSpaceFuelEfficiency = 0 --export Enter (0-5) your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency"
--- SkillRocketFuelEfficiency = 0 --export Enter (0-5) your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency"
-
-StatAtmosphericFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED ATMOSPHERIC FUEL TANKS (from the builders talent "Piloting -> Atmospheric Flight Technician -> Atmospheric Fuel-Tank Handling")
-StatSpaceFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL SPACE TANKS (from the builders talent "Piloting -> Atmospheric Engine Technician -> Space Fuel-Tank Handling")
-StatRocketFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL ROCKET TANKS (from the builders talent "Piloting -> Rocket Scientist -> Rocket Booster Fuel Tank Handling")
-StatContainerOptimization = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL TANKS "from the builders talent Mining and Inventory -> Stock Control -> Container Optimization"
-StatFuelTankOptimization = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL TANKS "from the builders talent Mining and Inventory -> Stock Control -> Fuel Tank Optimization"
-
-ShowWelcomeMessage = true --export Do you want the welcome message on the start screen with your name?
-AddSummertimeHour = false --export: Is summertime currently enabled in your location? (Adds one hour.)
-
---[[ 2. GLOBAL VARIABLES ]]
-
-UpdateDataInterval = 1.0 -- How often shall the data be updated? (Increase if running into CPU issues.)
-HighlightBlinkingInterval = 0.5 -- How fast shall highlight arrows of marked elements blink?
-
-ColorPrimary = "FF6700" -- Enter the hexcode of the main color to be used by all views.
-ColorSecondary = "FFFFFF" -- Enter the hexcode of the secondary color to be used by all views.
-ColorTertiary = "000000" -- Enter the hexcode of the tertiary color to be used by all views.
-ColorHealthy = "00FF00" -- Enter the hexcode of the 'healthy' color to be used by all views.
-ColorWarning = "FFFF00" -- Enter the hexcode of the 'warning' color to be used by all views.
-ColorCritical = "FF0000" -- Enter the hexcode of the 'critical' color to be used by all views.
-ColorBackground = "000000" -- Enter the hexcode of the background color to be used by all views.
-ColorBackgroundPattern = "4F4F4F" -- Enter the hexcode of the background color to be used by all views.
-ColorFuelAtmospheric = "004444" -- Enter the hexcode of the atmospheric fuel color.
-ColorFuelSpace = "444400" -- Enter the hexcode of the space fuel color.
-ColorFuelRocket = "440044" -- Enter the hexcode of the rocket fuel color.
-
-VERSION = 3.04
-DebugMode = false
-DebugRenderClickareas = true
-
-DBData = {}
-
-core = nil
-db = nil
-screens = {}
-dscreens = {}
-
-Warnings = {}
-
-screenModes = {
- ["flight"] = { id="flight" },
- ["damage"] = { id="damage" },
- ["damageoutline"] = { id="damageoutline" },
- ["fuel"] = { id="fuel" },
- ["cargo"] = { id="cargo" },
- ["agg"] = { id="agg" },
- ["map"] = { id="map" },
- ["time"] = { id="time", activetoggle="true" },
- ["settings1"] = { id="settings1" },
- ["startup"] = { id="startup" }
-}
-
-backgroundModes = { "deathstar", "capsule", "rain", "signal", "hexagon", "diagonal", "diamond", "plus", "dots" }
-BackgroundMode ="deathstar"
-BackgroundSelected = 1
-BackgroundModeOpacity = 0.25
-
-SaveVars = { "dscreens",
- "ColorPrimary", "ColorSecondary", "ColorTertiary",
- "ColorHealthy", "ColorWarning", "ColorCritical",
- "ColorBackground", "ColorBackgroundPattern",
- "ScrapTier", "HUDMode", "SimulationMode", "DMGOStretch",
- "HUDShiftU", "HUDShiftV", "colorIDIndex", "colorIDTable",
- "BackgroundMode", "BackgroundSelected", "BackgroundModeOpacity" }
-
-HUDMode = false
-HUDShiftU = 0
-HUDShiftV = 0
-hudSelectedIndex = 0
-hudStartIndex = 1
-hudArrowSticker = {}
-highlightOn = false
-highlightID = 0
-highlightX = 0
-highlightY = 0
-highlightZ = 0
-
-SimulationMode = false
-OkayCenterMessage = "All systems nominal."
-CurrentDamagedPage = 1
-CurrentBrokenPage = 1
-DamagePageSize = 12
-ScrapTier = 1
-totalScraps = 0
-ScrapTierRepairTimes = { 10, 50, 250, 1250 }
-
-coreWorldOffset = 0
-totalShipHP = 0
-formerTotalShipHP = -1
-totalShipMaxHP = 0
-totalShipIntegrity = 100
-elementsId = {}
-elementsIdList = {}
-damagedElements = {}
-brokenElements = {}
-rE = {}
-healthyElements = {}
-typeElements = {}
-ElementCounter = 0
-UseMyElementNames = true
-dmgoElements = {}
-DMGOMaxElements = 250
-DMGOStretch = false
-ShipXmin = 99999999
-ShipXmax = -99999999
-ShipYmin = 99999999
-ShipYmax = -99999999
-ShipZmin = 99999999
-ShipZmax = -99999999
-
-totalShipMass = 0
-formerTotalShipMass = -1
-
-formerTime = -1
-
-FuelAtmosphericTanks = {}
-FuelSpaceTanks = {}
-FuelRocketTanks = {}
-FuelAtmosphericTotal = 0
-FuelSpaceTotal = 0
-FuelRocketTotal = 0
-FuelAtmosphericCurrent = 0
-FuelSpaceTotalCurrent = 0
-FuelRocketTotalCurrent = 0
-formerFuelAtmosphericTotal = -1
-formerFuelSpaceTotal = -1
-formerFuelRocketTotal = -1
-
-hexTable = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"}
-colorIDIndex = 1
-colorIDTable = {
- [1] = {
- id="ColorPrimary",
- desc="Main HUD Color",
- basec = "FF6700",
- newc = "FF6700"
- },
- [2] = {
- id="ColorSecondary",
- desc="Secondary HUD Color",
- basec = "FFFFFF",
- newc = "FFFFFF"
- },
- [3] = {
- id="ColorTertiary",
- desc="Tertiary HUD Color",
- basec = "000000",
- newc = "000000"
- },
- [4] = {
- id="ColorHealthy",
- desc="Color code for Healthy/Okay",
- basec = "00FF00",
- newc = "00FF00"
- },
- [5] = {
- id="ColorWarning",
- desc="Color code for Damaged/Warning",
- basec = "FFFF00",
- newc = "FFFF00"
- },
- [6] = {
- id="ColorCritical",
- desc="Color code for Broken/Critical",
- basec = "FF0000",
- newc = "FF0000"
- },
- [7] = {
- id="ColorBackground",
- desc="Background Color",
- basec = "000000",
- newc = "000000"
- },
- [8] = {
- id="ColorBackgroundPattern",
- desc="Background Pattern Color",
- basec = "4F4F4F",
- newc = "4F4F4F"
- },
- [9] = {
- id="ColorFuelAtmospheric",
- desc="Color for Atmo Fuel/Elements",
- basec = "004444",
- newc = "004444"
- },
- [10] = {
- id="ColorFuelSpace",
- desc="Color for Space Fuel/Elements",
- basec = "444400",
- newc = "444400"
- },
- [11] = {
- id="ColorFuelRocket",
- desc="Color for Rocket Fuel/Elements",
- basec = "440044",
- newc = "440044"
- }
-}
-
-
---[[ 3. PROCESSING FUNCTIONS ]]
-
-function InitiateSlots()
- for slot_name, slot in pairs(unit) do
- if type(slot) == "table" and type(slot.export) == "table" and
- slot.getElementClass then
- local elementClass = slot.getElementClass():lower()
- if elementClass:find("coreunit") then
- core = slot
- local coreHP = core.getMaxHitPoints()
- if coreHP > 10000 then
- coreWorldOffset = 128
- elseif coreHP > 1000 then
- coreWorldOffset = 64
- elseif coreHP > 150 then
- coreWorldOffset = 32
- else
- coreWorldOffset = 16
- end
- elseif elementClass == 'databankunit' then
- db = slot
- elseif elementClass == "screenunit" then
- local iScreenMode = "startup"
- screens[#screens + 1] = {
- element = slot,
- id = slot.getId(),
- mode = iScreenMode,
- submode = "",
- ClickAreas = {},
- refresh = true,
- active = false,
- fuelA = true,
- fuelS = true,
- fuelR = true,
- fuelIndex = 1
- }
- end
- end
- end
-end
-
-function LoadFromDatabank()
- if db == nil then
- return
- else
- for _, data in pairs(SaveVars) do
- if db.hasKey(data) then
- local jData = json.decode( db.getStringValue(data) )
- if jData ~= nil then
- if data == "YourShipsName" or data == "AddSummertimeHour" or data == "UpdateDataInterval" or data == "HighlightBlinkingInterval" or
- data == "SkillRepairToolEfficiency" or data == "SkillRepairToolOptimization" or data == "SkillAtmosphericFuelEfficiency" or
- data == "SkillSpaceFuelEfficiency" or data == "SkillRocketFuelEfficiency" or data == "StatAtmosphericFuelTankHandling" or
- data == "StatSpaceFuelTankHandling" or data == "StatRocketFuelTankHandling"
- then
- -- Nada
- else
- _G[data] = jData
- end
- end
- end
- end
-
- for i,v in ipairs(screens) do
- for j,dv in ipairs(dscreens) do
- if screens[i].id == dscreens[j].id then
- screens[i].mode = dscreens[j].mode
- screens[i].submode = dscreens[j].submode
- screens[i].active = dscreens[j].active
- screens[i].refresh = true
- screens[i].fuelA = dscreens[j].fuelA
- screens[i].fuelS = dscreens[j].fuelS
- screens[i].fuelR = dscreens[j].fuelR
- screens[i].fuelIndex = dscreens[j].fuelIndex
- end
- end
- end
- end
-end
-
-function SaveToDatabank()
- if db == nil then
- return
- else
- dscreens = {}
- for i,screen in ipairs(screens) do
- dscreens[i] = {}
- dscreens[i].id = screen.id
- dscreens[i].mode = screen.mode
- dscreens[i].submode = screen.submode
- dscreens[i].active = screen.active
- dscreens[i].fuelA = screen.fuelA
- dscreens[i].fuelS = screen.fuelS
- dscreens[i].fuelR = screen.fuelR
- dscreens[i].fuelIndex = screen.fuelIndex
- end
-
- db.clear()
-
- for _, data in pairs(SaveVars) do
- db.setStringValue(data, json.encode(_G[data]))
- end
-
- end
-end
-
-function InitiateScreens()
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- screens[i] = CreateClickAreasForScreen(screens[i])
- end
- end
-end
-
-function UpdateTypeData()
- FuelAtmosphericTanks = {}
- FuelSpaceTanks = {}
- FuelRocketTanks = {}
-
- FuelAtmosphericTotal = 0
- FuelAtmosphericCurrent = 0
- FuelSpaceTotal = 0
- FuelSpaceCurrent = 0
- FuelRocketCurrent = 0
- FuelRocketTotal = 0
-
- local weightAtmosphericFuel = 4
- local weightSpaceFuel = 6
- local weightRocketFuel = 0.8
-
- --[[
- (FuelMass * (1-.05 * ) * (1-.05 * )
- It just seems to be that the Container Optimization and Fuel Tank Optimization are not added together so the max is not -50% (25% from each skill from the base mass) but 43.75% So the Fuel Tank Optimization uses the container optimization result as it's base value
- ]]
-
- if StatContainerOptimization > 0 then
- weightAtmosphericFuel = weightAtmosphericFuel - 0.05 * StatContainerOptimization * weightAtmosphericFuel
- weightSpaceFuel = weightSpaceFuel - 0.05 * StatContainerOptimization * weightSpaceFuel
- weightRocketFuel = weightRocketFuel - 0.05 * StatContainerOptimization * weightRocketFuel
- end
- if StatFuelTankOptimization > 0 then
- weightAtmosphericFuel = weightAtmosphericFuel - 0.05 * StatFuelTankOptimization * weightAtmosphericFuel
- weightSpaceFuel = weightSpaceFuel - 0.05 * StatFuelTankOptimization * weightSpaceFuel
- weightRocketFuel = weightRocketFuel - 0.05 * StatFuelTankOptimization * weightRocketFuel
- end
-
- for i, id in ipairs(typeElements) do
- local idName = core.getElementNameById(id) or ""
- local idType = core.getElementTypeById(id) or ""
- -- local idTypeClean = idType:gsub("[%s%-]+", ""):lower()
- local idPos = core.getElementPositionById(id) or 0
- local idHP = core.getElementHitPointsById(id) or 0
- local idMaxHP = core.getElementMaxHitPointsById(id) or 0
- local idMass = core.getElementMassById(id) or 0
-
- local baseSize = ""
- local baseVol = 0
- local baseMass = 0
- local cMass = 0
- local cVol = 0
-
- if idType == "atmospheric fuel-tank" then
- if idMaxHP > 10000 then
- baseSize = "L"
- baseMass = 5480
- baseVol = 12800
- elseif idMaxHP > 1300 then
- baseSize = "M"
- baseMass = 988.67
- baseVol = 1600
- elseif idMaxHP > 150 then
- baseSize = "S"
- baseMass = 182.67
- baseVol = 400
- else
- baseSize = "XS"
- baseMass = 35.03
- baseVol = 100
- end
- if StatAtmosphericFuelTankHandling > 0 then
- baseVol = 0.2 * StatAtmosphericFuelTankHandling * baseVol + baseVol
- end
- cMass = idMass - baseMass
- if cMass <=10 then cMass = 0 end
- cVol = string.format("%.0f", cMass / weightAtmosphericFuel)
- cPercent = string.format("%.1f", math.floor(100/baseVol * tonumber(cVol)))
- table.insert(FuelAtmosphericTanks, {
- type = 1,
- id = id,
- name = idName,
- maxhp = idMaxHP,
- hp = GetHPforElement(id),
- pos = idPos,
- size = baseSize,
- mass = baseMass,
- vol = baseVol,
- cvol = cVol,
- percent = cPercent
- })
- if idHP > 0 then
- FuelAtmosphericCurrent = FuelAtmosphericCurrent + cVol
- end
- FuelAtmosphericTotal = FuelAtmosphericTotal + baseVol
- elseif idType == "space fuel-tank" then
- if idMaxHP > 10000 then
- baseSize = "L"
- baseMass = 5480
- baseVol = 12800
- elseif idMaxHP > 1300 then
- baseSize = "M"
- baseMass = 988.67
- baseVol = 1600
- else
- baseSize = "S"
- baseMass = 182.67
- baseVol = 400
- end
- if StatSpaceFuelTankHandling > 0 then
- baseVol = 0.2 * StatSpaceFuelTankHandling * baseVol + baseVol
- end
- cMass = idMass - baseMass
- if cMass <=10 then cMass = 0 end
- cVol = string.format("%.0f", cMass / weightSpaceFuel)
- cPercent = string.format("%.1f", (100/baseVol * tonumber(cVol)))
- table.insert(FuelSpaceTanks, {
- type = 2,
- id = id,
- name = idName,
- maxhp = idMaxHP,
- hp = GetHPforElement(id),
- pos = idPos,
- size = baseSize,
- mass = baseMass,
- vol = baseVol,
- cvol = cVol,
- percent = cPercent
- })
- if idHP > 0 then
- FuelSpaceCurrent = FuelSpaceCurrent + cVol
- end
- FuelSpaceTotal = FuelSpaceTotal + baseVol
- elseif idType == "rocket fuel-tank" then
- if idMaxHP > 65000 then
- baseSize = "L"
- baseMass = 25740
- baseVol = 50000
- elseif idMaxHP > 6000 then
- baseSize = "M"
- baseMass = 4720
- baseVol = 6400
- elseif idMaxHP > 700 then
- baseSize = "S"
- baseMass = 886.72
- baseVol = 800
- else
- baseSize = "XS"
- baseMass = 173.42
- baseVol = 400
- end
- if StatRocketFuelTankHandling > 0 then
- baseVol = 0.2 * StatRocketFuelTankHandling * baseVol + baseVol
- end
- cMass = idMass - baseMass
- if cMass <=10 then cMass = 0 end
- cVol = string.format("%.0f", cMass / weightRocketFuel)
- cPercent = string.format("%.1f", (100/baseVol * tonumber(cVol)))
- table.insert(FuelRocketTanks, {
- type = 3,
- id = id,
- name = idName,
- maxhp = idMaxHP,
- hp = GetHPforElement(id),
- pos = idPos,
- size = baseSize,
- mass = baseMass,
- vol = baseVol,
- cvol = cVol,
- percent = cPercent
- })
- if idHP > 0 then
- FuelRocketCurrent = FuelRocketCurrent + cVol
- end
- FuelRocketTotal = FuelRocketTotal + baseVol
- end
-
- end
-
- if FuelAtmosphericCurrent ~= formerFuelAtmosphericCurrent then
- SetRefresh("fuel")
- formerFuelAtmosphericCurrent = FuelAtmosphericCurrent
- end
- if FuelSpaceCurrent ~= formerFuelSpaceCurrent then
- SetRefresh("fuel")
- formerFuelSpaceCurrent = FuelSpaceCurrent
- end
- if FuelRocketCurrent ~= formerFuelRocketCurrent then
- SetRefresh("fuel")
- formerFuelRocketCurrent = FuelRocketCurrent
- end
-
-end
-
-function UpdateDamageData(initial)
-
- initial = initial or false
-
- if SimulationActive == true then return end
-
- local formerTotalShipHP = totalShipHP
- totalShipHP = 0
- totalShipMaxHP = 0
- totalShipIntegrity = 100
- damagedElements = {}
- brokenElements = {}
- healthyElements = {}
- ElementCounter = 0
-
- elementsIdList = core.getElementIdList()
-
- for i, id in pairs(elementsIdList) do
-
- ElementCounter = ElementCounter + 1
-
- local idName = core.getElementNameById(id)
-
- local idType = core.getElementTypeById(id)
- -- local idTypeClean = idType:gsub("[%s%-]+", ""):lower()
- local idPos = core.getElementPositionById(id)
- local idHP = core.getElementHitPointsById(id)
- local idMaxHP = core.getElementMaxHitPointsById(id)
- -- local idMass = core.getElementMassById(id)
-
- if SimulationMode == true then
- SimulationActive = true
- local dice = math.random(0, 10)
- if dice < 2 and #brokenElements < 30 then
- idHP = 0
- elseif dice >= 2 and dice < 4 and #damagedElements < 30 then
- idHP = math.random(1, math.ceil(idMaxHP))
- else
- idHP = idMaxHP
- end
- end
-
- totalShipHP = totalShipHP + idHP
- totalShipMaxHP = totalShipMaxHP + idMaxHP
-
- if idMaxHP - idHP > constants.epsilon then
-
- if idHP > 0 then
- table.insert(damagedElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP - idHP,
- percent = math.ceil(100 / idMaxHP * idHP),
- pos = idPos
- })
- else
- table.insert(brokenElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP - idHP,
- percent = 0,
- pos = idPos
- })
- end
- else
- table.insert(healthyElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- pos = idPos
- })
- if id == highlightID then
- highlightID = 0
- highlightOn = false
- HideHighlight()
- hudSelectedIndex = 0
- end
- end
-
- if initial == true then
- if
- idType == "atmospheric fuel-tank" or
- idType == "space fuel-tank" or
- idType == "rocket fuel-tank"
- then
- table.insert(typeElements, id)
- end
- end
- end
-
- SortDamageTables()
-
- rE = {}
- if #brokenElements > 0 then
- for _,v in ipairs(brokenElements) do
- table.insert(rE, {id=v.id, missinghp=v.missinghp, hp=v.hp, name=v.name, type=v.type, pos=v.pos})
- end
- end
- if #damagedElements > 0 then
- for _,v in ipairs(damagedElements) do
- table.insert(rE, {id=v.id, missinghp=v.missinghp, hp=v.hp, name=v.name, type=v.type, pos=v.pos})
- end
- end
- if #rE > 0 then
- table.sort(rE, function(a,b) return a.missinghp>b.missinghp end)
- end
-
- totalShipIntegrity = string.format("%2.0f", 100 / totalShipMaxHP * totalShipHP)
-
- if formerTotalShipHP ~= totalShipHP then
- forceDamageRedraw = true
- formerTotalShipHP = totalShipHP
- else
- forceDamageRedraw = false
- end
-end
-
-function GetHPforElement(id)
- for i,v in ipairs(brokenElements) do
- if v.id == id then
- return 0
- end
- end
- for i,v in ipairs(damagedElements) do
- if v.id == id then
- return v.hp
- end
- end
- for i,v in ipairs(healthyElements) do
- if v.id == id then
- return v.maxhp
- end
- end
-end
-
-function UpdateClickArea(candidate, newEntry, mode)
- for i, screen in ipairs(screens) do
- for k, v in pairs(screens[i].ClickAreas) do
- if v.id == candidate and v.mode == mode then
- screens[i].ClickAreas[k] = newEntry
- end
- end
- end
-end
-
-function AddClickArea(mode, newEntry)
- for i, screen in ipairs(screens) do
- if screens[i].mode == mode then
- table.insert(screens[i].ClickAreas, newEntry)
- end
- end
-end
-
-function AddClickAreaForScreenID(screenid, newEntry)
- for i, screen in ipairs(screens) do
- if screens[i].id == screenid then
- table.insert(screens[i].ClickAreas, newEntry)
- end
- end
-end
-
-function DisableClickArea(candidate, mode)
- UpdateClickArea(candidate, {
- id = candidate,
- mode = mode,
- x1 = -1,
- x2 = -1,
- y1 = -1,
- y2 = -1
- })
-end
-
-function SetRefresh(mode, submode)
- mode = mode or "all"
- submode = submode or "all"
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- if screens[i].mode == mode or mode == "all" then
- if screens[i].submode == submode or submode =="all" then
- screens[i].refresh = true
- end
- end
- end
- end
-end
-
-function WipeClickAreasForScreen(screen)
- screen.ClickAreas = {}
- return screen
-end
-
-function CreateBaseClickAreas(screen)
- table.insert(screen.ClickAreas, {mode = "all", id = "ToggleHudMode", x1 = 1537, x2 = 1728, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "damage", x1 = 193, x2 = 384, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "damageoutline", x1 = 385, x2 = 576, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "fuel", x1 = 577, x2 = 768, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "flight", x1 = 769, x2 = 960, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "cargo", x1 = 961, x2 = 1152, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "agg", x1 = 1153, x2 = 1344, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "map", x1 = 1345, x2 = 1536, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "time", x1 = 0, x2 = 192, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "settings1", x1 = 1729, x2 = 1920, y1 = 1015, y2 = 1075} )
- return screen
-end
-
-function CreateClickAreasForScreen(screen)
-
- if screen == nil then return {} end
-
- if screen.mode == "flight" then
- elseif screen.mode == "damage" then
- table.insert( screen.ClickAreas, {mode = "damage", id = "ToggleElementLabel", x1 = 70, x2 = 425, y1 = 325, y2 = 355} )
- table.insert( screen.ClickAreas, {mode = "damage", id = "ToggleElementLabel2", x1 = 980, x2 = 1400, y1 = 325, y2 = 355} )
- elseif screen.mode == "damageoutline" then
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeView", param = "top", x1 = 60, x2 = 439, y1 = 150, y2 = 200} )
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeView", param = "side", x1 = 440, x2 = 824, y1 = 150, y2 = 200} )
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeView", param = "front", x1 = 825, x2 = 1215, y1 = 150, y2 = 200} )
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeStretch", x1 = 1530, x2 = 1580, y1 = 150, y2 = 200} )
- elseif screen.mode == "fuel" then
- elseif screen.mode == "cargo" then
- elseif screen.mode == "agg" then
- elseif screen.mode == "map" then
- elseif screen.mode == "time" then
- elseif screen.mode == "settings1" then
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ToggleBackground", x1 = 75, x2 = 860, y1 = 170, y2 = 215} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "PreviousBackground", x1 = 75, x2 = 460, y1 = 235, y2 = 285} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "NextBackground", x1 = 480, x2 = 860, y1 = 235, y2 = 285} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "DecreaseOpacity", x1 = 75, x2 = 460, y1 = 300, y2 = 350} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "IncreaseOpacity", x1 = 480, x2 = 860, y1 = 300, y2 = 350} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ResetColors", x1 = 75, x2 = 860, y1 = 370, y2 = 415} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "PreviousColorID", x1 = 90, x2 = 140, y1 = 500, y2 = 550} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "NextColorID", x1 = 795, x2 = 845, y1 = 500, y2 = 550} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="1", x1 = 210, x2 = 290, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="2", x1 = 300, x2 = 380, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="3", x1 = 385, x2 = 465, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="4", x1 = 470, x2 = 550, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="5", x1 = 560, x2 = 640, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="6", x1 = 645, x2 = 725, y1 = 655, y2 = 700} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="1", x1 = 210, x2 = 290, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="2", x1 = 300, x2 = 380, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="3", x1 = 385, x2 = 465, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="4", x1 = 470, x2 = 550, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="5", x1 = 560, x2 = 640, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="6", x1 = 645, x2 = 725, y1 = 740, y2 = 780} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ResetPosColor", x1 = 160, x2 = 340, y1 = 885, y2 = 935} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ApplyPosColor", x1 = 355, x2 = 780, y1 = 885, y2 = 935} )
-
- elseif screen.mode == "startup" then
- end
-
- screen = CreateBaseClickAreas(screen)
-
- return screen
-end
-
-function CheckClick(x, y, HitTarget)
- x = x*1920
- y = y*1120
- HitTarget = HitTarget or ""
- HitPayload = {}
- -- PrintConsole("Clicked: "..x.." / "..y)
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- if screens[i].active == true and screens[i].element.getMouseX() ~= -1 and screens[i].element.getMouseY() ~= -1 then
- if HitTarget == "" then
- for k, v in pairs(screens[i].ClickAreas) do
- if v ~=nil and x >= v.x1 and x <= v.x2 and y >= v.y1 and y <= v.y2 then
- HitTarget = v.id
- HitPayload = v
- break
- end
- end
- end
- if HitTarget == "ButtonPress" then
- if screens[i].mode == HitPayload.param then
- screens[i].mode = "startup"
- else
- screens[i].mode = HitPayload.param
- end
-
- if screens[i].mode == "damageoutline" then
- if screens[i].submode == "" then
- screens[i].submode = "top"
- end
- end
- screens[i].refresh = true
- screens[i].ClickAreas = {}
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "ToggleBackground" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundMode == "" then
- BackgroundSelected = 1
- BackgroundMode = backgroundModes[BackgroundSelected]
- else
- BackgroundSelected = 1
- BackgroundMode = ""
- end
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "PreviousBackground" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundMode == "" then
- BackgroundSelected = 1
- BackgroundMode = backgroundModes[BackgroundSelected]
- else
- if BackgroundSelected <= 1 then
- BackgroundSelected = #backgroundModes
- else
- BackgroundSelected = BackgroundSelected - 1
- end
- BackgroundMode = backgroundModes[BackgroundSelected]
- end
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "NextBackground" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundMode == "" then
- BackgroundSelected = 1
- BackgroundMode = backgroundModes[BackgroundSelected]
- else
- if BackgroundSelected >= #backgroundModes then
- BackgroundSelected = 1
- else
- BackgroundSelected = BackgroundSelected + 1
- end
- BackgroundMode = backgroundModes[BackgroundSelected]
- end
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "DecreaseOpacity" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundModeOpacity>0.1 then
- BackgroundModeOpacity = BackgroundModeOpacity - 0.05
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- end
- elseif HitTarget == "IncreaseOpacity" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundModeOpacity<1.0 then
- BackgroundModeOpacity = BackgroundModeOpacity + 0.05
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- end
- elseif HitTarget == "ResetColors" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- db.clear()
- ColorPrimary = "FF6700"
- ColorSecondary = "FFFFFF"
- ColorTertiary = "000000"
- ColorHealthy = "00FF00"
- ColorWarning = "FFFF00"
- ColorCritical = "FF0000"
- ColorBackground = "000000"
- ColorBackgroundPattern = "4f4f4f"
- BackgroundMode = "deathstar"
- BackgroundSelected = 1
- BackgroundModeOpacity = 0.25
- colorIDTable = {
- [1] = {
- id="ColorPrimary",
- desc="Main HUD Color",
- basec = "FF6700",
- newc = "FF6700"
- },
- [2] = {
- id="ColorSecondary",
- desc="Secondary HUD Color",
- basec = "FFFFFF",
- newc = "FFFFFF"
- },
- [3] = {
- id="ColorTertiary",
- desc="Tertiary HUD Color",
- basec = "000000",
- newc = "000000"
- },
- [4] = {
- id="ColorHealthy",
- desc="Color code for Healthy/Okay",
- basec = "00FF00",
- newc = "00FF00"
- },
- [5] = {
- id="ColorWarning",
- desc="Color code for Damaged/Warning",
- basec = "FFFF00",
- newc = "FFFF00"
- },
- [6] = {
- id="ColorCritical",
- desc="Color code for Broken/Critical",
- basec = "FF0000",
- newc = "FF0000"
- },
- [7] = {
- id="ColorBackground",
- desc="Background Color",
- basec = "000000",
- newc = "000000"
- },
- [8] = {
- id="ColorBackgroundPattern",
- desc="Background Pattern Color",
- basec = "4F4F4F",
- newc = "4F4F4F"
- },
- [9] = {
- id="ColorFuelAtmospheric",
- desc="Color for Atmo Fuel/Elements",
- basec = "004444",
- newc = "004444"
- },
- [10] = {
- id="ColorFuelSpace",
- desc="Color for Space Fuel/Elements",
- basec = "444400",
- newc = "444400"
- },
- [11] = {
- id="ColorFuelRocket",
- desc="Color for Rocket Fuel/Elements",
- basec = "440044",
- newc = "440044"
- }
- }
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "PreviousColorID" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- colorIDIndex = colorIDIndex - 1
- if colorIDIndex < 1 then colorIDIndex = #colorIDTable end
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "NextColorID" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- colorIDIndex = colorIDIndex + 1
- if colorIDIndex > #colorIDTable then colorIDIndex = 1 end
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "ColorPosUp" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- local s = tonumber(string.sub(colorIDTable[colorIDIndex].newc, HitPayload.param, HitPayload.param),16)
- s = s + 1
- if s > 15 then s = 0 end
- colorIDTable[colorIDIndex].newc = replace_char(HitPayload.param, colorIDTable[colorIDIndex].newc, hexTable[s+1])
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "ColorPosDown" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- local s = tonumber(string.sub(colorIDTable[colorIDIndex].newc, HitPayload.param, HitPayload.param),16)
- s = s - 1
- if s < 0 then s = 15 end
- colorIDTable[colorIDIndex].newc = replace_char(HitPayload.param, colorIDTable[colorIDIndex].newc, hexTable[s+1])
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "ResetPosColor" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- colorIDTable[colorIDIndex].newc = colorIDTable[colorIDIndex].basec
- _G[colorIDTable[colorIDIndex].id] = colorIDTable[colorIDIndex].basec
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "ApplyPosColor" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- _G[colorIDTable[colorIDIndex].id] = colorIDTable[colorIDIndex].newc
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "DamagedPageDown" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentDamagedPage = CurrentDamagedPage + 1
- if CurrentDamagedPage > math.ceil(#damagedElements / DamagePageSize) then
- CurrentDamagedPage = math.ceil(#damagedElements / DamagePageSize)
- end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "DamagedPageUp" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentDamagedPage = CurrentDamagedPage - 1
- if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "BrokenPageDown" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentBrokenPage = CurrentBrokenPage + 1
- if CurrentBrokenPage > math.ceil(#brokenElements / DamagePageSize) then
- CurrentBrokenPage = math.ceil(#brokenElements / DamagePageSize)
- end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "BrokenPageUp" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentBrokenPage = CurrentBrokenPage - 1
- if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "DMGOChangeView" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- screens[i].submode = HitPayload.param
- UpdateViewDamageoutline(screens[i])
- SaveToDatabank()
- SetRefresh("damageoutline", screens[i].submode)
- RenderScreens("damageoutline", screens[i].submode)
- elseif HitTarget == "DMGOChangeStretch" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if DMGOStretch == true then
- DMGOStretch = false
- else
- DMGOStretch = true
- end
- UpdateViewDamageoutline(screens[i])
- SaveToDatabank()
- SetRefresh("damageoutline")
- RenderScreens("damageoutline")
- elseif HitTarget == "ToggleDisplayAtmosphere" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if screens[i].fuelA == true then
- screens[i].fuelA = false
- else
- screens[i].fuelA = true
- end
- screens[i].fuelIndex = 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "ToggleDisplaySpace" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if screens[i].fuelS == true then
- screens[i].fuelS = false
- else
- screens[i].fuelS = true
- end
- screens[i].fuelIndex = 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "ToggleDisplayRocket" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if screens[i].fuelR == true then
- screens[i].fuelR = false
- else
- screens[i].fuelR = true
- end
- screens[i].fuelIndex = 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "DecreaseFuelIndex" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- screens[i].fuelIndex = screens[i].fuelIndex - 1
- if screens[i].fuelIndex < 1 then screens[i].fuelIndex = 1 end
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "IncreaseFuelIndex" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- screens[i].fuelIndex = screens[i].fuelIndex + 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "ToggleHudMode" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if HUDMode == true then
- HUDMode = false
- forceDamageRedraw = true
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- else
- HUDMode = true
- forceDamageRedraw = true
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- end
- elseif HitTarget == "ToggleSimulation" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentDamagedPage = 1
- CurrentBrokenPage = 1
- if SimulationMode == true then
- SimulationMode = false
- SimulationActive = false
- UpdateDamageData()
- UpdateTypeData()
- forceDamageRedraw = true
- HudDeselectElement()
- SetRefresh("damage")
- SetRefresh("damageoutline")
- SetRefresh("settings1")
- SetRefresh("fuel")
- SaveToDatabank()
- RenderScreens()
- else
- SimulationMode = true
- SimulationActive = false
- UpdateDamageData()
- UpdateTypeData()
- forceDamageRedraw = true
- HudDeselectElement()
- SetRefresh("damage")
- SetRefresh("damageoutline")
- SetRefresh("settings1")
- SetRefresh("fuel")
- SaveToDatabank()
- RenderScreens()
- end
- elseif (HitTarget == "ToggleElementLabel" or HitTarget == "ToggleElementLabel2") and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if UseMyElementNames == true then
- UseMyElementNames = false
- SetRefresh("damage")
- RenderScreens("damage")
- else
- UseMyElementNames = true
- SetRefresh("damage")
- RenderScreens("damage")
- end
- elseif (HitTarget == "SwitchScrapTier" or HitTarget == "SwitchScrapTier2") and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- ScrapTier = ScrapTier + 1
- if ScrapTier > 4 then ScrapTier = 1 end
- SetRefresh("damage")
- RenderScreens("damage")
- end
-
-
- end
- end
- end
-end
-
---[[ 4. RENDERING FUNCTIONS ]]
-
-function GetContentFlight()
- local output = ""
- output = output .. GetHeader("Flight Data Report") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentDamage()
- local output = ""
- if SimulationMode == true then
- output = output .. GetHeader("Damage Report (Simulated damage)") .. [[]]
- else
- output = output .. GetHeader("Damage Report") .. [[]]
- end
- output = output .. GetContentDamageScreen()
- return output
-end
-
-function GetContentDamageoutline(screen)
- UpdateDataDamageoutline()
- UpdateViewDamageoutline(screen)
- local output = ""
- output = output .. GetHeader("Damage Ship Outline Report") ..
- GetDamageoutlineShip() ..
- [[]]
-
- if screen.submode=="top" then
- output = output ..
- [[
-
- Top View
-
- Side View
-
- Front View
- ]]
- elseif screen.submode=="side" then
- output = output ..
- [[
-
- Top View
-
- Side View
-
- Front View
- ]]
- elseif screen.submode=="front" then
- output = output ..
- [[
-
- Top View
-
- Side View
-
- Front View
- ]]
- else
- end
- output = output .. [[]]..#dmgoElements..[[ of ]]..ElementCounter..[[ shown]]
- output = output .. [[]]
- if DMGOStretch == true then
- output = output .. [[]]
- end
- output = output .. [[Stretch both axis]]
- return output
-end
-
-function GetContentFuel(screen)
-
- if #FuelAtmosphericTanks < 1 and #FuelSpaceTanks < 1 and #FuelRocketTanks < 1 then return "" end
-
- local FuelTypes = 0
- local output = ""
- local addHeadline = {}
-
- FuelDisplay = { screen.fuelA, screen.fuelS, screen.fuelR }
-
- if FuelDisplay[1] == true and #FuelAtmosphericTanks > 0 then
- table.insert(addHeadline, "Atmospheric")
- FuelTypes = FuelTypes + 1
- end
- if FuelDisplay[2] == true and #FuelSpaceTanks > 0 then
- table.insert(addHeadline, "Space")
- FuelTypes = FuelTypes + 1
- end
- if FuelDisplay[3] == true and #FuelRocketTanks > 0 then
- table.insert(addHeadline, "Rocket")
- FuelTypes = FuelTypes + 1
- end
-
- output = output .. GetHeader("Fuel Report ("..table.concat(addHeadline, ", ")..")") ..
- [[
- ]]
-
- local totalH = 150
- local counter = 0
- local tOffset = 0
-
- if FuelDisplay[1] == true and #FuelAtmosphericTanks > 0 then
-
- if FuelTypes == 1 then tOffset = 50
- elseif FuelTypes == 2 then tOffset = 6
- elseif FuelTypes == 3 then tOffset = 0
- end
-
- output = output .. [[
-
-
-
- ]]
-
- output = output ..
- [[]]..
- GenerateCommaValue(FuelAtmosphericCurrent, true)..
- [[ of ]]..GenerateCommaValue(FuelAtmosphericTotal, true)..
- [[ | Total Atmospheric Fuel in ]]..#FuelAtmosphericTanks..[[ tank]]..(#FuelAtmosphericTanks==1 and "" or "s")..[[ (]]..math.floor(100/FuelAtmosphericTotal*FuelAtmosphericCurrent)..[[%)]]
- counter = counter + 1
- end
-
- if FuelDisplay[2] == true and #FuelSpaceTanks > 0 then
-
- if FuelTypes == 1 then tOffset = 50
- elseif FuelTypes == 2 then tOffset = 6
- elseif FuelTypes == 3 then tOffset = 0
- end
-
- output = output .. [[
-
-
-
- ]]
-
- output = output ..
- [[]]..
- GenerateCommaValue(FuelSpaceCurrent, true)..
- [[ of ]]..GenerateCommaValue(FuelSpaceTotal, true)..
- [[ | Total Space Fuel in ]]..#FuelSpaceTanks..[[ tank]]..(#FuelSpaceTanks==1 and "" or "s")..[[ (]]..math.floor(100/FuelSpaceTotal*FuelSpaceCurrent)..[[%)]]
- counter = counter + 1
- end
-
- if FuelDisplay[3] == true and #FuelRocketTanks > 0 then
-
- if FuelTypes == 1 then tOffset = 50
- elseif FuelTypes == 2 then tOffset = 6
- elseif FuelTypes == 3 then tOffset = 0
- end
-
- output = output .. [[
-
-
-
- ]]
-
- output = output ..
- [[]]..
- GenerateCommaValue(FuelRocketCurrent, true)..
- [[ of ]]..GenerateCommaValue(FuelRocketTotal, true)..
- [[ | Total Rocket Fuel in ]]..#FuelRocketTanks..[[ tank]]..(#FuelRocketTanks==1 and "" or "s")..[[ (]]..math.floor(100/FuelRocketTotal*FuelRocketCurrent)..[[%)]]
- end
-
- output = output .. [[
-
-
-
- ]]
-
- local DisplayTable = {}
- if screen.fuelIndex == nil or screen.fuelIndex < 1 then
- screen.fuelIndex = 1
- end
-
- if FuelDisplay[1] == true then
- for _,v in ipairs(FuelAtmosphericTanks) do
- table.insert(DisplayTable, v)
- end
- end
- if FuelDisplay[2] == true then
- for _,v in ipairs(FuelSpaceTanks) do
- table.insert(DisplayTable, v)
- end
- end
- if FuelDisplay[3] == true then
- for _,v in ipairs(FuelRocketTanks) do
- table.insert(DisplayTable, v)
- end
- end
-
- table.sort(DisplayTable, function(a,b) return a.type
-
-
- ]]
- if tank.hp == 0 then
- output = output .. [[]]
- elseif tank.maxhp - tank.hp > constants.epsilon then
- output = output .. [[]]
- else
- output = output .. [[]]
- end
- if tank.hp == 0 then output = output .. [[]]..tank.size..[[]]
- else output = output .. [[]]..tank.size..[[]]
- end
-
- if tank.hp == 0 then
- output = output .. [[Broken]] ..
- [[0 of ]]..GenerateCommaValue(tank.vol)..[[]]
- elseif tonumber(tank.percent) < 10 then
- output = output .. [[]]..tank.percent..[[%]] ..
- [[]]..GenerateCommaValue(tank.cvol)..[[ of ]]..GenerateCommaValue(tank.vol)..[[]]
- elseif tonumber(tank.percent) < 30 then
- output = output .. [[]]..tank.percent..[[%]] ..
- [[]]..GenerateCommaValue(tank.cvol)..[[ of ]]..GenerateCommaValue(tank.vol)..[[]]
- else output =
- output .. [[]]..tank.percent..[[%]] ..
- [[]]..GenerateCommaValue(tank.cvol)..[[ of ]]..GenerateCommaValue(tank.vol)..[[]]
- end
-
- output = output ..[[]]..tank.name..[[]]
-
- output = output .. [[]]
-
- end
- end
-
-
-
- if #FuelAtmosphericTanks > 0 then
- output = output .. [[]]
- if FuelDisplay[1] == true then
- output = output .. [[]]
- end
- output = output .. [[ATM]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "ToggleDisplayAtmosphere", x1 = 50, x2 = 100, y1 = 270, y2 = 320} )
- end
-
- if #FuelSpaceTanks > 0 then
- output = output .. [[]]
- if FuelDisplay[2] == true then
- output = output .. [[]]
- end
- output = output .. [[SPC]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "ToggleDisplaySpace", x1 = 200, x2 = 250, y1 = 270, y2 = 320} )
- end
-
- if #FuelRocketTanks > 0 then
- output = output .. [[]]
- if FuelDisplay[3] == true then
- output = output .. [[]]
- end
- output = output .. [[RKT]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "ToggleDisplayRocket", x1 = 350, x2 = 400, y1 = 270, y2 = 320} )
- end
-
- if screen.fuelIndex > 1 then
- output = output .. [[
-
-
- ]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "DecreaseFuelIndex", x1 = 1470, x2 = 1670, y1 = 270, y2 = 320} )
- end
-
- if screen.fuelIndex+cCounter-1 < #DisplayTable then
- output = output .. [[
-
-
- ]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "IncreaseFuelIndex", x1 = 1680, x2 = 1880, y1 = 270, y2 = 320} )
- end
-
- if cCounter > 0 then
- output = output .. [[]]..
- #DisplayTable..
- [[ Tank]]..(#DisplayTable == 1 and "" or "s")..
- [[ (Showing ]]..screen.fuelIndex..[[ to ]]..(screen.fuelIndex+cCounter-1)..[[)]]
- end
-
- return output
-end
-
-function GetContentCargo()
- local output = ""
- output = output .. GetHeader("Cargo Report") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentAGG()
- local output = ""
- output = output .. GetHeader("Anti-Grav Control") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentMap()
- local output = ""
- output = output .. GetHeader("Map Overview") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentTime()
- local output = ""
- output = output .. GetHeader("Time") .. epochTime()
- output = output ..
- [[
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetContentSettings1()
- local output = ""
- output = output .. GetHeader("Settings") .. [[]]
- if BackgroundMode=="" then
- output = output ..[[Activate background]]
- else
- output = output ..[[Deactivate background (']]..BackgroundMode..[[', ]]..string.format("%.0f",BackgroundModeOpacity*100)..[[%)]]
- end
- output = output ..[[
-
- Previous background
-
- Next background
-
-
- Decrease Opacity
-
- Increase Opacity
- ]]
-
- output = output ..
- [[]] ..
- [[Reset background and all colors]]
-
- output = output ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Select and change any of the ]]..#colorIDTable..[[ HUD colors]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]]..colorIDTable[colorIDIndex].desc..[[]] ..
- [[]] ..
- [[Current color]] ..
- [[]] ..
-
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
-
- [[#]] ..
-
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,1,1)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,2,2)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,3,3)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,4,4)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,5,5)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,6,6)..[[]] ..
-
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
-
- [[]] ..
- [[]] ..
- [[New color]] ..
- [[]] ..
- [[Apply new color]] ..
- [[]] ..
- [[Reset]] ..
- [[]]
-
- output = output ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Explanation / Hints]] ..
- [[Coming soon.]]
-
-
- output = output .. [[]]
-
- if SimulationMode == true then
- output = output .. [[Simulating Damage to elements]]
- AddClickArea("settings1", { id = "ToggleSimulation", mode ="settings1", x1 = 940, x2 = 1850, y1 = 919, y2 = 969 })
- else
- output = output .. [[Simulate Damage to elements]]
- AddClickArea("settings1", { id = "ToggleSimulation", mode ="settings1", x1 = 940, x2 = 1850, y1 = 919, y2 = 969 })
- end
-
- return output
-end
-
-function GetContentStartup()
- local output = ""
- output = output .. GetElementLogo(812, 380, "f", "f", "f")
- if YourShipsName == "Enter here" then
- output = output .. [[Spaceship ID ]]..ShipID..[[]]
- else
- output = output .. [[]]..YourShipsName..[[]]
- end
- if ShowWelcomeMessage == true then output = output .. [[Greetings, Commander ]]..PlayerName..[[.]] end
- if #Warnings > 0 then
- output = output .. [[Warning: ]]..(table.concat(Warnings, " "))..[[]]
- end
- output = output .. [[Damage Report v]]..VERSION..[[, by Scion Interstellar, DorianGray - Discord: Dorian Gray#2623. Under GNU Public License 3.0.]]
- return output
-end
-
-function RenderScreen(screen, contentToRender)
- if contentToRender == nil then
- PrintConsole("ERROR: contentToRender is nil.")
- unit.exit()
- end
-
- CreateClickAreasForScreen(screen)
-
- local output =""
- output = output .. [[
-
-
- ]]
-
- output = output .. contentToRender
-
- if screen.mode == "startup" then
- output = output .. [[]]
- else
- output = output .. [[]]
- end
-
- output = output .. [[
-
- ]]
- output = output .. [[]]
-
- -- Center:
-
- --
- --
- --
- --
-
- local outputLength = string.len(output)
- -- PrintConsole("Render: "..screen.mode.." ("..outputLength.." chars)")
- screen.element.setSVG(output)
-end
-
-function RenderScreens(onlymode, onlysubmode)
-
- onlymode = onlymode or "all"
- onlysubmode = onlysubmode or "all"
-
- if screens ~= nil and #screens > 0 then
-
- local contentFlight = ""
- local contentDamage = ""
- local contentDamageoutlineTop = ""
- local contentDamageoutlineSide = ""
- local contentDamageoutlineFront = ""
- local contentFuel = ""
- local contentCargo = ""
- local contentAGG = ""
- local contentMap = ""
- local contentTime = ""
- local contentSettings1 = ""
- local contentStartup = ""
-
- for k,screen in pairs(screens) do
- if screen.refresh == true then
- local contentToRender = ""
-
- if screen.mode == "flight" and (onlymode =="flight" or onlymode =="all") then
- if contentFlight == "" then contentFlight = GetContentFlight() end
- contentToRender = contentFlight
- elseif screen.mode == "damage" and (onlymode =="damage" or onlymode =="all") then
- if contentDamage == "" then contentDamage = GetContentDamage() end
- contentToRender = contentDamage
- elseif screen.mode == "damageoutline" and (onlymode =="damageoutline" or onlymode =="all") then
- if screen.submode == "" then
- screen.submode = "top"
- screens[k].submode = "top"
- end
- if screen.submode == "top" and (onlysubmode == "top" or onlysubmode == "all") then
- if contentDamageoutlineTop == "" then contentDamageoutlineTop = GetContentDamageoutline(screen) end
- contentToRender = contentDamageoutlineTop
- end
- if screen.submode == "side" and (onlysubmode == "side" or onlysubmode == "all") then
- if contentDamageoutlineSide == "" then contentDamageoutlineSide = GetContentDamageoutline(screen) end
- contentToRender = contentDamageoutlineSide
- end
- if screen.submode == "front" and (onlysubmode == "front" or onlysubmode == "all") then
- if contentDamageoutlineFront == "" then contentDamageoutlineFront = GetContentDamageoutline(screen) end
- contentToRender = contentDamageoutlineFront
- end
- elseif screen.mode == "fuel" and (onlymode =="fuel" or onlymode =="all") then
- screen = WipeClickAreasForScreen(screens[k])
- contentToRender = GetContentFuel(screen)
- elseif screen.mode == "cargo" and (onlymode =="cargo" or onlymode =="all") then
- if contentCargo == "" then contentCargo = GetContentCargo() end
- contentToRender = contentCargo
- elseif screen.mode == "agg" and (onlymode =="agg" or onlymode =="all") then
- if contentAGG == "" then contentAGG = GetContentAGG() end
- contentToRender = contentAGG
- elseif screen.mode == "map" and (onlymode =="map" or onlymode =="all") then
- if contentMap == "" then contentMap = GetContentMap() end
- contentToRender = contentMap
- elseif screen.mode == "time" and (onlymode =="time" or onlymode =="all") then
- if contentTime == "" then contentTime = GetContentTime() end
- contentToRender = contentTime
- elseif screen.mode == "settings1" and (onlymode =="settings1" or onlymode =="all") then
- if contentSettings1 == "" then contentSettings1 = GetContentSettings1() end
- contentToRender = contentSettings1
- elseif screen.mode == "startup" and (onlymode =="startup" or onlymode =="all") then
- if contentStartup == "" then contentStartup = GetContentStartup() end
- contentToRender = contentStartup
- else
- contentToRender = "Invalid screen mode. ('"..screen.mode.."')"
- end
-
- if contentToRender ~= "" then
- RenderScreen(screen, contentToRender)
- else
- DrawCenteredText("ERROR: No contentToRender delivered for "..screen.mode)
- PrintConsole("ERROR: No contentToRender delivered for "..screen.mode)
- unit.exit()
- end
- screens[k].refresh = false
- end
- end
- end
-
- if HUDMode == true then
- system.setScreen(GetContentDamageHUDOutput())
- system.showScreen(1)
- else
- system.showScreen(0)
- end
-
-end
-
-function OnTickData(initial)
- if formerTime + 60 < system.getTime() then
- SetRefresh("time")
- end
- totalShipMass = core.getConstructMass()
- if formerTotalShipMass ~= totalShipMass then
- UpdateDamageData(true)
- UpdateTypeData()
- SetRefresh()
- formerTotalShipMass = totalShipMass
- else
- UpdateDamageData(initial)
- UpdateTypeData()
- end
- RenderScreens()
-end
-
---[[ 5. EXECUTION ]]
-
-unit.hide()
-ClearConsole()
-PrintConsole("DAMAGE REPORT v"..VERSION.." STARTED", true)
-InitiateSlots()
-LoadFromDatabank()
-SwitchScreens("on")
-InitiateScreens()
-
-if core == nil then
- PrintConsole("ERROR: Connect the core to the programming board.")
- unit.exit()
-else
- OperatorID = unit.getMasterPlayerId()
- OperatorData = database.getPlayer(OperatorID)
- PlayerName = OperatorData["name"]
- ShipID = core.getConstructId()
-end
-
-if db == nil then
- table.insert(Warnings, "No databank connected, won't save/load settings.")
-end
-
-if YourShipsName == "Enter here" then
- table.insert(Warnings, "No ship name set in LUA settings.")
-end
-
-if SkillRepairToolEfficiency == 0 and SkillRepairToolOptimization == 0 and StatFuelTankOptimization == 0 and StatContainerOptimization ==0 and
- StatAtmosphericFuelTankHandling == 0 and StatSpaceFuelTankHandling == 0 and StatRocketFuelTankHandling ==0 then
- table.insert(Warnings, "No talents/stats set in LUA settings.")
-end
-
-if SkillRepairToolEfficiency < 0 or SkillRepairToolOptimization < 0 or StatFuelTankOptimization < 0 or StatContainerOptimization < 0 or
- StatAtmosphericFuelTankHandling < 0 or StatSpaceFuelTankHandling < 0 or StatRocketFuelTankHandling < 0 or
- SkillRepairToolEfficiency > 5 or SkillRepairToolOptimization > 5 or StatFuelTankOptimization > 5 or StatContainerOptimization > 5 or
- StatAtmosphericFuelTankHandling > 5 or StatSpaceFuelTankHandling > 5 or StatRocketFuelTankHandling > 5 then
- PrintConsole("ERROR: Talents/stats can only range from 0 to 5. Please set correctly in LUA settings and reactivate script.")
- unit.exit()
-end
-
-if screens == nil or #screens == 0 then
- HUDMode = true
- PrintConsole("Warning: No screens connected. Entering HUD mode only.")
-end
-
-OnTickData(true)
-
-unit.setTimer('UpdateData', UpdateDataInterval)
-unit.setTimer('UpdateHighlight', HighlightBlinkingInterval)
\ No newline at end of file
diff --git a/src/DamageReport_3_05_UnitStart_1.lua b/src/DamageReport_3_05_UnitStart_1.lua
deleted file mode 100644
index 5d905ed..0000000
--- a/src/DamageReport_3_05_UnitStart_1.lua
+++ /dev/null
@@ -1,1277 +0,0 @@
---[[
- Damage Report 3.05
- A LUA script for Dual Universe
-
- Created By Dorian Gray
- Ingame: DorianGray
- Discord: Dorian Gray#2623
-
- You can find/update this script on GitHub. Explanations, installation and usage information as well as screenshots can be found there too.
- GitHub: https://github.com/DorianTheGrey/DU-DamageReport
-
- GNU Public License 3.0. Use whatever you want, be so kind to leave credit.
-
- Credits & thanks:
- Thanks to NovaQuark for creating the MMO of the century.
- Thanks to Jericho, Dmentia and Archaegeo for learning a lot from their fine scripts.
- Thanks to TheBlacklist for testing and wonderful suggestions.
- SVG patterns by Hero Patterns.
- DU atlas data from Jayle Break.
-
-]]
-
---[[ 1. HELPER FUNCTIONS ]]
-
-function GenerateCommaValue(amount, kify, postcomma)
- kify = kify or false
- postcomma = postcomma or 1
- local formatted = amount
- if kify == true then
- if string.len(amount)>=4 then
- formatted = string.format("%."..postcomma.."fk", amount/1000)
- else
- formatted = string.format("%."..postcomma.."f", amount)
- end
- else
- while true do
- formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
- if (k == 0) then break end
- end
- end
- return formatted
-end
-
-function PrintConsole(output, highlight)
- highlight = highlight or false
- if highlight then
- system.print(
- "------------------------------------------------------------------------")
- end
- system.print(output)
- if highlight then
- system.print(
- "------------------------------------------------------------------------")
- end
-end
-
-function DrawCenteredText(output)
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- screens[i].element.setCenteredText(output)
- end
- end
-end
-
-function ClearConsole()
- for i = 1, 10, 1 do
- PrintConsole()
- end
-end
-
-function SwitchScreens(state)
- state = state or "on"
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- if state == "on" then
- screens[i].element.clear()
- screens[i].element.activate()
- screens[i].active = true
- else
- screens[i].element.clear()
- screens[i].element.deactivate()
- screens[i].active = false
- end
- end
- end
-end
-
---[[ Convert seconds to string (by Jericho) ]]
-function GetSecondsString(seconds)
- local seconds = tonumber(seconds)
-
- if seconds == nil or seconds <= 0 then
- return "-";
- else
- days = string.format("%2.f", math.floor(seconds/(3600*24)));
- hours = string.format("%2.f", math.floor(seconds/3600 - (days*24)));
- mins = string.format("%2.f", math.floor(seconds/60 - (hours*60) - (days*24*60)));
- secs = string.format("%2.f", math.floor(seconds - hours*3600 - (days*24*60*60) - mins *60));
- str = ""
- if tonumber(days) > 0 then str = str .. days.."d " end
- if tonumber(hours) > 0 then str = str .. hours.."h " end
- if tonumber(mins) > 0 then str = str .. mins.."m " end
- if tonumber(secs) > 0 then str = str .. secs .."s" end
- return str
- end
-end
-
-function replace_char(pos, str, r)
- return str:sub(1, pos-1) .. r .. str:sub(pos+1)
-end
-
---[[ 2. RENDER HELPER FUNCTIONS ]]
-
---[[ epochTime function by Leodr (clock script), enhanced by Jericho (DU Industry script) ]]
-function epochTime()
- function rZ(a)
- if string.len(a) <= 1 then
- return "0" .. a
- else
- return a
- end
- end
- function dPoint(b)
- if not (b == math.floor(b)) then
- return true
- else
- return false
- end
- end
- function lYear(year)
- if not dPoint(year / 4) then
- if dPoint(year / 100) then
- return true
- else
- if not dPoint(year / 400) then
- return true
- else
- return false
- end
- end
- else
- return false
- end
- end
- local c = 5;
- local d = 3600;
- local e = 86400;
- local f = 31536000;
- local g = 31622400;
- local h = 2419200;
- local i = 2505600;
- local j = 2592000;
- local k = 2678400;
- local l = {4, 6, 9, 11}
- local m = {1, 3, 5, 7, 8, 10, 12}
- local n = 0;
- local o = 1506816000;
- local q = system.getTime()
- _G["formerTime"] = q
- if AddSummertimeHour == true then q = q + 3600 end
- now = math.floor(q + o)
- year = 1970;
- secs = 0;
- n = 0;
- while secs + g < now or secs + f < now do
- if lYear(year + 1) then
- if secs + g < now then
- secs = secs + g;
- year = year + 1;
- n = n + 366
- end
- else
- if secs + f < now then
- secs = secs + f;
- year = year + 1;
- n = n + 365
- end
- end
- end
- secondsRemaining = now - secs;
- monthSecs = 0;
- yearlYear = lYear(year)
- month = 1;
- while monthSecs + h < secondsRemaining or monthSecs + j < secondsRemaining or
- monthSecs + k < secondsRemaining do
- if month == 1 then
- if monthSecs + k < secondsRemaining then
- month = 2;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 2 then
- if not yearlYear then
- if monthSecs + h < secondsRemaining then
- month = 3;
- monthSecs = monthSecs + h;
- n = n + 28
- else
- break
- end
- else
- if monthSecs + i < secondsRemaining then
- month = 3;
- monthSecs = monthSecs + i;
- n = n + 29
- else
- break
- end
- end
- end
- if month == 3 then
- if monthSecs + k < secondsRemaining then
- month = 4;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 4 then
- if monthSecs + j < secondsRemaining then
- month = 5;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- if month == 5 then
- if monthSecs + k < secondsRemaining then
- month = 6;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 6 then
- if monthSecs + j < secondsRemaining then
- month = 7;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- if month == 7 then
- if monthSecs + k < secondsRemaining then
- month = 8;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 8 then
- if monthSecs + k < secondsRemaining then
- month = 9;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 9 then
- if monthSecs + j < secondsRemaining then
- month = 10;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- if month == 10 then
- if monthSecs + k < secondsRemaining then
- month = 11;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 11 then
- if monthSecs + j < secondsRemaining then
- month = 12;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- end
- day = 1;
- daySecs = 0;
- daySecsRemaining = secondsRemaining - monthSecs;
- while daySecs + e < daySecsRemaining do
- day = day + 1;
- daySecs = daySecs + e;
- n = n + 1
- end
- hour = 0;
- hourSecs = 0;
- hourSecsRemaining = daySecsRemaining - daySecs;
- while hourSecs + d < hourSecsRemaining do
- hour = hour + 1;
- hourSecs = hourSecs + d
- end
- minute = 0;
- minuteSecs = 0;
- minuteSecsRemaining = hourSecsRemaining - hourSecs;
- while minuteSecs + 60 < minuteSecsRemaining do
- minute = minute + 1;
- minuteSecs = minuteSecs + 60
- end
- second = math.floor(now % 60)
- year = rZ(year)
- month = rZ(month)
- day = rZ(day)
- hour = rZ(hour)
- minute = rZ(minute)
- second = rZ(second)
-
- return [[]]..hour..":".. minute..[[]]..
- [[]]..year.."/".. month.."/"..day..[[]]
-end
-
-
-function ToggleHUD()
- if HUDMode == true then
- HUDMode = false
- forceDamageRedraw = true
- hudSelectedIndex = 0
- highlightID = 0
- HideHighlight()
- SetRefresh()
- RenderScreens()
- else
- HUDMode = true
- forceDamageRedraw = true
- hudSelectedIndex = 0
- highlightID = 0
- HideHighlight()
- SetRefresh()
- RenderScreens()
- end
-end
-
-function HudDeselectElement()
- hudSelectedIndex = 0
- hudStartIndex = 1
- highlightID = 0
- HideHighlight()
- if HUDMode == true then
- SetRefresh("damage")
- SetRefresh("damageoutline")
- RenderScreens()
- end
-end
-
-function ChangeHudSelectedElement(step)
- if HUDMode == true and #rE > 0 then
-
- hudSelectedIndex = hudSelectedIndex + step
- if hudSelectedIndex < 1 then hudSelectedIndex = 1
- elseif hudSelectedIndex > #rE then hudSelectedIndex = #rE
- end
-
- if hudSelectedIndex > 9 then
- hudStartIndex = hudSelectedIndex-9
- end
- if hudSelectedIndex ~= 0 then
- highlightID = rE[hudSelectedIndex].id
- if highlightID ~=nil and highlightID ~= 0 then
- -- PrintConsole("CHSE: hudSelectedIndex: "..hudSelectedIndex.." / hudStartIndex: "..hudStartIndex.." / highlightID: "..highlightID)
- HideHighlight()
- elementPosition = vec3(rE[hudSelectedIndex].pos)
- highlightX = elementPosition.x - coreWorldOffset
- highlightY = elementPosition.y - coreWorldOffset
- highlightZ = elementPosition.z - coreWorldOffset
- highlightOn = true
- ShowHighlight()
- end
- end
-
- SetRefresh("damage")
- SetRefresh("damageoutline")
- RenderScreens()
-
- end
-end
-
-function HideHighlight()
- if #hudArrowSticker > 0 then
- for i in pairs(hudArrowSticker) do
- core.deleteSticker(hudArrowSticker[i])
- end
- hudArrowSticker = {}
- end
-end
-
-function ShowHighlight()
- if highlightOn == true and highlightID > 0 then
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX + 2, highlightY, highlightZ, "north"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY - 2, highlightZ, "east"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX - 2, highlightY, highlightZ, "south"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY + 2, highlightZ, "west"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY, highlightZ - 2, "up"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY, highlightZ + 2,"down"))
- end
-end
-
-function ToggleHighlight()
- if highlightOn == true then
- highlightOn = false
- HideHighlight()
- else
- highlightOn = true
- ShowHighlight()
- end
-end
-
-function SortDamageTables()
- table.sort(damagedElements, function(a, b) return a.missinghp > b.missinghp end)
- table.sort(brokenElements, function(a, b) return a.maxhp > b.maxhp end)
-end
-
-function getScraps(damage,commaval)
- commaval = commaval or false
- damage = damage - SkillRepairToolOptimization * 0.05 * damage
- local res = math.ceil( damage / ( 10 * 5^(ScrapTier-1) ) )
- if commaval ==true then
- return GenerateCommaValue(string.format("%.0f", res ), false)
- else
- return res
- end
-end
-
-function getRepairTime(damage,buildstring)
- buildstring = buildstring or false
- damage = damage - SkillRepairToolOptimization * 0.05 * damage
- local res = math.ceil(damage / ScrapTierRepairTimes[ScrapTier])
- res = res - ( SkillRepairToolEfficiency * 0.1 * res )
- if buildstring == true then
- return GetSecondsString(string.format("%.0f", res ) )
- else
- return res
- end
-end
-
-function UpdateDataDamageoutline()
-
- dmgoElements = {}
-
- for i,element in ipairs(brokenElements) do
- if #dmgoElements < DMGOMaxElements then
- local elementPosition = vec3(element.pos)
- local x = elementPosition.x - coreWorldOffset
- local y = elementPosition.y - coreWorldOffset
- local z = elementPosition.z - coreWorldOffset
- if x < ShipXmin then ShipXmin = x end
- if y < ShipYmin then ShipYmin = y end
- if z < ShipZmin then ShipZmin = z end
- if x > ShipXmax then ShipXmax = x end
- if y > ShipYmax then ShipYmax = y end
- if z > ShipZmax then ShipZmax = z end
- table.insert( dmgoElements, {
- id = element.id,
- type = "b",
- size = element.maxhp,
- x = x, y = y, z = z,
- xp = 0, yp = 0, zp = 0,
- u = 0, v = 0
- })
- end
- end
-
- if #dmgoElements < DMGOMaxElements then
- for i,element in ipairs(damagedElements) do
- if #dmgoElements < DMGOMaxElements then
- local elementPosition = vec3(element.pos)
- local x = elementPosition.x - coreWorldOffset
- local y = elementPosition.y - coreWorldOffset
- local z = elementPosition.z - coreWorldOffset
- if x < ShipXmin then ShipXmin = x end
- if y < ShipYmin then ShipYmin = y end
- if z < ShipZmin then ShipZmin = z end
- if x > ShipXmax then ShipXmax = x end
- if y > ShipYmax then ShipYmax = y end
- if z > ShipZmax then ShipZmax = z end
- table.insert( dmgoElements, {
- id = element.id,
- type = "d",
- size = element.maxhp,
- x = x, y = y, z = z,
- xp = 0, yp = 0, zp = 0,
- u = 0, v = 0
- })
- end
- end
- end
-
- if #dmgoElements < DMGOMaxElements then
- for i,element in ipairs(healthyElements) do
- if #dmgoElements < DMGOMaxElements then
- local elementPosition = vec3(element.pos)
- local x = elementPosition.x - coreWorldOffset
- local y = elementPosition.y - coreWorldOffset
- local z = elementPosition.z - coreWorldOffset
- if x < ShipXmin then ShipXmin = x end
- if y < ShipYmin then ShipYmin = y end
- if z < ShipZmin then ShipZmin = z end
- if x > ShipXmax then ShipXmax = x end
- if y > ShipYmax then ShipYmax = y end
- if z > ShipZmax then ShipZmax = z end
- table.insert( dmgoElements, {
- id = element.id,
- type = "h",
- size = element.maxhp,
- x = x, y = y, z = z,
- xp = 0, yp = 0, zp = 0,
- u = 0, v = 0
- })
- end
- end
- end
-
- ShipX = math.abs(ShipXmax-ShipXmin)
- ShipY = math.abs(ShipYmax-ShipYmin)
- ShipZ = math.abs(ShipZmax-ShipZmin)
-
- --[[
- PrintConsole(
- "ShipXmin: "..string.format("%.2f",ShipXmin)..
- " - ShipYmin: "..string.format("%.2f",ShipYmin)..
- " - ShipZmin: "..string.format("%.2f",ShipZmin)..
- " - ShipXmax: "..string.format("%.2f",ShipXmax)..
- " - ShipYmax: "..string.format("%.2f",ShipYmax)..
- " - ShipZmax: "..string.format("%.2f",ShipZmax)
- )
-
- PrintConsole(
- "ShipX: "..string.format("%.2f",ShipX)..
- " - ShipY: "..string.format("%.2f",ShipY)..
- " - ShipZ: "..string.format("%.2f",ShipZ)
- )
- ]]
-
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].xp = math.abs(100/(ShipXmax-ShipXmin)*(element.x-ShipXmin))
- dmgoElements[i].yp = math.abs(100/(ShipYmax-ShipYmin)*(element.y-ShipYmin))
- dmgoElements[i].zp = math.abs(100/(ShipZmax-ShipZmin)*(element.z-ShipZmin))
- -- PrintConsole(i..". "..element.id..": "..string.format("%.2f",element.x).."/"..string.format("%.2f",element.y).."/"..string.format("%.2f",element.z).." - XP: "..dmgoElements[i].xp.." - YP: "..dmgoElements[i].yp.." - ZP: "..dmgoElements[i].zp)
- end
-
-end
-
-function UpdateViewDamageoutline(screen)
- -- Full Width of virtual screen:
- -- UStart = 20
- -- VStart = 180
- -- UDim = 1880
- -- VDim = 840
- -- Adding frames:
- UFrame = 40
- VFrame = 40
-
- UStart = 20 + UFrame
- VStart = 180 + VFrame
- UDim = 1880 - 2*UFrame
- VDim = 840 - 2*VFrame
-
- if screen.submode == "top" then
- if DMGOStretch == false then
- local UFactor = UDim/(ShipYmax-ShipYmin)
- local VFactor = VDim/(ShipXmax-ShipXmin)
- if UFactor>=VFactor then
- local cFactor = UFactor/VFactor
- local newUDim = math.floor(UDim/cFactor)
- UStart = UStart+(UDim-newUDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100/cFactor*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*element.xp+VStart)
- end
- else
- local cFactor = VFactor/UFactor
- local newVDim = math.floor(VDim/cFactor)
- VStart = VStart+(VDim-newVDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100/cFactor*element.xp+VStart)
- end
- end
- else
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*element.xp+VStart)
- end
- end
-
-
- elseif screen.submode == "front" then
- if DMGOStretch == false then
- local UFactor = UDim/(ShipXmax-ShipXmin)
- local VFactor = VDim/(ShipZmax-ShipZmin)
- if UFactor>=VFactor then
- local cFactor = UFactor/VFactor
- local newUDim = math.floor(UDim/cFactor)
- UStart = UStart+(UDim-newUDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100/cFactor*element.xp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- else
- local cFactor = VFactor/UFactor
- local newVDim = math.floor(VDim/cFactor)
- VStart = VStart+(VDim-newVDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.xp+UStart)
- dmgoElements[i].v = math.floor(VDim/100/cFactor*(100-element.zp)+VStart)
- end
- end
- else
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.xp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- end
-
- elseif screen.submode == "side" then
- if DMGOStretch == false then
- local UFactor = UDim/(ShipYmax-ShipYmin)
- local VFactor = VDim/(ShipXmax-ShipZmin)
- if UFactor>=VFactor then
- local cFactor = UFactor/VFactor
- local newUDim = math.floor(UDim/cFactor)
- UStart = UStart+(UDim-newUDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100/cFactor*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- else
- local cFactor = VFactor/UFactor
- local newVDim = math.floor(VDim/cFactor)
- VStart = VStart+(VDim-newVDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100/cFactor*(100-element.zp)+VStart)
- end
- end
- else
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- end
- else
- DrawCenteredText("ERROR: non-existing DMGO mode set.")
- PrintConsole("ERROR: non-existing DMGO mode set.")
- unit.exit()
- end
-end
-
-function GetDamageoutlineShip()
- local output = ""
-
- for i,element in ipairs(dmgoElements) do
- local cclass = ""
- local size = 1
-
- if element.type == "h" then
- cclass ="ch"
- elseif element.type == "d" then
- cclass = "cw"
- else
- cclass = "cc"
- end
- if element.id == highlightID then
- cclass = "f2"
- end
-
- if element.size > 0 and element.size < 1000 then
- size = 5
- elseif element.size >= 1000 and element.size < 2000 then
- size = 8
- elseif element.size >= 2000 and element.size < 5000 then
- size = 12
- elseif element.size >= 5000 and element.size < 10000 then
- size = 15
- elseif element.size >= 10000 and element.size < 20000 then
- size = 20
- elseif element.size >= 20000 then
- size = 30
- end
- output = output .. [[]]
- if element.id == highlightID then
- output = output .. [[]]
- output = output .. [[]]
- end
- end
-
- return output
-end
-
-function GetContentClickareas(screen)
- local output = ""
- if screen ~= nil and screen.ClickAreas ~= nil and #screen.ClickAreas > 0 then
- for i,ca in ipairs(screen.ClickAreas) do
- output = output ..
- [[]]
- end
- end
- return output
-end
-
-function GetElement1(x, y, width, height)
- x = x or 0
- y = y or 0
- width = width or 600
- height = height or 600
- local output = ""
- output = output ..
- [[
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetElement2(x, y)
- x = x or 0
- y = y or 0
- local output = ""
- output = output .. [[]]
- return output
-end
-
-function GetElementLogo(x, y, primaryC, secondaryC, tertiaryC)
- x = x or 812
- y = y or 380
- primaryC = primaryC or "f"
- secondaryC = secondaryC or "f2"
- tertiaryC = tertiaryC or "f3"
- local output = ""
- output = output .. [[
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetHeader(headertext)
- headertext = headertext or "ERROR: UNDEFINED"
- local output = ""
- output = output ..
- [[
- ]]..headertext..[[]]
- return output
-end
-
-function GetContentBackground(candidate, bgcolor)
- bgColor = ColorBackgroundPattern
-
- local output = ""
-
- if candidate == "dots" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' viewBox='0 0 4 4'%3E%3Cpath fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' d='M1 3h1v1H1V3zm2-2h1v1H3V1z'%3E%3C/path%3E%3C/svg%3E");]]
- elseif candidate == "rain" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='12' height='16' viewBox='0 0 12 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 .99C4 .445 4.444 0 5 0c.552 0 1 .45 1 .99v4.02C6 5.555 5.556 6 5 6c-.552 0-1-.45-1-.99V.99zm6 8c0-.546.444-.99 1-.99.552 0 1 .45 1 .99v4.02c0 .546-.444.99-1 .99-.552 0-1-.45-1-.99V8.99z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E");]]
- elseif candidate == "plus" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "signal" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='84' height='48' viewBox='0 0 84 48' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h12v6H0V0zm28 8h12v6H28V8zm14-8h12v6H42V0zm14 0h12v6H56V0zm0 8h12v6H56V8zM42 8h12v6H42V8zm0 16h12v6H42v-6zm14-8h12v6H56v-6zm14 0h12v6H70v-6zm0-16h12v6H70V0zM28 32h12v6H28v-6zM14 16h12v6H14v-6zM0 24h12v6H0v-6zm0 8h12v6H0v-6zm14 0h12v6H14v-6zm14 8h12v6H28v-6zm-14 0h12v6H14v-6zm28 0h12v6H42v-6zm14-8h12v6H56v-6zm0-8h12v6H56v-6zm14 8h12v6H70v-6zm0 8h12v6H70v-6zM14 24h12v6H14v-6zm14-8h12v6H28v-6zM14 8h12v6H14V8zM0 8h12v6H0V8z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E");]]
- elseif candidate == "deathstar" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='105' viewBox='0 0 80 105'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M20 10a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm15 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zM20 75a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zm30-65a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm0 65a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zM35 10a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zM5 45a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zm60 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10z' /%3E%3C/g%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "diamond" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='32' viewBox='0 0 16 32'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath fill-rule='evenodd' d='M0 24h4v2H0v-2zm0 4h6v2H0v-2zm0-8h2v2H0v-2zM0 0h4v2H0V0zm0 4h2v2H0V4zm16 20h-6v2h6v-2zm0 4H8v2h8v-2zm0-8h-4v2h4v-2zm0-20h-6v2h6V0zm0 4h-4v2h4V4zm-2 12h2v2h-2v-2zm0-8h2v2h-2V8zM2 8h10v2H2V8zm0 8h10v2H2v-2zm-2-4h14v2H0v-2zm4-8h6v2H4V4zm0 16h6v2H4v-2zM6 0h2v2H6V0zm0 24h2v2H6v-2z'/%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "hexagon" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='49' viewBox='0 0 28 49'%3E%3Cg fill-rule='evenodd'%3E%3Cg id='hexagons' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='nonzero'%3E%3Cpath d='M13.99 9.25l13 7.5v15l-13 7.5L1 31.75v-15l12.99-7.5zM3 17.9v12.7l10.99 6.34 11-6.35V17.9l-11-6.34L3 17.9zM0 15l12.98-7.5V0h-2v6.35L0 12.69v2.3zm0 18.5L12.98 41v8h-2v-6.85L0 35.81v-2.3zM15 0v7.5L27.99 15H28v-2.31h-.01L17 6.35V0h-2zm0 49v-8l12.99-7.5H28v2.31h-.01L17 42.15V49h-2z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "capsule" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='32' height='26' viewBox='0 0 32 26' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M14 0v3.994C14 7.864 10.858 11 7 11c-3.866 0-7-3.138-7-7.006V0h2v4.005C2 6.765 4.24 9 7 9c2.756 0 5-2.236 5-4.995V0h2zm0 26v-5.994C14 16.138 10.866 13 7 13c-3.858 0-7 3.137-7 7.006V26h2v-6.005C2 17.235 4.244 15 7 15c2.76 0 5 2.236 5 4.995V26h2zm2-18.994C16 3.136 19.142 0 23 0c3.866 0 7 3.138 7 7.006v9.988C30 20.864 26.858 24 23 24c-3.866 0-7-3.138-7-7.006V7.006zm2-.01C18 4.235 20.244 2 23 2c2.76 0 5 2.236 5 4.995v10.01C28 19.765 25.756 22 23 22c-2.76 0-5-2.236-5-4.995V6.995z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E");]]
- elseif candidate == "diagonal" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='6' height='6' viewBox='0 0 6 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'%3E%3Cpath d='M5 0h1L0 6V5zM6 5v1H5z'/%3E%3C/g%3E%3C/svg%3E");]]
- end
- return output;
-end
-
-function GetContentDamageHUDOutput()
- local hudWidth = 300
- local hudHeight = 165
- if #damagedElements > 0 or #brokenElements > 0 then hudHeight = 510 end
- local output = ""
-
- output = output .. [[
-
- ]]
- output = output .. [[]] ..
- [[]] ..
- [[]] ..
- [[]]..(YourShipsName=="Enter here" and ("Ship ID "..ShipID) or YourShipsName) .. [[]] ..
- [[]]
- if #brokenElements > 0 then
- output = output .. [[]]
- elseif #damagedElements > 0 then
- output = output .. [[]]
- else
- output = output .. [[]]
- end
-
- if #damagedElements > 0 or #brokenElements > 0 then
-
- output = output .. [[Total Damage]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", totalShipMaxHP - totalShipHP))..[[]]
- output = output .. [[T]]..ScrapTier..[[ Scrap Needed]] ..
- [[]]..getScraps(totalShipMaxHP - totalShipHP, true)..[[]]
- output = output .. [[Repair Time]] ..
- [[]]..getRepairTime(totalShipMaxHP - totalShipHP, true)..[[]]
-
- output = output .. [[]] ..
- [[]] ..
- [[]]..#healthyElements..[[]] ..
- [[]] ..
- [[]]..#damagedElements..[[]] ..
- [[]] ..
- [[]]..#brokenElements..[[]]
- local j=0
-
- for currentIndex=hudStartIndex,hudStartIndex+9,1 do
- if rE[currentIndex] ~= nil then
- v = rE[currentIndex]
- if v.hp > 0 then
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- if v.id == highlightID then
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- end
- else
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- if v.id == highlightID then
- highlightX = elementPosition.x - coreWorldOffset
- highlightY = elementPosition.y - coreWorldOffset
- highlightZ = elementPosition.z - coreWorldOffset
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- end
- end
- j=j+1
- end
- end
- output = output ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Up/down arrows to highlight]] ..
- [[CTRL + arrows to move HUD]] ..
- [[Left arrow to toggle HUD Mode]] ..
- [[ALT+1-4 to set Scrap Tier]] ..
- [[ALT+8 to reset HUD position]] ..
- [[ALT+9 to shut script off]] ..
- [[]] ..
- [[]]
- else
- output = output ..
- [[]] .. OkayCenterMessage .. [[]] ..
- [[]]..#healthyElements..[[ elements / ]] .. GenerateCommaValue(string.format("%.0f", totalShipMaxHP)) .. [[ HP.]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Left arrow to toggle HUD Mode]] ..
- [[CTRL + arrows to move HUD]] ..
- [[ALT+8 to reset HUD position]] ..
- [[ALT+9 to shut script off]] ..
- [[]] ..
- [[]]
- end
- output = output .. [[]]
- return output
-end
-
-function GetContentDamageScreen()
-
- local screenOutput = ""
-
- -- Draw damage elements
- if #damagedElements > 0 then
- local damagedElementsToDraw = #damagedElements
- if damagedElementsToDraw > DamagePageSize then
- damagedElementsToDraw = DamagePageSize
- end
- if CurrentDamagedPage == math.ceil(#damagedElements / DamagePageSize) then
- damagedElementsToDraw = #damagedElements % DamagePageSize + 12
- if damagedElementsToDraw > 12 then damagedElementsToDraw = damagedElementsToDraw - 12 end
- end
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
-
- if UseMyElementNames == true then screenOutput = screenOutput .. [[Damaged Name]]
- else screenOutput = screenOutput .. [[Damaged Type]]
- end
-
- screenOutput = screenOutput .. [[HLTHDMG]]
- screenOutput = screenOutput .. [[T]]..ScrapTier..[[ SCRREPTIME]]
-
- AddClickArea("damage", {
- id = "SwitchScrapTier",
- mode ="damage",
- x1 = 650,
- x2 = 775,
- y1 = 315,
- y2 = 360
- })
-
- local i = 0
- for j = 1 + (CurrentDamagedPage - 1) * DamagePageSize, damagedElementsToDraw + (CurrentDamagedPage - 1) * DamagePageSize, 1 do
- i = i + 1
- local DP = damagedElements[j]
- if UseMyElementNames == true then screenOutput = screenOutput .. [[]] .. string.format("%.23s", DP.name) .. [[]]
- else screenOutput = screenOutput .. [[]] .. string.format("%.23s", DP.type) .. [[]]
- end
- screenOutput = screenOutput .. [[]] .. DP.percent .. [[%]] ..
- [[]] .. GenerateCommaValue(string.format("%.0f", DP.missinghp), true) .. [[]] ..
- [[]] .. getScraps(DP.missinghp, true) .. [[]] ..
- [[]] .. getRepairTime(DP.missinghp, true) .. [[]] ..
- [[]]
- end
-
- if #damagedElements > DamagePageSize then
- screenOutput = screenOutput ..
- [[Page ]] .. CurrentDamagedPage .. " of " .. math.ceil(#damagedElements / DamagePageSize) ..[[]]
-
- if CurrentDamagedPage < math.ceil(#damagedElements / DamagePageSize) then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "DamagedPageDown",
- mode ="damage",
- x1 = 65,
- x2 = 260,
- y1 = 290 + (damagedElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (damagedElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("DamagedPageDown","damage")
- end
-
- if CurrentDamagedPage > 1 then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "DamagedPageUp",
- mode ="damage",
- x1 = 750,
- x2 = 950,
- y1 = 290 + (damagedElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (damagedElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("DamagedPageUp","damage")
- end
- end
- end
-
- -- Draw broken elements
- if #brokenElements > 0 then
- local brokenElementsToDraw = #brokenElements
- if brokenElementsToDraw > DamagePageSize then
- brokenElementsToDraw = DamagePageSize
- end
- if CurrentBrokenPage == math.ceil(#brokenElements / DamagePageSize) then
- brokenElementsToDraw = #brokenElements % DamagePageSize + 12
- if brokenElementsToDraw > 12 then brokenElementsToDraw = brokenElementsToDraw - 12 end
- end
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
-
- if UseMyElementNames == true then screenOutput = screenOutput .. [[Broken Name]]
- else screenOutput = screenOutput .. [[Broken Type]]
- end
-
- screenOutput = screenOutput .. [[DMG]]
- screenOutput = screenOutput .. [[T]]..ScrapTier..[[ SCRREPTIME]]
-
- AddClickArea("damage", {
- id = "SwitchScrapTier2",
- mode ="damage",
- x1 = 1570,
- x2 = 1690,
- y1 = 315,
- y2 = 360
- })
-
- local i = 0
- for j = 1 + (CurrentBrokenPage - 1) * DamagePageSize, brokenElementsToDraw + (CurrentBrokenPage - 1) * DamagePageSize, 1 do
- i = i + 1
- local DP = brokenElements[j]
- if UseMyElementNames == true then screenOutput = screenOutput .. [[]] .. string.format("%.30s", DP.name) .. [[]]
- else screenOutput = screenOutput .. [[]] .. string.format("%.30s", DP.type) .. [[]]
- end
- screenOutput = screenOutput .. [[]] .. GenerateCommaValue(string.format("%.0f", DP.missinghp), true) .. [[]] ..
- [[]] .. getScraps(DP.missinghp, true) .. [[]] ..
- [[]] .. getRepairTime(DP.missinghp, true) .. [[]] ..
- [[]]
- end
-
-
-
- if #brokenElements > DamagePageSize then
- screenOutput = screenOutput ..
- [[Page ]] .. CurrentBrokenPage .. " of " .. math.ceil(#brokenElements / DamagePageSize) .. [[]]
-
- if CurrentBrokenPage > 1 then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "BrokenPageUp",
- mode ="damage",
- x1 = 1665,
- x2 = 1865,
- y1 = 290 + (brokenElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (brokenElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("BrokenPageUp", "damage")
- end
-
- if CurrentBrokenPage < math.ceil(#brokenElements / DamagePageSize) then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "BrokenPageDown",
- mode ="damage",
- x1 = 980,
- x2 = 1180,
- y1 = 290 + (brokenElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (brokenElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("BrokenPageDown", "damage")
- end
- end
-
- end
-
- -- Draw summary
- if #damagedElements > 0 or #brokenElements > 0 then
- local dWidth = math.floor(1878/#elementsIdList*#damagedElements)
- local bWidth = math.floor(1878/#elementsIdList*#brokenElements)
- local hWidth = 1878-dWidth-bWidth+1
-
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
-
- if #damagedElements > 0 then
- screenOutput = screenOutput .. [[]]..#damagedElements..[[]]
- end
- if #healthyElements > 0 then
- screenOutput = screenOutput .. [[]]..#healthyElements..[[]]
- end
- if #brokenElements > 0 then
- screenOutput = screenOutput .. [[]]..#brokenElements..[[]]
- end
-
- screenOutput = screenOutput .. [[]]
-
- screenOutput = screenOutput .. [[]] ..
- GenerateCommaValue(string.format("%.0f", totalShipMaxHP - totalShipHP)) .. [[ HP damage in total ]] ..
- getScraps(totalShipMaxHP - totalShipHP, true) .. [[ T]]..ScrapTier..[[ scraps needed. ]] ..
- getRepairTime(totalShipMaxHP - totalShipHP, true) .. [[ projected repair time.]]
- else
- screenOutput = screenOutput .. GetElementLogo(812, 380, "ch", "ch", "ch") ..
- [[]] .. OkayCenterMessage .. [[]] ..
- [[]]..#healthyElements..[[ elements stand ]] .. GenerateCommaValue(string.format("%.0f", totalShipMaxHP)) .. [[ HP strong.]]
- end
-
- forceDamageRedraw = false
-
- return screenOutput
-end
-
-function ActionStopengines()
- ToggleHUD()
-end
-
-function ActionStrafeRight()
- if KeyCTRLPressed == true then
- if HUDShiftU < 4000 then
- HUDShiftU = HUDShiftU + 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- HudDeselectElement()
- end
-end
-
-function ActionStrafeLeft()
- if KeyCTRLPressed == true then
- if HUDShiftU >= 50 then
- HUDShiftU = HUDShiftU - 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- ToggleHUD()
- end
-end
-
-function ActionDown()
- if KeyCTRLPressed == true then
- if HUDShiftV < 4000 then
- HUDShiftV = HUDShiftV + 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- ChangeHudSelectedElement(1)
- end
-end
-
-function ActionUp()
- if KeyCTRLPressed == true then
- if HUDShiftV >= 50 then
- HUDShiftV = HUDShiftV - 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- ChangeHudSelectedElement(-1)
- end
-end
-
-function ActionOption1()
- ScrapTier = 1
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption2()
- ScrapTier = 2
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption3()
- ScrapTier = 3
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption4()
- ScrapTier = 4
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption8()
- HUDShiftU=0
- HUDShiftV=0
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption9()
- SaveToDatabank()
- SwitchScreens("off")
- unit.exit()
-end
diff --git a/src/DamageReport_3_05_UnitStart_2.lua b/src/DamageReport_3_05_UnitStart_2.lua
deleted file mode 100644
index d095f86..0000000
--- a/src/DamageReport_3_05_UnitStart_2.lua
+++ /dev/null
@@ -1,2048 +0,0 @@
---[[
- Damage Report 3.05
- A LUA script for Dual Universe
-
- Created By Dorian Gray
- Ingame: DorianGray
- Discord: Dorian Gray#2623
-
- You can find/update this script on GitHub. Explanations, installation and usage information as well as screenshots can be found there too.
- GitHub: https://github.com/DorianTheGrey/DU-DamageReport
-
- GNU Public License 3.0. Use whatever you want, be so kind to leave credit.
-
- Credits & thanks:
- Thanks to NovaQuark for creating the MMO of the century.
- Thanks to Jericho, Dmentia and Archaegeo for learning a lot from their fine scripts.
- Thanks to TheBlacklist for testing and wonderful suggestions.
- SVG patterns by Hero Patterns.
- DU atlas data from Jayle Break.
-
-]]
-
---[[ 1. USER DEFINED VARIABLES ]]
-
-YourShipsName = "Enter here" --export Enter your ship name here if you want it displayed instead of the ship's ID. YOU NEED TO LEAVE THE QUOTATION MARKS.
-
-SkillRepairToolEfficiency = 0 --export Enter (0-5) your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency"
-SkillRepairToolOptimization = 0 --export Enter your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Optimization"
-
-StatAtmosphericFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED ATMOSPHERIC FUEL TANKS (from the builders talent "Piloting -> Atmospheric Flight Technician -> Atmospheric Fuel-Tank Handling")
-StatSpaceFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL SPACE TANKS (from the builders talent "Piloting -> Atmospheric Engine Technician -> Space Fuel-Tank Handling")
-StatRocketFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL ROCKET TANKS (from the builders talent "Piloting -> Rocket Scientist -> Rocket Booster Fuel Tank Handling")
-StatContainerOptimization = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL TANKS "from the builders talent Mining and Inventory -> Stock Control -> Container Optimization"
-StatFuelTankOptimization = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL TANKS "from the builders talent Mining and Inventory -> Stock Control -> Fuel Tank Optimization"
-
-ShowWelcomeMessage = true --export Do you want the welcome message on the start screen with your name?
-AddSummertimeHour = false --export: Is summertime currently enabled in your location? (Adds one hour.)
-
--- SkillAtmosphericFuelEfficiency = 0 --export Enter (0-5) your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency"
--- SkillSpaceFuelEfficiency = 0 --export Enter (0-5) your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency"
--- SkillRocketFuelEfficiency = 0 --export Enter (0-5) your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency"
-
---[[ 2. GLOBAL VARIABLES ]]
-
-UpdateDataInterval = 1.0 -- How often shall the data be updated? (Increase if running into CPU issues.)
-HighlightBlinkingInterval = 0.5 -- How fast shall highlight arrows of marked elements blink?
-
-ColorPrimary = "FF6700" -- Enter the hexcode of the main color to be used by all views.
-ColorSecondary = "FFFFFF" -- Enter the hexcode of the secondary color to be used by all views.
-ColorTertiary = "000000" -- Enter the hexcode of the tertiary color to be used by all views.
-ColorHealthy = "00FF00" -- Enter the hexcode of the 'healthy' color to be used by all views.
-ColorWarning = "FFFF00" -- Enter the hexcode of the 'warning' color to be used by all views.
-ColorCritical = "FF0000" -- Enter the hexcode of the 'critical' color to be used by all views.
-ColorBackground = "000000" -- Enter the hexcode of the background color to be used by all views.
-ColorBackgroundPattern = "4F4F4F" -- Enter the hexcode of the background color to be used by all views.
-ColorFuelAtmospheric = "004444" -- Enter the hexcode of the atmospheric fuel color.
-ColorFuelSpace = "444400" -- Enter the hexcode of the space fuel color.
-ColorFuelRocket = "440044" -- Enter the hexcode of the rocket fuel color.
-
-VERSION = 3.05
-DebugMode = false
-DebugRenderClickareas = true
-
-DBData = {}
-
-core = nil
-db = nil
-screens = {}
-dscreens = {}
-
-Warnings = {}
-
-screenModes = {
- ["flight"] = { id="flight" },
- ["damage"] = { id="damage" },
- ["damageoutline"] = { id="damageoutline" },
- ["fuel"] = { id="fuel" },
- ["cargo"] = { id="cargo" },
- ["agg"] = { id="agg" },
- ["map"] = { id="map" },
- ["time"] = { id="time", activetoggle="true" },
- ["settings1"] = { id="settings1" },
- ["startup"] = { id="startup" }
-}
-
-backgroundModes = { "deathstar", "capsule", "rain", "signal", "hexagon", "diagonal", "diamond", "plus", "dots" }
-BackgroundMode ="deathstar"
-BackgroundSelected = 1
-BackgroundModeOpacity = 0.25
-
-SaveVars = { "dscreens",
- "ColorPrimary", "ColorSecondary", "ColorTertiary",
- "ColorHealthy", "ColorWarning", "ColorCritical",
- "ColorBackground", "ColorBackgroundPattern",
- "ScrapTier", "HUDMode", "SimulationMode", "DMGOStretch",
- "HUDShiftU", "HUDShiftV", "colorIDIndex", "colorIDTable",
- "BackgroundMode", "BackgroundSelected", "BackgroundModeOpacity" }
-
-HUDMode = false
-HUDShiftU = 0
-HUDShiftV = 0
-hudSelectedIndex = 0
-hudStartIndex = 1
-hudArrowSticker = {}
-highlightOn = false
-highlightID = 0
-highlightX = 0
-highlightY = 0
-highlightZ = 0
-
-SimulationMode = false
-OkayCenterMessage = "All systems nominal."
-CurrentDamagedPage = 1
-CurrentBrokenPage = 1
-DamagePageSize = 12
-ScrapTier = 1
-totalScraps = 0
-ScrapTierRepairTimes = { 10, 50, 250, 1250 }
-
-coreWorldOffset = 0
-totalShipHP = 0
-formerTotalShipHP = -1
-totalShipMaxHP = 0
-totalShipIntegrity = 100
-elementsId = {}
-elementsIdList = {}
-damagedElements = {}
-brokenElements = {}
-rE = {}
-healthyElements = {}
-typeElements = {}
-ElementCounter = 0
-UseMyElementNames = true
-dmgoElements = {}
-DMGOMaxElements = 250
-DMGOStretch = false
-ShipXmin = 99999999
-ShipXmax = -99999999
-ShipYmin = 99999999
-ShipYmax = -99999999
-ShipZmin = 99999999
-ShipZmax = -99999999
-
-totalShipMass = 0
-formerTotalShipMass = -1
-
-formerTime = -1
-
-FuelAtmosphericTanks = {}
-FuelSpaceTanks = {}
-FuelRocketTanks = {}
-FuelAtmosphericTotal = 0
-FuelSpaceTotal = 0
-FuelRocketTotal = 0
-FuelAtmosphericCurrent = 0
-FuelSpaceTotalCurrent = 0
-FuelRocketTotalCurrent = 0
-formerFuelAtmosphericTotal = -1
-formerFuelSpaceTotal = -1
-formerFuelRocketTotal = -1
-
-hexTable = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"}
-colorIDIndex = 1
-colorIDTable = {
- [1] = {
- id="ColorPrimary",
- desc="Main HUD Color",
- basec = "FF6700",
- newc = "FF6700"
- },
- [2] = {
- id="ColorSecondary",
- desc="Secondary HUD Color",
- basec = "FFFFFF",
- newc = "FFFFFF"
- },
- [3] = {
- id="ColorTertiary",
- desc="Tertiary HUD Color",
- basec = "000000",
- newc = "000000"
- },
- [4] = {
- id="ColorHealthy",
- desc="Color code for Healthy/Okay",
- basec = "00FF00",
- newc = "00FF00"
- },
- [5] = {
- id="ColorWarning",
- desc="Color code for Damaged/Warning",
- basec = "FFFF00",
- newc = "FFFF00"
- },
- [6] = {
- id="ColorCritical",
- desc="Color code for Broken/Critical",
- basec = "FF0000",
- newc = "FF0000"
- },
- [7] = {
- id="ColorBackground",
- desc="Background Color",
- basec = "000000",
- newc = "000000"
- },
- [8] = {
- id="ColorBackgroundPattern",
- desc="Background Pattern Color",
- basec = "4F4F4F",
- newc = "4F4F4F"
- },
- [9] = {
- id="ColorFuelAtmospheric",
- desc="Color for Atmo Fuel/Elements",
- basec = "004444",
- newc = "004444"
- },
- [10] = {
- id="ColorFuelSpace",
- desc="Color for Space Fuel/Elements",
- basec = "444400",
- newc = "444400"
- },
- [11] = {
- id="ColorFuelRocket",
- desc="Color for Rocket Fuel/Elements",
- basec = "440044",
- newc = "440044"
- }
-}
-
-
---[[ 3. PROCESSING FUNCTIONS ]]
-
-function InitiateSlots()
- for slot_name, slot in pairs(unit) do
- if type(slot) == "table" and type(slot.export) == "table" and
- slot.getElementClass then
- local elementClass = slot.getElementClass():lower()
- if elementClass:find("coreunit") then
- core = slot
- local coreHP = core.getMaxHitPoints()
- if coreHP > 10000 then
- coreWorldOffset = 128
- elseif coreHP > 1000 then
- coreWorldOffset = 64
- elseif coreHP > 150 then
- coreWorldOffset = 32
- else
- coreWorldOffset = 16
- end
- elseif elementClass == 'databankunit' then
- db = slot
- elseif elementClass == "screenunit" then
- local iScreenMode = "startup"
- screens[#screens + 1] = {
- element = slot,
- id = slot.getId(),
- mode = iScreenMode,
- submode = "",
- ClickAreas = {},
- refresh = true,
- active = false,
- fuelA = true,
- fuelS = true,
- fuelR = true,
- fuelIndex = 1
- }
- end
- end
- end
-end
-
-function LoadFromDatabank()
- if db == nil then
- return
- else
- for _, data in pairs(SaveVars) do
- if db.hasKey(data) then
- local jData = json.decode( db.getStringValue(data) )
- if jData ~= nil then
- if data == "YourShipsName" or data == "AddSummertimeHour" or data == "UpdateDataInterval" or data == "HighlightBlinkingInterval" or
- data == "SkillRepairToolEfficiency" or data == "SkillRepairToolOptimization" or data == "SkillAtmosphericFuelEfficiency" or
- data == "SkillSpaceFuelEfficiency" or data == "SkillRocketFuelEfficiency" or data == "StatAtmosphericFuelTankHandling" or
- data == "StatSpaceFuelTankHandling" or data == "StatRocketFuelTankHandling"
- then
- -- Nada
- else
- _G[data] = jData
- end
- end
- end
- end
-
- for i,v in ipairs(screens) do
- for j,dv in ipairs(dscreens) do
- if screens[i].id == dscreens[j].id then
- screens[i].mode = dscreens[j].mode
- screens[i].submode = dscreens[j].submode
- screens[i].active = dscreens[j].active
- screens[i].refresh = true
- screens[i].fuelA = dscreens[j].fuelA
- screens[i].fuelS = dscreens[j].fuelS
- screens[i].fuelR = dscreens[j].fuelR
- screens[i].fuelIndex = dscreens[j].fuelIndex
- end
- end
- end
- end
-end
-
-function SaveToDatabank()
- if db == nil then
- return
- else
- dscreens = {}
- for i,screen in ipairs(screens) do
- dscreens[i] = {}
- dscreens[i].id = screen.id
- dscreens[i].mode = screen.mode
- dscreens[i].submode = screen.submode
- dscreens[i].active = screen.active
- dscreens[i].fuelA = screen.fuelA
- dscreens[i].fuelS = screen.fuelS
- dscreens[i].fuelR = screen.fuelR
- dscreens[i].fuelIndex = screen.fuelIndex
- end
-
- db.clear()
-
- for _, data in pairs(SaveVars) do
- db.setStringValue(data, json.encode(_G[data]))
- end
-
- end
-end
-
-function InitiateScreens()
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- screens[i] = CreateClickAreasForScreen(screens[i])
- end
- end
-end
-
-function UpdateTypeData()
- FuelAtmosphericTanks = {}
- FuelSpaceTanks = {}
- FuelRocketTanks = {}
-
- FuelAtmosphericTotal = 0
- FuelAtmosphericCurrent = 0
- FuelSpaceTotal = 0
- FuelSpaceCurrent = 0
- FuelRocketCurrent = 0
- FuelRocketTotal = 0
-
- local weightAtmosphericFuel = 4
- local weightSpaceFuel = 6
- local weightRocketFuel = 0.8
-
- --[[
- (FuelMass * (1-.05 * ) * (1-.05 * )
- It just seems to be that the Container Optimization and Fuel Tank Optimization are not added together so the max is not -50% (25% from each skill from the base mass) but 43.75% So the Fuel Tank Optimization uses the container optimization result as it's base value
- ]]
-
- if StatContainerOptimization > 0 then
- weightAtmosphericFuel = weightAtmosphericFuel - 0.05 * StatContainerOptimization * weightAtmosphericFuel
- weightSpaceFuel = weightSpaceFuel - 0.05 * StatContainerOptimization * weightSpaceFuel
- weightRocketFuel = weightRocketFuel - 0.05 * StatContainerOptimization * weightRocketFuel
- end
- if StatFuelTankOptimization > 0 then
- weightAtmosphericFuel = weightAtmosphericFuel - 0.05 * StatFuelTankOptimization * weightAtmosphericFuel
- weightSpaceFuel = weightSpaceFuel - 0.05 * StatFuelTankOptimization * weightSpaceFuel
- weightRocketFuel = weightRocketFuel - 0.05 * StatFuelTankOptimization * weightRocketFuel
- end
-
- for i, id in ipairs(typeElements) do
- local idName = core.getElementNameById(id) or ""
- local idType = core.getElementTypeById(id) or ""
- -- local idTypeClean = idType:gsub("[%s%-]+", ""):lower()
- local idPos = core.getElementPositionById(id) or 0
- local idHP = core.getElementHitPointsById(id) or 0
- local idMaxHP = core.getElementMaxHitPointsById(id) or 0
- local idMass = core.getElementMassById(id) or 0
-
- local baseSize = ""
- local baseVol = 0
- local baseMass = 0
- local cMass = 0
- local cVol = 0
-
- if idType == "atmospheric fuel-tank" then
- if idMaxHP > 10000 then
- baseSize = "L"
- baseMass = 5480
- baseVol = 12800
- elseif idMaxHP > 1300 then
- baseSize = "M"
- baseMass = 988.67
- baseVol = 1600
- elseif idMaxHP > 150 then
- baseSize = "S"
- baseMass = 182.67
- baseVol = 400
- else
- baseSize = "XS"
- baseMass = 35.03
- baseVol = 100
- end
- if StatAtmosphericFuelTankHandling > 0 then
- baseVol = 0.2 * StatAtmosphericFuelTankHandling * baseVol + baseVol
- end
- cMass = idMass - baseMass
- if cMass <=10 then cMass = 0 end
- cVol = string.format("%.0f", cMass / weightAtmosphericFuel)
- cPercent = string.format("%.1f", math.floor(100/baseVol * tonumber(cVol)))
- table.insert(FuelAtmosphericTanks, {
- type = 1,
- id = id,
- name = idName,
- maxhp = idMaxHP,
- hp = GetHPforElement(id),
- pos = idPos,
- size = baseSize,
- mass = baseMass,
- vol = baseVol,
- cvol = cVol,
- percent = cPercent
- })
- if idHP > 0 then
- FuelAtmosphericCurrent = FuelAtmosphericCurrent + cVol
- end
- FuelAtmosphericTotal = FuelAtmosphericTotal + baseVol
- elseif idType == "space fuel-tank" then
- if idMaxHP > 10000 then
- baseSize = "L"
- baseMass = 5480
- baseVol = 12800
- elseif idMaxHP > 1300 then
- baseSize = "M"
- baseMass = 988.67
- baseVol = 1600
- else
- baseSize = "S"
- baseMass = 182.67
- baseVol = 400
- end
- if StatSpaceFuelTankHandling > 0 then
- baseVol = 0.2 * StatSpaceFuelTankHandling * baseVol + baseVol
- end
- cMass = idMass - baseMass
- if cMass <=10 then cMass = 0 end
- cVol = string.format("%.0f", cMass / weightSpaceFuel)
- cPercent = string.format("%.1f", (100/baseVol * tonumber(cVol)))
- table.insert(FuelSpaceTanks, {
- type = 2,
- id = id,
- name = idName,
- maxhp = idMaxHP,
- hp = GetHPforElement(id),
- pos = idPos,
- size = baseSize,
- mass = baseMass,
- vol = baseVol,
- cvol = cVol,
- percent = cPercent
- })
- if idHP > 0 then
- FuelSpaceCurrent = FuelSpaceCurrent + cVol
- end
- FuelSpaceTotal = FuelSpaceTotal + baseVol
- elseif idType == "rocket fuel-tank" then
- if idMaxHP > 65000 then
- baseSize = "L"
- baseMass = 25740
- baseVol = 50000
- elseif idMaxHP > 6000 then
- baseSize = "M"
- baseMass = 4720
- baseVol = 6400
- elseif idMaxHP > 700 then
- baseSize = "S"
- baseMass = 886.72
- baseVol = 800
- else
- baseSize = "XS"
- baseMass = 173.42
- baseVol = 400
- end
- if StatRocketFuelTankHandling > 0 then
- baseVol = 0.2 * StatRocketFuelTankHandling * baseVol + baseVol
- end
- cMass = idMass - baseMass
- if cMass <=10 then cMass = 0 end
- cVol = string.format("%.0f", cMass / weightRocketFuel)
- cPercent = string.format("%.1f", (100/baseVol * tonumber(cVol)))
- table.insert(FuelRocketTanks, {
- type = 3,
- id = id,
- name = idName,
- maxhp = idMaxHP,
- hp = GetHPforElement(id),
- pos = idPos,
- size = baseSize,
- mass = baseMass,
- vol = baseVol,
- cvol = cVol,
- percent = cPercent
- })
- if idHP > 0 then
- FuelRocketCurrent = FuelRocketCurrent + cVol
- end
- FuelRocketTotal = FuelRocketTotal + baseVol
- end
-
- end
-
- if FuelAtmosphericCurrent ~= formerFuelAtmosphericCurrent then
- SetRefresh("fuel")
- formerFuelAtmosphericCurrent = FuelAtmosphericCurrent
- end
- if FuelSpaceCurrent ~= formerFuelSpaceCurrent then
- SetRefresh("fuel")
- formerFuelSpaceCurrent = FuelSpaceCurrent
- end
- if FuelRocketCurrent ~= formerFuelRocketCurrent then
- SetRefresh("fuel")
- formerFuelRocketCurrent = FuelRocketCurrent
- end
-
-
-
-end
-
-function UpdateDamageData(initial)
-
- initial = initial or false
-
- if SimulationActive == true then return end
-
- local formerTotalShipHP = totalShipHP
- totalShipHP = 0
- totalShipMaxHP = 0
- totalShipIntegrity = 100
- damagedElements = {}
- brokenElements = {}
- healthyElements = {}
- if initial == true then
- typeElements = {}
- end
-
- ElementCounter = 0
-
- elementsIdList = core.getElementIdList()
-
- for i, id in pairs(elementsIdList) do
-
- ElementCounter = ElementCounter + 1
-
- local idName = core.getElementNameById(id)
-
- local idType = core.getElementTypeById(id)
- -- local idTypeClean = idType:gsub("[%s%-]+", ""):lower()
- local idPos = core.getElementPositionById(id)
- local idHP = core.getElementHitPointsById(id)
- local idMaxHP = core.getElementMaxHitPointsById(id)
- -- local idMass = core.getElementMassById(id)
-
- if SimulationMode == true then
- SimulationActive = true
- local dice = math.random(0, 10)
- if dice < 2 and #brokenElements < 30 then
- idHP = 0
- elseif dice >= 2 and dice < 4 and #damagedElements < 30 then
- idHP = math.random(1, math.ceil(idMaxHP))
- else
- idHP = idMaxHP
- end
- end
-
- totalShipHP = totalShipHP + idHP
- totalShipMaxHP = totalShipMaxHP + idMaxHP
-
- if idMaxHP - idHP > constants.epsilon then
-
- if idHP > 0 then
- table.insert(damagedElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP - idHP,
- percent = math.ceil(100 / idMaxHP * idHP),
- pos = idPos
- })
- else
- table.insert(brokenElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP - idHP,
- percent = 0,
- pos = idPos
- })
- end
- else
- table.insert(healthyElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- pos = idPos
- })
- if id == highlightID then
- highlightID = 0
- highlightOn = false
- HideHighlight()
- hudSelectedIndex = 0
- end
- end
-
- if initial == true then
- if
- idType == "atmospheric fuel-tank" or
- idType == "space fuel-tank" or
- idType == "rocket fuel-tank"
- then
- table.insert(typeElements, id)
- end
- end
- end
-
- SortDamageTables()
-
- rE = {}
-
- if #brokenElements > 0 then
- for _,v in ipairs(brokenElements) do
- table.insert(rE, {id=v.id, missinghp=v.missinghp, hp=v.hp, name=v.name, type=v.type, pos=v.pos})
- end
- end
- if #damagedElements > 0 then
- for _,v in ipairs(damagedElements) do
- table.insert(rE, {id=v.id, missinghp=v.missinghp, hp=v.hp, name=v.name, type=v.type, pos=v.pos})
- end
- end
- if #rE > 0 then
- table.sort(rE, function(a,b) return a.missinghp>b.missinghp end)
- end
-
- totalShipIntegrity = string.format("%2.0f", 100 / totalShipMaxHP * totalShipHP)
-
- if formerTotalShipHP ~= totalShipHP then
- forceDamageRedraw = true
- formerTotalShipHP = totalShipHP
- else
- forceDamageRedraw = false
- end
-end
-
-function GetHPforElement(id)
- for i,v in ipairs(brokenElements) do
- if v.id == id then
- return 0
- end
- end
- for i,v in ipairs(damagedElements) do
- if v.id == id then
- return v.hp
- end
- end
- for i,v in ipairs(healthyElements) do
- if v.id == id then
- return v.maxhp
- end
- end
-end
-
-function UpdateClickArea(candidate, newEntry, mode)
- for i, screen in ipairs(screens) do
- for k, v in pairs(screens[i].ClickAreas) do
- if v.id == candidate and v.mode == mode then
- screens[i].ClickAreas[k] = newEntry
- end
- end
- end
-end
-
-function AddClickArea(mode, newEntry)
- for i, screen in ipairs(screens) do
- if screens[i].mode == mode then
- table.insert(screens[i].ClickAreas, newEntry)
- end
- end
-end
-
-function AddClickAreaForScreenID(screenid, newEntry)
- for i, screen in ipairs(screens) do
- if screens[i].id == screenid then
- table.insert(screens[i].ClickAreas, newEntry)
- end
- end
-end
-
-function DisableClickArea(candidate, mode)
- UpdateClickArea(candidate, {
- id = candidate,
- mode = mode,
- x1 = -1,
- x2 = -1,
- y1 = -1,
- y2 = -1
- })
-end
-
-function SetRefresh(mode, submode)
- mode = mode or "all"
- submode = submode or "all"
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- if screens[i].mode == mode or mode == "all" then
- if screens[i].submode == submode or submode =="all" then
- screens[i].refresh = true
- end
- end
- end
- end
-end
-
-function WipeClickAreasForScreen(screen)
- screen.ClickAreas = {}
- return screen
-end
-
-function CreateBaseClickAreas(screen)
- table.insert(screen.ClickAreas, {mode = "all", id = "ToggleHudMode", x1 = 1537, x2 = 1728, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "damage", x1 = 193, x2 = 384, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "damageoutline", x1 = 385, x2 = 576, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "fuel", x1 = 577, x2 = 768, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "flight", x1 = 769, x2 = 960, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "cargo", x1 = 961, x2 = 1152, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "agg", x1 = 1153, x2 = 1344, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "map", x1 = 1345, x2 = 1536, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "time", x1 = 0, x2 = 192, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "settings1", x1 = 1729, x2 = 1920, y1 = 1015, y2 = 1075} )
- return screen
-end
-
-function CreateClickAreasForScreen(screen)
-
- if screen == nil then return {} end
-
- if screen.mode == "flight" then
- elseif screen.mode == "damage" then
- table.insert( screen.ClickAreas, {mode = "damage", id = "ToggleElementLabel", x1 = 70, x2 = 425, y1 = 325, y2 = 355} )
- table.insert( screen.ClickAreas, {mode = "damage", id = "ToggleElementLabel2", x1 = 980, x2 = 1400, y1 = 325, y2 = 355} )
- elseif screen.mode == "damageoutline" then
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeView", param = "top", x1 = 60, x2 = 439, y1 = 150, y2 = 200} )
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeView", param = "side", x1 = 440, x2 = 824, y1 = 150, y2 = 200} )
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeView", param = "front", x1 = 825, x2 = 1215, y1 = 150, y2 = 200} )
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeStretch", x1 = 1530, x2 = 1580, y1 = 150, y2 = 200} )
- elseif screen.mode == "fuel" then
- elseif screen.mode == "cargo" then
- elseif screen.mode == "agg" then
- elseif screen.mode == "map" then
- elseif screen.mode == "time" then
- elseif screen.mode == "settings1" then
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ToggleBackground", x1 = 75, x2 = 860, y1 = 170, y2 = 215} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "PreviousBackground", x1 = 75, x2 = 460, y1 = 235, y2 = 285} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "NextBackground", x1 = 480, x2 = 860, y1 = 235, y2 = 285} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "DecreaseOpacity", x1 = 75, x2 = 460, y1 = 300, y2 = 350} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "IncreaseOpacity", x1 = 480, x2 = 860, y1 = 300, y2 = 350} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ResetColors", x1 = 75, x2 = 860, y1 = 370, y2 = 415} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "PreviousColorID", x1 = 90, x2 = 140, y1 = 500, y2 = 550} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "NextColorID", x1 = 795, x2 = 845, y1 = 500, y2 = 550} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="1", x1 = 210, x2 = 290, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="2", x1 = 300, x2 = 380, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="3", x1 = 385, x2 = 465, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="4", x1 = 470, x2 = 550, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="5", x1 = 560, x2 = 640, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="6", x1 = 645, x2 = 725, y1 = 655, y2 = 700} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="1", x1 = 210, x2 = 290, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="2", x1 = 300, x2 = 380, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="3", x1 = 385, x2 = 465, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="4", x1 = 470, x2 = 550, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="5", x1 = 560, x2 = 640, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="6", x1 = 645, x2 = 725, y1 = 740, y2 = 780} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ResetPosColor", x1 = 160, x2 = 340, y1 = 885, y2 = 935} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ApplyPosColor", x1 = 355, x2 = 780, y1 = 885, y2 = 935} )
-
- elseif screen.mode == "startup" then
- end
-
- screen = CreateBaseClickAreas(screen)
-
- return screen
-end
-
-function CheckClick(x, y, HitTarget)
- x = x*1920
- y = y*1120
- HitTarget = HitTarget or ""
- HitPayload = {}
- -- PrintConsole("Clicked: "..x.." / "..y)
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- if screens[i].active == true and screens[i].element.getMouseX() ~= -1 and screens[i].element.getMouseY() ~= -1 then
- if HitTarget == "" then
- for k, v in pairs(screens[i].ClickAreas) do
- if v ~=nil and x >= v.x1 and x <= v.x2 and y >= v.y1 and y <= v.y2 then
- HitTarget = v.id
- HitPayload = v
- break
- end
- end
- end
- if HitTarget == "ButtonPress" then
- if screens[i].mode == HitPayload.param then
- screens[i].mode = "startup"
- else
- screens[i].mode = HitPayload.param
- end
-
- if screens[i].mode == "damageoutline" then
- if screens[i].submode == "" then
- screens[i].submode = "top"
- end
- end
- screens[i].refresh = true
- screens[i].ClickAreas = {}
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "ToggleBackground" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundMode == "" then
- BackgroundSelected = 1
- BackgroundMode = backgroundModes[BackgroundSelected]
- else
- BackgroundSelected = 1
- BackgroundMode = ""
- end
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "PreviousBackground" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundMode == "" then
- BackgroundSelected = 1
- BackgroundMode = backgroundModes[BackgroundSelected]
- else
- if BackgroundSelected <= 1 then
- BackgroundSelected = #backgroundModes
- else
- BackgroundSelected = BackgroundSelected - 1
- end
- BackgroundMode = backgroundModes[BackgroundSelected]
- end
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "NextBackground" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundMode == "" then
- BackgroundSelected = 1
- BackgroundMode = backgroundModes[BackgroundSelected]
- else
- if BackgroundSelected >= #backgroundModes then
- BackgroundSelected = 1
- else
- BackgroundSelected = BackgroundSelected + 1
- end
- BackgroundMode = backgroundModes[BackgroundSelected]
- end
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "DecreaseOpacity" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundModeOpacity>0.1 then
- BackgroundModeOpacity = BackgroundModeOpacity - 0.05
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- end
- elseif HitTarget == "IncreaseOpacity" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundModeOpacity<1.0 then
- BackgroundModeOpacity = BackgroundModeOpacity + 0.05
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- end
- elseif HitTarget == "ResetColors" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- db.clear()
- ColorPrimary = "FF6700"
- ColorSecondary = "FFFFFF"
- ColorTertiary = "000000"
- ColorHealthy = "00FF00"
- ColorWarning = "FFFF00"
- ColorCritical = "FF0000"
- ColorBackground = "000000"
- ColorBackgroundPattern = "4f4f4f"
- BackgroundMode = "deathstar"
- BackgroundSelected = 1
- BackgroundModeOpacity = 0.25
- colorIDTable = {
- [1] = {
- id="ColorPrimary",
- desc="Main HUD Color",
- basec = "FF6700",
- newc = "FF6700"
- },
- [2] = {
- id="ColorSecondary",
- desc="Secondary HUD Color",
- basec = "FFFFFF",
- newc = "FFFFFF"
- },
- [3] = {
- id="ColorTertiary",
- desc="Tertiary HUD Color",
- basec = "000000",
- newc = "000000"
- },
- [4] = {
- id="ColorHealthy",
- desc="Color code for Healthy/Okay",
- basec = "00FF00",
- newc = "00FF00"
- },
- [5] = {
- id="ColorWarning",
- desc="Color code for Damaged/Warning",
- basec = "FFFF00",
- newc = "FFFF00"
- },
- [6] = {
- id="ColorCritical",
- desc="Color code for Broken/Critical",
- basec = "FF0000",
- newc = "FF0000"
- },
- [7] = {
- id="ColorBackground",
- desc="Background Color",
- basec = "000000",
- newc = "000000"
- },
- [8] = {
- id="ColorBackgroundPattern",
- desc="Background Pattern Color",
- basec = "4F4F4F",
- newc = "4F4F4F"
- },
- [9] = {
- id="ColorFuelAtmospheric",
- desc="Color for Atmo Fuel/Elements",
- basec = "004444",
- newc = "004444"
- },
- [10] = {
- id="ColorFuelSpace",
- desc="Color for Space Fuel/Elements",
- basec = "444400",
- newc = "444400"
- },
- [11] = {
- id="ColorFuelRocket",
- desc="Color for Rocket Fuel/Elements",
- basec = "440044",
- newc = "440044"
- }
- }
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "PreviousColorID" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- colorIDIndex = colorIDIndex - 1
- if colorIDIndex < 1 then colorIDIndex = #colorIDTable end
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "NextColorID" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- colorIDIndex = colorIDIndex + 1
- if colorIDIndex > #colorIDTable then colorIDIndex = 1 end
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "ColorPosUp" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- local s = tonumber(string.sub(colorIDTable[colorIDIndex].newc, HitPayload.param, HitPayload.param),16)
- s = s + 1
- if s > 15 then s = 0 end
- colorIDTable[colorIDIndex].newc = replace_char(HitPayload.param, colorIDTable[colorIDIndex].newc, hexTable[s+1])
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "ColorPosDown" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- local s = tonumber(string.sub(colorIDTable[colorIDIndex].newc, HitPayload.param, HitPayload.param),16)
- s = s - 1
- if s < 0 then s = 15 end
- colorIDTable[colorIDIndex].newc = replace_char(HitPayload.param, colorIDTable[colorIDIndex].newc, hexTable[s+1])
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "ResetPosColor" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- colorIDTable[colorIDIndex].newc = colorIDTable[colorIDIndex].basec
- _G[colorIDTable[colorIDIndex].id] = colorIDTable[colorIDIndex].basec
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "ApplyPosColor" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- _G[colorIDTable[colorIDIndex].id] = colorIDTable[colorIDIndex].newc
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "DamagedPageDown" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentDamagedPage = CurrentDamagedPage + 1
- if CurrentDamagedPage > math.ceil(#damagedElements / DamagePageSize) then
- CurrentDamagedPage = math.ceil(#damagedElements / DamagePageSize)
- end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "DamagedPageUp" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentDamagedPage = CurrentDamagedPage - 1
- if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "BrokenPageDown" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentBrokenPage = CurrentBrokenPage + 1
- if CurrentBrokenPage > math.ceil(#brokenElements / DamagePageSize) then
- CurrentBrokenPage = math.ceil(#brokenElements / DamagePageSize)
- end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "BrokenPageUp" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentBrokenPage = CurrentBrokenPage - 1
- if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "DMGOChangeView" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- screens[i].submode = HitPayload.param
- UpdateViewDamageoutline(screens[i])
- SaveToDatabank()
- SetRefresh("damageoutline", screens[i].submode)
- RenderScreens("damageoutline", screens[i].submode)
- elseif HitTarget == "DMGOChangeStretch" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if DMGOStretch == true then
- DMGOStretch = false
- else
- DMGOStretch = true
- end
- UpdateViewDamageoutline(screens[i])
- SaveToDatabank()
- SetRefresh("damageoutline")
- RenderScreens("damageoutline")
- elseif HitTarget == "ToggleDisplayAtmosphere" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if screens[i].fuelA == true then
- screens[i].fuelA = false
- else
- screens[i].fuelA = true
- end
- screens[i].fuelIndex = 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "ToggleDisplaySpace" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if screens[i].fuelS == true then
- screens[i].fuelS = false
- else
- screens[i].fuelS = true
- end
- screens[i].fuelIndex = 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "ToggleDisplayRocket" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if screens[i].fuelR == true then
- screens[i].fuelR = false
- else
- screens[i].fuelR = true
- end
- screens[i].fuelIndex = 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "DecreaseFuelIndex" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- screens[i].fuelIndex = screens[i].fuelIndex - 1
- if screens[i].fuelIndex < 1 then screens[i].fuelIndex = 1 end
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "IncreaseFuelIndex" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- screens[i].fuelIndex = screens[i].fuelIndex + 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "ToggleHudMode" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if HUDMode == true then
- HUDMode = false
- forceDamageRedraw = true
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- else
- HUDMode = true
- forceDamageRedraw = true
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- end
- elseif HitTarget == "ToggleSimulation" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentDamagedPage = 1
- CurrentBrokenPage = 1
- if SimulationMode == true then
- SimulationMode = false
- SimulationActive = false
- UpdateDamageData()
- UpdateTypeData()
- forceDamageRedraw = true
- HudDeselectElement()
- SetRefresh("damage")
- SetRefresh("damageoutline")
- SetRefresh("settings1")
- SetRefresh("fuel")
- SaveToDatabank()
- RenderScreens()
- else
- SimulationMode = true
- SimulationActive = false
- UpdateDamageData()
- UpdateTypeData()
- forceDamageRedraw = true
- HudDeselectElement()
- SetRefresh("damage")
- SetRefresh("damageoutline")
- SetRefresh("settings1")
- SetRefresh("fuel")
- SaveToDatabank()
- RenderScreens()
- end
- elseif (HitTarget == "ToggleElementLabel" or HitTarget == "ToggleElementLabel2") and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if UseMyElementNames == true then
- UseMyElementNames = false
- SetRefresh("damage")
- RenderScreens("damage")
- else
- UseMyElementNames = true
- SetRefresh("damage")
- RenderScreens("damage")
- end
- elseif (HitTarget == "SwitchScrapTier" or HitTarget == "SwitchScrapTier2") and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- ScrapTier = ScrapTier + 1
- if ScrapTier > 4 then ScrapTier = 1 end
- SetRefresh("damage")
- RenderScreens("damage")
- end
-
-
- end
- end
- end
-end
-
---[[ 4. RENDERING FUNCTIONS ]]
-
-function GetContentFlight()
- local output = ""
- output = output .. GetHeader("Flight Data Report") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentDamage()
- local output = ""
- if SimulationMode == true then
- output = output .. GetHeader("Damage Report (Simulated damage)") .. [[]]
- else
- output = output .. GetHeader("Damage Report") .. [[]]
- end
- output = output .. GetContentDamageScreen()
- return output
-end
-
-function GetContentDamageoutline(screen)
- UpdateDataDamageoutline()
- UpdateViewDamageoutline(screen)
- local output = ""
- output = output .. GetHeader("Damage Ship Outline Report") ..
- GetDamageoutlineShip() ..
- [[]]
-
- if screen.submode=="top" then
- output = output ..
- [[
-
- Top View
-
- Side View
-
- Front View
- ]]
- elseif screen.submode=="side" then
- output = output ..
- [[
-
- Top View
-
- Side View
-
- Front View
- ]]
- elseif screen.submode=="front" then
- output = output ..
- [[
-
- Top View
-
- Side View
-
- Front View
- ]]
- else
- end
- output = output .. [[]]..#dmgoElements..[[ of ]]..ElementCounter..[[ shown]]
- output = output .. [[]]
- if DMGOStretch == true then
- output = output .. [[]]
- end
- output = output .. [[Stretch both axis]]
- return output
-end
-
-function GetContentFuel(screen)
-
- if #FuelAtmosphericTanks < 1 and #FuelSpaceTanks < 1 and #FuelRocketTanks < 1 then return "" end
-
- local FuelTypes = 0
- local output = ""
- local addHeadline = {}
-
- FuelDisplay = { screen.fuelA, screen.fuelS, screen.fuelR }
-
- if FuelDisplay[1] == true and #FuelAtmosphericTanks > 0 then
- table.insert(addHeadline, "Atmospheric")
- FuelTypes = FuelTypes + 1
- end
- if FuelDisplay[2] == true and #FuelSpaceTanks > 0 then
- table.insert(addHeadline, "Space")
- FuelTypes = FuelTypes + 1
- end
- if FuelDisplay[3] == true and #FuelRocketTanks > 0 then
- table.insert(addHeadline, "Rocket")
- FuelTypes = FuelTypes + 1
- end
-
- output = output .. GetHeader("Fuel Report ("..table.concat(addHeadline, ", ")..")") ..
- [[
- ]]
-
- local totalH = 150
- local counter = 0
- local tOffset = 0
-
- if FuelDisplay[1] == true and #FuelAtmosphericTanks > 0 then
-
- if FuelTypes == 1 then tOffset = 50
- elseif FuelTypes == 2 then tOffset = 6
- elseif FuelTypes == 3 then tOffset = 0
- end
-
- output = output .. [[
-
-
-
- ]]
-
- output = output ..
- [[]]..
- GenerateCommaValue(FuelAtmosphericCurrent, true)..
- [[ of ]]..GenerateCommaValue(FuelAtmosphericTotal, true)..
- [[ | Total Atmospheric Fuel in ]]..#FuelAtmosphericTanks..[[ tank]]..(#FuelAtmosphericTanks==1 and "" or "s")..[[ (]]..math.floor(100/FuelAtmosphericTotal*FuelAtmosphericCurrent)..[[%)]]
- counter = counter + 1
- end
-
- if FuelDisplay[2] == true and #FuelSpaceTanks > 0 then
-
- if FuelTypes == 1 then tOffset = 50
- elseif FuelTypes == 2 then tOffset = 6
- elseif FuelTypes == 3 then tOffset = 0
- end
-
- output = output .. [[
-
-
-
- ]]
-
- output = output ..
- [[]]..
- GenerateCommaValue(FuelSpaceCurrent, true)..
- [[ of ]]..GenerateCommaValue(FuelSpaceTotal, true)..
- [[ | Total Space Fuel in ]]..#FuelSpaceTanks..[[ tank]]..(#FuelSpaceTanks==1 and "" or "s")..[[ (]]..math.floor(100/FuelSpaceTotal*FuelSpaceCurrent)..[[%)]]
- counter = counter + 1
- end
-
- if FuelDisplay[3] == true and #FuelRocketTanks > 0 then
-
- if FuelTypes == 1 then tOffset = 50
- elseif FuelTypes == 2 then tOffset = 6
- elseif FuelTypes == 3 then tOffset = 0
- end
-
- output = output .. [[
-
-
-
- ]]
-
- output = output ..
- [[]]..
- GenerateCommaValue(FuelRocketCurrent, true)..
- [[ of ]]..GenerateCommaValue(FuelRocketTotal, true)..
- [[ | Total Rocket Fuel in ]]..#FuelRocketTanks..[[ tank]]..(#FuelRocketTanks==1 and "" or "s")..[[ (]]..math.floor(100/FuelRocketTotal*FuelRocketCurrent)..[[%)]]
- end
-
- output = output .. [[
-
-
-
- ]]
-
- local DisplayTable = {}
- if screen.fuelIndex == nil or screen.fuelIndex < 1 then
- screen.fuelIndex = 1
- end
-
- if FuelDisplay[1] == true then
- for _,v in ipairs(FuelAtmosphericTanks) do
- table.insert(DisplayTable, v)
- end
- end
- if FuelDisplay[2] == true then
- for _,v in ipairs(FuelSpaceTanks) do
- table.insert(DisplayTable, v)
- end
- end
- if FuelDisplay[3] == true then
- for _,v in ipairs(FuelRocketTanks) do
- table.insert(DisplayTable, v)
- end
- end
-
- table.sort(DisplayTable, function(a,b) return a.type
-
-
- ]]
- if tank.hp == 0 then
- output = output .. [[]]
- elseif tank.maxhp - tank.hp > constants.epsilon then
- output = output .. [[]]
- else
- output = output .. [[]]
- end
- if tank.hp == 0 then output = output .. [[]]..tank.size..[[]]
- else output = output .. [[]]..tank.size..[[]]
- end
-
- if tank.hp == 0 then
- output = output .. [[Broken]] ..
- [[0 of ]]..GenerateCommaValue(tank.vol)..[[]]
- elseif tonumber(tank.percent) < 10 then
- output = output .. [[]]..tank.percent..[[%]] ..
- [[]]..GenerateCommaValue(tank.cvol)..[[ of ]]..GenerateCommaValue(tank.vol)..[[]]
- elseif tonumber(tank.percent) < 30 then
- output = output .. [[]]..tank.percent..[[%]] ..
- [[]]..GenerateCommaValue(tank.cvol)..[[ of ]]..GenerateCommaValue(tank.vol)..[[]]
- else output =
- output .. [[]]..tank.percent..[[%]] ..
- [[]]..GenerateCommaValue(tank.cvol)..[[ of ]]..GenerateCommaValue(tank.vol)..[[]]
- end
-
- output = output ..[[]]..tank.name..[[]]
-
- output = output .. [[]]
-
- end
- end
-
-
-
- if #FuelAtmosphericTanks > 0 then
- output = output .. [[]]
- if FuelDisplay[1] == true then
- output = output .. [[]]
- end
- output = output .. [[ATM]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "ToggleDisplayAtmosphere", x1 = 50, x2 = 100, y1 = 270, y2 = 320} )
- end
-
- if #FuelSpaceTanks > 0 then
- output = output .. [[]]
- if FuelDisplay[2] == true then
- output = output .. [[]]
- end
- output = output .. [[SPC]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "ToggleDisplaySpace", x1 = 200, x2 = 250, y1 = 270, y2 = 320} )
- end
-
- if #FuelRocketTanks > 0 then
- output = output .. [[]]
- if FuelDisplay[3] == true then
- output = output .. [[]]
- end
- output = output .. [[RKT]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "ToggleDisplayRocket", x1 = 350, x2 = 400, y1 = 270, y2 = 320} )
- end
-
- if screen.fuelIndex > 1 then
- output = output .. [[
-
-
- ]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "DecreaseFuelIndex", x1 = 1470, x2 = 1670, y1 = 270, y2 = 320} )
- end
-
- if screen.fuelIndex+cCounter-1 < #DisplayTable then
- output = output .. [[
-
-
- ]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "IncreaseFuelIndex", x1 = 1680, x2 = 1880, y1 = 270, y2 = 320} )
- end
-
- if cCounter > 0 then
- output = output .. [[]]..
- #DisplayTable..
- [[ Tank]]..(#DisplayTable == 1 and "" or "s")..
- [[ (Showing ]]..screen.fuelIndex..[[ to ]]..(screen.fuelIndex+cCounter-1)..[[)]]
- end
-
- return output
-end
-
-function GetContentCargo()
- local output = ""
- output = output .. GetHeader("Cargo Report") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentAGG()
- local output = ""
- output = output .. GetHeader("Anti-Grav Control") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentMap()
- local output = ""
- output = output .. GetHeader("Map Overview") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentTime()
- local output = ""
- output = output .. GetHeader("Time") .. epochTime()
- output = output ..
- [[
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetContentSettings1()
- local output = ""
- output = output .. GetHeader("Settings") .. [[]]
- if BackgroundMode=="" then
- output = output ..[[Activate background]]
- else
- output = output ..[[Deactivate background (']]..BackgroundMode..[[', ]]..string.format("%.0f",BackgroundModeOpacity*100)..[[%)]]
- end
- output = output ..[[
-
- Previous background
-
- Next background
-
-
- Decrease Opacity
-
- Increase Opacity
- ]]
-
- output = output ..
- [[]] ..
- [[Reset background and all colors]]
-
- output = output ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Select and change any of the ]]..#colorIDTable..[[ HUD colors]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]]..colorIDTable[colorIDIndex].desc..[[]] ..
- [[]] ..
- [[Current color]] ..
- [[]] ..
-
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
-
- [[#]] ..
-
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,1,1)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,2,2)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,3,3)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,4,4)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,5,5)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,6,6)..[[]] ..
-
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
-
- [[]] ..
- [[]] ..
- [[New color]] ..
- [[]] ..
- [[Apply new color]] ..
- [[]] ..
- [[Reset]] ..
- [[]]
-
- output = output ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Explanation / Hints]] ..
- [[Coming soon.]]
-
-
- output = output .. [[]]
-
- if SimulationMode == true then
- output = output .. [[Simulating Damage to elements]]
- AddClickArea("settings1", { id = "ToggleSimulation", mode ="settings1", x1 = 940, x2 = 1850, y1 = 919, y2 = 969 })
- else
- output = output .. [[Simulate Damage to elements]]
- AddClickArea("settings1", { id = "ToggleSimulation", mode ="settings1", x1 = 940, x2 = 1850, y1 = 919, y2 = 969 })
- end
-
- return output
-end
-
-function GetContentStartup()
- local output = ""
- output = output .. GetElementLogo(812, 380, "f", "f", "f")
- if YourShipsName == "Enter here" then
- output = output .. [[Spaceship ID ]]..ShipID..[[]]
- else
- output = output .. [[]]..YourShipsName..[[]]
- end
- if ShowWelcomeMessage == true then output = output .. [[Greetings, Commander ]]..PlayerName..[[.]] end
- if #Warnings > 0 then
- output = output .. [[Warning: ]]..(table.concat(Warnings, " "))..[[]]
- end
- output = output .. [[Damage Report v]]..VERSION..[[, by Scion Interstellar, DorianGray - Discord: Dorian Gray#2623. Under GNU Public License 3.0.]]
- return output
-end
-
-function RenderScreen(screen, contentToRender)
- if contentToRender == nil then
- PrintConsole("ERROR: contentToRender is nil.")
- unit.exit()
- end
-
- CreateClickAreasForScreen(screen)
-
- local output =""
- output = output .. [[
-
-
- ]]
-
- output = output .. contentToRender
-
- if screen.mode == "startup" then
- output = output .. [[]]
- else
- output = output .. [[]]
- end
-
- output = output .. [[
-
- ]]
- output = output .. [[]]
-
- -- Center:
-
- --
- --
- --
- --
-
- local outputLength = string.len(output)
- -- PrintConsole("Render: "..screen.mode.." ("..outputLength.." chars)")
- screen.element.setSVG(output)
-end
-
-function RenderScreens(onlymode, onlysubmode)
-
- onlymode = onlymode or "all"
- onlysubmode = onlysubmode or "all"
-
- if screens ~= nil and #screens > 0 then
-
- local contentFlight = ""
- local contentDamage = ""
- local contentDamageoutlineTop = ""
- local contentDamageoutlineSide = ""
- local contentDamageoutlineFront = ""
- local contentFuel = ""
- local contentCargo = ""
- local contentAGG = ""
- local contentMap = ""
- local contentTime = ""
- local contentSettings1 = ""
- local contentStartup = ""
-
- for k,screen in pairs(screens) do
- if screen.refresh == true then
- local contentToRender = ""
-
- if screen.mode == "flight" and (onlymode =="flight" or onlymode =="all") then
- if contentFlight == "" then contentFlight = GetContentFlight() end
- contentToRender = contentFlight
- elseif screen.mode == "damage" and (onlymode =="damage" or onlymode =="all") then
- if contentDamage == "" then contentDamage = GetContentDamage() end
- contentToRender = contentDamage
- elseif screen.mode == "damageoutline" and (onlymode =="damageoutline" or onlymode =="all") then
- if screen.submode == "" then
- screen.submode = "top"
- screens[k].submode = "top"
- end
- if screen.submode == "top" and (onlysubmode == "top" or onlysubmode == "all") then
- if contentDamageoutlineTop == "" then contentDamageoutlineTop = GetContentDamageoutline(screen) end
- contentToRender = contentDamageoutlineTop
- end
- if screen.submode == "side" and (onlysubmode == "side" or onlysubmode == "all") then
- if contentDamageoutlineSide == "" then contentDamageoutlineSide = GetContentDamageoutline(screen) end
- contentToRender = contentDamageoutlineSide
- end
- if screen.submode == "front" and (onlysubmode == "front" or onlysubmode == "all") then
- if contentDamageoutlineFront == "" then contentDamageoutlineFront = GetContentDamageoutline(screen) end
- contentToRender = contentDamageoutlineFront
- end
- elseif screen.mode == "fuel" and (onlymode =="fuel" or onlymode =="all") then
- screen = WipeClickAreasForScreen(screens[k])
- contentToRender = GetContentFuel(screen)
- elseif screen.mode == "cargo" and (onlymode =="cargo" or onlymode =="all") then
- if contentCargo == "" then contentCargo = GetContentCargo() end
- contentToRender = contentCargo
- elseif screen.mode == "agg" and (onlymode =="agg" or onlymode =="all") then
- if contentAGG == "" then contentAGG = GetContentAGG() end
- contentToRender = contentAGG
- elseif screen.mode == "map" and (onlymode =="map" or onlymode =="all") then
- if contentMap == "" then contentMap = GetContentMap() end
- contentToRender = contentMap
- elseif screen.mode == "time" and (onlymode =="time" or onlymode =="all") then
- if contentTime == "" then contentTime = GetContentTime() end
- contentToRender = contentTime
- elseif screen.mode == "settings1" and (onlymode =="settings1" or onlymode =="all") then
- if contentSettings1 == "" then contentSettings1 = GetContentSettings1() end
- contentToRender = contentSettings1
- elseif screen.mode == "startup" and (onlymode =="startup" or onlymode =="all") then
- if contentStartup == "" then contentStartup = GetContentStartup() end
- contentToRender = contentStartup
- else
- contentToRender = "Invalid screen mode. ('"..screen.mode.."')"
- end
-
- if contentToRender ~= "" then
- RenderScreen(screen, contentToRender)
- else
- DrawCenteredText("ERROR: No contentToRender delivered for "..screen.mode)
- PrintConsole("ERROR: No contentToRender delivered for "..screen.mode)
- unit.exit()
- end
- screens[k].refresh = false
- end
- end
- end
-
- if HUDMode == true then
- system.setScreen(GetContentDamageHUDOutput())
- system.showScreen(1)
- else
- system.showScreen(0)
- end
-
-end
-
-function OnTickData(initial)
- if formerTime + 60 < system.getTime() then
- SetRefresh("time")
- end
- totalShipMass = core.getConstructMass()
- if formerTotalShipMass ~= totalShipMass then
- UpdateDamageData(true)
- UpdateTypeData()
- SetRefresh()
- formerTotalShipMass = totalShipMass
- else
- UpdateDamageData(initial)
- UpdateTypeData()
- end
- RenderScreens()
-end
-
---[[ 5. EXECUTION ]]
-
-unit.hide()
-ClearConsole()
-PrintConsole("DAMAGE REPORT v"..VERSION.." STARTED", true)
-InitiateSlots()
-LoadFromDatabank()
-SwitchScreens("on")
-InitiateScreens()
-
-if core == nil then
- PrintConsole("ERROR: Connect the core to the programming board.")
- unit.exit()
-else
- OperatorID = unit.getMasterPlayerId()
- OperatorData = database.getPlayer(OperatorID)
- PlayerName = OperatorData["name"]
- ShipID = core.getConstructId()
-end
-
-if db == nil then
- table.insert(Warnings, "No databank connected, won't save/load settings.")
-end
-
-if YourShipsName == "Enter here" then
- table.insert(Warnings, "No ship name set in LUA settings.")
-end
-
-if SkillRepairToolEfficiency == 0 and SkillRepairToolOptimization == 0 and StatFuelTankOptimization == 0 and StatContainerOptimization ==0 and
- StatAtmosphericFuelTankHandling == 0 and StatSpaceFuelTankHandling == 0 and StatRocketFuelTankHandling ==0 then
- table.insert(Warnings, "No talents/stats set in LUA settings.")
-end
-
-if SkillRepairToolEfficiency < 0 or SkillRepairToolOptimization < 0 or StatFuelTankOptimization < 0 or StatContainerOptimization < 0 or
- StatAtmosphericFuelTankHandling < 0 or StatSpaceFuelTankHandling < 0 or StatRocketFuelTankHandling < 0 or
- SkillRepairToolEfficiency > 5 or SkillRepairToolOptimization > 5 or StatFuelTankOptimization > 5 or StatContainerOptimization > 5 or
- StatAtmosphericFuelTankHandling > 5 or StatSpaceFuelTankHandling > 5 or StatRocketFuelTankHandling > 5 then
- PrintConsole("ERROR: Talents/stats can only range from 0 to 5. Please set correctly in LUA settings and reactivate script.")
- unit.exit()
-end
-
-if screens == nil or #screens == 0 then
- HUDMode = true
- PrintConsole("Warning: No screens connected. Entering HUD mode only.")
-end
-
-OnTickData(true)
-
-unit.setTimer('UpdateData', UpdateDataInterval)
-unit.setTimer('UpdateHighlight', HighlightBlinkingInterval)
\ No newline at end of file
diff --git a/src/DamageReport_3_11_UnitStart_1.lua b/src/DamageReport_3_11_UnitStart_1.lua
deleted file mode 100644
index 9e9cb12..0000000
--- a/src/DamageReport_3_11_UnitStart_1.lua
+++ /dev/null
@@ -1,1277 +0,0 @@
---[[
- Damage Report 3.11
- A LUA script for Dual Universe
-
- Created By Dorian Gray
- Ingame: DorianGray
- Discord: Dorian Gray#2623
-
- You can find/update this script on GitHub. Explanations, installation and usage information as well as screenshots can be found there too.
- GitHub: https://github.com/DorianTheGrey/DU-DamageReport
-
- GNU Public License 3.0. Use whatever you want, be so kind to leave credit.
-
- Credits & thanks:
- Thanks to NovaQuark for creating the MMO of the century.
- Thanks to Jericho, Dmentia and Archaegeo for learning a lot from their fine scripts.
- Thanks to TheBlacklist for testing and wonderful suggestions.
- SVG patterns by Hero Patterns.
- DU atlas data from Jayle Break.
-
-]]
-
---[[ 1. HELPER FUNCTIONS ]]
-
-function GenerateCommaValue(amount, kify, postcomma)
- kify = kify or false
- postcomma = postcomma or 1
- local formatted = amount
- if kify == true then
- if string.len(amount)>=4 then
- formatted = string.format("%."..postcomma.."fk", amount/1000)
- else
- formatted = string.format("%."..postcomma.."f", amount)
- end
- else
- while true do
- formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
- if (k == 0) then break end
- end
- end
- return formatted
-end
-
-function PrintConsole(output, highlight)
- highlight = highlight or false
- if highlight then
- system.print(
- "------------------------------------------------------------------------")
- end
- system.print(output)
- if highlight then
- system.print(
- "------------------------------------------------------------------------")
- end
-end
-
-function DrawCenteredText(output)
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- screens[i].element.setCenteredText(output)
- end
- end
-end
-
-function ClearConsole()
- for i = 1, 10, 1 do
- PrintConsole()
- end
-end
-
-function SwitchScreens(state)
- state = state or "on"
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- if state == "on" then
- screens[i].element.clear()
- screens[i].element.activate()
- screens[i].active = true
- else
- screens[i].element.clear()
- screens[i].element.deactivate()
- screens[i].active = false
- end
- end
- end
-end
-
---[[ Convert seconds to string (by Jericho) ]]
-function GetSecondsString(seconds)
- local seconds = tonumber(seconds)
-
- if seconds == nil or seconds <= 0 then
- return "-";
- else
- days = string.format("%2.f", math.floor(seconds/(3600*24)));
- hours = string.format("%2.f", math.floor(seconds/3600 - (days*24)));
- mins = string.format("%2.f", math.floor(seconds/60 - (hours*60) - (days*24*60)));
- secs = string.format("%2.f", math.floor(seconds - hours*3600 - (days*24*60*60) - mins *60));
- str = ""
- if tonumber(days) > 0 then str = str .. days.."d " end
- if tonumber(hours) > 0 then str = str .. hours.."h " end
- if tonumber(mins) > 0 then str = str .. mins.."m " end
- if tonumber(secs) > 0 then str = str .. secs .."s" end
- return str
- end
-end
-
-function replace_char(pos, str, r)
- return str:sub(1, pos-1) .. r .. str:sub(pos+1)
-end
-
---[[ 2. RENDER HELPER FUNCTIONS ]]
-
---[[ epochTime function by Leodr (clock script), enhanced by Jericho (DU Industry script) ]]
-function epochTime()
- function rZ(a)
- if string.len(a) <= 1 then
- return "0" .. a
- else
- return a
- end
- end
- function dPoint(b)
- if not (b == math.floor(b)) then
- return true
- else
- return false
- end
- end
- function lYear(year)
- if not dPoint(year / 4) then
- if dPoint(year / 100) then
- return true
- else
- if not dPoint(year / 400) then
- return true
- else
- return false
- end
- end
- else
- return false
- end
- end
- local c = 5;
- local d = 3600;
- local e = 86400;
- local f = 31536000;
- local g = 31622400;
- local h = 2419200;
- local i = 2505600;
- local j = 2592000;
- local k = 2678400;
- local l = {4, 6, 9, 11}
- local m = {1, 3, 5, 7, 8, 10, 12}
- local n = 0;
- local o = 1506816000;
- local q = system.getTime()
- _G["formerTime"] = q
- if AddSummertimeHour == true then q = q + 3600 end
- now = math.floor(q + o)
- year = 1970;
- secs = 0;
- n = 0;
- while secs + g < now or secs + f < now do
- if lYear(year + 1) then
- if secs + g < now then
- secs = secs + g;
- year = year + 1;
- n = n + 366
- end
- else
- if secs + f < now then
- secs = secs + f;
- year = year + 1;
- n = n + 365
- end
- end
- end
- secondsRemaining = now - secs;
- monthSecs = 0;
- yearlYear = lYear(year)
- month = 1;
- while monthSecs + h < secondsRemaining or monthSecs + j < secondsRemaining or
- monthSecs + k < secondsRemaining do
- if month == 1 then
- if monthSecs + k < secondsRemaining then
- month = 2;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 2 then
- if not yearlYear then
- if monthSecs + h < secondsRemaining then
- month = 3;
- monthSecs = monthSecs + h;
- n = n + 28
- else
- break
- end
- else
- if monthSecs + i < secondsRemaining then
- month = 3;
- monthSecs = monthSecs + i;
- n = n + 29
- else
- break
- end
- end
- end
- if month == 3 then
- if monthSecs + k < secondsRemaining then
- month = 4;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 4 then
- if monthSecs + j < secondsRemaining then
- month = 5;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- if month == 5 then
- if monthSecs + k < secondsRemaining then
- month = 6;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 6 then
- if monthSecs + j < secondsRemaining then
- month = 7;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- if month == 7 then
- if monthSecs + k < secondsRemaining then
- month = 8;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 8 then
- if monthSecs + k < secondsRemaining then
- month = 9;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 9 then
- if monthSecs + j < secondsRemaining then
- month = 10;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- if month == 10 then
- if monthSecs + k < secondsRemaining then
- month = 11;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 11 then
- if monthSecs + j < secondsRemaining then
- month = 12;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- end
- day = 1;
- daySecs = 0;
- daySecsRemaining = secondsRemaining - monthSecs;
- while daySecs + e < daySecsRemaining do
- day = day + 1;
- daySecs = daySecs + e;
- n = n + 1
- end
- hour = 0;
- hourSecs = 0;
- hourSecsRemaining = daySecsRemaining - daySecs;
- while hourSecs + d < hourSecsRemaining do
- hour = hour + 1;
- hourSecs = hourSecs + d
- end
- minute = 0;
- minuteSecs = 0;
- minuteSecsRemaining = hourSecsRemaining - hourSecs;
- while minuteSecs + 60 < minuteSecsRemaining do
- minute = minute + 1;
- minuteSecs = minuteSecs + 60
- end
- second = math.floor(now % 60)
- year = rZ(year)
- month = rZ(month)
- day = rZ(day)
- hour = rZ(hour)
- minute = rZ(minute)
- second = rZ(second)
-
- return [[]]..hour..":".. minute..[[]]..
- [[]]..year.."/".. month.."/"..day..[[]]
-end
-
-
-function ToggleHUD()
- if HUDMode == true then
- HUDMode = false
- forceDamageRedraw = true
- hudSelectedIndex = 0
- highlightID = 0
- HideHighlight()
- SetRefresh()
- RenderScreens()
- else
- HUDMode = true
- forceDamageRedraw = true
- hudSelectedIndex = 0
- highlightID = 0
- HideHighlight()
- SetRefresh()
- RenderScreens()
- end
-end
-
-function HudDeselectElement()
- hudSelectedIndex = 0
- hudStartIndex = 1
- highlightID = 0
- HideHighlight()
- if HUDMode == true then
- SetRefresh("damage")
- SetRefresh("damageoutline")
- RenderScreens()
- end
-end
-
-function ChangeHudSelectedElement(step)
- if HUDMode == true and #rE > 0 then
-
- hudSelectedIndex = hudSelectedIndex + step
- if hudSelectedIndex < 1 then hudSelectedIndex = 1
- elseif hudSelectedIndex > #rE then hudSelectedIndex = #rE
- end
-
- if hudSelectedIndex > 9 then
- hudStartIndex = hudSelectedIndex-9
- end
- if hudSelectedIndex ~= 0 then
- highlightID = rE[hudSelectedIndex].id
- if highlightID ~=nil and highlightID ~= 0 then
- -- PrintConsole("CHSE: hudSelectedIndex: "..hudSelectedIndex.." / hudStartIndex: "..hudStartIndex.." / highlightID: "..highlightID)
- HideHighlight()
- elementPosition = vec3(rE[hudSelectedIndex].pos)
- highlightX = elementPosition.x - coreWorldOffset
- highlightY = elementPosition.y - coreWorldOffset
- highlightZ = elementPosition.z - coreWorldOffset
- highlightOn = true
- ShowHighlight()
- end
- end
-
- SetRefresh("damage")
- SetRefresh("damageoutline")
- RenderScreens()
-
- end
-end
-
-function HideHighlight()
- if #hudArrowSticker > 0 then
- for i in pairs(hudArrowSticker) do
- core.deleteSticker(hudArrowSticker[i])
- end
- hudArrowSticker = {}
- end
-end
-
-function ShowHighlight()
- if highlightOn == true and highlightID > 0 then
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX + 2, highlightY, highlightZ, "north"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY - 2, highlightZ, "east"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX - 2, highlightY, highlightZ, "south"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY + 2, highlightZ, "west"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY, highlightZ - 2, "up"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY, highlightZ + 2,"down"))
- end
-end
-
-function ToggleHighlight()
- if highlightOn == true then
- highlightOn = false
- HideHighlight()
- else
- highlightOn = true
- ShowHighlight()
- end
-end
-
-function SortDamageTables()
- table.sort(damagedElements, function(a, b) return a.missinghp > b.missinghp end)
- table.sort(brokenElements, function(a, b) return a.maxhp > b.maxhp end)
-end
-
-function getScraps(damage,commaval)
- commaval = commaval or false
- damage = damage - SkillRepairToolOptimization * 0.05 * damage
- local res = math.ceil( damage / ( 10 * 5^(ScrapTier-1) ) )
- if commaval ==true then
- return GenerateCommaValue(string.format("%.0f", res ), false)
- else
- return res
- end
-end
-
-function getRepairTime(damage,buildstring)
- buildstring = buildstring or false
- damage = damage - SkillRepairToolOptimization * 0.05 * damage
- local res = math.ceil(damage / ScrapTierRepairTimes[ScrapTier])
- res = res - ( SkillRepairToolEfficiency * 0.1 * res )
- if buildstring == true then
- return GetSecondsString(string.format("%.0f", res ) )
- else
- return res
- end
-end
-
-function UpdateDataDamageoutline()
-
- dmgoElements = {}
-
- for i,element in ipairs(brokenElements) do
- if #dmgoElements < DMGOMaxElements then
- local elementPosition = vec3(element.pos)
- local x = elementPosition.x - coreWorldOffset
- local y = elementPosition.y - coreWorldOffset
- local z = elementPosition.z - coreWorldOffset
- if x < ShipXmin then ShipXmin = x end
- if y < ShipYmin then ShipYmin = y end
- if z < ShipZmin then ShipZmin = z end
- if x > ShipXmax then ShipXmax = x end
- if y > ShipYmax then ShipYmax = y end
- if z > ShipZmax then ShipZmax = z end
- table.insert( dmgoElements, {
- id = element.id,
- type = "b",
- size = element.maxhp,
- x = x, y = y, z = z,
- xp = 0, yp = 0, zp = 0,
- u = 0, v = 0
- })
- end
- end
-
- if #dmgoElements < DMGOMaxElements then
- for i,element in ipairs(damagedElements) do
- if #dmgoElements < DMGOMaxElements then
- local elementPosition = vec3(element.pos)
- local x = elementPosition.x - coreWorldOffset
- local y = elementPosition.y - coreWorldOffset
- local z = elementPosition.z - coreWorldOffset
- if x < ShipXmin then ShipXmin = x end
- if y < ShipYmin then ShipYmin = y end
- if z < ShipZmin then ShipZmin = z end
- if x > ShipXmax then ShipXmax = x end
- if y > ShipYmax then ShipYmax = y end
- if z > ShipZmax then ShipZmax = z end
- table.insert( dmgoElements, {
- id = element.id,
- type = "d",
- size = element.maxhp,
- x = x, y = y, z = z,
- xp = 0, yp = 0, zp = 0,
- u = 0, v = 0
- })
- end
- end
- end
-
- if #dmgoElements < DMGOMaxElements then
- for i,element in ipairs(healthyElements) do
- if #dmgoElements < DMGOMaxElements then
- local elementPosition = vec3(element.pos)
- local x = elementPosition.x - coreWorldOffset
- local y = elementPosition.y - coreWorldOffset
- local z = elementPosition.z - coreWorldOffset
- if x < ShipXmin then ShipXmin = x end
- if y < ShipYmin then ShipYmin = y end
- if z < ShipZmin then ShipZmin = z end
- if x > ShipXmax then ShipXmax = x end
- if y > ShipYmax then ShipYmax = y end
- if z > ShipZmax then ShipZmax = z end
- table.insert( dmgoElements, {
- id = element.id,
- type = "h",
- size = element.maxhp,
- x = x, y = y, z = z,
- xp = 0, yp = 0, zp = 0,
- u = 0, v = 0
- })
- end
- end
- end
-
- ShipX = math.abs(ShipXmax-ShipXmin)
- ShipY = math.abs(ShipYmax-ShipYmin)
- ShipZ = math.abs(ShipZmax-ShipZmin)
-
- --[[
- PrintConsole(
- "ShipXmin: "..string.format("%.2f",ShipXmin)..
- " - ShipYmin: "..string.format("%.2f",ShipYmin)..
- " - ShipZmin: "..string.format("%.2f",ShipZmin)..
- " - ShipXmax: "..string.format("%.2f",ShipXmax)..
- " - ShipYmax: "..string.format("%.2f",ShipYmax)..
- " - ShipZmax: "..string.format("%.2f",ShipZmax)
- )
-
- PrintConsole(
- "ShipX: "..string.format("%.2f",ShipX)..
- " - ShipY: "..string.format("%.2f",ShipY)..
- " - ShipZ: "..string.format("%.2f",ShipZ)
- )
- ]]
-
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].xp = math.abs(100/(ShipXmax-ShipXmin)*(element.x-ShipXmin))
- dmgoElements[i].yp = math.abs(100/(ShipYmax-ShipYmin)*(element.y-ShipYmin))
- dmgoElements[i].zp = math.abs(100/(ShipZmax-ShipZmin)*(element.z-ShipZmin))
- -- PrintConsole(i..". "..element.id..": "..string.format("%.2f",element.x).."/"..string.format("%.2f",element.y).."/"..string.format("%.2f",element.z).." - XP: "..dmgoElements[i].xp.." - YP: "..dmgoElements[i].yp.." - ZP: "..dmgoElements[i].zp)
- end
-
-end
-
-function UpdateViewDamageoutline(screen)
- -- Full Width of virtual screen:
- -- UStart = 20
- -- VStart = 180
- -- UDim = 1880
- -- VDim = 840
- -- Adding frames:
- UFrame = 40
- VFrame = 40
-
- UStart = 20 + UFrame
- VStart = 180 + VFrame
- UDim = 1880 - 2*UFrame
- VDim = 840 - 2*VFrame
-
- if screen.submode == "top" then
- if DMGOStretch == false then
- local UFactor = UDim/(ShipYmax-ShipYmin)
- local VFactor = VDim/(ShipXmax-ShipXmin)
- if UFactor>=VFactor then
- local cFactor = UFactor/VFactor
- local newUDim = math.floor(UDim/cFactor)
- UStart = UStart+(UDim-newUDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100/cFactor*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*element.xp+VStart)
- end
- else
- local cFactor = VFactor/UFactor
- local newVDim = math.floor(VDim/cFactor)
- VStart = VStart+(VDim-newVDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100/cFactor*element.xp+VStart)
- end
- end
- else
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*element.xp+VStart)
- end
- end
-
-
- elseif screen.submode == "front" then
- if DMGOStretch == false then
- local UFactor = UDim/(ShipXmax-ShipXmin)
- local VFactor = VDim/(ShipZmax-ShipZmin)
- if UFactor>=VFactor then
- local cFactor = UFactor/VFactor
- local newUDim = math.floor(UDim/cFactor)
- UStart = UStart+(UDim-newUDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100/cFactor*element.xp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- else
- local cFactor = VFactor/UFactor
- local newVDim = math.floor(VDim/cFactor)
- VStart = VStart+(VDim-newVDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.xp+UStart)
- dmgoElements[i].v = math.floor(VDim/100/cFactor*(100-element.zp)+VStart)
- end
- end
- else
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.xp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- end
-
- elseif screen.submode == "side" then
- if DMGOStretch == false then
- local UFactor = UDim/(ShipYmax-ShipYmin)
- local VFactor = VDim/(ShipXmax-ShipZmin)
- if UFactor>=VFactor then
- local cFactor = UFactor/VFactor
- local newUDim = math.floor(UDim/cFactor)
- UStart = UStart+(UDim-newUDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100/cFactor*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- else
- local cFactor = VFactor/UFactor
- local newVDim = math.floor(VDim/cFactor)
- VStart = VStart+(VDim-newVDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100/cFactor*(100-element.zp)+VStart)
- end
- end
- else
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- end
- else
- DrawCenteredText("ERROR: non-existing DMGO mode set.")
- PrintConsole("ERROR: non-existing DMGO mode set.")
- unit.exit()
- end
-end
-
-function GetDamageoutlineShip()
- local output = ""
-
- for i,element in ipairs(dmgoElements) do
- local cclass = ""
- local size = 1
-
- if element.type == "h" then
- cclass ="ch"
- elseif element.type == "d" then
- cclass = "cw"
- else
- cclass = "cc"
- end
- if element.id == highlightID then
- cclass = "f2"
- end
-
- if element.size > 0 and element.size < 1000 then
- size = 5
- elseif element.size >= 1000 and element.size < 2000 then
- size = 8
- elseif element.size >= 2000 and element.size < 5000 then
- size = 12
- elseif element.size >= 5000 and element.size < 10000 then
- size = 15
- elseif element.size >= 10000 and element.size < 20000 then
- size = 20
- elseif element.size >= 20000 then
- size = 30
- end
- output = output .. [[]]
- if element.id == highlightID then
- output = output .. [[]]
- output = output .. [[]]
- end
- end
-
- return output
-end
-
-function GetContentClickareas(screen)
- local output = ""
- if screen ~= nil and screen.ClickAreas ~= nil and #screen.ClickAreas > 0 then
- for i,ca in ipairs(screen.ClickAreas) do
- output = output ..
- [[]]
- end
- end
- return output
-end
-
-function GetElement1(x, y, width, height)
- x = x or 0
- y = y or 0
- width = width or 600
- height = height or 600
- local output = ""
- output = output ..
- [[
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetElement2(x, y)
- x = x or 0
- y = y or 0
- local output = ""
- output = output .. [[]]
- return output
-end
-
-function GetElementLogo(x, y, primaryC, secondaryC, tertiaryC)
- x = x or 812
- y = y or 380
- primaryC = primaryC or "f"
- secondaryC = secondaryC or "f2"
- tertiaryC = tertiaryC or "f3"
- local output = ""
- output = output .. [[
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetHeader(headertext)
- headertext = headertext or "ERROR: UNDEFINED"
- local output = ""
- output = output ..
- [[
- ]]..headertext..[[]]
- return output
-end
-
-function GetContentBackground(candidate, bgcolor)
- bgColor = ColorBackgroundPattern
-
- local output = ""
-
- if candidate == "dots" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' viewBox='0 0 4 4'%3E%3Cpath fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' d='M1 3h1v1H1V3zm2-2h1v1H3V1z'%3E%3C/path%3E%3C/svg%3E");]]
- elseif candidate == "rain" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='12' height='16' viewBox='0 0 12 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 .99C4 .445 4.444 0 5 0c.552 0 1 .45 1 .99v4.02C6 5.555 5.556 6 5 6c-.552 0-1-.45-1-.99V.99zm6 8c0-.546.444-.99 1-.99.552 0 1 .45 1 .99v4.02c0 .546-.444.99-1 .99-.552 0-1-.45-1-.99V8.99z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E");]]
- elseif candidate == "plus" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "signal" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='84' height='48' viewBox='0 0 84 48' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h12v6H0V0zm28 8h12v6H28V8zm14-8h12v6H42V0zm14 0h12v6H56V0zm0 8h12v6H56V8zM42 8h12v6H42V8zm0 16h12v6H42v-6zm14-8h12v6H56v-6zm14 0h12v6H70v-6zm0-16h12v6H70V0zM28 32h12v6H28v-6zM14 16h12v6H14v-6zM0 24h12v6H0v-6zm0 8h12v6H0v-6zm14 0h12v6H14v-6zm14 8h12v6H28v-6zm-14 0h12v6H14v-6zm28 0h12v6H42v-6zm14-8h12v6H56v-6zm0-8h12v6H56v-6zm14 8h12v6H70v-6zm0 8h12v6H70v-6zM14 24h12v6H14v-6zm14-8h12v6H28v-6zM14 8h12v6H14V8zM0 8h12v6H0V8z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E");]]
- elseif candidate == "deathstar" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='105' viewBox='0 0 80 105'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M20 10a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm15 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zM20 75a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zm30-65a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm0 65a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zM35 10a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zM5 45a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zm60 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10z' /%3E%3C/g%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "diamond" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='32' viewBox='0 0 16 32'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath fill-rule='evenodd' d='M0 24h4v2H0v-2zm0 4h6v2H0v-2zm0-8h2v2H0v-2zM0 0h4v2H0V0zm0 4h2v2H0V4zm16 20h-6v2h6v-2zm0 4H8v2h8v-2zm0-8h-4v2h4v-2zm0-20h-6v2h6V0zm0 4h-4v2h4V4zm-2 12h2v2h-2v-2zm0-8h2v2h-2V8zM2 8h10v2H2V8zm0 8h10v2H2v-2zm-2-4h14v2H0v-2zm4-8h6v2H4V4zm0 16h6v2H4v-2zM6 0h2v2H6V0zm0 24h2v2H6v-2z'/%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "hexagon" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='49' viewBox='0 0 28 49'%3E%3Cg fill-rule='evenodd'%3E%3Cg id='hexagons' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='nonzero'%3E%3Cpath d='M13.99 9.25l13 7.5v15l-13 7.5L1 31.75v-15l12.99-7.5zM3 17.9v12.7l10.99 6.34 11-6.35V17.9l-11-6.34L3 17.9zM0 15l12.98-7.5V0h-2v6.35L0 12.69v2.3zm0 18.5L12.98 41v8h-2v-6.85L0 35.81v-2.3zM15 0v7.5L27.99 15H28v-2.31h-.01L17 6.35V0h-2zm0 49v-8l12.99-7.5H28v2.31h-.01L17 42.15V49h-2z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "capsule" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='32' height='26' viewBox='0 0 32 26' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M14 0v3.994C14 7.864 10.858 11 7 11c-3.866 0-7-3.138-7-7.006V0h2v4.005C2 6.765 4.24 9 7 9c2.756 0 5-2.236 5-4.995V0h2zm0 26v-5.994C14 16.138 10.866 13 7 13c-3.858 0-7 3.137-7 7.006V26h2v-6.005C2 17.235 4.244 15 7 15c2.76 0 5 2.236 5 4.995V26h2zm2-18.994C16 3.136 19.142 0 23 0c3.866 0 7 3.138 7 7.006v9.988C30 20.864 26.858 24 23 24c-3.866 0-7-3.138-7-7.006V7.006zm2-.01C18 4.235 20.244 2 23 2c2.76 0 5 2.236 5 4.995v10.01C28 19.765 25.756 22 23 22c-2.76 0-5-2.236-5-4.995V6.995z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E");]]
- elseif candidate == "diagonal" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='6' height='6' viewBox='0 0 6 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'%3E%3Cpath d='M5 0h1L0 6V5zM6 5v1H5z'/%3E%3C/g%3E%3C/svg%3E");]]
- end
- return output;
-end
-
-function GetContentDamageHUDOutput()
- local hudWidth = 300
- local hudHeight = 165
- if #damagedElements > 0 or #brokenElements > 0 then hudHeight = 510 end
- local output = ""
-
- output = output .. [[
-
- ]]
- output = output .. [[]] ..
- [[]] ..
- [[]] ..
- [[]]..(YourShipsName=="Enter here" and ("Ship ID "..ShipID) or YourShipsName) .. [[]] ..
- [[]]
- if #brokenElements > 0 then
- output = output .. [[]]
- elseif #damagedElements > 0 then
- output = output .. [[]]
- else
- output = output .. [[]]
- end
-
- if #damagedElements > 0 or #brokenElements > 0 then
-
- output = output .. [[Total Damage]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", totalShipMaxHP - totalShipHP))..[[]]
- output = output .. [[T]]..ScrapTier..[[ Scrap Needed]] ..
- [[]]..getScraps(totalShipMaxHP - totalShipHP, true)..[[]]
- output = output .. [[Repair Time]] ..
- [[]]..getRepairTime(totalShipMaxHP - totalShipHP, true)..[[]]
-
- output = output .. [[]] ..
- [[]] ..
- [[]]..#healthyElements..[[]] ..
- [[]] ..
- [[]]..#damagedElements..[[]] ..
- [[]] ..
- [[]]..#brokenElements..[[]]
- local j=0
-
- for currentIndex=hudStartIndex,hudStartIndex+9,1 do
- if rE[currentIndex] ~= nil then
- v = rE[currentIndex]
- if v.hp > 0 then
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- if v.id == highlightID then
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- end
- else
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- if v.id == highlightID then
- highlightX = elementPosition.x - coreWorldOffset
- highlightY = elementPosition.y - coreWorldOffset
- highlightZ = elementPosition.z - coreWorldOffset
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- end
- end
- j=j+1
- end
- end
- output = output ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Up/down arrows to highlight]] ..
- [[CTRL + arrows to move HUD]] ..
- [[Left arrow to toggle HUD Mode]] ..
- [[ALT+1-4 to set Scrap Tier]] ..
- [[ALT+8 to reset HUD position]] ..
- [[ALT+9 to shut script off]] ..
- [[]] ..
- [[]]
- else
- output = output ..
- [[]] .. OkayCenterMessage .. [[]] ..
- [[]]..#healthyElements..[[ elements / ]] .. GenerateCommaValue(string.format("%.0f", totalShipMaxHP)) .. [[ HP.]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Left arrow to toggle HUD Mode]] ..
- [[CTRL + arrows to move HUD]] ..
- [[ALT+8 to reset HUD position]] ..
- [[ALT+9 to shut script off]] ..
- [[]] ..
- [[]]
- end
- output = output .. [[]]
- return output
-end
-
-function GetContentDamageScreen()
-
- local screenOutput = ""
-
- -- Draw damage elements
- if #damagedElements > 0 then
- local damagedElementsToDraw = #damagedElements
- if damagedElementsToDraw > DamagePageSize then
- damagedElementsToDraw = DamagePageSize
- end
- if CurrentDamagedPage == math.ceil(#damagedElements / DamagePageSize) then
- damagedElementsToDraw = #damagedElements % DamagePageSize + 12
- if damagedElementsToDraw > 12 then damagedElementsToDraw = damagedElementsToDraw - 12 end
- end
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
-
- if UseMyElementNames == true then screenOutput = screenOutput .. [[Damaged Name]]
- else screenOutput = screenOutput .. [[Damaged Type]]
- end
-
- screenOutput = screenOutput .. [[HLTHDMG]]
- screenOutput = screenOutput .. [[T]]..ScrapTier..[[ SCRREPTIME]]
-
- AddClickArea("damage", {
- id = "SwitchScrapTier",
- mode ="damage",
- x1 = 650,
- x2 = 775,
- y1 = 315,
- y2 = 360
- })
-
- local i = 0
- for j = 1 + (CurrentDamagedPage - 1) * DamagePageSize, damagedElementsToDraw + (CurrentDamagedPage - 1) * DamagePageSize, 1 do
- i = i + 1
- local DP = damagedElements[j]
- if UseMyElementNames == true then screenOutput = screenOutput .. [[]] .. string.format("%.23s", DP.name) .. [[]]
- else screenOutput = screenOutput .. [[]] .. string.format("%.23s", DP.type) .. [[]]
- end
- screenOutput = screenOutput .. [[]] .. DP.percent .. [[%]] ..
- [[]] .. GenerateCommaValue(string.format("%.0f", DP.missinghp), true) .. [[]] ..
- [[]] .. getScraps(DP.missinghp, true) .. [[]] ..
- [[]] .. getRepairTime(DP.missinghp, true) .. [[]] ..
- [[]]
- end
-
- if #damagedElements > DamagePageSize then
- screenOutput = screenOutput ..
- [[Page ]] .. CurrentDamagedPage .. " of " .. math.ceil(#damagedElements / DamagePageSize) ..[[]]
-
- if CurrentDamagedPage < math.ceil(#damagedElements / DamagePageSize) then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "DamagedPageDown",
- mode ="damage",
- x1 = 65,
- x2 = 260,
- y1 = 290 + (damagedElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (damagedElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("DamagedPageDown","damage")
- end
-
- if CurrentDamagedPage > 1 then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "DamagedPageUp",
- mode ="damage",
- x1 = 750,
- x2 = 950,
- y1 = 290 + (damagedElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (damagedElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("DamagedPageUp","damage")
- end
- end
- end
-
- -- Draw broken elements
- if #brokenElements > 0 then
- local brokenElementsToDraw = #brokenElements
- if brokenElementsToDraw > DamagePageSize then
- brokenElementsToDraw = DamagePageSize
- end
- if CurrentBrokenPage == math.ceil(#brokenElements / DamagePageSize) then
- brokenElementsToDraw = #brokenElements % DamagePageSize + 12
- if brokenElementsToDraw > 12 then brokenElementsToDraw = brokenElementsToDraw - 12 end
- end
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
-
- if UseMyElementNames == true then screenOutput = screenOutput .. [[Broken Name]]
- else screenOutput = screenOutput .. [[Broken Type]]
- end
-
- screenOutput = screenOutput .. [[DMG]]
- screenOutput = screenOutput .. [[T]]..ScrapTier..[[ SCRREPTIME]]
-
- AddClickArea("damage", {
- id = "SwitchScrapTier2",
- mode ="damage",
- x1 = 1570,
- x2 = 1690,
- y1 = 315,
- y2 = 360
- })
-
- local i = 0
- for j = 1 + (CurrentBrokenPage - 1) * DamagePageSize, brokenElementsToDraw + (CurrentBrokenPage - 1) * DamagePageSize, 1 do
- i = i + 1
- local DP = brokenElements[j]
- if UseMyElementNames == true then screenOutput = screenOutput .. [[]] .. string.format("%.30s", DP.name) .. [[]]
- else screenOutput = screenOutput .. [[]] .. string.format("%.30s", DP.type) .. [[]]
- end
- screenOutput = screenOutput .. [[]] .. GenerateCommaValue(string.format("%.0f", DP.missinghp), true) .. [[]] ..
- [[]] .. getScraps(DP.missinghp, true) .. [[]] ..
- [[]] .. getRepairTime(DP.missinghp, true) .. [[]] ..
- [[]]
- end
-
-
-
- if #brokenElements > DamagePageSize then
- screenOutput = screenOutput ..
- [[Page ]] .. CurrentBrokenPage .. " of " .. math.ceil(#brokenElements / DamagePageSize) .. [[]]
-
- if CurrentBrokenPage > 1 then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "BrokenPageUp",
- mode ="damage",
- x1 = 1665,
- x2 = 1865,
- y1 = 290 + (brokenElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (brokenElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("BrokenPageUp", "damage")
- end
-
- if CurrentBrokenPage < math.ceil(#brokenElements / DamagePageSize) then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "BrokenPageDown",
- mode ="damage",
- x1 = 980,
- x2 = 1180,
- y1 = 290 + (brokenElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (brokenElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("BrokenPageDown", "damage")
- end
- end
-
- end
-
- -- Draw summary
- if #damagedElements > 0 or #brokenElements > 0 then
- local dWidth = math.floor(1878/#elementsIdList*#damagedElements)
- local bWidth = math.floor(1878/#elementsIdList*#brokenElements)
- local hWidth = 1878-dWidth-bWidth+1
-
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
-
- if #damagedElements > 0 then
- screenOutput = screenOutput .. [[]]..#damagedElements..[[]]
- end
- if #healthyElements > 0 then
- screenOutput = screenOutput .. [[]]..#healthyElements..[[]]
- end
- if #brokenElements > 0 then
- screenOutput = screenOutput .. [[]]..#brokenElements..[[]]
- end
-
- screenOutput = screenOutput .. [[]]
-
- screenOutput = screenOutput .. [[]] ..
- GenerateCommaValue(string.format("%.0f", totalShipMaxHP - totalShipHP)) .. [[ HP damage in total ]] ..
- getScraps(totalShipMaxHP - totalShipHP, true) .. [[ T]]..ScrapTier..[[ scraps needed. ]] ..
- getRepairTime(totalShipMaxHP - totalShipHP, true) .. [[ projected repair time.]]
- else
- screenOutput = screenOutput .. GetElementLogo(812, 380, "ch", "ch", "ch") ..
- [[]] .. OkayCenterMessage .. [[]] ..
- [[]]..#healthyElements..[[ elements stand ]] .. GenerateCommaValue(string.format("%.0f", totalShipMaxHP)) .. [[ HP strong.]]
- end
-
- forceDamageRedraw = false
-
- return screenOutput
-end
-
-function ActionStopengines()
- ToggleHUD()
-end
-
-function ActionStrafeRight()
- if KeyCTRLPressed == true then
- if HUDShiftU < 4000 then
- HUDShiftU = HUDShiftU + 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- HudDeselectElement()
- end
-end
-
-function ActionStrafeLeft()
- if KeyCTRLPressed == true then
- if HUDShiftU >= 50 then
- HUDShiftU = HUDShiftU - 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- ToggleHUD()
- end
-end
-
-function ActionDown()
- if KeyCTRLPressed == true then
- if HUDShiftV < 4000 then
- HUDShiftV = HUDShiftV + 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- ChangeHudSelectedElement(1)
- end
-end
-
-function ActionUp()
- if KeyCTRLPressed == true then
- if HUDShiftV >= 50 then
- HUDShiftV = HUDShiftV - 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- ChangeHudSelectedElement(-1)
- end
-end
-
-function ActionOption1()
- ScrapTier = 1
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption2()
- ScrapTier = 2
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption3()
- ScrapTier = 3
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption4()
- ScrapTier = 4
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption8()
- HUDShiftU=0
- HUDShiftV=0
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption9()
- SaveToDatabank()
- SwitchScreens("off")
- unit.exit()
-end
diff --git a/src/DamageReport_3_11_UnitStart_2.lua b/src/DamageReport_3_11_UnitStart_2.lua
deleted file mode 100644
index 59532b5..0000000
--- a/src/DamageReport_3_11_UnitStart_2.lua
+++ /dev/null
@@ -1,2051 +0,0 @@
---[[
- Damage Report 3.11
- A LUA script for Dual Universe
-
- Created By Dorian Gray
- Ingame: DorianGray
- Discord: Dorian Gray#2623
-
- You can find/update this script on GitHub. Explanations, installation and usage information as well as screenshots can be found there too.
- GitHub: https://github.com/DorianTheGrey/DU-DamageReport
-
- GNU Public License 3.0. Use whatever you want, be so kind to leave credit.
-
- Credits & thanks:
- Thanks to NovaQuark for creating the MMO of the century.
- Thanks to Jericho, Dmentia and Archaegeo for learning a lot from their fine scripts.
- Thanks to TheBlacklist for testing and wonderful suggestions.
- SVG patterns by Hero Patterns.
- DU atlas data from Jayle Break.
-
-]]
-
---[[ 1. USER DEFINED VARIABLES ]]
-
-YourShipsName = "Enter here" --export Enter your ship name here if you want it displayed instead of the ship's ID. YOU NEED TO LEAVE THE QUOTATION MARKS.
-
-SkillRepairToolEfficiency = 0 --export Enter (0-5) your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency"
-SkillRepairToolOptimization = 0 --export Enter your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Optimization"
-
-StatAtmosphericFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED ATMOSPHERIC FUEL TANKS (from the builders talent "Piloting -> Atmospheric Flight Technician -> Atmospheric Fuel-Tank Handling")
-StatSpaceFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL SPACE TANKS (from the builders talent "Piloting -> Atmospheric Engine Technician -> Space Fuel-Tank Handling")
-StatRocketFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL ROCKET TANKS (from the builders talent "Piloting -> Rocket Scientist -> Rocket Booster Fuel Tank Handling")
-StatContainerOptimization = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL TANKS "from the builders talent Mining and Inventory -> Stock Control -> Container Optimization"
-StatFuelTankOptimization = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL TANKS "from the builders talent Mining and Inventory -> Stock Control -> Fuel Tank Optimization"
-
-ShowWelcomeMessage = true --export Do you want the welcome message on the start screen with your name?
-AddSummertimeHour = false --export: Is summertime currently enabled in your location? (Adds one hour.)
-
--- SkillAtmosphericFuelEfficiency = 0 --export Enter (0-5) your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency"
--- SkillSpaceFuelEfficiency = 0 --export Enter (0-5) your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency"
--- SkillRocketFuelEfficiency = 0 --export Enter (0-5) your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency"
-
---[[ 2. GLOBAL VARIABLES ]]
-
-UpdateDataInterval = 1.0 -- How often shall the data be updated? (Increase if running into CPU issues.)
-HighlightBlinkingInterval = 0.5 -- How fast shall highlight arrows of marked elements blink?
-
-ColorPrimary = "FF6700" -- Enter the hexcode of the main color to be used by all views.
-ColorSecondary = "FFFFFF" -- Enter the hexcode of the secondary color to be used by all views.
-ColorTertiary = "000000" -- Enter the hexcode of the tertiary color to be used by all views.
-ColorHealthy = "00FF00" -- Enter the hexcode of the 'healthy' color to be used by all views.
-ColorWarning = "FFFF00" -- Enter the hexcode of the 'warning' color to be used by all views.
-ColorCritical = "FF0000" -- Enter the hexcode of the 'critical' color to be used by all views.
-ColorBackground = "000000" -- Enter the hexcode of the background color to be used by all views.
-ColorBackgroundPattern = "4F4F4F" -- Enter the hexcode of the background color to be used by all views.
-ColorFuelAtmospheric = "004444" -- Enter the hexcode of the atmospheric fuel color.
-ColorFuelSpace = "444400" -- Enter the hexcode of the space fuel color.
-ColorFuelRocket = "440044" -- Enter the hexcode of the rocket fuel color.
-
-VERSION = 3.11
-DebugMode = false
-DebugRenderClickareas = true
-
-DBData = {}
-
-core = nil
-db = nil
-screens = {}
-dscreens = {}
-
-Warnings = {}
-
-screenModes = {
- ["flight"] = { id="flight" },
- ["damage"] = { id="damage" },
- ["damageoutline"] = { id="damageoutline" },
- ["fuel"] = { id="fuel" },
- ["cargo"] = { id="cargo" },
- ["agg"] = { id="agg" },
- ["map"] = { id="map" },
- ["time"] = { id="time", activetoggle="true" },
- ["settings1"] = { id="settings1" },
- ["startup"] = { id="startup" }
-}
-
-backgroundModes = { "deathstar", "capsule", "rain", "signal", "hexagon", "diagonal", "diamond", "plus", "dots" }
-BackgroundMode ="deathstar"
-BackgroundSelected = 1
-BackgroundModeOpacity = 0.25
-
-SaveVars = { "dscreens",
- "ColorPrimary", "ColorSecondary", "ColorTertiary",
- "ColorHealthy", "ColorWarning", "ColorCritical",
- "ColorBackground", "ColorBackgroundPattern",
- "ScrapTier", "HUDMode", "SimulationMode", "DMGOStretch",
- "HUDShiftU", "HUDShiftV", "colorIDIndex", "colorIDTable",
- "BackgroundMode", "BackgroundSelected", "BackgroundModeOpacity" }
-
-HUDMode = false
-HUDShiftU = 0
-HUDShiftV = 0
-hudSelectedIndex = 0
-hudStartIndex = 1
-hudArrowSticker = {}
-highlightOn = false
-highlightID = 0
-highlightX = 0
-highlightY = 0
-highlightZ = 0
-
-SimulationMode = false
-OkayCenterMessage = "All systems nominal."
-CurrentDamagedPage = 1
-CurrentBrokenPage = 1
-DamagePageSize = 12
-ScrapTier = 1
-totalScraps = 0
-ScrapTierRepairTimes = { 10, 50, 250, 1250 }
-
-coreWorldOffset = 0
-totalShipHP = 0
-formerTotalShipHP = -1
-totalShipMaxHP = 0
-totalShipIntegrity = 100
-elementsId = {}
-elementsIdList = {}
-damagedElements = {}
-brokenElements = {}
-rE = {}
-healthyElements = {}
-typeElements = {}
-ElementCounter = 0
-UseMyElementNames = true
-dmgoElements = {}
-DMGOMaxElements = 250
-DMGOStretch = false
-ShipXmin = 99999999
-ShipXmax = -99999999
-ShipYmin = 99999999
-ShipYmax = -99999999
-ShipZmin = 99999999
-ShipZmax = -99999999
-
-totalShipMass = 0
-formerTotalShipMass = -1
-
-formerTime = -1
-
-FuelAtmosphericTanks = {}
-FuelSpaceTanks = {}
-FuelRocketTanks = {}
-FuelAtmosphericTotal = 0
-FuelSpaceTotal = 0
-FuelRocketTotal = 0
-FuelAtmosphericCurrent = 0
-FuelSpaceTotalCurrent = 0
-FuelRocketTotalCurrent = 0
-formerFuelAtmosphericTotal = -1
-formerFuelSpaceTotal = -1
-formerFuelRocketTotal = -1
-
-hexTable = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"}
-colorIDIndex = 1
-colorIDTable = {
- [1] = {
- id="ColorPrimary",
- desc="Main HUD Color",
- basec = "FF6700",
- newc = "FF6700"
- },
- [2] = {
- id="ColorSecondary",
- desc="Secondary HUD Color",
- basec = "FFFFFF",
- newc = "FFFFFF"
- },
- [3] = {
- id="ColorTertiary",
- desc="Tertiary HUD Color",
- basec = "000000",
- newc = "000000"
- },
- [4] = {
- id="ColorHealthy",
- desc="Color code for Healthy/Okay",
- basec = "00FF00",
- newc = "00FF00"
- },
- [5] = {
- id="ColorWarning",
- desc="Color code for Damaged/Warning",
- basec = "FFFF00",
- newc = "FFFF00"
- },
- [6] = {
- id="ColorCritical",
- desc="Color code for Broken/Critical",
- basec = "FF0000",
- newc = "FF0000"
- },
- [7] = {
- id="ColorBackground",
- desc="Background Color",
- basec = "000000",
- newc = "000000"
- },
- [8] = {
- id="ColorBackgroundPattern",
- desc="Background Pattern Color",
- basec = "4F4F4F",
- newc = "4F4F4F"
- },
- [9] = {
- id="ColorFuelAtmospheric",
- desc="Color for Atmo Fuel/Elements",
- basec = "004444",
- newc = "004444"
- },
- [10] = {
- id="ColorFuelSpace",
- desc="Color for Space Fuel/Elements",
- basec = "444400",
- newc = "444400"
- },
- [11] = {
- id="ColorFuelRocket",
- desc="Color for Rocket Fuel/Elements",
- basec = "440044",
- newc = "440044"
- }
-}
-
-
---[[ 3. PROCESSING FUNCTIONS ]]
-
-function InitiateSlots()
- for slot_name, slot in pairs(unit) do
- if type(slot) == "table" and type(slot.export) == "table" and
- slot.getElementClass then
- local elementClass = slot.getElementClass():lower()
- if elementClass:find("coreunit") then
- core = slot
- local coreHP = core.getMaxHitPoints()
- if coreHP > 10000 then
- coreWorldOffset = 128
- elseif coreHP > 1000 then
- coreWorldOffset = 64
- elseif coreHP > 150 then
- coreWorldOffset = 32
- else
- coreWorldOffset = 16
- end
- elseif elementClass == 'databankunit' then
- db = slot
- elseif elementClass == "screenunit" then
- local iScreenMode = "startup"
- screens[#screens + 1] = {
- element = slot,
- id = slot.getId(),
- mode = iScreenMode,
- submode = "",
- ClickAreas = {},
- refresh = true,
- active = false,
- fuelA = true,
- fuelS = true,
- fuelR = true,
- fuelIndex = 1
- }
- end
- end
- end
-end
-
-function LoadFromDatabank()
- if db == nil then
- return
- else
- for _, data in pairs(SaveVars) do
- if db.hasKey(data) then
- local jData = json.decode( db.getStringValue(data) )
- if jData ~= nil then
- if data == "YourShipsName" or data == "AddSummertimeHour" or data == "UpdateDataInterval" or data == "HighlightBlinkingInterval" or
- data == "SkillRepairToolEfficiency" or data == "SkillRepairToolOptimization" or data == "SkillAtmosphericFuelEfficiency" or
- data == "SkillSpaceFuelEfficiency" or data == "SkillRocketFuelEfficiency" or data == "StatAtmosphericFuelTankHandling" or
- data == "StatSpaceFuelTankHandling" or data == "StatRocketFuelTankHandling"
- then
- -- Nada
- else
- _G[data] = jData
- end
- end
- end
- end
-
- for i,v in ipairs(screens) do
- for j,dv in ipairs(dscreens) do
- if screens[i].id == dscreens[j].id then
- screens[i].mode = dscreens[j].mode
- screens[i].submode = dscreens[j].submode
- screens[i].active = dscreens[j].active
- screens[i].refresh = true
- screens[i].fuelA = dscreens[j].fuelA
- screens[i].fuelS = dscreens[j].fuelS
- screens[i].fuelR = dscreens[j].fuelR
- screens[i].fuelIndex = dscreens[j].fuelIndex
- end
- end
- end
- end
-end
-
-function SaveToDatabank()
- if db == nil then
- return
- else
- dscreens = {}
- for i,screen in ipairs(screens) do
- dscreens[i] = {}
- dscreens[i].id = screen.id
- dscreens[i].mode = screen.mode
- dscreens[i].submode = screen.submode
- dscreens[i].active = screen.active
- dscreens[i].fuelA = screen.fuelA
- dscreens[i].fuelS = screen.fuelS
- dscreens[i].fuelR = screen.fuelR
- dscreens[i].fuelIndex = screen.fuelIndex
- end
-
- db.clear()
-
- for _, data in pairs(SaveVars) do
- db.setStringValue(data, json.encode(_G[data]))
- end
-
- end
-end
-
-function InitiateScreens()
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- screens[i] = CreateClickAreasForScreen(screens[i])
- end
- end
-end
-
-function UpdateTypeData()
- FuelAtmosphericTanks = {}
- FuelSpaceTanks = {}
- FuelRocketTanks = {}
-
- FuelAtmosphericTotal = 0
- FuelAtmosphericCurrent = 0
- FuelSpaceTotal = 0
- FuelSpaceCurrent = 0
- FuelRocketCurrent = 0
- FuelRocketTotal = 0
-
- local weightAtmosphericFuel = 4
- local weightSpaceFuel = 6
- local weightRocketFuel = 0.8
-
- --[[
- (FuelMass * (1-.05 * ) * (1-.05 * )
- It just seems to be that the Container Optimization and Fuel Tank Optimization are not added together so the max is not -50% (25% from each skill from the base mass) but 43.75% So the Fuel Tank Optimization uses the container optimization result as it's base value
- ]]
-
- if StatContainerOptimization > 0 then
- weightAtmosphericFuel = weightAtmosphericFuel - 0.05 * StatContainerOptimization * weightAtmosphericFuel
- weightSpaceFuel = weightSpaceFuel - 0.05 * StatContainerOptimization * weightSpaceFuel
- weightRocketFuel = weightRocketFuel - 0.05 * StatContainerOptimization * weightRocketFuel
- end
- if StatFuelTankOptimization > 0 then
- weightAtmosphericFuel = weightAtmosphericFuel - 0.05 * StatFuelTankOptimization * weightAtmosphericFuel
- weightSpaceFuel = weightSpaceFuel - 0.05 * StatFuelTankOptimization * weightSpaceFuel
- weightRocketFuel = weightRocketFuel - 0.05 * StatFuelTankOptimization * weightRocketFuel
- end
-
- for i, id in ipairs(typeElements) do
- local idName = core.getElementNameById(id) or ""
- local idType = core.getElementTypeById(id) or ""
- -- local idTypeClean = idType:gsub("[%s%-]+", ""):lower()
- local idPos = core.getElementPositionById(id) or 0
- local idHP = core.getElementHitPointsById(id) or 0
- local idMaxHP = core.getElementMaxHitPointsById(id) or 0
- local idMass = core.getElementMassById(id) or 0
-
- local baseSize = ""
- local baseVol = 0
- local baseMass = 0
- local cMass = 0
- local cVol = 0
-
- if idType == "atmospheric fuel-tank" then
- if idMaxHP > 10000 then
- baseSize = "L"
- baseMass = 5480
- baseVol = 12800
- elseif idMaxHP > 1300 then
- baseSize = "M"
- baseMass = 988.67
- baseVol = 1600
- elseif idMaxHP > 150 then
- baseSize = "S"
- baseMass = 182.67
- baseVol = 400
- else
- baseSize = "XS"
- baseMass = 35.03
- baseVol = 100
- end
- if StatAtmosphericFuelTankHandling > 0 then
- baseVol = 0.2 * StatAtmosphericFuelTankHandling * baseVol + baseVol
- end
- cMass = idMass - baseMass
- if cMass <=10 then cMass = 0 end
- cVol = string.format("%.0f", cMass / weightAtmosphericFuel)
- cPercent = string.format("%.1f", math.floor(100/baseVol * tonumber(cVol)))
- table.insert(FuelAtmosphericTanks, {
- type = 1,
- id = id,
- name = idName,
- maxhp = idMaxHP,
- hp = GetHPforElement(id),
- pos = idPos,
- size = baseSize,
- mass = baseMass,
- vol = baseVol,
- cvol = cVol,
- percent = cPercent
- })
- if idHP > 0 then
- FuelAtmosphericCurrent = FuelAtmosphericCurrent + cVol
- end
- FuelAtmosphericTotal = FuelAtmosphericTotal + baseVol
- elseif idType == "space fuel-tank" then
- if idMaxHP > 10000 then
- baseSize = "L"
- baseMass = 5480
- baseVol = 12800
- elseif idMaxHP > 1300 then
- baseSize = "M"
- baseMass = 988.67
- baseVol = 1600
- else
- baseSize = "S"
- baseMass = 182.67
- baseVol = 400
- end
- if StatSpaceFuelTankHandling > 0 then
- baseVol = 0.2 * StatSpaceFuelTankHandling * baseVol + baseVol
- end
- cMass = idMass - baseMass
- if cMass <=10 then cMass = 0 end
- cVol = string.format("%.0f", cMass / weightSpaceFuel)
- cPercent = string.format("%.1f", (100/baseVol * tonumber(cVol)))
- table.insert(FuelSpaceTanks, {
- type = 2,
- id = id,
- name = idName,
- maxhp = idMaxHP,
- hp = GetHPforElement(id),
- pos = idPos,
- size = baseSize,
- mass = baseMass,
- vol = baseVol,
- cvol = cVol,
- percent = cPercent
- })
- if idHP > 0 then
- FuelSpaceCurrent = FuelSpaceCurrent + cVol
- end
- FuelSpaceTotal = FuelSpaceTotal + baseVol
- elseif idType == "rocket fuel-tank" then
- if idMaxHP > 65000 then
- baseSize = "L"
- baseMass = 25740
- baseVol = 50000
- elseif idMaxHP > 6000 then
- baseSize = "M"
- baseMass = 4720
- baseVol = 6400
- elseif idMaxHP > 700 then
- baseSize = "S"
- baseMass = 886.72
- baseVol = 800
- else
- baseSize = "XS"
- baseMass = 173.42
- baseVol = 400
- end
- if StatRocketFuelTankHandling > 0 then
- baseVol = 0.2 * StatRocketFuelTankHandling * baseVol + baseVol
- end
- cMass = idMass - baseMass
- if cMass <=10 then cMass = 0 end
- cVol = string.format("%.0f", cMass / weightRocketFuel)
- cPercent = string.format("%.1f", (100/baseVol * tonumber(cVol)))
- table.insert(FuelRocketTanks, {
- type = 3,
- id = id,
- name = idName,
- maxhp = idMaxHP,
- hp = GetHPforElement(id),
- pos = idPos,
- size = baseSize,
- mass = baseMass,
- vol = baseVol,
- cvol = cVol,
- percent = cPercent
- })
- if idHP > 0 then
- FuelRocketCurrent = FuelRocketCurrent + cVol
- end
- FuelRocketTotal = FuelRocketTotal + baseVol
- end
-
- end
-
- if FuelAtmosphericCurrent ~= formerFuelAtmosphericCurrent then
- SetRefresh("fuel")
- formerFuelAtmosphericCurrent = FuelAtmosphericCurrent
- end
- if FuelSpaceCurrent ~= formerFuelSpaceCurrent then
- SetRefresh("fuel")
- formerFuelSpaceCurrent = FuelSpaceCurrent
- end
- if FuelRocketCurrent ~= formerFuelRocketCurrent then
- SetRefresh("fuel")
- formerFuelRocketCurrent = FuelRocketCurrent
- end
-
-
-
-end
-
-function UpdateDamageData(initial)
-
- initial = initial or false
-
- if SimulationActive == true then return end
-
- local formerTotalShipHP = totalShipHP
- totalShipHP = 0
- totalShipMaxHP = 0
- totalShipIntegrity = 100
- damagedElements = {}
- brokenElements = {}
- healthyElements = {}
- if initial == true then
- typeElements = {}
- end
-
- ElementCounter = 0
-
- elementsIdList = core.getElementIdList()
-
- for i, id in pairs(elementsIdList) do
-
- ElementCounter = ElementCounter + 1
-
- local idName = core.getElementNameById(id)
-
- local idType = core.getElementTypeById(id)
- -- local idTypeClean = idType:gsub("[%s%-]+", ""):lower()
- local idPos = core.getElementPositionById(id)
- local idHP = core.getElementHitPointsById(id)
- local idMaxHP = core.getElementMaxHitPointsById(id)
- -- local idMass = core.getElementMassById(id)
-
- if SimulationMode == true then
- SimulationActive = true
- local dice = math.random(0, 10)
- if dice < 2 and #brokenElements < 30 then
- idHP = 0
- elseif dice >= 2 and dice < 4 and #damagedElements < 30 then
- idHP = math.random(1, math.ceil(idMaxHP))
- else
- idHP = idMaxHP
- end
- end
-
- totalShipHP = totalShipHP + idHP
- totalShipMaxHP = totalShipMaxHP + idMaxHP
-
- if idMaxHP - idHP > constants.epsilon then
-
- if idHP > 0 then
- table.insert(damagedElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP - idHP,
- percent = math.ceil(100 / idMaxHP * idHP),
- pos = idPos
- })
- else
- table.insert(brokenElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP - idHP,
- percent = 0,
- pos = idPos
- })
- end
- else
- table.insert(healthyElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- pos = idPos
- })
- if id == highlightID then
- highlightID = 0
- highlightOn = false
- HideHighlight()
- hudSelectedIndex = 0
- end
- end
-
- if initial == true then
- if
- idType == "atmospheric fuel-tank" or
- idType == "space fuel-tank" or
- idType == "rocket fuel-tank"
- then
- table.insert(typeElements, id)
- end
- end
- end
-
- SortDamageTables()
-
- rE = {}
-
- if #brokenElements > 0 then
- for _,v in ipairs(brokenElements) do
- table.insert(rE, {id=v.id, missinghp=v.missinghp, hp=v.hp, name=v.name, type=v.type, pos=v.pos})
- end
- end
- if #damagedElements > 0 then
- for _,v in ipairs(damagedElements) do
- table.insert(rE, {id=v.id, missinghp=v.missinghp, hp=v.hp, name=v.name, type=v.type, pos=v.pos})
- end
- end
- if #rE > 0 then
- table.sort(rE, function(a,b) return a.missinghp>b.missinghp end)
- end
-
- totalShipIntegrity = string.format("%2.0f", 100 / totalShipMaxHP * totalShipHP)
-
- if formerTotalShipHP ~= totalShipHP then
- forceDamageRedraw = true
- formerTotalShipHP = totalShipHP
- else
- forceDamageRedraw = false
- end
-end
-
-function GetHPforElement(id)
- for i,v in ipairs(brokenElements) do
- if v.id == id then
- return 0
- end
- end
- for i,v in ipairs(damagedElements) do
- if v.id == id then
- return v.hp
- end
- end
- for i,v in ipairs(healthyElements) do
- if v.id == id then
- return v.maxhp
- end
- end
-end
-
-function UpdateClickArea(candidate, newEntry, mode)
- for i, screen in ipairs(screens) do
- for k, v in pairs(screens[i].ClickAreas) do
- if v.id == candidate and v.mode == mode then
- screens[i].ClickAreas[k] = newEntry
- end
- end
- end
-end
-
-function AddClickArea(mode, newEntry)
- for i, screen in ipairs(screens) do
- if screens[i].mode == mode then
- table.insert(screens[i].ClickAreas, newEntry)
- end
- end
-end
-
-function AddClickAreaForScreenID(screenid, newEntry)
- for i, screen in ipairs(screens) do
- if screens[i].id == screenid then
- table.insert(screens[i].ClickAreas, newEntry)
- end
- end
-end
-
-function DisableClickArea(candidate, mode)
- UpdateClickArea(candidate, {
- id = candidate,
- mode = mode,
- x1 = -1,
- x2 = -1,
- y1 = -1,
- y2 = -1
- })
-end
-
-function SetRefresh(mode, submode)
- mode = mode or "all"
- submode = submode or "all"
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- if screens[i].mode == mode or mode == "all" then
- if screens[i].submode == submode or submode =="all" then
- screens[i].refresh = true
- end
- end
- end
- end
-end
-
-function WipeClickAreasForScreen(screen)
- screen.ClickAreas = {}
- return screen
-end
-
-function CreateBaseClickAreas(screen)
- table.insert(screen.ClickAreas, {mode = "all", id = "ToggleHudMode", x1 = 1537, x2 = 1728, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "damage", x1 = 193, x2 = 384, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "damageoutline", x1 = 385, x2 = 576, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "fuel", x1 = 577, x2 = 768, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "flight", x1 = 769, x2 = 960, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "cargo", x1 = 961, x2 = 1152, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "agg", x1 = 1153, x2 = 1344, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "map", x1 = 1345, x2 = 1536, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "time", x1 = 0, x2 = 192, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "settings1", x1 = 1729, x2 = 1920, y1 = 1015, y2 = 1075} )
- return screen
-end
-
-function CreateClickAreasForScreen(screen)
-
- if screen == nil then return {} end
-
- if screen.mode == "flight" then
- elseif screen.mode == "damage" then
- table.insert( screen.ClickAreas, {mode = "damage", id = "ToggleElementLabel", x1 = 70, x2 = 425, y1 = 325, y2 = 355} )
- table.insert( screen.ClickAreas, {mode = "damage", id = "ToggleElementLabel2", x1 = 980, x2 = 1400, y1 = 325, y2 = 355} )
- elseif screen.mode == "damageoutline" then
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeView", param = "top", x1 = 60, x2 = 439, y1 = 150, y2 = 200} )
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeView", param = "side", x1 = 440, x2 = 824, y1 = 150, y2 = 200} )
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeView", param = "front", x1 = 825, x2 = 1215, y1 = 150, y2 = 200} )
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeStretch", x1 = 1530, x2 = 1580, y1 = 150, y2 = 200} )
- elseif screen.mode == "fuel" then
- elseif screen.mode == "cargo" then
- elseif screen.mode == "agg" then
- elseif screen.mode == "map" then
- elseif screen.mode == "time" then
- elseif screen.mode == "settings1" then
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ToggleBackground", x1 = 75, x2 = 860, y1 = 170, y2 = 215} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "PreviousBackground", x1 = 75, x2 = 460, y1 = 235, y2 = 285} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "NextBackground", x1 = 480, x2 = 860, y1 = 235, y2 = 285} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "DecreaseOpacity", x1 = 75, x2 = 460, y1 = 300, y2 = 350} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "IncreaseOpacity", x1 = 480, x2 = 860, y1 = 300, y2 = 350} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ResetColors", x1 = 75, x2 = 860, y1 = 370, y2 = 415} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "PreviousColorID", x1 = 90, x2 = 140, y1 = 500, y2 = 550} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "NextColorID", x1 = 795, x2 = 845, y1 = 500, y2 = 550} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="1", x1 = 210, x2 = 290, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="2", x1 = 300, x2 = 380, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="3", x1 = 385, x2 = 465, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="4", x1 = 470, x2 = 550, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="5", x1 = 560, x2 = 640, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="6", x1 = 645, x2 = 725, y1 = 655, y2 = 700} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="1", x1 = 210, x2 = 290, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="2", x1 = 300, x2 = 380, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="3", x1 = 385, x2 = 465, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="4", x1 = 470, x2 = 550, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="5", x1 = 560, x2 = 640, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="6", x1 = 645, x2 = 725, y1 = 740, y2 = 780} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ResetPosColor", x1 = 160, x2 = 340, y1 = 885, y2 = 935} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ApplyPosColor", x1 = 355, x2 = 780, y1 = 885, y2 = 935} )
-
- elseif screen.mode == "startup" then
- end
-
- screen = CreateBaseClickAreas(screen)
-
- return screen
-end
-
-function CheckClick(x, y, HitTarget)
- x = x*1920
- y = y*1120
- HitTarget = HitTarget or ""
- HitPayload = {}
- -- PrintConsole("Clicked: "..x.." / "..y)
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- if screens[i].active == true and screens[i].element.getMouseX() ~= -1 and screens[i].element.getMouseY() ~= -1 then
- if HitTarget == "" then
- for k, v in pairs(screens[i].ClickAreas) do
- if v ~=nil and x >= v.x1 and x <= v.x2 and y >= v.y1 and y <= v.y2 then
- HitTarget = v.id
- HitPayload = v
- break
- end
- end
- end
- if HitTarget == "ButtonPress" then
- if screens[i].mode == HitPayload.param then
- screens[i].mode = "startup"
- else
- screens[i].mode = HitPayload.param
- end
-
- if screens[i].mode == "damageoutline" then
- if screens[i].submode == "" then
- screens[i].submode = "top"
- end
- end
- screens[i].refresh = true
- screens[i].ClickAreas = {}
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "ToggleBackground" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundMode == "" then
- BackgroundSelected = 1
- BackgroundMode = backgroundModes[BackgroundSelected]
- else
- BackgroundSelected = 1
- BackgroundMode = ""
- end
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "PreviousBackground" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundMode == "" then
- BackgroundSelected = 1
- BackgroundMode = backgroundModes[BackgroundSelected]
- else
- if BackgroundSelected <= 1 then
- BackgroundSelected = #backgroundModes
- else
- BackgroundSelected = BackgroundSelected - 1
- end
- BackgroundMode = backgroundModes[BackgroundSelected]
- end
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "NextBackground" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundMode == "" then
- BackgroundSelected = 1
- BackgroundMode = backgroundModes[BackgroundSelected]
- else
- if BackgroundSelected >= #backgroundModes then
- BackgroundSelected = 1
- else
- BackgroundSelected = BackgroundSelected + 1
- end
- BackgroundMode = backgroundModes[BackgroundSelected]
- end
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "DecreaseOpacity" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundModeOpacity>0.1 then
- BackgroundModeOpacity = BackgroundModeOpacity - 0.05
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- end
- elseif HitTarget == "IncreaseOpacity" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundModeOpacity<1.0 then
- BackgroundModeOpacity = BackgroundModeOpacity + 0.05
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- end
- elseif HitTarget == "ResetColors" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- db.clear()
- ColorPrimary = "FF6700"
- ColorSecondary = "FFFFFF"
- ColorTertiary = "000000"
- ColorHealthy = "00FF00"
- ColorWarning = "FFFF00"
- ColorCritical = "FF0000"
- ColorBackground = "000000"
- ColorBackgroundPattern = "4f4f4f"
- ColorFuelAtmospheric = "004444"
- ColorFuelSpace = "444400"
- ColorFuelRocket = "440044"
- BackgroundMode = "deathstar"
- BackgroundSelected = 1
- BackgroundModeOpacity = 0.25
- colorIDTable = {
- [1] = {
- id="ColorPrimary",
- desc="Main HUD Color",
- basec = "FF6700",
- newc = "FF6700"
- },
- [2] = {
- id="ColorSecondary",
- desc="Secondary HUD Color",
- basec = "FFFFFF",
- newc = "FFFFFF"
- },
- [3] = {
- id="ColorTertiary",
- desc="Tertiary HUD Color",
- basec = "000000",
- newc = "000000"
- },
- [4] = {
- id="ColorHealthy",
- desc="Color code for Healthy/Okay",
- basec = "00FF00",
- newc = "00FF00"
- },
- [5] = {
- id="ColorWarning",
- desc="Color code for Damaged/Warning",
- basec = "FFFF00",
- newc = "FFFF00"
- },
- [6] = {
- id="ColorCritical",
- desc="Color code for Broken/Critical",
- basec = "FF0000",
- newc = "FF0000"
- },
- [7] = {
- id="ColorBackground",
- desc="Background Color",
- basec = "000000",
- newc = "000000"
- },
- [8] = {
- id="ColorBackgroundPattern",
- desc="Background Pattern Color",
- basec = "4F4F4F",
- newc = "4F4F4F"
- },
- [9] = {
- id="ColorFuelAtmospheric",
- desc="Color for Atmo Fuel/Elements",
- basec = "004444",
- newc = "004444"
- },
- [10] = {
- id="ColorFuelSpace",
- desc="Color for Space Fuel/Elements",
- basec = "444400",
- newc = "444400"
- },
- [11] = {
- id="ColorFuelRocket",
- desc="Color for Rocket Fuel/Elements",
- basec = "440044",
- newc = "440044"
- }
- }
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "PreviousColorID" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- colorIDIndex = colorIDIndex - 1
- if colorIDIndex < 1 then colorIDIndex = #colorIDTable end
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "NextColorID" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- colorIDIndex = colorIDIndex + 1
- if colorIDIndex > #colorIDTable then colorIDIndex = 1 end
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "ColorPosUp" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- local s = tonumber(string.sub(colorIDTable[colorIDIndex].newc, HitPayload.param, HitPayload.param),16)
- s = s + 1
- if s > 15 then s = 0 end
- colorIDTable[colorIDIndex].newc = replace_char(HitPayload.param, colorIDTable[colorIDIndex].newc, hexTable[s+1])
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "ColorPosDown" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- local s = tonumber(string.sub(colorIDTable[colorIDIndex].newc, HitPayload.param, HitPayload.param),16)
- s = s - 1
- if s < 0 then s = 15 end
- colorIDTable[colorIDIndex].newc = replace_char(HitPayload.param, colorIDTable[colorIDIndex].newc, hexTable[s+1])
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "ResetPosColor" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- colorIDTable[colorIDIndex].newc = colorIDTable[colorIDIndex].basec
- _G[colorIDTable[colorIDIndex].id] = colorIDTable[colorIDIndex].basec
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "ApplyPosColor" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- _G[colorIDTable[colorIDIndex].id] = colorIDTable[colorIDIndex].newc
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "DamagedPageDown" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentDamagedPage = CurrentDamagedPage + 1
- if CurrentDamagedPage > math.ceil(#damagedElements / DamagePageSize) then
- CurrentDamagedPage = math.ceil(#damagedElements / DamagePageSize)
- end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "DamagedPageUp" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentDamagedPage = CurrentDamagedPage - 1
- if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "BrokenPageDown" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentBrokenPage = CurrentBrokenPage + 1
- if CurrentBrokenPage > math.ceil(#brokenElements / DamagePageSize) then
- CurrentBrokenPage = math.ceil(#brokenElements / DamagePageSize)
- end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "BrokenPageUp" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentBrokenPage = CurrentBrokenPage - 1
- if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "DMGOChangeView" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- screens[i].submode = HitPayload.param
- UpdateViewDamageoutline(screens[i])
- SaveToDatabank()
- SetRefresh("damageoutline", screens[i].submode)
- RenderScreens("damageoutline", screens[i].submode)
- elseif HitTarget == "DMGOChangeStretch" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if DMGOStretch == true then
- DMGOStretch = false
- else
- DMGOStretch = true
- end
- UpdateViewDamageoutline(screens[i])
- SaveToDatabank()
- SetRefresh("damageoutline")
- RenderScreens("damageoutline")
- elseif HitTarget == "ToggleDisplayAtmosphere" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if screens[i].fuelA == true then
- screens[i].fuelA = false
- else
- screens[i].fuelA = true
- end
- screens[i].fuelIndex = 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "ToggleDisplaySpace" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if screens[i].fuelS == true then
- screens[i].fuelS = false
- else
- screens[i].fuelS = true
- end
- screens[i].fuelIndex = 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "ToggleDisplayRocket" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if screens[i].fuelR == true then
- screens[i].fuelR = false
- else
- screens[i].fuelR = true
- end
- screens[i].fuelIndex = 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "DecreaseFuelIndex" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- screens[i].fuelIndex = screens[i].fuelIndex - 1
- if screens[i].fuelIndex < 1 then screens[i].fuelIndex = 1 end
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "IncreaseFuelIndex" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- screens[i].fuelIndex = screens[i].fuelIndex + 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "ToggleHudMode" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if HUDMode == true then
- HUDMode = false
- forceDamageRedraw = true
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- else
- HUDMode = true
- forceDamageRedraw = true
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- end
- elseif HitTarget == "ToggleSimulation" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentDamagedPage = 1
- CurrentBrokenPage = 1
- if SimulationMode == true then
- SimulationMode = false
- SimulationActive = false
- UpdateDamageData()
- UpdateTypeData()
- forceDamageRedraw = true
- HudDeselectElement()
- SetRefresh("damage")
- SetRefresh("damageoutline")
- SetRefresh("settings1")
- SetRefresh("fuel")
- SaveToDatabank()
- RenderScreens()
- else
- SimulationMode = true
- SimulationActive = false
- UpdateDamageData()
- UpdateTypeData()
- forceDamageRedraw = true
- HudDeselectElement()
- SetRefresh("damage")
- SetRefresh("damageoutline")
- SetRefresh("settings1")
- SetRefresh("fuel")
- SaveToDatabank()
- RenderScreens()
- end
- elseif (HitTarget == "ToggleElementLabel" or HitTarget == "ToggleElementLabel2") and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if UseMyElementNames == true then
- UseMyElementNames = false
- SetRefresh("damage")
- RenderScreens("damage")
- else
- UseMyElementNames = true
- SetRefresh("damage")
- RenderScreens("damage")
- end
- elseif (HitTarget == "SwitchScrapTier" or HitTarget == "SwitchScrapTier2") and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- ScrapTier = ScrapTier + 1
- if ScrapTier > 4 then ScrapTier = 1 end
- SetRefresh("damage")
- RenderScreens("damage")
- end
-
-
- end
- end
- end
-end
-
---[[ 4. RENDERING FUNCTIONS ]]
-
-function GetContentFlight()
- local output = ""
- output = output .. GetHeader("Flight Data Report") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentDamage()
- local output = ""
- if SimulationMode == true then
- output = output .. GetHeader("Damage Report (Simulated damage)") .. [[]]
- else
- output = output .. GetHeader("Damage Report") .. [[]]
- end
- output = output .. GetContentDamageScreen()
- return output
-end
-
-function GetContentDamageoutline(screen)
- UpdateDataDamageoutline()
- UpdateViewDamageoutline(screen)
- local output = ""
- output = output .. GetHeader("Damage Ship Outline Report") ..
- GetDamageoutlineShip() ..
- [[]]
-
- if screen.submode=="top" then
- output = output ..
- [[
-
- Top View
-
- Side View
-
- Front View
- ]]
- elseif screen.submode=="side" then
- output = output ..
- [[
-
- Top View
-
- Side View
-
- Front View
- ]]
- elseif screen.submode=="front" then
- output = output ..
- [[
-
- Top View
-
- Side View
-
- Front View
- ]]
- else
- end
- output = output .. [[]]..#dmgoElements..[[ of ]]..ElementCounter..[[ shown]]
- output = output .. [[]]
- if DMGOStretch == true then
- output = output .. [[]]
- end
- output = output .. [[Stretch both axis]]
- return output
-end
-
-function GetContentFuel(screen)
-
- if #FuelAtmosphericTanks < 1 and #FuelSpaceTanks < 1 and #FuelRocketTanks < 1 then return "" end
-
- local FuelTypes = 0
- local output = ""
- local addHeadline = {}
-
- FuelDisplay = { screen.fuelA, screen.fuelS, screen.fuelR }
-
- if FuelDisplay[1] == true and #FuelAtmosphericTanks > 0 then
- table.insert(addHeadline, "Atmospheric")
- FuelTypes = FuelTypes + 1
- end
- if FuelDisplay[2] == true and #FuelSpaceTanks > 0 then
- table.insert(addHeadline, "Space")
- FuelTypes = FuelTypes + 1
- end
- if FuelDisplay[3] == true and #FuelRocketTanks > 0 then
- table.insert(addHeadline, "Rocket")
- FuelTypes = FuelTypes + 1
- end
-
- output = output .. GetHeader("Fuel Report ("..table.concat(addHeadline, ", ")..")") ..
- [[
- ]]
-
- local totalH = 150
- local counter = 0
- local tOffset = 0
-
- if FuelDisplay[1] == true and #FuelAtmosphericTanks > 0 then
-
- if FuelTypes == 1 then tOffset = 50
- elseif FuelTypes == 2 then tOffset = 6
- elseif FuelTypes == 3 then tOffset = 0
- end
-
- output = output .. [[
-
-
-
- ]]
-
- output = output ..
- [[]]..
- GenerateCommaValue(FuelAtmosphericCurrent, true)..
- [[ of ]]..GenerateCommaValue(FuelAtmosphericTotal, true)..
- [[ | Total Atmospheric Fuel in ]]..#FuelAtmosphericTanks..[[ tank]]..(#FuelAtmosphericTanks==1 and "" or "s")..[[ (]]..math.floor(100/FuelAtmosphericTotal*FuelAtmosphericCurrent)..[[%)]]
- counter = counter + 1
- end
-
- if FuelDisplay[2] == true and #FuelSpaceTanks > 0 then
-
- if FuelTypes == 1 then tOffset = 50
- elseif FuelTypes == 2 then tOffset = 6
- elseif FuelTypes == 3 then tOffset = 0
- end
-
- output = output .. [[
-
-
-
- ]]
-
- output = output ..
- [[]]..
- GenerateCommaValue(FuelSpaceCurrent, true)..
- [[ of ]]..GenerateCommaValue(FuelSpaceTotal, true)..
- [[ | Total Space Fuel in ]]..#FuelSpaceTanks..[[ tank]]..(#FuelSpaceTanks==1 and "" or "s")..[[ (]]..math.floor(100/FuelSpaceTotal*FuelSpaceCurrent)..[[%)]]
- counter = counter + 1
- end
-
- if FuelDisplay[3] == true and #FuelRocketTanks > 0 then
-
- if FuelTypes == 1 then tOffset = 50
- elseif FuelTypes == 2 then tOffset = 6
- elseif FuelTypes == 3 then tOffset = 0
- end
-
- output = output .. [[
-
-
-
- ]]
-
- output = output ..
- [[]]..
- GenerateCommaValue(FuelRocketCurrent, true)..
- [[ of ]]..GenerateCommaValue(FuelRocketTotal, true)..
- [[ | Total Rocket Fuel in ]]..#FuelRocketTanks..[[ tank]]..(#FuelRocketTanks==1 and "" or "s")..[[ (]]..math.floor(100/FuelRocketTotal*FuelRocketCurrent)..[[%)]]
- end
-
- output = output .. [[
-
-
-
- ]]
-
- local DisplayTable = {}
- if screen.fuelIndex == nil or screen.fuelIndex < 1 then
- screen.fuelIndex = 1
- end
-
- if FuelDisplay[1] == true then
- for _,v in ipairs(FuelAtmosphericTanks) do
- table.insert(DisplayTable, v)
- end
- end
- if FuelDisplay[2] == true then
- for _,v in ipairs(FuelSpaceTanks) do
- table.insert(DisplayTable, v)
- end
- end
- if FuelDisplay[3] == true then
- for _,v in ipairs(FuelRocketTanks) do
- table.insert(DisplayTable, v)
- end
- end
-
- table.sort(DisplayTable, function(a,b) return a.type
-
-
- ]]
- if tank.hp == 0 then
- output = output .. [[]]
- elseif tank.maxhp - tank.hp > constants.epsilon then
- output = output .. [[]]
- else
- output = output .. [[]]
- end
- if tank.hp == 0 then output = output .. [[]]..tank.size..[[]]
- else output = output .. [[]]..tank.size..[[]]
- end
-
- if tank.hp == 0 then
- output = output .. [[Broken]] ..
- [[0 of ]]..GenerateCommaValue(tank.vol)..[[]]
- elseif tonumber(tank.percent) < 10 then
- output = output .. [[]]..tank.percent..[[%]] ..
- [[]]..GenerateCommaValue(tank.cvol)..[[ of ]]..GenerateCommaValue(tank.vol)..[[]]
- elseif tonumber(tank.percent) < 30 then
- output = output .. [[]]..tank.percent..[[%]] ..
- [[]]..GenerateCommaValue(tank.cvol)..[[ of ]]..GenerateCommaValue(tank.vol)..[[]]
- else output =
- output .. [[]]..tank.percent..[[%]] ..
- [[]]..GenerateCommaValue(tank.cvol)..[[ of ]]..GenerateCommaValue(tank.vol)..[[]]
- end
-
- output = output ..[[]]..tank.name..[[]]
-
- output = output .. [[]]
-
- end
- end
-
-
-
- if #FuelAtmosphericTanks > 0 then
- output = output .. [[]]
- if FuelDisplay[1] == true then
- output = output .. [[]]
- end
- output = output .. [[ATM]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "ToggleDisplayAtmosphere", x1 = 50, x2 = 100, y1 = 270, y2 = 320} )
- end
-
- if #FuelSpaceTanks > 0 then
- output = output .. [[]]
- if FuelDisplay[2] == true then
- output = output .. [[]]
- end
- output = output .. [[SPC]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "ToggleDisplaySpace", x1 = 200, x2 = 250, y1 = 270, y2 = 320} )
- end
-
- if #FuelRocketTanks > 0 then
- output = output .. [[]]
- if FuelDisplay[3] == true then
- output = output .. [[]]
- end
- output = output .. [[RKT]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "ToggleDisplayRocket", x1 = 350, x2 = 400, y1 = 270, y2 = 320} )
- end
-
- if screen.fuelIndex > 1 then
- output = output .. [[
-
-
- ]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "DecreaseFuelIndex", x1 = 1470, x2 = 1670, y1 = 270, y2 = 320} )
- end
-
- if screen.fuelIndex+cCounter-1 < #DisplayTable then
- output = output .. [[
-
-
- ]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "IncreaseFuelIndex", x1 = 1680, x2 = 1880, y1 = 270, y2 = 320} )
- end
-
- if cCounter > 0 then
- output = output .. [[]]..
- #DisplayTable..
- [[ Tank]]..(#DisplayTable == 1 and "" or "s")..
- [[ (Showing ]]..screen.fuelIndex..[[ to ]]..(screen.fuelIndex+cCounter-1)..[[)]]
- end
-
- return output
-end
-
-function GetContentCargo()
- local output = ""
- output = output .. GetHeader("Cargo Report") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentAGG()
- local output = ""
- output = output .. GetHeader("Anti-Grav Control") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentMap()
- local output = ""
- output = output .. GetHeader("Map Overview") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentTime()
- local output = ""
- output = output .. GetHeader("Time") .. epochTime()
- output = output ..
- [[
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetContentSettings1()
- local output = ""
- output = output .. GetHeader("Settings") .. [[]]
- if BackgroundMode=="" then
- output = output ..[[Activate background]]
- else
- output = output ..[[Deactivate background (']]..BackgroundMode..[[', ]]..string.format("%.0f",BackgroundModeOpacity*100)..[[%)]]
- end
- output = output ..[[
-
- Previous background
-
- Next background
-
-
- Decrease Opacity
-
- Increase Opacity
- ]]
-
- output = output ..
- [[]] ..
- [[Reset background and all colors]]
-
- output = output ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Select and change any of the ]]..#colorIDTable..[[ HUD colors]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]]..colorIDTable[colorIDIndex].desc..[[]] ..
- [[]] ..
- [[Current color]] ..
- [[]] ..
-
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
-
- [[#]] ..
-
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,1,1)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,2,2)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,3,3)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,4,4)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,5,5)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,6,6)..[[]] ..
-
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
-
- [[]] ..
- [[]] ..
- [[New color]] ..
- [[]] ..
- [[Apply new color]] ..
- [[]] ..
- [[Reset]] ..
- [[]]
-
- output = output ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Explanation / Hints]] ..
- [[Coming soon.]]
-
-
- output = output .. [[]]
-
- if SimulationMode == true then
- output = output .. [[Simulating Damage to elements]]
- AddClickArea("settings1", { id = "ToggleSimulation", mode ="settings1", x1 = 940, x2 = 1850, y1 = 919, y2 = 969 })
- else
- output = output .. [[Simulate Damage to elements]]
- AddClickArea("settings1", { id = "ToggleSimulation", mode ="settings1", x1 = 940, x2 = 1850, y1 = 919, y2 = 969 })
- end
-
- return output
-end
-
-function GetContentStartup()
- local output = ""
- output = output .. GetElementLogo(812, 380, "f", "f", "f")
- if YourShipsName == "Enter here" then
- output = output .. [[Spaceship ID ]]..ShipID..[[]]
- else
- output = output .. [[]]..YourShipsName..[[]]
- end
- if ShowWelcomeMessage == true then output = output .. [[Greetings, Commander ]]..PlayerName..[[.]] end
- if #Warnings > 0 then
- output = output .. [[Warning: ]]..(table.concat(Warnings, " "))..[[]]
- end
- output = output .. [[Damage Report v]]..VERSION..[[, by Scion Interstellar, DorianGray - Discord: Dorian Gray#2623. Under GNU Public License 3.0.]]
- return output
-end
-
-function RenderScreen(screen, contentToRender)
- if contentToRender == nil then
- PrintConsole("ERROR: contentToRender is nil.")
- unit.exit()
- end
-
- CreateClickAreasForScreen(screen)
-
- local output =""
- output = output .. [[
-
-
- ]]
-
- output = output .. contentToRender
-
- if screen.mode == "startup" then
- output = output .. [[]]
- else
- output = output .. [[]]
- end
-
- output = output .. [[
-
- ]]
- output = output .. [[]]
-
- -- Center:
-
- --
- --
- --
- --
-
- local outputLength = string.len(output)
- -- PrintConsole("Render: "..screen.mode.." ("..outputLength.." chars)")
- screen.element.setSVG(output)
-end
-
-function RenderScreens(onlymode, onlysubmode)
-
- onlymode = onlymode or "all"
- onlysubmode = onlysubmode or "all"
-
- if screens ~= nil and #screens > 0 then
-
- local contentFlight = ""
- local contentDamage = ""
- local contentDamageoutlineTop = ""
- local contentDamageoutlineSide = ""
- local contentDamageoutlineFront = ""
- local contentFuel = ""
- local contentCargo = ""
- local contentAGG = ""
- local contentMap = ""
- local contentTime = ""
- local contentSettings1 = ""
- local contentStartup = ""
-
- for k,screen in pairs(screens) do
- if screen.refresh == true then
- local contentToRender = ""
-
- if screen.mode == "flight" and (onlymode =="flight" or onlymode =="all") then
- if contentFlight == "" then contentFlight = GetContentFlight() end
- contentToRender = contentFlight
- elseif screen.mode == "damage" and (onlymode =="damage" or onlymode =="all") then
- if contentDamage == "" then contentDamage = GetContentDamage() end
- contentToRender = contentDamage
- elseif screen.mode == "damageoutline" and (onlymode =="damageoutline" or onlymode =="all") then
- if screen.submode == "" then
- screen.submode = "top"
- screens[k].submode = "top"
- end
- if screen.submode == "top" and (onlysubmode == "top" or onlysubmode == "all") then
- if contentDamageoutlineTop == "" then contentDamageoutlineTop = GetContentDamageoutline(screen) end
- contentToRender = contentDamageoutlineTop
- end
- if screen.submode == "side" and (onlysubmode == "side" or onlysubmode == "all") then
- if contentDamageoutlineSide == "" then contentDamageoutlineSide = GetContentDamageoutline(screen) end
- contentToRender = contentDamageoutlineSide
- end
- if screen.submode == "front" and (onlysubmode == "front" or onlysubmode == "all") then
- if contentDamageoutlineFront == "" then contentDamageoutlineFront = GetContentDamageoutline(screen) end
- contentToRender = contentDamageoutlineFront
- end
- elseif screen.mode == "fuel" and (onlymode =="fuel" or onlymode =="all") then
- screen = WipeClickAreasForScreen(screens[k])
- contentToRender = GetContentFuel(screen)
- elseif screen.mode == "cargo" and (onlymode =="cargo" or onlymode =="all") then
- if contentCargo == "" then contentCargo = GetContentCargo() end
- contentToRender = contentCargo
- elseif screen.mode == "agg" and (onlymode =="agg" or onlymode =="all") then
- if contentAGG == "" then contentAGG = GetContentAGG() end
- contentToRender = contentAGG
- elseif screen.mode == "map" and (onlymode =="map" or onlymode =="all") then
- if contentMap == "" then contentMap = GetContentMap() end
- contentToRender = contentMap
- elseif screen.mode == "time" and (onlymode =="time" or onlymode =="all") then
- if contentTime == "" then contentTime = GetContentTime() end
- contentToRender = contentTime
- elseif screen.mode == "settings1" and (onlymode =="settings1" or onlymode =="all") then
- if contentSettings1 == "" then contentSettings1 = GetContentSettings1() end
- contentToRender = contentSettings1
- elseif screen.mode == "startup" and (onlymode =="startup" or onlymode =="all") then
- if contentStartup == "" then contentStartup = GetContentStartup() end
- contentToRender = contentStartup
- else
- contentToRender = "Invalid screen mode. ('"..screen.mode.."')"
- end
-
- if contentToRender ~= "" then
- RenderScreen(screen, contentToRender)
- else
- DrawCenteredText("ERROR: No contentToRender delivered for "..screen.mode)
- PrintConsole("ERROR: No contentToRender delivered for "..screen.mode)
- unit.exit()
- end
- screens[k].refresh = false
- end
- end
- end
-
- if HUDMode == true then
- system.setScreen(GetContentDamageHUDOutput())
- system.showScreen(1)
- else
- system.showScreen(0)
- end
-
-end
-
-function OnTickData(initial)
- if formerTime + 60 < system.getTime() then
- SetRefresh("time")
- end
- totalShipMass = core.getConstructMass()
- if formerTotalShipMass ~= totalShipMass then
- UpdateDamageData(true)
- UpdateTypeData()
- SetRefresh()
- formerTotalShipMass = totalShipMass
- else
- UpdateDamageData(initial)
- UpdateTypeData()
- end
- RenderScreens()
-end
-
---[[ 5. EXECUTION ]]
-
-unit.hide()
-ClearConsole()
-PrintConsole("DAMAGE REPORT v"..VERSION.." STARTED", true)
-InitiateSlots()
-LoadFromDatabank()
-SwitchScreens("on")
-InitiateScreens()
-
-if core == nil then
- PrintConsole("ERROR: Connect the core to the programming board.")
- unit.exit()
-else
- OperatorID = unit.getMasterPlayerId()
- OperatorData = database.getPlayer(OperatorID)
- PlayerName = OperatorData["name"]
- ShipID = core.getConstructId()
-end
-
-if db == nil then
- table.insert(Warnings, "No databank connected, won't save/load settings.")
-end
-
-if YourShipsName == "Enter here" then
- table.insert(Warnings, "No ship name set in LUA settings.")
-end
-
-if SkillRepairToolEfficiency == 0 and SkillRepairToolOptimization == 0 and StatFuelTankOptimization == 0 and StatContainerOptimization ==0 and
- StatAtmosphericFuelTankHandling == 0 and StatSpaceFuelTankHandling == 0 and StatRocketFuelTankHandling ==0 then
- table.insert(Warnings, "No talents/stats set in LUA settings.")
-end
-
-if SkillRepairToolEfficiency < 0 or SkillRepairToolOptimization < 0 or StatFuelTankOptimization < 0 or StatContainerOptimization < 0 or
- StatAtmosphericFuelTankHandling < 0 or StatSpaceFuelTankHandling < 0 or StatRocketFuelTankHandling < 0 or
- SkillRepairToolEfficiency > 5 or SkillRepairToolOptimization > 5 or StatFuelTankOptimization > 5 or StatContainerOptimization > 5 or
- StatAtmosphericFuelTankHandling > 5 or StatSpaceFuelTankHandling > 5 or StatRocketFuelTankHandling > 5 then
- PrintConsole("ERROR: Talents/stats can only range from 0 to 5. Please set correctly in LUA settings and reactivate script.")
- unit.exit()
-end
-
-if screens == nil or #screens == 0 then
- HUDMode = true
- PrintConsole("Warning: No screens connected. Entering HUD mode only.")
-end
-
-OnTickData(true)
-
-unit.setTimer('UpdateData', UpdateDataInterval)
-unit.setTimer('UpdateHighlight', HighlightBlinkingInterval)
\ No newline at end of file
diff --git a/src/DamageReport_3_12_UnitStart_1.lua b/src/DamageReport_3_12_UnitStart_1.lua
deleted file mode 100644
index 44ad4f0..0000000
--- a/src/DamageReport_3_12_UnitStart_1.lua
+++ /dev/null
@@ -1,1320 +0,0 @@
---[[
- Damage Report 3.12
- A LUA script for Dual Universe
-
- Created By Dorian Gray
- Ingame: DorianGray
- Discord: Dorian Gray#2623
-
- You can find/update this script on GitHub. Explanations, installation and usage information as well as screenshots can be found there too.
- GitHub: https://github.com/DorianTheGrey/DU-DamageReport
-
- GNU Public License 3.0. Use whatever you want, be so kind to leave credit.
-
- Credits & thanks:
- Thanks to NovaQuark for creating the MMO of the century.
- Thanks to Jericho, Dmentia and Archaegeo for learning a lot from their fine scripts.
- Thanks to TheBlacklist for testing and wonderful suggestions.
- SVG patterns by Hero Patterns.
- DU atlas data from Jayle Break.
-
-]]
-
---[[ 1. HELPER FUNCTIONS ]]
-
-function GenerateCommaValue(amount, kify, postcomma)
- kify = kify or false
- postcomma = postcomma or 1
- local formatted = amount
- if kify == true then
- if string.len(amount)>=4 then
- formatted = string.format("%."..postcomma.."fk", amount/1000)
- else
- formatted = string.format("%."..postcomma.."f", amount)
- end
- else
- while true do
- formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
- if (k == 0) then break end
- end
- end
- return formatted
-end
-
-function PrintConsole(output, highlight)
- highlight = highlight or false
- if highlight then
- system.print(
- "------------------------------------------------------------------------")
- end
- system.print(output)
- if highlight then
- system.print(
- "------------------------------------------------------------------------")
- end
-end
-
-function DrawCenteredText(output)
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- screens[i].element.setCenteredText(output)
- end
- end
-end
-
-function ClearConsole()
- for i = 1, 10, 1 do
- PrintConsole()
- end
-end
-
-function SwitchScreens(state)
- state = state or "on"
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- if state == "on" then
- screens[i].element.clear()
- screens[i].element.activate()
- screens[i].active = true
- else
- screens[i].element.clear()
- screens[i].element.deactivate()
- screens[i].active = false
- end
- end
- end
-end
-
---[[ Convert seconds to string (by Jericho) ]]
-function GetSecondsString(seconds)
- local seconds = tonumber(seconds)
-
- if seconds == nil or seconds <= 0 then
- return "-";
- else
- days = string.format("%2.f", math.floor(seconds/(3600*24)));
- hours = string.format("%2.f", math.floor(seconds/3600 - (days*24)));
- mins = string.format("%2.f", math.floor(seconds/60 - (hours*60) - (days*24*60)));
- secs = string.format("%2.f", math.floor(seconds - hours*3600 - (days*24*60*60) - mins *60));
- str = ""
- if tonumber(days) > 0 then str = str .. days.."d " end
- if tonumber(hours) > 0 then str = str .. hours.."h " end
- if tonumber(mins) > 0 then str = str .. mins.."m " end
- if tonumber(secs) > 0 then str = str .. secs .."s" end
- return str
- end
-end
-
-function replace_char(pos, str, r)
- return str:sub(1, pos-1) .. r .. str:sub(pos+1)
-end
-
---[[ 2. RENDER HELPER FUNCTIONS ]]
-
---[[ epochTime function by Leodr (clock script), enhanced by Jericho (DU Industry script) ]]
-function epochTime()
- function rZ(a)
- if string.len(a) <= 1 then
- return "0" .. a
- else
- return a
- end
- end
- function dPoint(b)
- if not (b == math.floor(b)) then
- return true
- else
- return false
- end
- end
- function lYear(year)
- if not dPoint(year / 4) then
- if dPoint(year / 100) then
- return true
- else
- if not dPoint(year / 400) then
- return true
- else
- return false
- end
- end
- else
- return false
- end
- end
- local c = 5;
- local d = 3600;
- local e = 86400;
- local f = 31536000;
- local g = 31622400;
- local h = 2419200;
- local i = 2505600;
- local j = 2592000;
- local k = 2678400;
- local l = {4, 6, 9, 11}
- local m = {1, 3, 5, 7, 8, 10, 12}
- local n = 0;
- local o = 1506816000;
- local q = system.getTime()
- _G["formerTime"] = q
- if AddSummertimeHour == true then q = q + 3600 end
- now = math.floor(q + o)
- year = 1970;
- secs = 0;
- n = 0;
- while secs + g < now or secs + f < now do
- if lYear(year + 1) then
- if secs + g < now then
- secs = secs + g;
- year = year + 1;
- n = n + 366
- end
- else
- if secs + f < now then
- secs = secs + f;
- year = year + 1;
- n = n + 365
- end
- end
- end
- secondsRemaining = now - secs;
- monthSecs = 0;
- yearlYear = lYear(year)
- month = 1;
- while monthSecs + h < secondsRemaining or monthSecs + j < secondsRemaining or
- monthSecs + k < secondsRemaining do
- if month == 1 then
- if monthSecs + k < secondsRemaining then
- month = 2;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 2 then
- if not yearlYear then
- if monthSecs + h < secondsRemaining then
- month = 3;
- monthSecs = monthSecs + h;
- n = n + 28
- else
- break
- end
- else
- if monthSecs + i < secondsRemaining then
- month = 3;
- monthSecs = monthSecs + i;
- n = n + 29
- else
- break
- end
- end
- end
- if month == 3 then
- if monthSecs + k < secondsRemaining then
- month = 4;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 4 then
- if monthSecs + j < secondsRemaining then
- month = 5;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- if month == 5 then
- if monthSecs + k < secondsRemaining then
- month = 6;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 6 then
- if monthSecs + j < secondsRemaining then
- month = 7;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- if month == 7 then
- if monthSecs + k < secondsRemaining then
- month = 8;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 8 then
- if monthSecs + k < secondsRemaining then
- month = 9;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 9 then
- if monthSecs + j < secondsRemaining then
- month = 10;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- if month == 10 then
- if monthSecs + k < secondsRemaining then
- month = 11;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 11 then
- if monthSecs + j < secondsRemaining then
- month = 12;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- end
- day = 1;
- daySecs = 0;
- daySecsRemaining = secondsRemaining - monthSecs;
- while daySecs + e < daySecsRemaining do
- day = day + 1;
- daySecs = daySecs + e;
- n = n + 1
- end
- hour = 0;
- hourSecs = 0;
- hourSecsRemaining = daySecsRemaining - daySecs;
- while hourSecs + d < hourSecsRemaining do
- hour = hour + 1;
- hourSecs = hourSecs + d
- end
- minute = 0;
- minuteSecs = 0;
- minuteSecsRemaining = hourSecsRemaining - hourSecs;
- while minuteSecs + 60 < minuteSecsRemaining do
- minute = minute + 1;
- minuteSecs = minuteSecs + 60
- end
- second = math.floor(now % 60)
- year = rZ(year)
- month = rZ(month)
- day = rZ(day)
- hour = rZ(hour)
- minute = rZ(minute)
- second = rZ(second)
-
- return [[]]..hour..":".. minute..[[]]..
- [[]]..year.."/".. month.."/"..day..[[]]
-end
-
-
-function ToggleHUD()
- if HUDMode == true then
- HUDMode = false
- forceDamageRedraw = true
- hudSelectedIndex = 0
- highlightID = 0
- HideHighlight()
- SetRefresh()
- RenderScreens()
- else
- HUDMode = true
- forceDamageRedraw = true
- hudSelectedIndex = 0
- highlightID = 0
- HideHighlight()
- SetRefresh()
- RenderScreens()
- end
-end
-
-function HudDeselectElement()
- hudSelectedIndex = 0
- hudStartIndex = 1
- highlightID = 0
- HideHighlight()
- if HUDMode == true then
- SetRefresh("damage")
- SetRefresh("damageoutline")
- RenderScreens()
- end
-end
-
-function ChangeHudSelectedElement(step)
- if HUDMode == true and #rE > 0 then
-
- hudSelectedIndex = hudSelectedIndex + step
- if hudSelectedIndex < 1 then hudSelectedIndex = 1
- elseif hudSelectedIndex > #rE then hudSelectedIndex = #rE
- end
-
- if hudSelectedIndex > 9 then
- hudStartIndex = hudSelectedIndex-9
- end
- if hudSelectedIndex ~= 0 then
- highlightID = rE[hudSelectedIndex].id
- if highlightID ~=nil and highlightID ~= 0 then
- -- PrintConsole("CHSE: hudSelectedIndex: "..hudSelectedIndex.." / hudStartIndex: "..hudStartIndex.." / highlightID: "..highlightID)
- HideHighlight()
- elementPosition = vec3(rE[hudSelectedIndex].pos)
- highlightX = elementPosition.x - coreWorldOffset
- highlightY = elementPosition.y - coreWorldOffset
- highlightZ = elementPosition.z - coreWorldOffset
- highlightOn = true
- ShowHighlight()
- end
- end
-
- SetRefresh("damage")
- SetRefresh("damageoutline")
- RenderScreens()
-
- end
-end
-
-function HideHighlight()
- if #hudArrowSticker > 0 then
- for i in pairs(hudArrowSticker) do
- core.deleteSticker(hudArrowSticker[i])
- end
- hudArrowSticker = {}
- end
-end
-
-function ShowHighlight()
- if highlightOn == true and highlightID > 0 then
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX + 2, highlightY, highlightZ, "north"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY - 2, highlightZ, "east"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX - 2, highlightY, highlightZ, "south"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY + 2, highlightZ, "west"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY, highlightZ - 2, "up"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY, highlightZ + 2,"down"))
- end
-end
-
-function ToggleHighlight()
- if highlightOn == true then
- highlightOn = false
- HideHighlight()
- else
- highlightOn = true
- ShowHighlight()
- end
-end
-
-function SortDamageTables()
- table.sort(damagedElements, function(a, b) return a.missinghp > b.missinghp end)
- table.sort(brokenElements, function(a, b) return a.maxhp > b.maxhp end)
-end
-
-function getScraps(damage,commaval)
- commaval = commaval or false
- damage = damage - SkillRepairToolOptimization * 0.05 * damage
- local res = math.ceil( damage / ( 10 * 5^(ScrapTier-1) ) )
- if commaval ==true then
- return GenerateCommaValue(string.format("%.0f", res ), false)
- else
- return res
- end
-end
-
-function getRepairTime(damage,buildstring)
- buildstring = buildstring or false
- damage = damage - SkillRepairToolOptimization * 0.05 * damage
- local res = math.ceil(damage / ScrapTierRepairTimes[ScrapTier])
- res = res - ( SkillRepairToolEfficiency * 0.1 * res )
- if buildstring == true then
- return GetSecondsString(string.format("%.0f", res ) )
- else
- return res
- end
-end
-
-function UpdateDataDamageoutline()
-
- dmgoElements = {}
-
- for i,element in ipairs(brokenElements) do
- if #dmgoElements < DMGOMaxElements then
- local elementPosition = vec3(element.pos)
- local x = elementPosition.x - coreWorldOffset
- local y = elementPosition.y - coreWorldOffset
- local z = elementPosition.z - coreWorldOffset
- if x < ShipXmin then ShipXmin = x end
- if y < ShipYmin then ShipYmin = y end
- if z < ShipZmin then ShipZmin = z end
- if x > ShipXmax then ShipXmax = x end
- if y > ShipYmax then ShipYmax = y end
- if z > ShipZmax then ShipZmax = z end
- table.insert( dmgoElements, {
- id = element.id,
- type = "b",
- size = element.maxhp,
- x = x, y = y, z = z,
- xp = 0, yp = 0, zp = 0,
- u = 0, v = 0
- })
- end
- end
-
- if #dmgoElements < DMGOMaxElements then
- for i,element in ipairs(damagedElements) do
- if #dmgoElements < DMGOMaxElements then
- local elementPosition = vec3(element.pos)
- local x = elementPosition.x - coreWorldOffset
- local y = elementPosition.y - coreWorldOffset
- local z = elementPosition.z - coreWorldOffset
- if x < ShipXmin then ShipXmin = x end
- if y < ShipYmin then ShipYmin = y end
- if z < ShipZmin then ShipZmin = z end
- if x > ShipXmax then ShipXmax = x end
- if y > ShipYmax then ShipYmax = y end
- if z > ShipZmax then ShipZmax = z end
- table.insert( dmgoElements, {
- id = element.id,
- type = "d",
- size = element.maxhp,
- x = x, y = y, z = z,
- xp = 0, yp = 0, zp = 0,
- u = 0, v = 0
- })
- end
- end
- end
-
- if #dmgoElements < DMGOMaxElements then
- for i,element in ipairs(healthyElements) do
- if #dmgoElements < DMGOMaxElements then
- local elementPosition = vec3(element.pos)
- local x = elementPosition.x - coreWorldOffset
- local y = elementPosition.y - coreWorldOffset
- local z = elementPosition.z - coreWorldOffset
- if x < ShipXmin then ShipXmin = x end
- if y < ShipYmin then ShipYmin = y end
- if z < ShipZmin then ShipZmin = z end
- if x > ShipXmax then ShipXmax = x end
- if y > ShipYmax then ShipYmax = y end
- if z > ShipZmax then ShipZmax = z end
- table.insert( dmgoElements, {
- id = element.id,
- type = "h",
- size = element.maxhp,
- x = x, y = y, z = z,
- xp = 0, yp = 0, zp = 0,
- u = 0, v = 0
- })
- end
- end
- end
-
- ShipX = math.abs(ShipXmax-ShipXmin)
- ShipY = math.abs(ShipYmax-ShipYmin)
- ShipZ = math.abs(ShipZmax-ShipZmin)
-
- --[[
- PrintConsole(
- "ShipXmin: "..string.format("%.2f",ShipXmin)..
- " - ShipYmin: "..string.format("%.2f",ShipYmin)..
- " - ShipZmin: "..string.format("%.2f",ShipZmin)..
- " - ShipXmax: "..string.format("%.2f",ShipXmax)..
- " - ShipYmax: "..string.format("%.2f",ShipYmax)..
- " - ShipZmax: "..string.format("%.2f",ShipZmax)
- )
-
- PrintConsole(
- "ShipX: "..string.format("%.2f",ShipX)..
- " - ShipY: "..string.format("%.2f",ShipY)..
- " - ShipZ: "..string.format("%.2f",ShipZ)
- )
- ]]
-
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].xp = math.abs(100/(ShipXmax-ShipXmin)*(element.x-ShipXmin))
- dmgoElements[i].yp = math.abs(100/(ShipYmax-ShipYmin)*(element.y-ShipYmin))
- dmgoElements[i].zp = math.abs(100/(ShipZmax-ShipZmin)*(element.z-ShipZmin))
- -- PrintConsole(i..". "..element.id..": "..string.format("%.2f",element.x).."/"..string.format("%.2f",element.y).."/"..string.format("%.2f",element.z).." - XP: "..dmgoElements[i].xp.." - YP: "..dmgoElements[i].yp.." - ZP: "..dmgoElements[i].zp)
- end
-
-end
-
-function UpdateViewDamageoutline(screen)
- -- Full Width of virtual screen:
- -- UStart = 20
- -- VStart = 180
- -- UDim = 1880
- -- VDim = 840
- -- Adding frames:
- UFrame = 40
- VFrame = 40
-
- UStart = 20 + UFrame
- VStart = 180 + VFrame
- UDim = 1880 - 2*UFrame
- VDim = 840 - 2*VFrame
-
- if screen.submode == "top" then
- if DMGOStretch == false then
- local UFactor = UDim/(ShipYmax-ShipYmin)
- local VFactor = VDim/(ShipXmax-ShipXmin)
- if UFactor>=VFactor then
- local cFactor = UFactor/VFactor
- local newUDim = math.floor(UDim/cFactor)
- UStart = UStart+(UDim-newUDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100/cFactor*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*element.xp+VStart)
- end
- else
- local cFactor = VFactor/UFactor
- local newVDim = math.floor(VDim/cFactor)
- VStart = VStart+(VDim-newVDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100/cFactor*element.xp+VStart)
- end
- end
- else
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*element.xp+VStart)
- end
- end
-
-
- elseif screen.submode == "front" then
- if DMGOStretch == false then
- local UFactor = UDim/(ShipXmax-ShipXmin)
- local VFactor = VDim/(ShipZmax-ShipZmin)
- if UFactor>=VFactor then
- local cFactor = UFactor/VFactor
- local newUDim = math.floor(UDim/cFactor)
- UStart = UStart+(UDim-newUDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100/cFactor*element.xp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- else
- local cFactor = VFactor/UFactor
- local newVDim = math.floor(VDim/cFactor)
- VStart = VStart+(VDim-newVDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.xp+UStart)
- dmgoElements[i].v = math.floor(VDim/100/cFactor*(100-element.zp)+VStart)
- end
- end
- else
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.xp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- end
-
- elseif screen.submode == "side" then
- if DMGOStretch == false then
- local UFactor = UDim/(ShipYmax-ShipYmin)
- local VFactor = VDim/(ShipXmax-ShipZmin)
- if UFactor>=VFactor then
- local cFactor = UFactor/VFactor
- local newUDim = math.floor(UDim/cFactor)
- UStart = UStart+(UDim-newUDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100/cFactor*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- else
- local cFactor = VFactor/UFactor
- local newVDim = math.floor(VDim/cFactor)
- VStart = VStart+(VDim-newVDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100/cFactor*(100-element.zp)+VStart)
- end
- end
- else
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- end
- else
- DrawCenteredText("ERROR: non-existing DMGO mode set.")
- PrintConsole("ERROR: non-existing DMGO mode set.")
- unit.exit()
- end
-end
-
-function GetDamageoutlineShip()
- local output = ""
-
- for i,element in ipairs(dmgoElements) do
- local cclass = ""
- local size = 1
-
- if element.type == "h" then
- cclass ="ch"
- elseif element.type == "d" then
- cclass = "cw"
- else
- cclass = "cc"
- end
- if element.id == highlightID then
- cclass = "f2"
- end
-
- if element.size > 0 and element.size < 1000 then
- size = 5
- elseif element.size >= 1000 and element.size < 2000 then
- size = 8
- elseif element.size >= 2000 and element.size < 5000 then
- size = 12
- elseif element.size >= 5000 and element.size < 10000 then
- size = 15
- elseif element.size >= 10000 and element.size < 20000 then
- size = 20
- elseif element.size >= 20000 then
- size = 30
- end
- output = output .. [[]]
- if element.id == highlightID then
- output = output .. [[]]
- output = output .. [[]]
- end
- end
-
- return output
-end
-
-function GetContentClickareas(screen)
- local output = ""
- if screen ~= nil and screen.ClickAreas ~= nil and #screen.ClickAreas > 0 then
- for i,ca in ipairs(screen.ClickAreas) do
- output = output ..
- [[]]
- end
- end
- return output
-end
-
-function GetElement1(x, y, width, height)
- x = x or 0
- y = y or 0
- width = width or 600
- height = height or 600
- local output = ""
- output = output ..
- [[
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetElement2(x, y)
- x = x or 0
- y = y or 0
- local output = ""
- output = output .. [[]]
- return output
-end
-
-function GetElementLogo(x, y, primaryC, secondaryC, tertiaryC)
- x = x or 812
- y = y or 380
- primaryC = primaryC or "f"
- secondaryC = secondaryC or "f2"
- tertiaryC = tertiaryC or "f3"
- local output = ""
- output = output .. [[
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetHeader(headertext)
- headertext = headertext or "ERROR: UNDEFINED"
- local output = ""
- output = output ..
- [[
- ]]..headertext..[[]]
- return output
-end
-
-function GetContentBackground(candidate, bgcolor)
- bgColor = ColorBackgroundPattern
-
- local output = ""
-
- if candidate == "dots" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' viewBox='0 0 4 4'%3E%3Cpath fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' d='M1 3h1v1H1V3zm2-2h1v1H3V1z'%3E%3C/path%3E%3C/svg%3E");]]
- elseif candidate == "rain" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='12' height='16' viewBox='0 0 12 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 .99C4 .445 4.444 0 5 0c.552 0 1 .45 1 .99v4.02C6 5.555 5.556 6 5 6c-.552 0-1-.45-1-.99V.99zm6 8c0-.546.444-.99 1-.99.552 0 1 .45 1 .99v4.02c0 .546-.444.99-1 .99-.552 0-1-.45-1-.99V8.99z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E");]]
- elseif candidate == "plus" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "signal" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='84' height='48' viewBox='0 0 84 48' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h12v6H0V0zm28 8h12v6H28V8zm14-8h12v6H42V0zm14 0h12v6H56V0zm0 8h12v6H56V8zM42 8h12v6H42V8zm0 16h12v6H42v-6zm14-8h12v6H56v-6zm14 0h12v6H70v-6zm0-16h12v6H70V0zM28 32h12v6H28v-6zM14 16h12v6H14v-6zM0 24h12v6H0v-6zm0 8h12v6H0v-6zm14 0h12v6H14v-6zm14 8h12v6H28v-6zm-14 0h12v6H14v-6zm28 0h12v6H42v-6zm14-8h12v6H56v-6zm0-8h12v6H56v-6zm14 8h12v6H70v-6zm0 8h12v6H70v-6zM14 24h12v6H14v-6zm14-8h12v6H28v-6zM14 8h12v6H14V8zM0 8h12v6H0V8z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E");]]
- elseif candidate == "deathstar" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='105' viewBox='0 0 80 105'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M20 10a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm15 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zM20 75a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zm30-65a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm0 65a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zM35 10a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zM5 45a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zm60 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10z' /%3E%3C/g%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "diamond" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='32' viewBox='0 0 16 32'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath fill-rule='evenodd' d='M0 24h4v2H0v-2zm0 4h6v2H0v-2zm0-8h2v2H0v-2zM0 0h4v2H0V0zm0 4h2v2H0V4zm16 20h-6v2h6v-2zm0 4H8v2h8v-2zm0-8h-4v2h4v-2zm0-20h-6v2h6V0zm0 4h-4v2h4V4zm-2 12h2v2h-2v-2zm0-8h2v2h-2V8zM2 8h10v2H2V8zm0 8h10v2H2v-2zm-2-4h14v2H0v-2zm4-8h6v2H4V4zm0 16h6v2H4v-2zM6 0h2v2H6V0zm0 24h2v2H6v-2z'/%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "hexagon" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='49' viewBox='0 0 28 49'%3E%3Cg fill-rule='evenodd'%3E%3Cg id='hexagons' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='nonzero'%3E%3Cpath d='M13.99 9.25l13 7.5v15l-13 7.5L1 31.75v-15l12.99-7.5zM3 17.9v12.7l10.99 6.34 11-6.35V17.9l-11-6.34L3 17.9zM0 15l12.98-7.5V0h-2v6.35L0 12.69v2.3zm0 18.5L12.98 41v8h-2v-6.85L0 35.81v-2.3zM15 0v7.5L27.99 15H28v-2.31h-.01L17 6.35V0h-2zm0 49v-8l12.99-7.5H28v2.31h-.01L17 42.15V49h-2z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "capsule" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='32' height='26' viewBox='0 0 32 26' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M14 0v3.994C14 7.864 10.858 11 7 11c-3.866 0-7-3.138-7-7.006V0h2v4.005C2 6.765 4.24 9 7 9c2.756 0 5-2.236 5-4.995V0h2zm0 26v-5.994C14 16.138 10.866 13 7 13c-3.858 0-7 3.137-7 7.006V26h2v-6.005C2 17.235 4.244 15 7 15c2.76 0 5 2.236 5 4.995V26h2zm2-18.994C16 3.136 19.142 0 23 0c3.866 0 7 3.138 7 7.006v9.988C30 20.864 26.858 24 23 24c-3.866 0-7-3.138-7-7.006V7.006zm2-.01C18 4.235 20.244 2 23 2c2.76 0 5 2.236 5 4.995v10.01C28 19.765 25.756 22 23 22c-2.76 0-5-2.236-5-4.995V6.995z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E");]]
- elseif candidate == "diagonal" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='6' height='6' viewBox='0 0 6 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'%3E%3Cpath d='M5 0h1L0 6V5zM6 5v1H5z'/%3E%3C/g%3E%3C/svg%3E");]]
- end
- return output;
-end
-
-function GetContentDamageHUDOutput()
- local hudWidth = 300
- local hudHeight = 165
- if #damagedElements > 0 or #brokenElements > 0 then hudHeight = 510 end
- local output = ""
-
- output = output .. [[
-
- ]]
- output = output .. [[]] ..
- [[]] ..
- [[]] ..
- [[]]..(YourShipsName=="Enter here" and ("Ship ID "..ShipID) or YourShipsName) .. [[]] ..
- [[]]
- if #brokenElements > 0 then
- output = output .. [[]]
- elseif #damagedElements > 0 then
- output = output .. [[]]
- else
- output = output .. [[]]
- end
-
- if #damagedElements > 0 or #brokenElements > 0 then
-
- output = output .. [[Total Damage]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", totalShipMaxHP - totalShipHP))..[[]]
- output = output .. [[T]]..ScrapTier..[[ Scrap Needed]] ..
- [[]]..getScraps(totalShipMaxHP - totalShipHP, true)..[[]]
- output = output .. [[Repair Time]] ..
- [[]]..getRepairTime(totalShipMaxHP - totalShipHP, true)..[[]]
-
- output = output .. [[]] ..
- [[]] ..
- [[]]..#healthyElements..[[]] ..
- [[]] ..
- [[]]..#damagedElements..[[]] ..
- [[]] ..
- [[]]..#brokenElements..[[]]
- local j=0
-
- for currentIndex=hudStartIndex,hudStartIndex+9,1 do
- if rE[currentIndex] ~= nil then
- v = rE[currentIndex]
- if v.hp > 0 then
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- if v.id == highlightID then
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- end
- else
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- if v.id == highlightID then
- highlightX = elementPosition.x - coreWorldOffset
- highlightY = elementPosition.y - coreWorldOffset
- highlightZ = elementPosition.z - coreWorldOffset
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- end
- end
- j=j+1
- end
- end
- if DisallowKeyPresses == true then
- output = output ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Keypresses disabled.]] ..
- [[Change in LUA parameters]] ..
- [[by unchecking DisallowKeyPresses.]] ..
- [[]] ..
- [[]] ..
- [[]]
- else
- output = output ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Up/down arrows to highlight]] ..
- [[CTRL + arrows to move HUD]] ..
- [[Left arrow to toggle HUD Mode]] ..
- [[ALT+1-4 to set Scrap Tier]] ..
- [[ALT+8 to reset HUD position]] ..
- [[ALT+9 to shut script off]] ..
- [[]] ..
- [[]]
- end
- else
- if DisallowKeyPresses == true then
- output = output ..
- [[]] .. OkayCenterMessage .. [[]] ..
- [[]]..#healthyElements..[[ elements / ]] .. GenerateCommaValue(string.format("%.0f", totalShipMaxHP)) .. [[ HP.]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Keypresses disabled.]] ..
- [[Change in LUA parameters]] ..
- [[by unchecking DisallowKeyPresses.]] ..
- [[]] ..
- [[]] ..
- [[]]
- else
- output = output ..
- [[]] .. OkayCenterMessage .. [[]] ..
- [[]]..#healthyElements..[[ elements / ]] .. GenerateCommaValue(string.format("%.0f", totalShipMaxHP)) .. [[ HP.]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Left arrow to toggle HUD Mode]] ..
- [[CTRL + arrows to move HUD]] ..
- [[ALT+8 to reset HUD position]] ..
- [[ALT+9 to shut script off]] ..
- [[]] ..
- [[]]
- end
- end
- output = output .. [[]]
- return output
-end
-
-function GetContentDamageScreen()
-
- local screenOutput = ""
-
- -- Draw damage elements
- if #damagedElements > 0 then
- local damagedElementsToDraw = #damagedElements
- if damagedElementsToDraw > DamagePageSize then
- damagedElementsToDraw = DamagePageSize
- end
- if CurrentDamagedPage == math.ceil(#damagedElements / DamagePageSize) then
- damagedElementsToDraw = #damagedElements % DamagePageSize + 12
- if damagedElementsToDraw > 12 then damagedElementsToDraw = damagedElementsToDraw - 12 end
- end
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
-
- if UseMyElementNames == true then screenOutput = screenOutput .. [[Damaged Name]]
- else screenOutput = screenOutput .. [[Damaged Type]]
- end
-
- screenOutput = screenOutput .. [[HLTHDMG]]
- screenOutput = screenOutput .. [[T]]..ScrapTier..[[ SCRREPTIME]]
-
- AddClickArea("damage", {
- id = "SwitchScrapTier",
- mode ="damage",
- x1 = 650,
- x2 = 775,
- y1 = 315,
- y2 = 360
- })
-
- local i = 0
- for j = 1 + (CurrentDamagedPage - 1) * DamagePageSize, damagedElementsToDraw + (CurrentDamagedPage - 1) * DamagePageSize, 1 do
- i = i + 1
- local DP = damagedElements[j]
- if UseMyElementNames == true then screenOutput = screenOutput .. [[]] .. string.format("%.23s", DP.name) .. [[]]
- else screenOutput = screenOutput .. [[]] .. string.format("%.23s", DP.type) .. [[]]
- end
- screenOutput = screenOutput .. [[]] .. DP.percent .. [[%]] ..
- [[]] .. GenerateCommaValue(string.format("%.0f", DP.missinghp), true) .. [[]] ..
- [[]] .. getScraps(DP.missinghp, true) .. [[]] ..
- [[]] .. getRepairTime(DP.missinghp, true) .. [[]] ..
- [[]]
- end
-
- if #damagedElements > DamagePageSize then
- screenOutput = screenOutput ..
- [[Page ]] .. CurrentDamagedPage .. " of " .. math.ceil(#damagedElements / DamagePageSize) ..[[]]
-
- if CurrentDamagedPage < math.ceil(#damagedElements / DamagePageSize) then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "DamagedPageDown",
- mode ="damage",
- x1 = 65,
- x2 = 260,
- y1 = 290 + (damagedElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (damagedElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("DamagedPageDown","damage")
- end
-
- if CurrentDamagedPage > 1 then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "DamagedPageUp",
- mode ="damage",
- x1 = 750,
- x2 = 950,
- y1 = 290 + (damagedElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (damagedElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("DamagedPageUp","damage")
- end
- end
- end
-
- -- Draw broken elements
- if #brokenElements > 0 then
- local brokenElementsToDraw = #brokenElements
- if brokenElementsToDraw > DamagePageSize then
- brokenElementsToDraw = DamagePageSize
- end
- if CurrentBrokenPage == math.ceil(#brokenElements / DamagePageSize) then
- brokenElementsToDraw = #brokenElements % DamagePageSize + 12
- if brokenElementsToDraw > 12 then brokenElementsToDraw = brokenElementsToDraw - 12 end
- end
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
-
- if UseMyElementNames == true then screenOutput = screenOutput .. [[Broken Name]]
- else screenOutput = screenOutput .. [[Broken Type]]
- end
-
- screenOutput = screenOutput .. [[DMG]]
- screenOutput = screenOutput .. [[T]]..ScrapTier..[[ SCRREPTIME]]
-
- AddClickArea("damage", {
- id = "SwitchScrapTier2",
- mode ="damage",
- x1 = 1570,
- x2 = 1690,
- y1 = 315,
- y2 = 360
- })
-
- local i = 0
- for j = 1 + (CurrentBrokenPage - 1) * DamagePageSize, brokenElementsToDraw + (CurrentBrokenPage - 1) * DamagePageSize, 1 do
- i = i + 1
- local DP = brokenElements[j]
- if UseMyElementNames == true then screenOutput = screenOutput .. [[]] .. string.format("%.30s", DP.name) .. [[]]
- else screenOutput = screenOutput .. [[]] .. string.format("%.30s", DP.type) .. [[]]
- end
- screenOutput = screenOutput .. [[]] .. GenerateCommaValue(string.format("%.0f", DP.missinghp), true) .. [[]] ..
- [[]] .. getScraps(DP.missinghp, true) .. [[]] ..
- [[]] .. getRepairTime(DP.missinghp, true) .. [[]] ..
- [[]]
- end
-
-
-
- if #brokenElements > DamagePageSize then
- screenOutput = screenOutput ..
- [[Page ]] .. CurrentBrokenPage .. " of " .. math.ceil(#brokenElements / DamagePageSize) .. [[]]
-
- if CurrentBrokenPage > 1 then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "BrokenPageUp",
- mode ="damage",
- x1 = 1665,
- x2 = 1865,
- y1 = 290 + (brokenElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (brokenElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("BrokenPageUp", "damage")
- end
-
- if CurrentBrokenPage < math.ceil(#brokenElements / DamagePageSize) then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "BrokenPageDown",
- mode ="damage",
- x1 = 980,
- x2 = 1180,
- y1 = 290 + (brokenElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (brokenElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("BrokenPageDown", "damage")
- end
- end
-
- end
-
- -- Draw summary
- if #damagedElements > 0 or #brokenElements > 0 then
- local dWidth = math.floor(1878/#elementsIdList*#damagedElements)
- local bWidth = math.floor(1878/#elementsIdList*#brokenElements)
- local hWidth = 1878-dWidth-bWidth+1
-
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
-
- if #damagedElements > 0 then
- screenOutput = screenOutput .. [[]]..#damagedElements..[[]]
- end
- if #healthyElements > 0 then
- screenOutput = screenOutput .. [[]]..#healthyElements..[[]]
- end
- if #brokenElements > 0 then
- screenOutput = screenOutput .. [[]]..#brokenElements..[[]]
- end
-
- screenOutput = screenOutput .. [[]]
-
- screenOutput = screenOutput .. [[]] ..
- GenerateCommaValue(string.format("%.0f", totalShipMaxHP - totalShipHP)) .. [[ HP damage in total ]] ..
- getScraps(totalShipMaxHP - totalShipHP, true) .. [[ T]]..ScrapTier..[[ scraps needed. ]] ..
- getRepairTime(totalShipMaxHP - totalShipHP, true) .. [[ projected repair time.]]
- else
- screenOutput = screenOutput .. GetElementLogo(812, 380, "ch", "ch", "ch") ..
- [[]] .. OkayCenterMessage .. [[]] ..
- [[]]..#healthyElements..[[ elements stand ]] .. GenerateCommaValue(string.format("%.0f", totalShipMaxHP)) .. [[ HP strong.]]
- end
-
- forceDamageRedraw = false
-
- return screenOutput
-end
-
-function ActionStopengines()
- if DisallowKeyPresses == true then return end
- ToggleHUD()
-end
-
-function ActionStrafeRight()
- if DisallowKeyPresses == true then return end
- if KeyCTRLPressed == true then
- if HUDShiftU < 4000 then
- HUDShiftU = HUDShiftU + 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- HudDeselectElement()
- end
-end
-
-function ActionStrafeLeft()
- if DisallowKeyPresses == true then return end
- if KeyCTRLPressed == true then
- if HUDShiftU >= 50 then
- HUDShiftU = HUDShiftU - 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- ToggleHUD()
- end
-end
-
-function ActionDown()
- if DisallowKeyPresses == true then return end
- if KeyCTRLPressed == true then
- if HUDShiftV < 4000 then
- HUDShiftV = HUDShiftV + 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- ChangeHudSelectedElement(1)
- end
-end
-
-function ActionUp()
- if DisallowKeyPresses == true then return end
- if KeyCTRLPressed == true then
- if HUDShiftV >= 50 then
- HUDShiftV = HUDShiftV - 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- ChangeHudSelectedElement(-1)
- end
-end
-
-function ActionOption1()
- if DisallowKeyPresses == true then return end
- ScrapTier = 1
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption2()
- if DisallowKeyPresses == true then return end
- ScrapTier = 2
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption3()
- if DisallowKeyPresses == true then return end
- ScrapTier = 3
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption4()
- if DisallowKeyPresses == true then return end
- ScrapTier = 4
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption8()
- if DisallowKeyPresses == true then return end
- HUDShiftU=0
- HUDShiftV=0
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption9()
- if DisallowKeyPresses == true then return end
- SaveToDatabank()
- SwitchScreens("off")
- unit.exit()
-end
diff --git a/src/DamageReport_3_12_UnitStart_2.lua b/src/DamageReport_3_12_UnitStart_2.lua
deleted file mode 100644
index 5349375..0000000
--- a/src/DamageReport_3_12_UnitStart_2.lua
+++ /dev/null
@@ -1,2052 +0,0 @@
---[[
- Damage Report 3.12
- A LUA script for Dual Universe
-
- Created By Dorian Gray
- Ingame: DorianGray
- Discord: Dorian Gray#2623
-
- You can find/update this script on GitHub. Explanations, installation and usage information as well as screenshots can be found there too.
- GitHub: https://github.com/DorianTheGrey/DU-DamageReport
-
- GNU Public License 3.0. Use whatever you want, be so kind to leave credit.
-
- Credits & thanks:
- Thanks to NovaQuark for creating the MMO of the century.
- Thanks to Jericho, Dmentia and Archaegeo for learning a lot from their fine scripts.
- Thanks to TheBlacklist for testing and wonderful suggestions.
- SVG patterns by Hero Patterns.
- DU atlas data from Jayle Break.
-
-]]
-
---[[ 1. USER DEFINED VARIABLES ]]
-
-YourShipsName = "Enter here" --export Enter your ship name here if you want it displayed instead of the ship's ID. YOU NEED TO LEAVE THE QUOTATION MARKS.
-
-SkillRepairToolEfficiency = 0 --export Enter (0-5) your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency"
-SkillRepairToolOptimization = 0 --export Enter your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Optimization"
-
-StatAtmosphericFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED ATMOSPHERIC FUEL TANKS (from the builders talent "Piloting -> Atmospheric Flight Technician -> Atmospheric Fuel-Tank Handling")
-StatSpaceFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL SPACE TANKS (from the builders talent "Piloting -> Atmospheric Engine Technician -> Space Fuel-Tank Handling")
-StatRocketFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL ROCKET TANKS (from the builders talent "Piloting -> Rocket Scientist -> Rocket Booster Fuel Tank Handling")
-StatContainerOptimization = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL TANKS "from the builders talent Mining and Inventory -> Stock Control -> Container Optimization"
-StatFuelTankOptimization = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL TANKS "from the builders talent Mining and Inventory -> Stock Control -> Fuel Tank Optimization"
-
-ShowWelcomeMessage = true --export Do you want the welcome message on the start screen with your name?
-DisallowKeyPresses = false --export Need your keys for other scripts/huds and want to prevent Damage Report keypresses to be processed? Then check this. (Usability of the HUD mode will be small.)
-AddSummertimeHour = false --export: Is summertime currently enabled in your location? (Adds one hour.)
-
--- SkillAtmosphericFuelEfficiency = 0 --export Enter (0-5) your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency"
--- SkillSpaceFuelEfficiency = 0 --export Enter (0-5) your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency"
--- SkillRocketFuelEfficiency = 0 --export Enter (0-5) your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency"
-
---[[ 2. GLOBAL VARIABLES ]]
-
-UpdateDataInterval = 1.0 -- How often shall the data be updated? (Increase if running into CPU issues.)
-HighlightBlinkingInterval = 0.5 -- How fast shall highlight arrows of marked elements blink?
-
-ColorPrimary = "FF6700" -- Enter the hexcode of the main color to be used by all views.
-ColorSecondary = "FFFFFF" -- Enter the hexcode of the secondary color to be used by all views.
-ColorTertiary = "000000" -- Enter the hexcode of the tertiary color to be used by all views.
-ColorHealthy = "00FF00" -- Enter the hexcode of the 'healthy' color to be used by all views.
-ColorWarning = "FFFF00" -- Enter the hexcode of the 'warning' color to be used by all views.
-ColorCritical = "FF0000" -- Enter the hexcode of the 'critical' color to be used by all views.
-ColorBackground = "000000" -- Enter the hexcode of the background color to be used by all views.
-ColorBackgroundPattern = "4F4F4F" -- Enter the hexcode of the background color to be used by all views.
-ColorFuelAtmospheric = "004444" -- Enter the hexcode of the atmospheric fuel color.
-ColorFuelSpace = "444400" -- Enter the hexcode of the space fuel color.
-ColorFuelRocket = "440044" -- Enter the hexcode of the rocket fuel color.
-
-VERSION = 3.12
-DebugMode = false
-DebugRenderClickareas = true
-
-DBData = {}
-
-core = nil
-db = nil
-screens = {}
-dscreens = {}
-
-Warnings = {}
-
-screenModes = {
- ["flight"] = { id="flight" },
- ["damage"] = { id="damage" },
- ["damageoutline"] = { id="damageoutline" },
- ["fuel"] = { id="fuel" },
- ["cargo"] = { id="cargo" },
- ["agg"] = { id="agg" },
- ["map"] = { id="map" },
- ["time"] = { id="time", activetoggle="true" },
- ["settings1"] = { id="settings1" },
- ["startup"] = { id="startup" }
-}
-
-backgroundModes = { "deathstar", "capsule", "rain", "signal", "hexagon", "diagonal", "diamond", "plus", "dots" }
-BackgroundMode ="deathstar"
-BackgroundSelected = 1
-BackgroundModeOpacity = 0.25
-
-SaveVars = { "dscreens",
- "ColorPrimary", "ColorSecondary", "ColorTertiary",
- "ColorHealthy", "ColorWarning", "ColorCritical",
- "ColorBackground", "ColorBackgroundPattern",
- "ScrapTier", "HUDMode", "SimulationMode", "DMGOStretch",
- "HUDShiftU", "HUDShiftV", "colorIDIndex", "colorIDTable",
- "BackgroundMode", "BackgroundSelected", "BackgroundModeOpacity" }
-
-HUDMode = false
-HUDShiftU = 0
-HUDShiftV = 0
-hudSelectedIndex = 0
-hudStartIndex = 1
-hudArrowSticker = {}
-highlightOn = false
-highlightID = 0
-highlightX = 0
-highlightY = 0
-highlightZ = 0
-
-SimulationMode = false
-OkayCenterMessage = "All systems nominal."
-CurrentDamagedPage = 1
-CurrentBrokenPage = 1
-DamagePageSize = 12
-ScrapTier = 1
-totalScraps = 0
-ScrapTierRepairTimes = { 10, 50, 250, 1250 }
-
-coreWorldOffset = 0
-totalShipHP = 0
-formerTotalShipHP = -1
-totalShipMaxHP = 0
-totalShipIntegrity = 100
-elementsId = {}
-elementsIdList = {}
-damagedElements = {}
-brokenElements = {}
-rE = {}
-healthyElements = {}
-typeElements = {}
-ElementCounter = 0
-UseMyElementNames = true
-dmgoElements = {}
-DMGOMaxElements = 250
-DMGOStretch = false
-ShipXmin = 99999999
-ShipXmax = -99999999
-ShipYmin = 99999999
-ShipYmax = -99999999
-ShipZmin = 99999999
-ShipZmax = -99999999
-
-totalShipMass = 0
-formerTotalShipMass = -1
-
-formerTime = -1
-
-FuelAtmosphericTanks = {}
-FuelSpaceTanks = {}
-FuelRocketTanks = {}
-FuelAtmosphericTotal = 0
-FuelSpaceTotal = 0
-FuelRocketTotal = 0
-FuelAtmosphericCurrent = 0
-FuelSpaceTotalCurrent = 0
-FuelRocketTotalCurrent = 0
-formerFuelAtmosphericTotal = -1
-formerFuelSpaceTotal = -1
-formerFuelRocketTotal = -1
-
-hexTable = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"}
-colorIDIndex = 1
-colorIDTable = {
- [1] = {
- id="ColorPrimary",
- desc="Main HUD Color",
- basec = "FF6700",
- newc = "FF6700"
- },
- [2] = {
- id="ColorSecondary",
- desc="Secondary HUD Color",
- basec = "FFFFFF",
- newc = "FFFFFF"
- },
- [3] = {
- id="ColorTertiary",
- desc="Tertiary HUD Color",
- basec = "000000",
- newc = "000000"
- },
- [4] = {
- id="ColorHealthy",
- desc="Color code for Healthy/Okay",
- basec = "00FF00",
- newc = "00FF00"
- },
- [5] = {
- id="ColorWarning",
- desc="Color code for Damaged/Warning",
- basec = "FFFF00",
- newc = "FFFF00"
- },
- [6] = {
- id="ColorCritical",
- desc="Color code for Broken/Critical",
- basec = "FF0000",
- newc = "FF0000"
- },
- [7] = {
- id="ColorBackground",
- desc="Background Color",
- basec = "000000",
- newc = "000000"
- },
- [8] = {
- id="ColorBackgroundPattern",
- desc="Background Pattern Color",
- basec = "4F4F4F",
- newc = "4F4F4F"
- },
- [9] = {
- id="ColorFuelAtmospheric",
- desc="Color for Atmo Fuel/Elements",
- basec = "004444",
- newc = "004444"
- },
- [10] = {
- id="ColorFuelSpace",
- desc="Color for Space Fuel/Elements",
- basec = "444400",
- newc = "444400"
- },
- [11] = {
- id="ColorFuelRocket",
- desc="Color for Rocket Fuel/Elements",
- basec = "440044",
- newc = "440044"
- }
-}
-
-
---[[ 3. PROCESSING FUNCTIONS ]]
-
-function InitiateSlots()
- for slot_name, slot in pairs(unit) do
- if type(slot) == "table" and type(slot.export) == "table" and
- slot.getElementClass then
- local elementClass = slot.getElementClass():lower()
- if elementClass:find("coreunit") then
- core = slot
- local coreHP = core.getMaxHitPoints()
- if coreHP > 10000 then
- coreWorldOffset = 128
- elseif coreHP > 1000 then
- coreWorldOffset = 64
- elseif coreHP > 150 then
- coreWorldOffset = 32
- else
- coreWorldOffset = 16
- end
- elseif elementClass == 'databankunit' then
- db = slot
- elseif elementClass == "screenunit" then
- local iScreenMode = "startup"
- screens[#screens + 1] = {
- element = slot,
- id = slot.getId(),
- mode = iScreenMode,
- submode = "",
- ClickAreas = {},
- refresh = true,
- active = false,
- fuelA = true,
- fuelS = true,
- fuelR = true,
- fuelIndex = 1
- }
- end
- end
- end
-end
-
-function LoadFromDatabank()
- if db == nil then
- return
- else
- for _, data in pairs(SaveVars) do
- if db.hasKey(data) then
- local jData = json.decode( db.getStringValue(data) )
- if jData ~= nil then
- if data == "YourShipsName" or data == "AddSummertimeHour" or data == "UpdateDataInterval" or data == "HighlightBlinkingInterval" or
- data == "SkillRepairToolEfficiency" or data == "SkillRepairToolOptimization" or data == "SkillAtmosphericFuelEfficiency" or
- data == "SkillSpaceFuelEfficiency" or data == "SkillRocketFuelEfficiency" or data == "StatAtmosphericFuelTankHandling" or
- data == "StatSpaceFuelTankHandling" or data == "StatRocketFuelTankHandling"
- then
- -- Nada
- else
- _G[data] = jData
- end
- end
- end
- end
-
- for i,v in ipairs(screens) do
- for j,dv in ipairs(dscreens) do
- if screens[i].id == dscreens[j].id then
- screens[i].mode = dscreens[j].mode
- screens[i].submode = dscreens[j].submode
- screens[i].active = dscreens[j].active
- screens[i].refresh = true
- screens[i].fuelA = dscreens[j].fuelA
- screens[i].fuelS = dscreens[j].fuelS
- screens[i].fuelR = dscreens[j].fuelR
- screens[i].fuelIndex = dscreens[j].fuelIndex
- end
- end
- end
- end
-end
-
-function SaveToDatabank()
- if db == nil then
- return
- else
- dscreens = {}
- for i,screen in ipairs(screens) do
- dscreens[i] = {}
- dscreens[i].id = screen.id
- dscreens[i].mode = screen.mode
- dscreens[i].submode = screen.submode
- dscreens[i].active = screen.active
- dscreens[i].fuelA = screen.fuelA
- dscreens[i].fuelS = screen.fuelS
- dscreens[i].fuelR = screen.fuelR
- dscreens[i].fuelIndex = screen.fuelIndex
- end
-
- db.clear()
-
- for _, data in pairs(SaveVars) do
- db.setStringValue(data, json.encode(_G[data]))
- end
-
- end
-end
-
-function InitiateScreens()
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- screens[i] = CreateClickAreasForScreen(screens[i])
- end
- end
-end
-
-function UpdateTypeData()
- FuelAtmosphericTanks = {}
- FuelSpaceTanks = {}
- FuelRocketTanks = {}
-
- FuelAtmosphericTotal = 0
- FuelAtmosphericCurrent = 0
- FuelSpaceTotal = 0
- FuelSpaceCurrent = 0
- FuelRocketCurrent = 0
- FuelRocketTotal = 0
-
- local weightAtmosphericFuel = 4
- local weightSpaceFuel = 6
- local weightRocketFuel = 0.8
-
- --[[
- (FuelMass * (1-.05 * ) * (1-.05 * )
- It just seems to be that the Container Optimization and Fuel Tank Optimization are not added together so the max is not -50% (25% from each skill from the base mass) but 43.75% So the Fuel Tank Optimization uses the container optimization result as it's base value
- ]]
-
- if StatContainerOptimization > 0 then
- weightAtmosphericFuel = weightAtmosphericFuel - 0.05 * StatContainerOptimization * weightAtmosphericFuel
- weightSpaceFuel = weightSpaceFuel - 0.05 * StatContainerOptimization * weightSpaceFuel
- weightRocketFuel = weightRocketFuel - 0.05 * StatContainerOptimization * weightRocketFuel
- end
- if StatFuelTankOptimization > 0 then
- weightAtmosphericFuel = weightAtmosphericFuel - 0.05 * StatFuelTankOptimization * weightAtmosphericFuel
- weightSpaceFuel = weightSpaceFuel - 0.05 * StatFuelTankOptimization * weightSpaceFuel
- weightRocketFuel = weightRocketFuel - 0.05 * StatFuelTankOptimization * weightRocketFuel
- end
-
- for i, id in ipairs(typeElements) do
- local idName = core.getElementNameById(id) or ""
- local idType = core.getElementTypeById(id) or ""
- -- local idTypeClean = idType:gsub("[%s%-]+", ""):lower()
- local idPos = core.getElementPositionById(id) or 0
- local idHP = core.getElementHitPointsById(id) or 0
- local idMaxHP = core.getElementMaxHitPointsById(id) or 0
- local idMass = core.getElementMassById(id) or 0
-
- local baseSize = ""
- local baseVol = 0
- local baseMass = 0
- local cMass = 0
- local cVol = 0
-
- if idType == "atmospheric fuel-tank" then
- if idMaxHP > 10000 then
- baseSize = "L"
- baseMass = 5480
- baseVol = 12800
- elseif idMaxHP > 1300 then
- baseSize = "M"
- baseMass = 988.67
- baseVol = 1600
- elseif idMaxHP > 150 then
- baseSize = "S"
- baseMass = 182.67
- baseVol = 400
- else
- baseSize = "XS"
- baseMass = 35.03
- baseVol = 100
- end
- if StatAtmosphericFuelTankHandling > 0 then
- baseVol = 0.2 * StatAtmosphericFuelTankHandling * baseVol + baseVol
- end
- cMass = idMass - baseMass
- if cMass <=10 then cMass = 0 end
- cVol = string.format("%.0f", cMass / weightAtmosphericFuel)
- cPercent = string.format("%.1f", math.floor(100/baseVol * tonumber(cVol)))
- table.insert(FuelAtmosphericTanks, {
- type = 1,
- id = id,
- name = idName,
- maxhp = idMaxHP,
- hp = GetHPforElement(id),
- pos = idPos,
- size = baseSize,
- mass = baseMass,
- vol = baseVol,
- cvol = cVol,
- percent = cPercent
- })
- if idHP > 0 then
- FuelAtmosphericCurrent = FuelAtmosphericCurrent + cVol
- end
- FuelAtmosphericTotal = FuelAtmosphericTotal + baseVol
- elseif idType == "space fuel-tank" then
- if idMaxHP > 10000 then
- baseSize = "L"
- baseMass = 5480
- baseVol = 12800
- elseif idMaxHP > 1300 then
- baseSize = "M"
- baseMass = 988.67
- baseVol = 1600
- else
- baseSize = "S"
- baseMass = 182.67
- baseVol = 400
- end
- if StatSpaceFuelTankHandling > 0 then
- baseVol = 0.2 * StatSpaceFuelTankHandling * baseVol + baseVol
- end
- cMass = idMass - baseMass
- if cMass <=10 then cMass = 0 end
- cVol = string.format("%.0f", cMass / weightSpaceFuel)
- cPercent = string.format("%.1f", (100/baseVol * tonumber(cVol)))
- table.insert(FuelSpaceTanks, {
- type = 2,
- id = id,
- name = idName,
- maxhp = idMaxHP,
- hp = GetHPforElement(id),
- pos = idPos,
- size = baseSize,
- mass = baseMass,
- vol = baseVol,
- cvol = cVol,
- percent = cPercent
- })
- if idHP > 0 then
- FuelSpaceCurrent = FuelSpaceCurrent + cVol
- end
- FuelSpaceTotal = FuelSpaceTotal + baseVol
- elseif idType == "rocket fuel-tank" then
- if idMaxHP > 65000 then
- baseSize = "L"
- baseMass = 25740
- baseVol = 50000
- elseif idMaxHP > 6000 then
- baseSize = "M"
- baseMass = 4720
- baseVol = 6400
- elseif idMaxHP > 700 then
- baseSize = "S"
- baseMass = 886.72
- baseVol = 800
- else
- baseSize = "XS"
- baseMass = 173.42
- baseVol = 400
- end
- if StatRocketFuelTankHandling > 0 then
- baseVol = 0.2 * StatRocketFuelTankHandling * baseVol + baseVol
- end
- cMass = idMass - baseMass
- if cMass <=10 then cMass = 0 end
- cVol = string.format("%.0f", cMass / weightRocketFuel)
- cPercent = string.format("%.1f", (100/baseVol * tonumber(cVol)))
- table.insert(FuelRocketTanks, {
- type = 3,
- id = id,
- name = idName,
- maxhp = idMaxHP,
- hp = GetHPforElement(id),
- pos = idPos,
- size = baseSize,
- mass = baseMass,
- vol = baseVol,
- cvol = cVol,
- percent = cPercent
- })
- if idHP > 0 then
- FuelRocketCurrent = FuelRocketCurrent + cVol
- end
- FuelRocketTotal = FuelRocketTotal + baseVol
- end
-
- end
-
- if FuelAtmosphericCurrent ~= formerFuelAtmosphericCurrent then
- SetRefresh("fuel")
- formerFuelAtmosphericCurrent = FuelAtmosphericCurrent
- end
- if FuelSpaceCurrent ~= formerFuelSpaceCurrent then
- SetRefresh("fuel")
- formerFuelSpaceCurrent = FuelSpaceCurrent
- end
- if FuelRocketCurrent ~= formerFuelRocketCurrent then
- SetRefresh("fuel")
- formerFuelRocketCurrent = FuelRocketCurrent
- end
-
-
-
-end
-
-function UpdateDamageData(initial)
-
- initial = initial or false
-
- if SimulationActive == true then return end
-
- local formerTotalShipHP = totalShipHP
- totalShipHP = 0
- totalShipMaxHP = 0
- totalShipIntegrity = 100
- damagedElements = {}
- brokenElements = {}
- healthyElements = {}
- if initial == true then
- typeElements = {}
- end
-
- ElementCounter = 0
-
- elementsIdList = core.getElementIdList()
-
- for i, id in pairs(elementsIdList) do
-
- ElementCounter = ElementCounter + 1
-
- local idName = core.getElementNameById(id)
-
- local idType = core.getElementTypeById(id)
- -- local idTypeClean = idType:gsub("[%s%-]+", ""):lower()
- local idPos = core.getElementPositionById(id)
- local idHP = core.getElementHitPointsById(id)
- local idMaxHP = core.getElementMaxHitPointsById(id)
- -- local idMass = core.getElementMassById(id)
-
- if SimulationMode == true then
- SimulationActive = true
- local dice = math.random(0, 10)
- if dice < 2 and #brokenElements < 30 then
- idHP = 0
- elseif dice >= 2 and dice < 4 and #damagedElements < 30 then
- idHP = math.random(1, math.ceil(idMaxHP))
- else
- idHP = idMaxHP
- end
- end
-
- totalShipHP = totalShipHP + idHP
- totalShipMaxHP = totalShipMaxHP + idMaxHP
-
- if idMaxHP - idHP > constants.epsilon then
-
- if idHP > 0 then
- table.insert(damagedElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP - idHP,
- percent = math.ceil(100 / idMaxHP * idHP),
- pos = idPos
- })
- else
- table.insert(brokenElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP - idHP,
- percent = 0,
- pos = idPos
- })
- end
- else
- table.insert(healthyElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- pos = idPos
- })
- if id == highlightID then
- highlightID = 0
- highlightOn = false
- HideHighlight()
- hudSelectedIndex = 0
- end
- end
-
- if initial == true then
- if
- idType == "atmospheric fuel-tank" or
- idType == "space fuel-tank" or
- idType == "rocket fuel-tank"
- then
- table.insert(typeElements, id)
- end
- end
- end
-
- SortDamageTables()
-
- rE = {}
-
- if #brokenElements > 0 then
- for _,v in ipairs(brokenElements) do
- table.insert(rE, {id=v.id, missinghp=v.missinghp, hp=v.hp, name=v.name, type=v.type, pos=v.pos})
- end
- end
- if #damagedElements > 0 then
- for _,v in ipairs(damagedElements) do
- table.insert(rE, {id=v.id, missinghp=v.missinghp, hp=v.hp, name=v.name, type=v.type, pos=v.pos})
- end
- end
- if #rE > 0 then
- table.sort(rE, function(a,b) return a.missinghp>b.missinghp end)
- end
-
- totalShipIntegrity = string.format("%2.0f", 100 / totalShipMaxHP * totalShipHP)
-
- if formerTotalShipHP ~= totalShipHP then
- forceDamageRedraw = true
- formerTotalShipHP = totalShipHP
- else
- forceDamageRedraw = false
- end
-end
-
-function GetHPforElement(id)
- for i,v in ipairs(brokenElements) do
- if v.id == id then
- return 0
- end
- end
- for i,v in ipairs(damagedElements) do
- if v.id == id then
- return v.hp
- end
- end
- for i,v in ipairs(healthyElements) do
- if v.id == id then
- return v.maxhp
- end
- end
-end
-
-function UpdateClickArea(candidate, newEntry, mode)
- for i, screen in ipairs(screens) do
- for k, v in pairs(screens[i].ClickAreas) do
- if v.id == candidate and v.mode == mode then
- screens[i].ClickAreas[k] = newEntry
- end
- end
- end
-end
-
-function AddClickArea(mode, newEntry)
- for i, screen in ipairs(screens) do
- if screens[i].mode == mode then
- table.insert(screens[i].ClickAreas, newEntry)
- end
- end
-end
-
-function AddClickAreaForScreenID(screenid, newEntry)
- for i, screen in ipairs(screens) do
- if screens[i].id == screenid then
- table.insert(screens[i].ClickAreas, newEntry)
- end
- end
-end
-
-function DisableClickArea(candidate, mode)
- UpdateClickArea(candidate, {
- id = candidate,
- mode = mode,
- x1 = -1,
- x2 = -1,
- y1 = -1,
- y2 = -1
- })
-end
-
-function SetRefresh(mode, submode)
- mode = mode or "all"
- submode = submode or "all"
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- if screens[i].mode == mode or mode == "all" then
- if screens[i].submode == submode or submode =="all" then
- screens[i].refresh = true
- end
- end
- end
- end
-end
-
-function WipeClickAreasForScreen(screen)
- screen.ClickAreas = {}
- return screen
-end
-
-function CreateBaseClickAreas(screen)
- table.insert(screen.ClickAreas, {mode = "all", id = "ToggleHudMode", x1 = 1537, x2 = 1728, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "damage", x1 = 193, x2 = 384, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "damageoutline", x1 = 385, x2 = 576, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "fuel", x1 = 577, x2 = 768, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "flight", x1 = 769, x2 = 960, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "cargo", x1 = 961, x2 = 1152, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "agg", x1 = 1153, x2 = 1344, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "map", x1 = 1345, x2 = 1536, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "time", x1 = 0, x2 = 192, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "settings1", x1 = 1729, x2 = 1920, y1 = 1015, y2 = 1075} )
- return screen
-end
-
-function CreateClickAreasForScreen(screen)
-
- if screen == nil then return {} end
-
- if screen.mode == "flight" then
- elseif screen.mode == "damage" then
- table.insert( screen.ClickAreas, {mode = "damage", id = "ToggleElementLabel", x1 = 70, x2 = 425, y1 = 325, y2 = 355} )
- table.insert( screen.ClickAreas, {mode = "damage", id = "ToggleElementLabel2", x1 = 980, x2 = 1400, y1 = 325, y2 = 355} )
- elseif screen.mode == "damageoutline" then
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeView", param = "top", x1 = 60, x2 = 439, y1 = 150, y2 = 200} )
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeView", param = "side", x1 = 440, x2 = 824, y1 = 150, y2 = 200} )
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeView", param = "front", x1 = 825, x2 = 1215, y1 = 150, y2 = 200} )
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeStretch", x1 = 1530, x2 = 1580, y1 = 150, y2 = 200} )
- elseif screen.mode == "fuel" then
- elseif screen.mode == "cargo" then
- elseif screen.mode == "agg" then
- elseif screen.mode == "map" then
- elseif screen.mode == "time" then
- elseif screen.mode == "settings1" then
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ToggleBackground", x1 = 75, x2 = 860, y1 = 170, y2 = 215} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "PreviousBackground", x1 = 75, x2 = 460, y1 = 235, y2 = 285} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "NextBackground", x1 = 480, x2 = 860, y1 = 235, y2 = 285} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "DecreaseOpacity", x1 = 75, x2 = 460, y1 = 300, y2 = 350} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "IncreaseOpacity", x1 = 480, x2 = 860, y1 = 300, y2 = 350} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ResetColors", x1 = 75, x2 = 860, y1 = 370, y2 = 415} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "PreviousColorID", x1 = 90, x2 = 140, y1 = 500, y2 = 550} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "NextColorID", x1 = 795, x2 = 845, y1 = 500, y2 = 550} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="1", x1 = 210, x2 = 290, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="2", x1 = 300, x2 = 380, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="3", x1 = 385, x2 = 465, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="4", x1 = 470, x2 = 550, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="5", x1 = 560, x2 = 640, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="6", x1 = 645, x2 = 725, y1 = 655, y2 = 700} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="1", x1 = 210, x2 = 290, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="2", x1 = 300, x2 = 380, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="3", x1 = 385, x2 = 465, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="4", x1 = 470, x2 = 550, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="5", x1 = 560, x2 = 640, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="6", x1 = 645, x2 = 725, y1 = 740, y2 = 780} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ResetPosColor", x1 = 160, x2 = 340, y1 = 885, y2 = 935} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ApplyPosColor", x1 = 355, x2 = 780, y1 = 885, y2 = 935} )
-
- elseif screen.mode == "startup" then
- end
-
- screen = CreateBaseClickAreas(screen)
-
- return screen
-end
-
-function CheckClick(x, y, HitTarget)
- x = x*1920
- y = y*1120
- HitTarget = HitTarget or ""
- HitPayload = {}
- -- PrintConsole("Clicked: "..x.." / "..y)
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- if screens[i].active == true and screens[i].element.getMouseX() ~= -1 and screens[i].element.getMouseY() ~= -1 then
- if HitTarget == "" then
- for k, v in pairs(screens[i].ClickAreas) do
- if v ~=nil and x >= v.x1 and x <= v.x2 and y >= v.y1 and y <= v.y2 then
- HitTarget = v.id
- HitPayload = v
- break
- end
- end
- end
- if HitTarget == "ButtonPress" then
- if screens[i].mode == HitPayload.param then
- screens[i].mode = "startup"
- else
- screens[i].mode = HitPayload.param
- end
-
- if screens[i].mode == "damageoutline" then
- if screens[i].submode == "" then
- screens[i].submode = "top"
- end
- end
- screens[i].refresh = true
- screens[i].ClickAreas = {}
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "ToggleBackground" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundMode == "" then
- BackgroundSelected = 1
- BackgroundMode = backgroundModes[BackgroundSelected]
- else
- BackgroundSelected = 1
- BackgroundMode = ""
- end
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "PreviousBackground" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundMode == "" then
- BackgroundSelected = 1
- BackgroundMode = backgroundModes[BackgroundSelected]
- else
- if BackgroundSelected <= 1 then
- BackgroundSelected = #backgroundModes
- else
- BackgroundSelected = BackgroundSelected - 1
- end
- BackgroundMode = backgroundModes[BackgroundSelected]
- end
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "NextBackground" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundMode == "" then
- BackgroundSelected = 1
- BackgroundMode = backgroundModes[BackgroundSelected]
- else
- if BackgroundSelected >= #backgroundModes then
- BackgroundSelected = 1
- else
- BackgroundSelected = BackgroundSelected + 1
- end
- BackgroundMode = backgroundModes[BackgroundSelected]
- end
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "DecreaseOpacity" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundModeOpacity>0.1 then
- BackgroundModeOpacity = BackgroundModeOpacity - 0.05
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- end
- elseif HitTarget == "IncreaseOpacity" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundModeOpacity<1.0 then
- BackgroundModeOpacity = BackgroundModeOpacity + 0.05
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- end
- elseif HitTarget == "ResetColors" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- db.clear()
- ColorPrimary = "FF6700"
- ColorSecondary = "FFFFFF"
- ColorTertiary = "000000"
- ColorHealthy = "00FF00"
- ColorWarning = "FFFF00"
- ColorCritical = "FF0000"
- ColorBackground = "000000"
- ColorBackgroundPattern = "4f4f4f"
- ColorFuelAtmospheric = "004444"
- ColorFuelSpace = "444400"
- ColorFuelRocket = "440044"
- BackgroundMode = "deathstar"
- BackgroundSelected = 1
- BackgroundModeOpacity = 0.25
- colorIDTable = {
- [1] = {
- id="ColorPrimary",
- desc="Main HUD Color",
- basec = "FF6700",
- newc = "FF6700"
- },
- [2] = {
- id="ColorSecondary",
- desc="Secondary HUD Color",
- basec = "FFFFFF",
- newc = "FFFFFF"
- },
- [3] = {
- id="ColorTertiary",
- desc="Tertiary HUD Color",
- basec = "000000",
- newc = "000000"
- },
- [4] = {
- id="ColorHealthy",
- desc="Color code for Healthy/Okay",
- basec = "00FF00",
- newc = "00FF00"
- },
- [5] = {
- id="ColorWarning",
- desc="Color code for Damaged/Warning",
- basec = "FFFF00",
- newc = "FFFF00"
- },
- [6] = {
- id="ColorCritical",
- desc="Color code for Broken/Critical",
- basec = "FF0000",
- newc = "FF0000"
- },
- [7] = {
- id="ColorBackground",
- desc="Background Color",
- basec = "000000",
- newc = "000000"
- },
- [8] = {
- id="ColorBackgroundPattern",
- desc="Background Pattern Color",
- basec = "4F4F4F",
- newc = "4F4F4F"
- },
- [9] = {
- id="ColorFuelAtmospheric",
- desc="Color for Atmo Fuel/Elements",
- basec = "004444",
- newc = "004444"
- },
- [10] = {
- id="ColorFuelSpace",
- desc="Color for Space Fuel/Elements",
- basec = "444400",
- newc = "444400"
- },
- [11] = {
- id="ColorFuelRocket",
- desc="Color for Rocket Fuel/Elements",
- basec = "440044",
- newc = "440044"
- }
- }
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "PreviousColorID" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- colorIDIndex = colorIDIndex - 1
- if colorIDIndex < 1 then colorIDIndex = #colorIDTable end
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "NextColorID" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- colorIDIndex = colorIDIndex + 1
- if colorIDIndex > #colorIDTable then colorIDIndex = 1 end
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "ColorPosUp" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- local s = tonumber(string.sub(colorIDTable[colorIDIndex].newc, HitPayload.param, HitPayload.param),16)
- s = s + 1
- if s > 15 then s = 0 end
- colorIDTable[colorIDIndex].newc = replace_char(HitPayload.param, colorIDTable[colorIDIndex].newc, hexTable[s+1])
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "ColorPosDown" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- local s = tonumber(string.sub(colorIDTable[colorIDIndex].newc, HitPayload.param, HitPayload.param),16)
- s = s - 1
- if s < 0 then s = 15 end
- colorIDTable[colorIDIndex].newc = replace_char(HitPayload.param, colorIDTable[colorIDIndex].newc, hexTable[s+1])
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "ResetPosColor" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- colorIDTable[colorIDIndex].newc = colorIDTable[colorIDIndex].basec
- _G[colorIDTable[colorIDIndex].id] = colorIDTable[colorIDIndex].basec
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "ApplyPosColor" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- _G[colorIDTable[colorIDIndex].id] = colorIDTable[colorIDIndex].newc
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "DamagedPageDown" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentDamagedPage = CurrentDamagedPage + 1
- if CurrentDamagedPage > math.ceil(#damagedElements / DamagePageSize) then
- CurrentDamagedPage = math.ceil(#damagedElements / DamagePageSize)
- end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "DamagedPageUp" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentDamagedPage = CurrentDamagedPage - 1
- if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "BrokenPageDown" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentBrokenPage = CurrentBrokenPage + 1
- if CurrentBrokenPage > math.ceil(#brokenElements / DamagePageSize) then
- CurrentBrokenPage = math.ceil(#brokenElements / DamagePageSize)
- end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "BrokenPageUp" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentBrokenPage = CurrentBrokenPage - 1
- if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "DMGOChangeView" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- screens[i].submode = HitPayload.param
- UpdateViewDamageoutline(screens[i])
- SaveToDatabank()
- SetRefresh("damageoutline", screens[i].submode)
- RenderScreens("damageoutline", screens[i].submode)
- elseif HitTarget == "DMGOChangeStretch" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if DMGOStretch == true then
- DMGOStretch = false
- else
- DMGOStretch = true
- end
- UpdateViewDamageoutline(screens[i])
- SaveToDatabank()
- SetRefresh("damageoutline")
- RenderScreens("damageoutline")
- elseif HitTarget == "ToggleDisplayAtmosphere" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if screens[i].fuelA == true then
- screens[i].fuelA = false
- else
- screens[i].fuelA = true
- end
- screens[i].fuelIndex = 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "ToggleDisplaySpace" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if screens[i].fuelS == true then
- screens[i].fuelS = false
- else
- screens[i].fuelS = true
- end
- screens[i].fuelIndex = 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "ToggleDisplayRocket" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if screens[i].fuelR == true then
- screens[i].fuelR = false
- else
- screens[i].fuelR = true
- end
- screens[i].fuelIndex = 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "DecreaseFuelIndex" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- screens[i].fuelIndex = screens[i].fuelIndex - 1
- if screens[i].fuelIndex < 1 then screens[i].fuelIndex = 1 end
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "IncreaseFuelIndex" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- screens[i].fuelIndex = screens[i].fuelIndex + 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "ToggleHudMode" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if HUDMode == true then
- HUDMode = false
- forceDamageRedraw = true
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- else
- HUDMode = true
- forceDamageRedraw = true
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- end
- elseif HitTarget == "ToggleSimulation" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentDamagedPage = 1
- CurrentBrokenPage = 1
- if SimulationMode == true then
- SimulationMode = false
- SimulationActive = false
- UpdateDamageData()
- UpdateTypeData()
- forceDamageRedraw = true
- HudDeselectElement()
- SetRefresh("damage")
- SetRefresh("damageoutline")
- SetRefresh("settings1")
- SetRefresh("fuel")
- SaveToDatabank()
- RenderScreens()
- else
- SimulationMode = true
- SimulationActive = false
- UpdateDamageData()
- UpdateTypeData()
- forceDamageRedraw = true
- HudDeselectElement()
- SetRefresh("damage")
- SetRefresh("damageoutline")
- SetRefresh("settings1")
- SetRefresh("fuel")
- SaveToDatabank()
- RenderScreens()
- end
- elseif (HitTarget == "ToggleElementLabel" or HitTarget == "ToggleElementLabel2") and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if UseMyElementNames == true then
- UseMyElementNames = false
- SetRefresh("damage")
- RenderScreens("damage")
- else
- UseMyElementNames = true
- SetRefresh("damage")
- RenderScreens("damage")
- end
- elseif (HitTarget == "SwitchScrapTier" or HitTarget == "SwitchScrapTier2") and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- ScrapTier = ScrapTier + 1
- if ScrapTier > 4 then ScrapTier = 1 end
- SetRefresh("damage")
- RenderScreens("damage")
- end
-
-
- end
- end
- end
-end
-
---[[ 4. RENDERING FUNCTIONS ]]
-
-function GetContentFlight()
- local output = ""
- output = output .. GetHeader("Flight Data Report") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentDamage()
- local output = ""
- if SimulationMode == true then
- output = output .. GetHeader("Damage Report (Simulated damage)") .. [[]]
- else
- output = output .. GetHeader("Damage Report") .. [[]]
- end
- output = output .. GetContentDamageScreen()
- return output
-end
-
-function GetContentDamageoutline(screen)
- UpdateDataDamageoutline()
- UpdateViewDamageoutline(screen)
- local output = ""
- output = output .. GetHeader("Damage Ship Outline Report") ..
- GetDamageoutlineShip() ..
- [[]]
-
- if screen.submode=="top" then
- output = output ..
- [[
-
- Top View
-
- Side View
-
- Front View
- ]]
- elseif screen.submode=="side" then
- output = output ..
- [[
-
- Top View
-
- Side View
-
- Front View
- ]]
- elseif screen.submode=="front" then
- output = output ..
- [[
-
- Top View
-
- Side View
-
- Front View
- ]]
- else
- end
- output = output .. [[]]..#dmgoElements..[[ of ]]..ElementCounter..[[ shown]]
- output = output .. [[]]
- if DMGOStretch == true then
- output = output .. [[]]
- end
- output = output .. [[Stretch both axis]]
- return output
-end
-
-function GetContentFuel(screen)
-
- if #FuelAtmosphericTanks < 1 and #FuelSpaceTanks < 1 and #FuelRocketTanks < 1 then return "" end
-
- local FuelTypes = 0
- local output = ""
- local addHeadline = {}
-
- FuelDisplay = { screen.fuelA, screen.fuelS, screen.fuelR }
-
- if FuelDisplay[1] == true and #FuelAtmosphericTanks > 0 then
- table.insert(addHeadline, "Atmospheric")
- FuelTypes = FuelTypes + 1
- end
- if FuelDisplay[2] == true and #FuelSpaceTanks > 0 then
- table.insert(addHeadline, "Space")
- FuelTypes = FuelTypes + 1
- end
- if FuelDisplay[3] == true and #FuelRocketTanks > 0 then
- table.insert(addHeadline, "Rocket")
- FuelTypes = FuelTypes + 1
- end
-
- output = output .. GetHeader("Fuel Report ("..table.concat(addHeadline, ", ")..")") ..
- [[
- ]]
-
- local totalH = 150
- local counter = 0
- local tOffset = 0
-
- if FuelDisplay[1] == true and #FuelAtmosphericTanks > 0 then
-
- if FuelTypes == 1 then tOffset = 50
- elseif FuelTypes == 2 then tOffset = 6
- elseif FuelTypes == 3 then tOffset = 0
- end
-
- output = output .. [[
-
-
-
- ]]
-
- output = output ..
- [[]]..
- GenerateCommaValue(FuelAtmosphericCurrent, true)..
- [[ of ]]..GenerateCommaValue(FuelAtmosphericTotal, true)..
- [[ | Total Atmospheric Fuel in ]]..#FuelAtmosphericTanks..[[ tank]]..(#FuelAtmosphericTanks==1 and "" or "s")..[[ (]]..math.floor(100/FuelAtmosphericTotal*FuelAtmosphericCurrent)..[[%)]]
- counter = counter + 1
- end
-
- if FuelDisplay[2] == true and #FuelSpaceTanks > 0 then
-
- if FuelTypes == 1 then tOffset = 50
- elseif FuelTypes == 2 then tOffset = 6
- elseif FuelTypes == 3 then tOffset = 0
- end
-
- output = output .. [[
-
-
-
- ]]
-
- output = output ..
- [[]]..
- GenerateCommaValue(FuelSpaceCurrent, true)..
- [[ of ]]..GenerateCommaValue(FuelSpaceTotal, true)..
- [[ | Total Space Fuel in ]]..#FuelSpaceTanks..[[ tank]]..(#FuelSpaceTanks==1 and "" or "s")..[[ (]]..math.floor(100/FuelSpaceTotal*FuelSpaceCurrent)..[[%)]]
- counter = counter + 1
- end
-
- if FuelDisplay[3] == true and #FuelRocketTanks > 0 then
-
- if FuelTypes == 1 then tOffset = 50
- elseif FuelTypes == 2 then tOffset = 6
- elseif FuelTypes == 3 then tOffset = 0
- end
-
- output = output .. [[
-
-
-
- ]]
-
- output = output ..
- [[]]..
- GenerateCommaValue(FuelRocketCurrent, true)..
- [[ of ]]..GenerateCommaValue(FuelRocketTotal, true)..
- [[ | Total Rocket Fuel in ]]..#FuelRocketTanks..[[ tank]]..(#FuelRocketTanks==1 and "" or "s")..[[ (]]..math.floor(100/FuelRocketTotal*FuelRocketCurrent)..[[%)]]
- end
-
- output = output .. [[
-
-
-
- ]]
-
- local DisplayTable = {}
- if screen.fuelIndex == nil or screen.fuelIndex < 1 then
- screen.fuelIndex = 1
- end
-
- if FuelDisplay[1] == true then
- for _,v in ipairs(FuelAtmosphericTanks) do
- table.insert(DisplayTable, v)
- end
- end
- if FuelDisplay[2] == true then
- for _,v in ipairs(FuelSpaceTanks) do
- table.insert(DisplayTable, v)
- end
- end
- if FuelDisplay[3] == true then
- for _,v in ipairs(FuelRocketTanks) do
- table.insert(DisplayTable, v)
- end
- end
-
- table.sort(DisplayTable, function(a,b) return a.type
-
-
- ]]
- if tank.hp == 0 then
- output = output .. [[]]
- elseif tank.maxhp - tank.hp > constants.epsilon then
- output = output .. [[]]
- else
- output = output .. [[]]
- end
- if tank.hp == 0 then output = output .. [[]]..tank.size..[[]]
- else output = output .. [[]]..tank.size..[[]]
- end
-
- if tank.hp == 0 then
- output = output .. [[Broken]] ..
- [[0 of ]]..GenerateCommaValue(tank.vol)..[[]]
- elseif tonumber(tank.percent) < 10 then
- output = output .. [[]]..tank.percent..[[%]] ..
- [[]]..GenerateCommaValue(tank.cvol)..[[ of ]]..GenerateCommaValue(tank.vol)..[[]]
- elseif tonumber(tank.percent) < 30 then
- output = output .. [[]]..tank.percent..[[%]] ..
- [[]]..GenerateCommaValue(tank.cvol)..[[ of ]]..GenerateCommaValue(tank.vol)..[[]]
- else output =
- output .. [[]]..tank.percent..[[%]] ..
- [[]]..GenerateCommaValue(tank.cvol)..[[ of ]]..GenerateCommaValue(tank.vol)..[[]]
- end
-
- output = output ..[[]]..tank.name..[[]]
-
- output = output .. [[]]
-
- end
- end
-
-
-
- if #FuelAtmosphericTanks > 0 then
- output = output .. [[]]
- if FuelDisplay[1] == true then
- output = output .. [[]]
- end
- output = output .. [[ATM]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "ToggleDisplayAtmosphere", x1 = 50, x2 = 100, y1 = 270, y2 = 320} )
- end
-
- if #FuelSpaceTanks > 0 then
- output = output .. [[]]
- if FuelDisplay[2] == true then
- output = output .. [[]]
- end
- output = output .. [[SPC]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "ToggleDisplaySpace", x1 = 200, x2 = 250, y1 = 270, y2 = 320} )
- end
-
- if #FuelRocketTanks > 0 then
- output = output .. [[]]
- if FuelDisplay[3] == true then
- output = output .. [[]]
- end
- output = output .. [[RKT]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "ToggleDisplayRocket", x1 = 350, x2 = 400, y1 = 270, y2 = 320} )
- end
-
- if screen.fuelIndex > 1 then
- output = output .. [[
-
-
- ]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "DecreaseFuelIndex", x1 = 1470, x2 = 1670, y1 = 270, y2 = 320} )
- end
-
- if screen.fuelIndex+cCounter-1 < #DisplayTable then
- output = output .. [[
-
-
- ]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "IncreaseFuelIndex", x1 = 1680, x2 = 1880, y1 = 270, y2 = 320} )
- end
-
- if cCounter > 0 then
- output = output .. [[]]..
- #DisplayTable..
- [[ Tank]]..(#DisplayTable == 1 and "" or "s")..
- [[ (Showing ]]..screen.fuelIndex..[[ to ]]..(screen.fuelIndex+cCounter-1)..[[)]]
- end
-
- return output
-end
-
-function GetContentCargo()
- local output = ""
- output = output .. GetHeader("Cargo Report") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentAGG()
- local output = ""
- output = output .. GetHeader("Anti-Grav Control") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentMap()
- local output = ""
- output = output .. GetHeader("Map Overview") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentTime()
- local output = ""
- output = output .. GetHeader("Time") .. epochTime()
- output = output ..
- [[
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetContentSettings1()
- local output = ""
- output = output .. GetHeader("Settings") .. [[]]
- if BackgroundMode=="" then
- output = output ..[[Activate background]]
- else
- output = output ..[[Deactivate background (']]..BackgroundMode..[[', ]]..string.format("%.0f",BackgroundModeOpacity*100)..[[%)]]
- end
- output = output ..[[
-
- Previous background
-
- Next background
-
-
- Decrease Opacity
-
- Increase Opacity
- ]]
-
- output = output ..
- [[]] ..
- [[Reset background and all colors]]
-
- output = output ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Select and change any of the ]]..#colorIDTable..[[ HUD colors]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]]..colorIDTable[colorIDIndex].desc..[[]] ..
- [[]] ..
- [[Current color]] ..
- [[]] ..
-
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
-
- [[#]] ..
-
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,1,1)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,2,2)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,3,3)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,4,4)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,5,5)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,6,6)..[[]] ..
-
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
-
- [[]] ..
- [[]] ..
- [[New color]] ..
- [[]] ..
- [[Apply new color]] ..
- [[]] ..
- [[Reset]] ..
- [[]]
-
- output = output ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Explanation / Hints]] ..
- [[Coming soon.]]
-
-
- output = output .. [[]]
-
- if SimulationMode == true then
- output = output .. [[Simulating Damage to elements]]
- AddClickArea("settings1", { id = "ToggleSimulation", mode ="settings1", x1 = 940, x2 = 1850, y1 = 919, y2 = 969 })
- else
- output = output .. [[Simulate Damage to elements]]
- AddClickArea("settings1", { id = "ToggleSimulation", mode ="settings1", x1 = 940, x2 = 1850, y1 = 919, y2 = 969 })
- end
-
- return output
-end
-
-function GetContentStartup()
- local output = ""
- output = output .. GetElementLogo(812, 380, "f", "f", "f")
- if YourShipsName == "Enter here" then
- output = output .. [[Spaceship ID ]]..ShipID..[[]]
- else
- output = output .. [[]]..YourShipsName..[[]]
- end
- if ShowWelcomeMessage == true then output = output .. [[Greetings, Commander ]]..PlayerName..[[.]] end
- if #Warnings > 0 then
- output = output .. [[Warning: ]]..(table.concat(Warnings, " "))..[[]]
- end
- output = output .. [[Damage Report v]]..VERSION..[[, by Scion Interstellar, DorianGray - Discord: Dorian Gray#2623. Under GNU Public License 3.0.]]
- return output
-end
-
-function RenderScreen(screen, contentToRender)
- if contentToRender == nil then
- PrintConsole("ERROR: contentToRender is nil.")
- unit.exit()
- end
-
- CreateClickAreasForScreen(screen)
-
- local output =""
- output = output .. [[
-
-
- ]]
-
- output = output .. contentToRender
-
- if screen.mode == "startup" then
- output = output .. [[]]
- else
- output = output .. [[]]
- end
-
- output = output .. [[
-
- ]]
- output = output .. [[]]
-
- -- Center:
-
- --
- --
- --
- --
-
- local outputLength = string.len(output)
- -- PrintConsole("Render: "..screen.mode.." ("..outputLength.." chars)")
- screen.element.setSVG(output)
-end
-
-function RenderScreens(onlymode, onlysubmode)
-
- onlymode = onlymode or "all"
- onlysubmode = onlysubmode or "all"
-
- if screens ~= nil and #screens > 0 then
-
- local contentFlight = ""
- local contentDamage = ""
- local contentDamageoutlineTop = ""
- local contentDamageoutlineSide = ""
- local contentDamageoutlineFront = ""
- local contentFuel = ""
- local contentCargo = ""
- local contentAGG = ""
- local contentMap = ""
- local contentTime = ""
- local contentSettings1 = ""
- local contentStartup = ""
-
- for k,screen in pairs(screens) do
- if screen.refresh == true then
- local contentToRender = ""
-
- if screen.mode == "flight" and (onlymode =="flight" or onlymode =="all") then
- if contentFlight == "" then contentFlight = GetContentFlight() end
- contentToRender = contentFlight
- elseif screen.mode == "damage" and (onlymode =="damage" or onlymode =="all") then
- if contentDamage == "" then contentDamage = GetContentDamage() end
- contentToRender = contentDamage
- elseif screen.mode == "damageoutline" and (onlymode =="damageoutline" or onlymode =="all") then
- if screen.submode == "" then
- screen.submode = "top"
- screens[k].submode = "top"
- end
- if screen.submode == "top" and (onlysubmode == "top" or onlysubmode == "all") then
- if contentDamageoutlineTop == "" then contentDamageoutlineTop = GetContentDamageoutline(screen) end
- contentToRender = contentDamageoutlineTop
- end
- if screen.submode == "side" and (onlysubmode == "side" or onlysubmode == "all") then
- if contentDamageoutlineSide == "" then contentDamageoutlineSide = GetContentDamageoutline(screen) end
- contentToRender = contentDamageoutlineSide
- end
- if screen.submode == "front" and (onlysubmode == "front" or onlysubmode == "all") then
- if contentDamageoutlineFront == "" then contentDamageoutlineFront = GetContentDamageoutline(screen) end
- contentToRender = contentDamageoutlineFront
- end
- elseif screen.mode == "fuel" and (onlymode =="fuel" or onlymode =="all") then
- screen = WipeClickAreasForScreen(screens[k])
- contentToRender = GetContentFuel(screen)
- elseif screen.mode == "cargo" and (onlymode =="cargo" or onlymode =="all") then
- if contentCargo == "" then contentCargo = GetContentCargo() end
- contentToRender = contentCargo
- elseif screen.mode == "agg" and (onlymode =="agg" or onlymode =="all") then
- if contentAGG == "" then contentAGG = GetContentAGG() end
- contentToRender = contentAGG
- elseif screen.mode == "map" and (onlymode =="map" or onlymode =="all") then
- if contentMap == "" then contentMap = GetContentMap() end
- contentToRender = contentMap
- elseif screen.mode == "time" and (onlymode =="time" or onlymode =="all") then
- if contentTime == "" then contentTime = GetContentTime() end
- contentToRender = contentTime
- elseif screen.mode == "settings1" and (onlymode =="settings1" or onlymode =="all") then
- if contentSettings1 == "" then contentSettings1 = GetContentSettings1() end
- contentToRender = contentSettings1
- elseif screen.mode == "startup" and (onlymode =="startup" or onlymode =="all") then
- if contentStartup == "" then contentStartup = GetContentStartup() end
- contentToRender = contentStartup
- else
- contentToRender = "Invalid screen mode. ('"..screen.mode.."')"
- end
-
- if contentToRender ~= "" then
- RenderScreen(screen, contentToRender)
- else
- DrawCenteredText("ERROR: No contentToRender delivered for "..screen.mode)
- PrintConsole("ERROR: No contentToRender delivered for "..screen.mode)
- unit.exit()
- end
- screens[k].refresh = false
- end
- end
- end
-
- if HUDMode == true then
- system.setScreen(GetContentDamageHUDOutput())
- system.showScreen(1)
- else
- system.showScreen(0)
- end
-
-end
-
-function OnTickData(initial)
- if formerTime + 60 < system.getTime() then
- SetRefresh("time")
- end
- totalShipMass = core.getConstructMass()
- if formerTotalShipMass ~= totalShipMass then
- UpdateDamageData(true)
- UpdateTypeData()
- SetRefresh()
- formerTotalShipMass = totalShipMass
- else
- UpdateDamageData(initial)
- UpdateTypeData()
- end
- RenderScreens()
-end
-
---[[ 5. EXECUTION ]]
-
-unit.hide()
-ClearConsole()
-PrintConsole("DAMAGE REPORT v"..VERSION.." STARTED", true)
-InitiateSlots()
-LoadFromDatabank()
-SwitchScreens("on")
-InitiateScreens()
-
-if core == nil then
- PrintConsole("ERROR: Connect the core to the programming board.")
- unit.exit()
-else
- OperatorID = unit.getMasterPlayerId()
- OperatorData = database.getPlayer(OperatorID)
- PlayerName = OperatorData["name"]
- ShipID = core.getConstructId()
-end
-
-if db == nil then
- table.insert(Warnings, "No databank connected, won't save/load settings.")
-end
-
-if YourShipsName == "Enter here" then
- table.insert(Warnings, "No ship name set in LUA settings.")
-end
-
-if SkillRepairToolEfficiency == 0 and SkillRepairToolOptimization == 0 and StatFuelTankOptimization == 0 and StatContainerOptimization ==0 and
- StatAtmosphericFuelTankHandling == 0 and StatSpaceFuelTankHandling == 0 and StatRocketFuelTankHandling ==0 then
- table.insert(Warnings, "No talents/stats set in LUA settings.")
-end
-
-if SkillRepairToolEfficiency < 0 or SkillRepairToolOptimization < 0 or StatFuelTankOptimization < 0 or StatContainerOptimization < 0 or
- StatAtmosphericFuelTankHandling < 0 or StatSpaceFuelTankHandling < 0 or StatRocketFuelTankHandling < 0 or
- SkillRepairToolEfficiency > 5 or SkillRepairToolOptimization > 5 or StatFuelTankOptimization > 5 or StatContainerOptimization > 5 or
- StatAtmosphericFuelTankHandling > 5 or StatSpaceFuelTankHandling > 5 or StatRocketFuelTankHandling > 5 then
- PrintConsole("ERROR: Talents/stats can only range from 0 to 5. Please set correctly in LUA settings and reactivate script.")
- unit.exit()
-end
-
-if screens == nil or #screens == 0 then
- HUDMode = true
- PrintConsole("Warning: No screens connected. Entering HUD mode only.")
-end
-
-OnTickData(true)
-
-unit.setTimer('UpdateData', UpdateDataInterval)
-unit.setTimer('UpdateHighlight', HighlightBlinkingInterval)
\ No newline at end of file
diff --git a/src/DamageReport_3_13_UnitStart_1.lua b/src/DamageReport_3_13_UnitStart_1.lua
deleted file mode 100644
index 9d922fb..0000000
--- a/src/DamageReport_3_13_UnitStart_1.lua
+++ /dev/null
@@ -1,1302 +0,0 @@
---[[
- Damage Report 3.13
- A LUA script for Dual Universe
-
- Created By Dorian Gray
- Ingame: DorianGray
- Discord: Dorian Gray#2623
-
- You can find/update this script on GitHub. Explanations, installation and usage information as well as screenshots can be found there too.
- GitHub: https://github.com/DorianTheGrey/DU-DamageReport
-
- GNU Public License 3.0. Use whatever you want, be so kind to leave credit.
-
- Credits & thanks:
- Thanks to NovaQuark for creating the MMO of the century.
- Thanks to Jericho, Dmentia and Archaegeo for learning a lot from their fine scripts.
- Thanks to TheBlacklist for testing and wonderful suggestions.
- SVG patterns by Hero Patterns.
- DU atlas data from Jayle Break.
-
-]]
-
---[[ 1. HELPER FUNCTIONS ]]
-
-function GenerateCommaValue(amount, kify, postcomma)
- kify = kify or false
- postcomma = postcomma or 1
- local formatted = amount
- if kify == true then
- if string.len(amount)>=4 then
- formatted = string.format("%."..postcomma.."fk", amount/1000)
- else
- formatted = string.format("%."..postcomma.."f", amount)
- end
- else
- while true do
- formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
- if (k == 0) then break end
- end
- end
- return formatted
-end
-
-function PrintConsole(output, highlight)
- highlight = highlight or false
- if highlight then
- system.print(
- "------------------------------------------------------------------------")
- end
- system.print(output)
- if highlight then
- system.print(
- "------------------------------------------------------------------------")
- end
-end
-
-function DrawCenteredText(output)
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- screens[i].element.setCenteredText(output)
- end
- end
-end
-
-function ClearConsole()
- for i = 1, 10, 1 do
- PrintConsole()
- end
-end
-
-function SwitchScreens(state)
- state = state or "on"
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- if state == "on" then
- screens[i].element.clear()
- screens[i].element.activate()
- screens[i].active = true
- else
- screens[i].element.clear()
- screens[i].element.deactivate()
- screens[i].active = false
- end
- end
- end
-end
-
---[[ Convert seconds to string (by Jericho) ]]
-function GetSecondsString(seconds)
- local seconds = tonumber(seconds)
-
- if seconds == nil or seconds <= 0 then
- return "-";
- else
- days = string.format("%2.f", math.floor(seconds/(3600*24)));
- hours = string.format("%2.f", math.floor(seconds/3600 - (days*24)));
- mins = string.format("%2.f", math.floor(seconds/60 - (hours*60) - (days*24*60)));
- secs = string.format("%2.f", math.floor(seconds - hours*3600 - (days*24*60*60) - mins *60));
- str = ""
- if tonumber(days) > 0 then str = str .. days.."d " end
- if tonumber(hours) > 0 then str = str .. hours.."h " end
- if tonumber(mins) > 0 then str = str .. mins.."m " end
- if tonumber(secs) > 0 then str = str .. secs .."s" end
- return str
- end
-end
-
-function replace_char(pos, str, r)
- return str:sub(1, pos-1) .. r .. str:sub(pos+1)
-end
-
---[[ 2. RENDER HELPER FUNCTIONS ]]
-
---[[ epochTime function by Leodr (clock script), enhanced by Jericho (DU Industry script) ]]
-function epochTime()
- function rZ(a)
- if string.len(a) <= 1 then
- return "0" .. a
- else
- return a
- end
- end
- function dPoint(b)
- if not (b == math.floor(b)) then
- return true
- else
- return false
- end
- end
- function lYear(year)
- if not dPoint(year / 4) then
- if dPoint(year / 100) then
- return true
- else
- if not dPoint(year / 400) then
- return true
- else
- return false
- end
- end
- else
- return false
- end
- end
- local c = 5;
- local d = 3600;
- local e = 86400;
- local f = 31536000;
- local g = 31622400;
- local h = 2419200;
- local i = 2505600;
- local j = 2592000;
- local k = 2678400;
- local l = {4, 6, 9, 11}
- local m = {1, 3, 5, 7, 8, 10, 12}
- local n = 0;
- local o = 1506816000;
- local q = system.getTime()
- _G["formerTime"] = q
- if AddSummertimeHour == true then q = q + 3600 end
- now = math.floor(q + o)
- year = 1970;
- secs = 0;
- n = 0;
- while secs + g < now or secs + f < now do
- if lYear(year + 1) then
- if secs + g < now then
- secs = secs + g;
- year = year + 1;
- n = n + 366
- end
- else
- if secs + f < now then
- secs = secs + f;
- year = year + 1;
- n = n + 365
- end
- end
- end
- secondsRemaining = now - secs;
- monthSecs = 0;
- yearlYear = lYear(year)
- month = 1;
- while monthSecs + h < secondsRemaining or monthSecs + j < secondsRemaining or
- monthSecs + k < secondsRemaining do
- if month == 1 then
- if monthSecs + k < secondsRemaining then
- month = 2;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 2 then
- if not yearlYear then
- if monthSecs + h < secondsRemaining then
- month = 3;
- monthSecs = monthSecs + h;
- n = n + 28
- else
- break
- end
- else
- if monthSecs + i < secondsRemaining then
- month = 3;
- monthSecs = monthSecs + i;
- n = n + 29
- else
- break
- end
- end
- end
- if month == 3 then
- if monthSecs + k < secondsRemaining then
- month = 4;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 4 then
- if monthSecs + j < secondsRemaining then
- month = 5;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- if month == 5 then
- if monthSecs + k < secondsRemaining then
- month = 6;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 6 then
- if monthSecs + j < secondsRemaining then
- month = 7;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- if month == 7 then
- if monthSecs + k < secondsRemaining then
- month = 8;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 8 then
- if monthSecs + k < secondsRemaining then
- month = 9;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 9 then
- if monthSecs + j < secondsRemaining then
- month = 10;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- if month == 10 then
- if monthSecs + k < secondsRemaining then
- month = 11;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 11 then
- if monthSecs + j < secondsRemaining then
- month = 12;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- end
- day = 1;
- daySecs = 0;
- daySecsRemaining = secondsRemaining - monthSecs;
- while daySecs + e < daySecsRemaining do
- day = day + 1;
- daySecs = daySecs + e;
- n = n + 1
- end
- hour = 0;
- hourSecs = 0;
- hourSecsRemaining = daySecsRemaining - daySecs;
- while hourSecs + d < hourSecsRemaining do
- hour = hour + 1;
- hourSecs = hourSecs + d
- end
- minute = 0;
- minuteSecs = 0;
- minuteSecsRemaining = hourSecsRemaining - hourSecs;
- while minuteSecs + 60 < minuteSecsRemaining do
- minute = minute + 1;
- minuteSecs = minuteSecs + 60
- end
- second = math.floor(now % 60)
- year = rZ(year)
- month = rZ(month)
- day = rZ(day)
- hour = rZ(hour)
- minute = rZ(minute)
- second = rZ(second)
-
- return [[]]..hour..":".. minute..[[]]..
- [[]]..year.."/".. month.."/"..day..[[]]
-end
-
-
-function ToggleHUD()
- if HUDMode == true then
- HUDMode = false
- forceDamageRedraw = true
- hudSelectedIndex = 0
- highlightID = 0
- HideHighlight()
- SetRefresh()
- RenderScreens()
- else
- HUDMode = true
- forceDamageRedraw = true
- hudSelectedIndex = 0
- highlightID = 0
- HideHighlight()
- SetRefresh()
- RenderScreens()
- end
-end
-
-function HudDeselectElement()
- hudSelectedIndex = 0
- hudStartIndex = 1
- highlightID = 0
- HideHighlight()
- if HUDMode == true then
- SetRefresh("damage")
- SetRefresh("damageoutline")
- RenderScreens()
- end
-end
-
-function ChangeHudSelectedElement(step)
- if HUDMode == true and #rE > 0 then
-
- hudSelectedIndex = hudSelectedIndex + step
- if hudSelectedIndex < 1 then hudSelectedIndex = 1
- elseif hudSelectedIndex > #rE then hudSelectedIndex = #rE
- end
-
- if hudSelectedIndex > 9 then
- hudStartIndex = hudSelectedIndex-9
- end
- if hudSelectedIndex ~= 0 then
- highlightID = rE[hudSelectedIndex].id
- if highlightID ~=nil and highlightID ~= 0 then
- -- PrintConsole("CHSE: hudSelectedIndex: "..hudSelectedIndex.." / hudStartIndex: "..hudStartIndex.." / highlightID: "..highlightID)
- HideHighlight()
- elementPosition = vec3(rE[hudSelectedIndex].pos)
- highlightX = elementPosition.x - coreWorldOffset
- highlightY = elementPosition.y - coreWorldOffset
- highlightZ = elementPosition.z - coreWorldOffset
- highlightOn = true
- ShowHighlight()
- end
- end
-
- SetRefresh("damage")
- SetRefresh("damageoutline")
- RenderScreens()
-
- end
-end
-
-function HideHighlight()
- if #hudArrowSticker > 0 then
- for i in pairs(hudArrowSticker) do
- core.deleteSticker(hudArrowSticker[i])
- end
- hudArrowSticker = {}
- end
-end
-
-function ShowHighlight()
- if highlightOn == true and highlightID > 0 then
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX + 2, highlightY, highlightZ, "north"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY - 2, highlightZ, "east"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX - 2, highlightY, highlightZ, "south"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY + 2, highlightZ, "west"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY, highlightZ - 2, "up"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY, highlightZ + 2,"down"))
- end
-end
-
-function ToggleHighlight()
- if highlightOn == true then
- highlightOn = false
- HideHighlight()
- else
- highlightOn = true
- ShowHighlight()
- end
-end
-
-function SortDamageTables()
- table.sort(damagedElements, function(a, b) return a.missinghp > b.missinghp end)
- table.sort(brokenElements, function(a, b) return a.maxhp > b.maxhp end)
-end
-
-function getScraps(damage,commaval)
- commaval = commaval or false
- damage = damage - SkillRepairToolOptimization * 0.05 * damage
- local res = math.ceil( damage / ( 10 * 5^(ScrapTier-1) ) )
- if commaval ==true then
- return GenerateCommaValue(string.format("%.0f", res ), false)
- else
- return res
- end
-end
-
-function getRepairTime(damage,buildstring)
- buildstring = buildstring or false
- damage = damage - SkillRepairToolOptimization * 0.05 * damage
- local res = math.ceil(damage / ScrapTierRepairTimes[ScrapTier])
- res = res - ( SkillRepairToolEfficiency * 0.1 * res )
- if buildstring == true then
- return GetSecondsString(string.format("%.0f", res ) )
- else
- return res
- end
-end
-
-function UpdateDataDamageoutline()
-
- dmgoElements = {}
-
- for i,element in ipairs(brokenElements) do
- if #dmgoElements < DMGOMaxElements then
- local elementPosition = vec3(element.pos)
- local x = elementPosition.x - coreWorldOffset
- local y = elementPosition.y - coreWorldOffset
- local z = elementPosition.z - coreWorldOffset
- if x < ShipXmin then ShipXmin = x end
- if y < ShipYmin then ShipYmin = y end
- if z < ShipZmin then ShipZmin = z end
- if x > ShipXmax then ShipXmax = x end
- if y > ShipYmax then ShipYmax = y end
- if z > ShipZmax then ShipZmax = z end
- table.insert( dmgoElements, {
- id = element.id,
- type = "b",
- size = element.maxhp,
- x = x, y = y, z = z,
- xp = 0, yp = 0, zp = 0,
- u = 0, v = 0
- })
- end
- end
-
- if #dmgoElements < DMGOMaxElements then
- for i,element in ipairs(damagedElements) do
- if #dmgoElements < DMGOMaxElements then
- local elementPosition = vec3(element.pos)
- local x = elementPosition.x - coreWorldOffset
- local y = elementPosition.y - coreWorldOffset
- local z = elementPosition.z - coreWorldOffset
- if x < ShipXmin then ShipXmin = x end
- if y < ShipYmin then ShipYmin = y end
- if z < ShipZmin then ShipZmin = z end
- if x > ShipXmax then ShipXmax = x end
- if y > ShipYmax then ShipYmax = y end
- if z > ShipZmax then ShipZmax = z end
- table.insert( dmgoElements, {
- id = element.id,
- type = "d",
- size = element.maxhp,
- x = x, y = y, z = z,
- xp = 0, yp = 0, zp = 0,
- u = 0, v = 0
- })
- end
- end
- end
-
- if #dmgoElements < DMGOMaxElements then
- for i,element in ipairs(healthyElements) do
- if #dmgoElements < DMGOMaxElements then
- local elementPosition = vec3(element.pos)
- local x = elementPosition.x - coreWorldOffset
- local y = elementPosition.y - coreWorldOffset
- local z = elementPosition.z - coreWorldOffset
- if x < ShipXmin then ShipXmin = x end
- if y < ShipYmin then ShipYmin = y end
- if z < ShipZmin then ShipZmin = z end
- if x > ShipXmax then ShipXmax = x end
- if y > ShipYmax then ShipYmax = y end
- if z > ShipZmax then ShipZmax = z end
- table.insert( dmgoElements, {
- id = element.id,
- type = "h",
- size = element.maxhp,
- x = x, y = y, z = z,
- xp = 0, yp = 0, zp = 0,
- u = 0, v = 0
- })
- end
- end
- end
-
- ShipX = math.abs(ShipXmax-ShipXmin)
- ShipY = math.abs(ShipYmax-ShipYmin)
- ShipZ = math.abs(ShipZmax-ShipZmin)
-
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].xp = math.abs(100/(ShipXmax-ShipXmin)*(element.x-ShipXmin))
- dmgoElements[i].yp = math.abs(100/(ShipYmax-ShipYmin)*(element.y-ShipYmin))
- dmgoElements[i].zp = math.abs(100/(ShipZmax-ShipZmin)*(element.z-ShipZmin))
- end
-
-end
-
-function UpdateViewDamageoutline(screen)
- -- Full Width of virtual screen:
- -- UStart = 20
- -- VStart = 180
- -- UDim = 1880
- -- VDim = 840
- -- Adding frames:
- UFrame = 40
- VFrame = 40
-
- UStart = 20 + UFrame
- VStart = 180 + VFrame
- UDim = 1880 - 2*UFrame
- VDim = 840 - 2*VFrame
-
- if screen.submode == "top" then
- if DMGOStretch == false then
- local UFactor = UDim/(ShipYmax-ShipYmin)
- local VFactor = VDim/(ShipXmax-ShipXmin)
- if UFactor>=VFactor then
- local cFactor = UFactor/VFactor
- local newUDim = math.floor(UDim/cFactor)
- UStart = UStart+(UDim-newUDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100/cFactor*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*element.xp+VStart)
- end
- else
- local cFactor = VFactor/UFactor
- local newVDim = math.floor(VDim/cFactor)
- VStart = VStart+(VDim-newVDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100/cFactor*element.xp+VStart)
- end
- end
- else
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*element.xp+VStart)
- end
- end
-
-
- elseif screen.submode == "front" then
- if DMGOStretch == false then
- local UFactor = UDim/(ShipXmax-ShipXmin)
- local VFactor = VDim/(ShipZmax-ShipZmin)
- if UFactor>=VFactor then
- local cFactor = UFactor/VFactor
- local newUDim = math.floor(UDim/cFactor)
- UStart = UStart+(UDim-newUDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100/cFactor*element.xp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- else
- local cFactor = VFactor/UFactor
- local newVDim = math.floor(VDim/cFactor)
- VStart = VStart+(VDim-newVDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.xp+UStart)
- dmgoElements[i].v = math.floor(VDim/100/cFactor*(100-element.zp)+VStart)
- end
- end
- else
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.xp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- end
-
- elseif screen.submode == "side" then
- if DMGOStretch == false then
- local UFactor = UDim/(ShipYmax-ShipYmin)
- local VFactor = VDim/(ShipXmax-ShipZmin)
- if UFactor>=VFactor then
- local cFactor = UFactor/VFactor
- local newUDim = math.floor(UDim/cFactor)
- UStart = UStart+(UDim-newUDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100/cFactor*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- else
- local cFactor = VFactor/UFactor
- local newVDim = math.floor(VDim/cFactor)
- VStart = VStart+(VDim-newVDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100/cFactor*(100-element.zp)+VStart)
- end
- end
- else
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- end
- else
- DrawCenteredText("ERROR: non-existing DMGO mode set.")
- PrintConsole("ERROR: non-existing DMGO mode set.")
- unit.exit()
- end
-end
-
-function GetDamageoutlineShip()
- local output = ""
-
- for i,element in ipairs(dmgoElements) do
- local cclass = ""
- local size = 1
-
- if element.type == "h" then
- cclass ="ch"
- elseif element.type == "d" then
- cclass = "cw"
- else
- cclass = "cc"
- end
- if element.id == highlightID then
- cclass = "f2"
- end
-
- if element.size > 0 and element.size < 1000 then
- size = 5
- elseif element.size >= 1000 and element.size < 2000 then
- size = 8
- elseif element.size >= 2000 and element.size < 5000 then
- size = 12
- elseif element.size >= 5000 and element.size < 10000 then
- size = 15
- elseif element.size >= 10000 and element.size < 20000 then
- size = 20
- elseif element.size >= 20000 then
- size = 30
- end
- output = output .. [[]]
- if element.id == highlightID then
- output = output .. [[]]
- output = output .. [[]]
- end
- end
-
- return output
-end
-
-function GetContentClickareas(screen)
- local output = ""
- if screen ~= nil and screen.ClickAreas ~= nil and #screen.ClickAreas > 0 then
- for i,ca in ipairs(screen.ClickAreas) do
- output = output ..
- [[]]
- end
- end
- return output
-end
-
-function GetElement1(x, y, width, height)
- x = x or 0
- y = y or 0
- width = width or 600
- height = height or 600
- local output = ""
- output = output ..
- [[
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetElement2(x, y)
- x = x or 0
- y = y or 0
- local output = ""
- output = output .. [[]]
- return output
-end
-
-function GetElementLogo(x, y, primaryC, secondaryC, tertiaryC)
- x = x or 812
- y = y or 380
- primaryC = primaryC or "f"
- secondaryC = secondaryC or "f2"
- tertiaryC = tertiaryC or "f3"
- local output = ""
- output = output .. [[
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetHeader(headertext)
- headertext = headertext or "ERROR: UNDEFINED"
- local output = ""
- output = output ..
- [[
- ]]..headertext..[[]]
- return output
-end
-
-function GetContentBackground(candidate, bgcolor)
- bgColor = ColorBackgroundPattern
-
- local output = ""
-
- if candidate == "dots" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' viewBox='0 0 4 4'%3E%3Cpath fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' d='M1 3h1v1H1V3zm2-2h1v1H3V1z'%3E%3C/path%3E%3C/svg%3E");]]
- elseif candidate == "rain" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='12' height='16' viewBox='0 0 12 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 .99C4 .445 4.444 0 5 0c.552 0 1 .45 1 .99v4.02C6 5.555 5.556 6 5 6c-.552 0-1-.45-1-.99V.99zm6 8c0-.546.444-.99 1-.99.552 0 1 .45 1 .99v4.02c0 .546-.444.99-1 .99-.552 0-1-.45-1-.99V8.99z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E");]]
- elseif candidate == "plus" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "signal" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='84' height='48' viewBox='0 0 84 48' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h12v6H0V0zm28 8h12v6H28V8zm14-8h12v6H42V0zm14 0h12v6H56V0zm0 8h12v6H56V8zM42 8h12v6H42V8zm0 16h12v6H42v-6zm14-8h12v6H56v-6zm14 0h12v6H70v-6zm0-16h12v6H70V0zM28 32h12v6H28v-6zM14 16h12v6H14v-6zM0 24h12v6H0v-6zm0 8h12v6H0v-6zm14 0h12v6H14v-6zm14 8h12v6H28v-6zm-14 0h12v6H14v-6zm28 0h12v6H42v-6zm14-8h12v6H56v-6zm0-8h12v6H56v-6zm14 8h12v6H70v-6zm0 8h12v6H70v-6zM14 24h12v6H14v-6zm14-8h12v6H28v-6zM14 8h12v6H14V8zM0 8h12v6H0V8z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E");]]
- elseif candidate == "deathstar" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='105' viewBox='0 0 80 105'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M20 10a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm15 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zM20 75a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zm30-65a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm0 65a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zM35 10a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zM5 45a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zm60 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10z' /%3E%3C/g%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "diamond" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='32' viewBox='0 0 16 32'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath fill-rule='evenodd' d='M0 24h4v2H0v-2zm0 4h6v2H0v-2zm0-8h2v2H0v-2zM0 0h4v2H0V0zm0 4h2v2H0V4zm16 20h-6v2h6v-2zm0 4H8v2h8v-2zm0-8h-4v2h4v-2zm0-20h-6v2h6V0zm0 4h-4v2h4V4zm-2 12h2v2h-2v-2zm0-8h2v2h-2V8zM2 8h10v2H2V8zm0 8h10v2H2v-2zm-2-4h14v2H0v-2zm4-8h6v2H4V4zm0 16h6v2H4v-2zM6 0h2v2H6V0zm0 24h2v2H6v-2z'/%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "hexagon" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='49' viewBox='0 0 28 49'%3E%3Cg fill-rule='evenodd'%3E%3Cg id='hexagons' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='nonzero'%3E%3Cpath d='M13.99 9.25l13 7.5v15l-13 7.5L1 31.75v-15l12.99-7.5zM3 17.9v12.7l10.99 6.34 11-6.35V17.9l-11-6.34L3 17.9zM0 15l12.98-7.5V0h-2v6.35L0 12.69v2.3zm0 18.5L12.98 41v8h-2v-6.85L0 35.81v-2.3zM15 0v7.5L27.99 15H28v-2.31h-.01L17 6.35V0h-2zm0 49v-8l12.99-7.5H28v2.31h-.01L17 42.15V49h-2z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "capsule" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='32' height='26' viewBox='0 0 32 26' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M14 0v3.994C14 7.864 10.858 11 7 11c-3.866 0-7-3.138-7-7.006V0h2v4.005C2 6.765 4.24 9 7 9c2.756 0 5-2.236 5-4.995V0h2zm0 26v-5.994C14 16.138 10.866 13 7 13c-3.858 0-7 3.137-7 7.006V26h2v-6.005C2 17.235 4.244 15 7 15c2.76 0 5 2.236 5 4.995V26h2zm2-18.994C16 3.136 19.142 0 23 0c3.866 0 7 3.138 7 7.006v9.988C30 20.864 26.858 24 23 24c-3.866 0-7-3.138-7-7.006V7.006zm2-.01C18 4.235 20.244 2 23 2c2.76 0 5 2.236 5 4.995v10.01C28 19.765 25.756 22 23 22c-2.76 0-5-2.236-5-4.995V6.995z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E");]]
- elseif candidate == "diagonal" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='6' height='6' viewBox='0 0 6 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'%3E%3Cpath d='M5 0h1L0 6V5zM6 5v1H5z'/%3E%3C/g%3E%3C/svg%3E");]]
- end
- return output;
-end
-
-function GetContentDamageHUDOutput()
- local hudWidth = 300
- local hudHeight = 165
- if #damagedElements > 0 or #brokenElements > 0 then hudHeight = 510 end
- local output = ""
-
- output = output .. [[
-
- ]]
- output = output .. [[]] ..
- [[]] ..
- [[]] ..
- [[]]..(YourShipsName=="Enter here" and ("Ship ID "..ShipID) or YourShipsName) .. [[]] ..
- [[]]
- if #brokenElements > 0 then
- output = output .. [[]]
- elseif #damagedElements > 0 then
- output = output .. [[]]
- else
- output = output .. [[]]
- end
-
- if #damagedElements > 0 or #brokenElements > 0 then
-
- output = output .. [[Total Damage]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", totalShipMaxHP - totalShipHP))..[[]]
- output = output .. [[T]]..ScrapTier..[[ Scrap Needed]] ..
- [[]]..getScraps(totalShipMaxHP - totalShipHP, true)..[[]]
- output = output .. [[Repair Time]] ..
- [[]]..getRepairTime(totalShipMaxHP - totalShipHP, true)..[[]]
-
- output = output .. [[]] ..
- [[]] ..
- [[]]..#healthyElements..[[]] ..
- [[]] ..
- [[]]..#damagedElements..[[]] ..
- [[]] ..
- [[]]..#brokenElements..[[]]
- local j=0
-
- for currentIndex=hudStartIndex,hudStartIndex+9,1 do
- if rE[currentIndex] ~= nil then
- v = rE[currentIndex]
- if v.hp > 0 then
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- if v.id == highlightID then
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- end
- else
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- if v.id == highlightID then
- highlightX = elementPosition.x - coreWorldOffset
- highlightY = elementPosition.y - coreWorldOffset
- highlightZ = elementPosition.z - coreWorldOffset
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- end
- end
- j=j+1
- end
- end
- if DisallowKeyPresses == true then
- output = output ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Keypresses disabled.]] ..
- [[Change in LUA parameters]] ..
- [[by unchecking DisallowKeyPresses.]] ..
- [[]] ..
- [[]] ..
- [[]]
- else
- output = output ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Up/down arrows to highlight]] ..
- [[CTRL + arrows to move HUD]] ..
- [[Left arrow to toggle HUD Mode]] ..
- [[ALT+1-4 to set Scrap Tier]] ..
- [[ALT+8 to reset HUD position]] ..
- [[ALT+9 to shut script off]] ..
- [[]] ..
- [[]]
- end
- else
- if DisallowKeyPresses == true then
- output = output ..
- [[]] .. OkayCenterMessage .. [[]] ..
- [[]]..#healthyElements..[[ elements / ]] .. GenerateCommaValue(string.format("%.0f", totalShipMaxHP)) .. [[ HP.]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Keypresses disabled.]] ..
- [[Change in LUA parameters]] ..
- [[by unchecking DisallowKeyPresses.]] ..
- [[]] ..
- [[]] ..
- [[]]
- else
- output = output ..
- [[]] .. OkayCenterMessage .. [[]] ..
- [[]]..#healthyElements..[[ elements / ]] .. GenerateCommaValue(string.format("%.0f", totalShipMaxHP)) .. [[ HP.]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Left arrow to toggle HUD Mode]] ..
- [[CTRL + arrows to move HUD]] ..
- [[ALT+8 to reset HUD position]] ..
- [[ALT+9 to shut script off]] ..
- [[]] ..
- [[]]
- end
- end
- output = output .. [[]]
- return output
-end
-
-function GetContentDamageScreen()
-
- local screenOutput = ""
-
- -- Draw damage elements
- if #damagedElements > 0 then
- local damagedElementsToDraw = #damagedElements
- if damagedElementsToDraw > DamagePageSize then
- damagedElementsToDraw = DamagePageSize
- end
- if CurrentDamagedPage == math.ceil(#damagedElements / DamagePageSize) then
- damagedElementsToDraw = #damagedElements % DamagePageSize + 12
- if damagedElementsToDraw > 12 then damagedElementsToDraw = damagedElementsToDraw - 12 end
- end
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
-
- if UseMyElementNames == true then screenOutput = screenOutput .. [[Damaged Name]]
- else screenOutput = screenOutput .. [[Damaged Type]]
- end
-
- screenOutput = screenOutput .. [[HLTHDMG]]
- screenOutput = screenOutput .. [[T]]..ScrapTier..[[ SCRREPTIME]]
-
- AddClickArea("damage", {
- id = "SwitchScrapTier",
- mode ="damage",
- x1 = 650,
- x2 = 775,
- y1 = 315,
- y2 = 360
- })
-
- local i = 0
- for j = 1 + (CurrentDamagedPage - 1) * DamagePageSize, damagedElementsToDraw + (CurrentDamagedPage - 1) * DamagePageSize, 1 do
- i = i + 1
- local DP = damagedElements[j]
- if UseMyElementNames == true then screenOutput = screenOutput .. [[]] .. string.format("%.23s", DP.name) .. [[]]
- else screenOutput = screenOutput .. [[]] .. string.format("%.23s", DP.type) .. [[]]
- end
- screenOutput = screenOutput .. [[]] .. DP.percent .. [[%]] ..
- [[]] .. GenerateCommaValue(string.format("%.0f", DP.missinghp), true) .. [[]] ..
- [[]] .. getScraps(DP.missinghp, true) .. [[]] ..
- [[]] .. getRepairTime(DP.missinghp, true) .. [[]] ..
- [[]]
- end
-
- if #damagedElements > DamagePageSize then
- screenOutput = screenOutput ..
- [[Page ]] .. CurrentDamagedPage .. " of " .. math.ceil(#damagedElements / DamagePageSize) ..[[]]
-
- if CurrentDamagedPage < math.ceil(#damagedElements / DamagePageSize) then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "DamagedPageDown",
- mode ="damage",
- x1 = 65,
- x2 = 260,
- y1 = 290 + (damagedElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (damagedElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("DamagedPageDown","damage")
- end
-
- if CurrentDamagedPage > 1 then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "DamagedPageUp",
- mode ="damage",
- x1 = 750,
- x2 = 950,
- y1 = 290 + (damagedElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (damagedElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("DamagedPageUp","damage")
- end
- end
- end
-
- -- Draw broken elements
- if #brokenElements > 0 then
- local brokenElementsToDraw = #brokenElements
- if brokenElementsToDraw > DamagePageSize then
- brokenElementsToDraw = DamagePageSize
- end
- if CurrentBrokenPage == math.ceil(#brokenElements / DamagePageSize) then
- brokenElementsToDraw = #brokenElements % DamagePageSize + 12
- if brokenElementsToDraw > 12 then brokenElementsToDraw = brokenElementsToDraw - 12 end
- end
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
-
- if UseMyElementNames == true then screenOutput = screenOutput .. [[Broken Name]]
- else screenOutput = screenOutput .. [[Broken Type]]
- end
-
- screenOutput = screenOutput .. [[DMG]]
- screenOutput = screenOutput .. [[T]]..ScrapTier..[[ SCRREPTIME]]
-
- AddClickArea("damage", {
- id = "SwitchScrapTier2",
- mode ="damage",
- x1 = 1570,
- x2 = 1690,
- y1 = 315,
- y2 = 360
- })
-
- local i = 0
- for j = 1 + (CurrentBrokenPage - 1) * DamagePageSize, brokenElementsToDraw + (CurrentBrokenPage - 1) * DamagePageSize, 1 do
- i = i + 1
- local DP = brokenElements[j]
- if UseMyElementNames == true then screenOutput = screenOutput .. [[]] .. string.format("%.30s", DP.name) .. [[]]
- else screenOutput = screenOutput .. [[]] .. string.format("%.30s", DP.type) .. [[]]
- end
- screenOutput = screenOutput .. [[]] .. GenerateCommaValue(string.format("%.0f", DP.missinghp), true) .. [[]] ..
- [[]] .. getScraps(DP.missinghp, true) .. [[]] ..
- [[]] .. getRepairTime(DP.missinghp, true) .. [[]] ..
- [[]]
- end
-
-
-
- if #brokenElements > DamagePageSize then
- screenOutput = screenOutput ..
- [[Page ]] .. CurrentBrokenPage .. " of " .. math.ceil(#brokenElements / DamagePageSize) .. [[]]
-
- if CurrentBrokenPage > 1 then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "BrokenPageUp",
- mode ="damage",
- x1 = 1665,
- x2 = 1865,
- y1 = 290 + (brokenElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (brokenElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("BrokenPageUp", "damage")
- end
-
- if CurrentBrokenPage < math.ceil(#brokenElements / DamagePageSize) then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "BrokenPageDown",
- mode ="damage",
- x1 = 980,
- x2 = 1180,
- y1 = 290 + (brokenElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (brokenElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("BrokenPageDown", "damage")
- end
- end
-
- end
-
- -- Draw summary
- if #damagedElements > 0 or #brokenElements > 0 then
- local dWidth = math.floor(1878/#elementsIdList*#damagedElements)
- local bWidth = math.floor(1878/#elementsIdList*#brokenElements)
- local hWidth = 1878-dWidth-bWidth+1
-
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
-
- if #damagedElements > 0 then
- screenOutput = screenOutput .. [[]]..#damagedElements..[[]]
- end
- if #healthyElements > 0 then
- screenOutput = screenOutput .. [[]]..#healthyElements..[[]]
- end
- if #brokenElements > 0 then
- screenOutput = screenOutput .. [[]]..#brokenElements..[[]]
- end
-
- screenOutput = screenOutput .. [[]]
-
- screenOutput = screenOutput .. [[]] ..
- GenerateCommaValue(string.format("%.0f", totalShipMaxHP - totalShipHP)) .. [[ HP damage in total ]] ..
- getScraps(totalShipMaxHP - totalShipHP, true) .. [[ T]]..ScrapTier..[[ scraps needed. ]] ..
- getRepairTime(totalShipMaxHP - totalShipHP, true) .. [[ projected repair time.]]
- else
- screenOutput = screenOutput .. GetElementLogo(812, 380, "ch", "ch", "ch") ..
- [[]] .. OkayCenterMessage .. [[]] ..
- [[]]..#healthyElements..[[ elements stand ]] .. GenerateCommaValue(string.format("%.0f", totalShipMaxHP)) .. [[ HP strong.]]
- end
-
- forceDamageRedraw = false
-
- return screenOutput
-end
-
-function ActionStopengines()
- if DisallowKeyPresses == true then return end
- ToggleHUD()
-end
-
-function ActionStrafeRight()
- if DisallowKeyPresses == true then return end
- if KeyCTRLPressed == true then
- if HUDShiftU < 4000 then
- HUDShiftU = HUDShiftU + 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- HudDeselectElement()
- end
-end
-
-function ActionStrafeLeft()
- if DisallowKeyPresses == true then return end
- if KeyCTRLPressed == true then
- if HUDShiftU >= 50 then
- HUDShiftU = HUDShiftU - 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- ToggleHUD()
- end
-end
-
-function ActionDown()
- if DisallowKeyPresses == true then return end
- if KeyCTRLPressed == true then
- if HUDShiftV < 4000 then
- HUDShiftV = HUDShiftV + 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- ChangeHudSelectedElement(1)
- end
-end
-
-function ActionUp()
- if DisallowKeyPresses == true then return end
- if KeyCTRLPressed == true then
- if HUDShiftV >= 50 then
- HUDShiftV = HUDShiftV - 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- ChangeHudSelectedElement(-1)
- end
-end
-
-function ActionOption1()
- if DisallowKeyPresses == true then return end
- ScrapTier = 1
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption2()
- if DisallowKeyPresses == true then return end
- ScrapTier = 2
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption3()
- if DisallowKeyPresses == true then return end
- ScrapTier = 3
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption4()
- if DisallowKeyPresses == true then return end
- ScrapTier = 4
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption8()
- if DisallowKeyPresses == true then return end
- HUDShiftU=0
- HUDShiftV=0
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption9()
- if DisallowKeyPresses == true then return end
- SaveToDatabank()
- SwitchScreens("off")
- unit.exit()
-end
diff --git a/src/DamageReport_3_13_UnitStart_2.lua b/src/DamageReport_3_13_UnitStart_2.lua
deleted file mode 100644
index 71d442d..0000000
--- a/src/DamageReport_3_13_UnitStart_2.lua
+++ /dev/null
@@ -1,2045 +0,0 @@
---[[
- Damage Report 3.13
- A LUA script for Dual Universe
-
- Created By Dorian Gray
- Ingame: DorianGray
- Discord: Dorian Gray#2623
-
- You can find/update this script on GitHub. Explanations, installation and usage information as well as screenshots can be found there too.
- GitHub: https://github.com/DorianTheGrey/DU-DamageReport
-
- GNU Public License 3.0. Use whatever you want, be so kind to leave credit.
-
- Credits & thanks:
- Thanks to NovaQuark for creating the MMO of the century.
- Thanks to Jericho, Dmentia and Archaegeo for learning a lot from their fine scripts.
- Thanks to TheBlacklist for testing and wonderful suggestions.
- SVG patterns by Hero Patterns.
- DU atlas data from Jayle Break.
-
-]]
-
---[[ 1. USER DEFINED VARIABLES ]]
-
-YourShipsName = "Enter here" --export Enter your ship name here if you want it displayed instead of the ship's ID. YOU NEED TO LEAVE THE QUOTATION MARKS.
-
-SkillRepairToolEfficiency = 0 --export Enter (0-5) your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency"
-SkillRepairToolOptimization = 0 --export Enter your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Optimization"
-
-StatAtmosphericFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED ATMOSPHERIC FUEL TANKS (from the builders talent "Piloting -> Atmospheric Flight Technician -> Atmospheric Fuel-Tank Handling")
-StatSpaceFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL SPACE TANKS (from the builders talent "Piloting -> Atmospheric Engine Technician -> Space Fuel-Tank Handling")
-StatRocketFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL ROCKET TANKS (from the builders talent "Piloting -> Rocket Scientist -> Rocket Booster Fuel Tank Handling")
-StatContainerOptimization = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL TANKS "from the builders talent Mining and Inventory -> Stock Control -> Container Optimization"
-StatFuelTankOptimization = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL TANKS "from the builders talent Mining and Inventory -> Stock Control -> Fuel Tank Optimization"
-
-ShowWelcomeMessage = true --export Do you want the welcome message on the start screen with your name?
-DisallowKeyPresses = false --export Need your keys for other scripts/huds and want to prevent Damage Report keypresses to be processed? Then check this. (Usability of the HUD mode will be small.)
-AddSummertimeHour = false --export: Is summertime currently enabled in your location? (Adds one hour.)
-
--- SkillAtmosphericFuelEfficiency = 0 --export Enter (0-5) your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency"
--- SkillSpaceFuelEfficiency = 0 --export Enter (0-5) your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency"
--- SkillRocketFuelEfficiency = 0 --export Enter (0-5) your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency"
-
---[[ 2. GLOBAL VARIABLES ]]
-
-UpdateDataInterval = 1.0 -- How often shall the data be updated? (Increase if running into CPU issues.)
-HighlightBlinkingInterval = 0.5 -- How fast shall highlight arrows of marked elements blink?
-
-ColorPrimary = "FF6700" -- Enter the hexcode of the main color to be used by all views.
-ColorSecondary = "FFFFFF" -- Enter the hexcode of the secondary color to be used by all views.
-ColorTertiary = "000000" -- Enter the hexcode of the tertiary color to be used by all views.
-ColorHealthy = "00FF00" -- Enter the hexcode of the 'healthy' color to be used by all views.
-ColorWarning = "FFFF00" -- Enter the hexcode of the 'warning' color to be used by all views.
-ColorCritical = "FF0000" -- Enter the hexcode of the 'critical' color to be used by all views.
-ColorBackground = "000000" -- Enter the hexcode of the background color to be used by all views.
-ColorBackgroundPattern = "4F4F4F" -- Enter the hexcode of the background color to be used by all views.
-ColorFuelAtmospheric = "004444" -- Enter the hexcode of the atmospheric fuel color.
-ColorFuelSpace = "444400" -- Enter the hexcode of the space fuel color.
-ColorFuelRocket = "440044" -- Enter the hexcode of the rocket fuel color.
-
-VERSION = 3.13
-DebugMode = false
-DebugRenderClickareas = true
-
-DBData = {}
-
-core = nil
-db = nil
-screens = {}
-dscreens = {}
-
-Warnings = {}
-
-screenModes = {
- ["flight"] = { id="flight" },
- ["damage"] = { id="damage" },
- ["damageoutline"] = { id="damageoutline" },
- ["fuel"] = { id="fuel" },
- ["cargo"] = { id="cargo" },
- ["agg"] = { id="agg" },
- ["map"] = { id="map" },
- ["time"] = { id="time", activetoggle="true" },
- ["settings1"] = { id="settings1" },
- ["startup"] = { id="startup" }
-}
-
-backgroundModes = { "deathstar", "capsule", "rain", "signal", "hexagon", "diagonal", "diamond", "plus", "dots" }
-BackgroundMode ="deathstar"
-BackgroundSelected = 1
-BackgroundModeOpacity = 0.25
-
-SaveVars = { "dscreens",
- "ColorPrimary", "ColorSecondary", "ColorTertiary",
- "ColorHealthy", "ColorWarning", "ColorCritical",
- "ColorBackground", "ColorBackgroundPattern",
- "ColorFuelAtmospheric", "ColorFuelSpace", "ColorFuelRocket",
- "ScrapTier", "HUDMode", "SimulationMode", "DMGOStretch",
- "HUDShiftU", "HUDShiftV", "colorIDIndex", "colorIDTable",
- "BackgroundMode", "BackgroundSelected", "BackgroundModeOpacity" }
-
-HUDMode = false
-HUDShiftU = 0
-HUDShiftV = 0
-hudSelectedIndex = 0
-hudStartIndex = 1
-hudArrowSticker = {}
-highlightOn = false
-highlightID = 0
-highlightX = 0
-highlightY = 0
-highlightZ = 0
-
-SimulationMode = false
-OkayCenterMessage = "All systems nominal."
-CurrentDamagedPage = 1
-CurrentBrokenPage = 1
-DamagePageSize = 12
-ScrapTier = 1
-totalScraps = 0
-ScrapTierRepairTimes = { 10, 50, 250, 1250 }
-
-coreWorldOffset = 0
-totalShipHP = 0
-formerTotalShipHP = -1
-totalShipMaxHP = 0
-totalShipIntegrity = 100
-elementsId = {}
-elementsIdList = {}
-damagedElements = {}
-brokenElements = {}
-rE = {}
-healthyElements = {}
-typeElements = {}
-ElementCounter = 0
-UseMyElementNames = true
-dmgoElements = {}
-DMGOMaxElements = 250
-DMGOStretch = false
-ShipXmin = 99999999
-ShipXmax = -99999999
-ShipYmin = 99999999
-ShipYmax = -99999999
-ShipZmin = 99999999
-ShipZmax = -99999999
-
-totalShipMass = 0
-formerTotalShipMass = -1
-
-formerTime = -1
-
-FuelAtmosphericTanks = {}
-FuelSpaceTanks = {}
-FuelRocketTanks = {}
-FuelAtmosphericTotal = 0
-FuelSpaceTotal = 0
-FuelRocketTotal = 0
-FuelAtmosphericCurrent = 0
-FuelSpaceTotalCurrent = 0
-FuelRocketTotalCurrent = 0
-formerFuelAtmosphericTotal = -1
-formerFuelSpaceTotal = -1
-formerFuelRocketTotal = -1
-
-hexTable = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"}
-colorIDIndex = 1
-colorIDTable = {
- [1] = {
- id="ColorPrimary",
- desc="Main HUD Color",
- basec = "FF6700",
- newc = "FF6700"
- },
- [2] = {
- id="ColorSecondary",
- desc="Secondary HUD Color",
- basec = "FFFFFF",
- newc = "FFFFFF"
- },
- [3] = {
- id="ColorTertiary",
- desc="Tertiary HUD Color",
- basec = "000000",
- newc = "000000"
- },
- [4] = {
- id="ColorHealthy",
- desc="Color code for Healthy/Okay",
- basec = "00FF00",
- newc = "00FF00"
- },
- [5] = {
- id="ColorWarning",
- desc="Color code for Damaged/Warning",
- basec = "FFFF00",
- newc = "FFFF00"
- },
- [6] = {
- id="ColorCritical",
- desc="Color code for Broken/Critical",
- basec = "FF0000",
- newc = "FF0000"
- },
- [7] = {
- id="ColorBackground",
- desc="Background Color",
- basec = "000000",
- newc = "000000"
- },
- [8] = {
- id="ColorBackgroundPattern",
- desc="Background Pattern Color",
- basec = "4F4F4F",
- newc = "4F4F4F"
- },
- [9] = {
- id="ColorFuelAtmospheric",
- desc="Color for Atmo Fuel/Elements",
- basec = "004444",
- newc = "004444"
- },
- [10] = {
- id="ColorFuelSpace",
- desc="Color for Space Fuel/Elements",
- basec = "444400",
- newc = "444400"
- },
- [11] = {
- id="ColorFuelRocket",
- desc="Color for Rocket Fuel/Elements",
- basec = "440044",
- newc = "440044"
- }
-}
-
-
---[[ 3. PROCESSING FUNCTIONS ]]
-
-function InitiateSlots()
- for slot_name, slot in pairs(unit) do
- if type(slot) == "table" and type(slot.export) == "table" and
- slot.getElementClass then
- local elementClass = slot.getElementClass():lower()
- if elementClass:find("coreunit") then
- core = slot
- local coreHP = core.getMaxHitPoints()
- if coreHP > 10000 then
- coreWorldOffset = 128
- elseif coreHP > 1000 then
- coreWorldOffset = 64
- elseif coreHP > 150 then
- coreWorldOffset = 32
- else
- coreWorldOffset = 16
- end
- elseif elementClass == 'databankunit' then
- db = slot
- elseif elementClass == "screenunit" then
- local iScreenMode = "startup"
- screens[#screens + 1] = {
- element = slot,
- id = slot.getId(),
- mode = iScreenMode,
- submode = "",
- ClickAreas = {},
- refresh = true,
- active = false,
- fuelA = true,
- fuelS = true,
- fuelR = true,
- fuelIndex = 1
- }
- end
- end
- end
-end
-
-function LoadFromDatabank()
- if db == nil then
- return
- else
- for _, data in pairs(SaveVars) do
- if db.hasKey(data) then
- local jData = json.decode( db.getStringValue(data) )
- if jData ~= nil then
- if data == "YourShipsName" or data == "AddSummertimeHour" or data == "UpdateDataInterval" or data == "HighlightBlinkingInterval" or
- data == "SkillRepairToolEfficiency" or data == "SkillRepairToolOptimization" or data == "SkillAtmosphericFuelEfficiency" or
- data == "SkillSpaceFuelEfficiency" or data == "SkillRocketFuelEfficiency" or data == "StatAtmosphericFuelTankHandling" or
- data == "StatSpaceFuelTankHandling" or data == "StatRocketFuelTankHandling"
- then
- -- Nada
- else
- _G[data] = jData
- end
- end
- end
- end
-
- for i,v in ipairs(screens) do
- for j,dv in ipairs(dscreens) do
- if screens[i].id == dscreens[j].id then
- screens[i].mode = dscreens[j].mode
- screens[i].submode = dscreens[j].submode
- screens[i].active = dscreens[j].active
- screens[i].refresh = true
- screens[i].fuelA = dscreens[j].fuelA
- screens[i].fuelS = dscreens[j].fuelS
- screens[i].fuelR = dscreens[j].fuelR
- screens[i].fuelIndex = dscreens[j].fuelIndex
- end
- end
- end
- end
-end
-
-function SaveToDatabank()
- if db == nil then
- return
- else
- dscreens = {}
- for i,screen in ipairs(screens) do
- dscreens[i] = {}
- dscreens[i].id = screen.id
- dscreens[i].mode = screen.mode
- dscreens[i].submode = screen.submode
- dscreens[i].active = screen.active
- dscreens[i].fuelA = screen.fuelA
- dscreens[i].fuelS = screen.fuelS
- dscreens[i].fuelR = screen.fuelR
- dscreens[i].fuelIndex = screen.fuelIndex
- end
-
- db.clear()
-
- for _, data in pairs(SaveVars) do
- db.setStringValue(data, json.encode(_G[data]))
- end
-
- end
-end
-
-function InitiateScreens()
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- screens[i] = CreateClickAreasForScreen(screens[i])
- end
- end
-end
-
-function UpdateTypeData()
- FuelAtmosphericTanks = {}
- FuelSpaceTanks = {}
- FuelRocketTanks = {}
-
- FuelAtmosphericTotal = 0
- FuelAtmosphericCurrent = 0
- FuelSpaceTotal = 0
- FuelSpaceCurrent = 0
- FuelRocketCurrent = 0
- FuelRocketTotal = 0
-
- local weightAtmosphericFuel = 4
- local weightSpaceFuel = 6
- local weightRocketFuel = 0.8
-
- if StatContainerOptimization > 0 then
- weightAtmosphericFuel = weightAtmosphericFuel - 0.05 * StatContainerOptimization * weightAtmosphericFuel
- weightSpaceFuel = weightSpaceFuel - 0.05 * StatContainerOptimization * weightSpaceFuel
- weightRocketFuel = weightRocketFuel - 0.05 * StatContainerOptimization * weightRocketFuel
- end
- if StatFuelTankOptimization > 0 then
- weightAtmosphericFuel = weightAtmosphericFuel - 0.05 * StatFuelTankOptimization * weightAtmosphericFuel
- weightSpaceFuel = weightSpaceFuel - 0.05 * StatFuelTankOptimization * weightSpaceFuel
- weightRocketFuel = weightRocketFuel - 0.05 * StatFuelTankOptimization * weightRocketFuel
- end
-
- for i, id in ipairs(typeElements) do
- local idName = core.getElementNameById(id) or ""
- local idType = core.getElementTypeById(id) or ""
- local idPos = core.getElementPositionById(id) or 0
- local idHP = core.getElementHitPointsById(id) or 0
- local idMaxHP = core.getElementMaxHitPointsById(id) or 0
- local idMass = core.getElementMassById(id) or 0
-
- local baseSize = ""
- local baseVol = 0
- local baseMass = 0
- local cMass = 0
- local cVol = 0
-
- if idType == "Atmospheric Fuel Tank" then
- if idMaxHP > 10000 then
- baseSize = "L"
- baseMass = 5480
- baseVol = 12800
- elseif idMaxHP > 1300 then
- baseSize = "M"
- baseMass = 988.67
- baseVol = 1600
- elseif idMaxHP > 150 then
- baseSize = "S"
- baseMass = 182.67
- baseVol = 400
- else
- baseSize = "XS"
- baseMass = 35.03
- baseVol = 100
- end
- if StatAtmosphericFuelTankHandling > 0 then
- baseVol = 0.2 * StatAtmosphericFuelTankHandling * baseVol + baseVol
- end
- cMass = idMass - baseMass
- if cMass <=10 then cMass = 0 end
- cVol = string.format("%.0f", cMass / weightAtmosphericFuel)
- cPercent = string.format("%.1f", math.floor(100/baseVol * tonumber(cVol)))
- table.insert(FuelAtmosphericTanks, {
- type = 1,
- id = id,
- name = idName,
- maxhp = idMaxHP,
- hp = GetHPforElement(id),
- pos = idPos,
- size = baseSize,
- mass = baseMass,
- vol = baseVol,
- cvol = cVol,
- percent = cPercent
- })
- if idHP > 0 then
- FuelAtmosphericCurrent = FuelAtmosphericCurrent + cVol
- end
- FuelAtmosphericTotal = FuelAtmosphericTotal + baseVol
- elseif idType == "Space Fuel Tank" then
- if idMaxHP > 10000 then
- baseSize = "L"
- baseMass = 5480
- baseVol = 12800
- elseif idMaxHP > 1300 then
- baseSize = "M"
- baseMass = 988.67
- baseVol = 1600
- else
- baseSize = "S"
- baseMass = 182.67
- baseVol = 400
- end
- if StatSpaceFuelTankHandling > 0 then
- baseVol = 0.2 * StatSpaceFuelTankHandling * baseVol + baseVol
- end
- cMass = idMass - baseMass
- if cMass <=10 then cMass = 0 end
- cVol = string.format("%.0f", cMass / weightSpaceFuel)
- cPercent = string.format("%.1f", (100/baseVol * tonumber(cVol)))
- table.insert(FuelSpaceTanks, {
- type = 2,
- id = id,
- name = idName,
- maxhp = idMaxHP,
- hp = GetHPforElement(id),
- pos = idPos,
- size = baseSize,
- mass = baseMass,
- vol = baseVol,
- cvol = cVol,
- percent = cPercent
- })
- if idHP > 0 then
- FuelSpaceCurrent = FuelSpaceCurrent + cVol
- end
- FuelSpaceTotal = FuelSpaceTotal + baseVol
- elseif idType == "Rocket Fuel Tank" then
- if idMaxHP > 65000 then
- baseSize = "L"
- baseMass = 25740
- baseVol = 50000
- elseif idMaxHP > 6000 then
- baseSize = "M"
- baseMass = 4720
- baseVol = 6400
- elseif idMaxHP > 700 then
- baseSize = "S"
- baseMass = 886.72
- baseVol = 800
- else
- baseSize = "XS"
- baseMass = 173.42
- baseVol = 400
- end
- if StatRocketFuelTankHandling > 0 then
- baseVol = 0.1 * StatRocketFuelTankHandling * baseVol + baseVol
- end
- cMass = idMass - baseMass
- if cMass <=10 then cMass = 0 end
- cVol = string.format("%.0f", cMass / weightRocketFuel)
- cPercent = string.format("%.1f", (100/baseVol * tonumber(cVol)))
- table.insert(FuelRocketTanks, {
- type = 3,
- id = id,
- name = idName,
- maxhp = idMaxHP,
- hp = GetHPforElement(id),
- pos = idPos,
- size = baseSize,
- mass = baseMass,
- vol = baseVol,
- cvol = cVol,
- percent = cPercent
- })
- if idHP > 0 then
- FuelRocketCurrent = FuelRocketCurrent + cVol
- end
- FuelRocketTotal = FuelRocketTotal + baseVol
- end
-
- end
-
- if FuelAtmosphericCurrent ~= formerFuelAtmosphericCurrent then
- SetRefresh("fuel")
- formerFuelAtmosphericCurrent = FuelAtmosphericCurrent
- end
- if FuelSpaceCurrent ~= formerFuelSpaceCurrent then
- SetRefresh("fuel")
- formerFuelSpaceCurrent = FuelSpaceCurrent
- end
- if FuelRocketCurrent ~= formerFuelRocketCurrent then
- SetRefresh("fuel")
- formerFuelRocketCurrent = FuelRocketCurrent
- end
-
-
-
-end
-
-function UpdateDamageData(initial)
-
- initial = initial or false
-
- if SimulationActive == true then return end
-
- local formerTotalShipHP = totalShipHP
- totalShipHP = 0
- totalShipMaxHP = 0
- totalShipIntegrity = 100
- damagedElements = {}
- brokenElements = {}
- healthyElements = {}
- if initial == true then
- typeElements = {}
- end
-
- ElementCounter = 0
-
- elementsIdList = core.getElementIdList()
-
- for i, id in pairs(elementsIdList) do
-
- ElementCounter = ElementCounter + 1
-
- local idName = core.getElementNameById(id)
-
- local idType = core.getElementTypeById(id)
- local idPos = core.getElementPositionById(id)
- local idHP = core.getElementHitPointsById(id)
- local idMaxHP = core.getElementMaxHitPointsById(id)
-
- if SimulationMode == true then
- SimulationActive = true
- local dice = math.random(0, 10)
- if dice < 2 and #brokenElements < 30 then
- idHP = 0
- elseif dice >= 2 and dice < 4 and #damagedElements < 30 then
- idHP = math.random(1, math.ceil(idMaxHP))
- else
- idHP = idMaxHP
- end
- end
-
- totalShipHP = totalShipHP + idHP
- totalShipMaxHP = totalShipMaxHP + idMaxHP
-
- if idMaxHP - idHP > constants.epsilon then
-
- if idHP > 0 then
- table.insert(damagedElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP - idHP,
- percent = math.ceil(100 / idMaxHP * idHP),
- pos = idPos
- })
- else
- table.insert(brokenElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP - idHP,
- percent = 0,
- pos = idPos
- })
- end
- else
- table.insert(healthyElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- pos = idPos
- })
- if id == highlightID then
- highlightID = 0
- highlightOn = false
- HideHighlight()
- hudSelectedIndex = 0
- end
- end
-
- if initial == true then
- if
- idType == "Atmospheric Fuel Tank" or
- idType == "Space Fuel Tank" or
- idType == "Rocket Fuel Tank"
- then
- table.insert(typeElements, id)
- end
- end
- end
-
- SortDamageTables()
-
- rE = {}
-
- if #brokenElements > 0 then
- for _,v in ipairs(brokenElements) do
- table.insert(rE, {id=v.id, missinghp=v.missinghp, hp=v.hp, name=v.name, type=v.type, pos=v.pos})
- end
- end
- if #damagedElements > 0 then
- for _,v in ipairs(damagedElements) do
- table.insert(rE, {id=v.id, missinghp=v.missinghp, hp=v.hp, name=v.name, type=v.type, pos=v.pos})
- end
- end
- if #rE > 0 then
- table.sort(rE, function(a,b) return a.missinghp>b.missinghp end)
- end
-
- totalShipIntegrity = string.format("%2.0f", 100 / totalShipMaxHP * totalShipHP)
-
- if formerTotalShipHP ~= totalShipHP then
- forceDamageRedraw = true
- formerTotalShipHP = totalShipHP
- else
- forceDamageRedraw = false
- end
-end
-
-function GetHPforElement(id)
- for i,v in ipairs(brokenElements) do
- if v.id == id then
- return 0
- end
- end
- for i,v in ipairs(damagedElements) do
- if v.id == id then
- return v.hp
- end
- end
- for i,v in ipairs(healthyElements) do
- if v.id == id then
- return v.maxhp
- end
- end
-end
-
-function UpdateClickArea(candidate, newEntry, mode)
- for i, screen in ipairs(screens) do
- for k, v in pairs(screens[i].ClickAreas) do
- if v.id == candidate and v.mode == mode then
- screens[i].ClickAreas[k] = newEntry
- end
- end
- end
-end
-
-function AddClickArea(mode, newEntry)
- for i, screen in ipairs(screens) do
- if screens[i].mode == mode then
- table.insert(screens[i].ClickAreas, newEntry)
- end
- end
-end
-
-function AddClickAreaForScreenID(screenid, newEntry)
- for i, screen in ipairs(screens) do
- if screens[i].id == screenid then
- table.insert(screens[i].ClickAreas, newEntry)
- end
- end
-end
-
-function DisableClickArea(candidate, mode)
- UpdateClickArea(candidate, {
- id = candidate,
- mode = mode,
- x1 = -1,
- x2 = -1,
- y1 = -1,
- y2 = -1
- })
-end
-
-function SetRefresh(mode, submode)
- mode = mode or "all"
- submode = submode or "all"
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- if screens[i].mode == mode or mode == "all" then
- if screens[i].submode == submode or submode =="all" then
- screens[i].refresh = true
- end
- end
- end
- end
-end
-
-function WipeClickAreasForScreen(screen)
- screen.ClickAreas = {}
- return screen
-end
-
-function CreateBaseClickAreas(screen)
- table.insert(screen.ClickAreas, {mode = "all", id = "ToggleHudMode", x1 = 1537, x2 = 1728, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "damage", x1 = 193, x2 = 384, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "damageoutline", x1 = 385, x2 = 576, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "fuel", x1 = 577, x2 = 768, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "flight", x1 = 769, x2 = 960, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "cargo", x1 = 961, x2 = 1152, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "agg", x1 = 1153, x2 = 1344, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "map", x1 = 1345, x2 = 1536, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "time", x1 = 0, x2 = 192, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "settings1", x1 = 1729, x2 = 1920, y1 = 1015, y2 = 1075} )
- return screen
-end
-
-function CreateClickAreasForScreen(screen)
-
- if screen == nil then return {} end
-
- if screen.mode == "flight" then
- elseif screen.mode == "damage" then
- table.insert( screen.ClickAreas, {mode = "damage", id = "ToggleElementLabel", x1 = 70, x2 = 425, y1 = 325, y2 = 355} )
- table.insert( screen.ClickAreas, {mode = "damage", id = "ToggleElementLabel2", x1 = 980, x2 = 1400, y1 = 325, y2 = 355} )
- elseif screen.mode == "damageoutline" then
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeView", param = "top", x1 = 60, x2 = 439, y1 = 150, y2 = 200} )
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeView", param = "side", x1 = 440, x2 = 824, y1 = 150, y2 = 200} )
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeView", param = "front", x1 = 825, x2 = 1215, y1 = 150, y2 = 200} )
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeStretch", x1 = 1530, x2 = 1580, y1 = 150, y2 = 200} )
- elseif screen.mode == "fuel" then
- elseif screen.mode == "cargo" then
- elseif screen.mode == "agg" then
- elseif screen.mode == "map" then
- elseif screen.mode == "time" then
- elseif screen.mode == "settings1" then
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ToggleBackground", x1 = 75, x2 = 860, y1 = 170, y2 = 215} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "PreviousBackground", x1 = 75, x2 = 460, y1 = 235, y2 = 285} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "NextBackground", x1 = 480, x2 = 860, y1 = 235, y2 = 285} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "DecreaseOpacity", x1 = 75, x2 = 460, y1 = 300, y2 = 350} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "IncreaseOpacity", x1 = 480, x2 = 860, y1 = 300, y2 = 350} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ResetColors", x1 = 75, x2 = 860, y1 = 370, y2 = 415} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "PreviousColorID", x1 = 90, x2 = 140, y1 = 500, y2 = 550} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "NextColorID", x1 = 795, x2 = 845, y1 = 500, y2 = 550} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="1", x1 = 210, x2 = 290, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="2", x1 = 300, x2 = 380, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="3", x1 = 385, x2 = 465, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="4", x1 = 470, x2 = 550, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="5", x1 = 560, x2 = 640, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="6", x1 = 645, x2 = 725, y1 = 655, y2 = 700} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="1", x1 = 210, x2 = 290, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="2", x1 = 300, x2 = 380, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="3", x1 = 385, x2 = 465, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="4", x1 = 470, x2 = 550, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="5", x1 = 560, x2 = 640, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="6", x1 = 645, x2 = 725, y1 = 740, y2 = 780} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ResetPosColor", x1 = 160, x2 = 340, y1 = 885, y2 = 935} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ApplyPosColor", x1 = 355, x2 = 780, y1 = 885, y2 = 935} )
-
- elseif screen.mode == "startup" then
- end
-
- screen = CreateBaseClickAreas(screen)
-
- return screen
-end
-
-function CheckClick(x, y, HitTarget)
- x = x*1920
- y = y*1120
- HitTarget = HitTarget or ""
- HitPayload = {}
- -- PrintConsole("Clicked: "..x.." / "..y)
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- if screens[i].active == true and screens[i].element.getMouseX() ~= -1 and screens[i].element.getMouseY() ~= -1 then
- if HitTarget == "" then
- for k, v in pairs(screens[i].ClickAreas) do
- if v ~=nil and x >= v.x1 and x <= v.x2 and y >= v.y1 and y <= v.y2 then
- HitTarget = v.id
- HitPayload = v
- break
- end
- end
- end
- if HitTarget == "ButtonPress" then
- if screens[i].mode == HitPayload.param then
- screens[i].mode = "startup"
- else
- screens[i].mode = HitPayload.param
- end
-
- if screens[i].mode == "damageoutline" then
- if screens[i].submode == "" then
- screens[i].submode = "top"
- end
- end
- screens[i].refresh = true
- screens[i].ClickAreas = {}
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "ToggleBackground" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundMode == "" then
- BackgroundSelected = 1
- BackgroundMode = backgroundModes[BackgroundSelected]
- else
- BackgroundSelected = 1
- BackgroundMode = ""
- end
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "PreviousBackground" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundMode == "" then
- BackgroundSelected = 1
- BackgroundMode = backgroundModes[BackgroundSelected]
- else
- if BackgroundSelected <= 1 then
- BackgroundSelected = #backgroundModes
- else
- BackgroundSelected = BackgroundSelected - 1
- end
- BackgroundMode = backgroundModes[BackgroundSelected]
- end
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "NextBackground" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundMode == "" then
- BackgroundSelected = 1
- BackgroundMode = backgroundModes[BackgroundSelected]
- else
- if BackgroundSelected >= #backgroundModes then
- BackgroundSelected = 1
- else
- BackgroundSelected = BackgroundSelected + 1
- end
- BackgroundMode = backgroundModes[BackgroundSelected]
- end
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "DecreaseOpacity" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundModeOpacity>0.1 then
- BackgroundModeOpacity = BackgroundModeOpacity - 0.05
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- end
- elseif HitTarget == "IncreaseOpacity" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundModeOpacity<1.0 then
- BackgroundModeOpacity = BackgroundModeOpacity + 0.05
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- end
- elseif HitTarget == "ResetColors" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- db.clear()
- ColorPrimary = "FF6700"
- ColorSecondary = "FFFFFF"
- ColorTertiary = "000000"
- ColorHealthy = "00FF00"
- ColorWarning = "FFFF00"
- ColorCritical = "FF0000"
- ColorBackground = "000000"
- ColorBackgroundPattern = "4f4f4f"
- ColorFuelAtmospheric = "004444"
- ColorFuelSpace = "444400"
- ColorFuelRocket = "440044"
- BackgroundMode = "deathstar"
- BackgroundSelected = 1
- BackgroundModeOpacity = 0.25
- colorIDTable = {
- [1] = {
- id="ColorPrimary",
- desc="Main HUD Color",
- basec = "FF6700",
- newc = "FF6700"
- },
- [2] = {
- id="ColorSecondary",
- desc="Secondary HUD Color",
- basec = "FFFFFF",
- newc = "FFFFFF"
- },
- [3] = {
- id="ColorTertiary",
- desc="Tertiary HUD Color",
- basec = "000000",
- newc = "000000"
- },
- [4] = {
- id="ColorHealthy",
- desc="Color code for Healthy/Okay",
- basec = "00FF00",
- newc = "00FF00"
- },
- [5] = {
- id="ColorWarning",
- desc="Color code for Damaged/Warning",
- basec = "FFFF00",
- newc = "FFFF00"
- },
- [6] = {
- id="ColorCritical",
- desc="Color code for Broken/Critical",
- basec = "FF0000",
- newc = "FF0000"
- },
- [7] = {
- id="ColorBackground",
- desc="Background Color",
- basec = "000000",
- newc = "000000"
- },
- [8] = {
- id="ColorBackgroundPattern",
- desc="Background Pattern Color",
- basec = "4F4F4F",
- newc = "4F4F4F"
- },
- [9] = {
- id="ColorFuelAtmospheric",
- desc="Color for Atmo Fuel/Elements",
- basec = "004444",
- newc = "004444"
- },
- [10] = {
- id="ColorFuelSpace",
- desc="Color for Space Fuel/Elements",
- basec = "444400",
- newc = "444400"
- },
- [11] = {
- id="ColorFuelRocket",
- desc="Color for Rocket Fuel/Elements",
- basec = "440044",
- newc = "440044"
- }
- }
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "PreviousColorID" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- colorIDIndex = colorIDIndex - 1
- if colorIDIndex < 1 then colorIDIndex = #colorIDTable end
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "NextColorID" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- colorIDIndex = colorIDIndex + 1
- if colorIDIndex > #colorIDTable then colorIDIndex = 1 end
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "ColorPosUp" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- local s = tonumber(string.sub(colorIDTable[colorIDIndex].newc, HitPayload.param, HitPayload.param),16)
- s = s + 1
- if s > 15 then s = 0 end
- colorIDTable[colorIDIndex].newc = replace_char(HitPayload.param, colorIDTable[colorIDIndex].newc, hexTable[s+1])
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "ColorPosDown" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- local s = tonumber(string.sub(colorIDTable[colorIDIndex].newc, HitPayload.param, HitPayload.param),16)
- s = s - 1
- if s < 0 then s = 15 end
- colorIDTable[colorIDIndex].newc = replace_char(HitPayload.param, colorIDTable[colorIDIndex].newc, hexTable[s+1])
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "ResetPosColor" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- colorIDTable[colorIDIndex].newc = colorIDTable[colorIDIndex].basec
- _G[colorIDTable[colorIDIndex].id] = colorIDTable[colorIDIndex].basec
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "ApplyPosColor" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- _G[colorIDTable[colorIDIndex].id] = colorIDTable[colorIDIndex].newc
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "DamagedPageDown" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentDamagedPage = CurrentDamagedPage + 1
- if CurrentDamagedPage > math.ceil(#damagedElements / DamagePageSize) then
- CurrentDamagedPage = math.ceil(#damagedElements / DamagePageSize)
- end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "DamagedPageUp" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentDamagedPage = CurrentDamagedPage - 1
- if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "BrokenPageDown" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentBrokenPage = CurrentBrokenPage + 1
- if CurrentBrokenPage > math.ceil(#brokenElements / DamagePageSize) then
- CurrentBrokenPage = math.ceil(#brokenElements / DamagePageSize)
- end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "BrokenPageUp" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentBrokenPage = CurrentBrokenPage - 1
- if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "DMGOChangeView" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- screens[i].submode = HitPayload.param
- UpdateViewDamageoutline(screens[i])
- SaveToDatabank()
- SetRefresh("damageoutline", screens[i].submode)
- RenderScreens("damageoutline", screens[i].submode)
- elseif HitTarget == "DMGOChangeStretch" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if DMGOStretch == true then
- DMGOStretch = false
- else
- DMGOStretch = true
- end
- UpdateViewDamageoutline(screens[i])
- SaveToDatabank()
- SetRefresh("damageoutline")
- RenderScreens("damageoutline")
- elseif HitTarget == "ToggleDisplayAtmosphere" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if screens[i].fuelA == true then
- screens[i].fuelA = false
- else
- screens[i].fuelA = true
- end
- screens[i].fuelIndex = 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "ToggleDisplaySpace" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if screens[i].fuelS == true then
- screens[i].fuelS = false
- else
- screens[i].fuelS = true
- end
- screens[i].fuelIndex = 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "ToggleDisplayRocket" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if screens[i].fuelR == true then
- screens[i].fuelR = false
- else
- screens[i].fuelR = true
- end
- screens[i].fuelIndex = 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "DecreaseFuelIndex" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- screens[i].fuelIndex = screens[i].fuelIndex - 1
- if screens[i].fuelIndex < 1 then screens[i].fuelIndex = 1 end
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "IncreaseFuelIndex" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- screens[i].fuelIndex = screens[i].fuelIndex + 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "ToggleHudMode" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if HUDMode == true then
- HUDMode = false
- forceDamageRedraw = true
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- else
- HUDMode = true
- forceDamageRedraw = true
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- end
- elseif HitTarget == "ToggleSimulation" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentDamagedPage = 1
- CurrentBrokenPage = 1
- if SimulationMode == true then
- SimulationMode = false
- SimulationActive = false
- UpdateDamageData()
- UpdateTypeData()
- forceDamageRedraw = true
- HudDeselectElement()
- SetRefresh("damage")
- SetRefresh("damageoutline")
- SetRefresh("settings1")
- SetRefresh("fuel")
- SaveToDatabank()
- RenderScreens()
- else
- SimulationMode = true
- SimulationActive = false
- UpdateDamageData()
- UpdateTypeData()
- forceDamageRedraw = true
- HudDeselectElement()
- SetRefresh("damage")
- SetRefresh("damageoutline")
- SetRefresh("settings1")
- SetRefresh("fuel")
- SaveToDatabank()
- RenderScreens()
- end
- elseif (HitTarget == "ToggleElementLabel" or HitTarget == "ToggleElementLabel2") and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if UseMyElementNames == true then
- UseMyElementNames = false
- SetRefresh("damage")
- RenderScreens("damage")
- else
- UseMyElementNames = true
- SetRefresh("damage")
- RenderScreens("damage")
- end
- elseif (HitTarget == "SwitchScrapTier" or HitTarget == "SwitchScrapTier2") and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- ScrapTier = ScrapTier + 1
- if ScrapTier > 4 then ScrapTier = 1 end
- SetRefresh("damage")
- RenderScreens("damage")
- end
-
-
- end
- end
- end
-end
-
---[[ 4. RENDERING FUNCTIONS ]]
-
-function GetContentFlight()
- local output = ""
- output = output .. GetHeader("Flight Data Report") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentDamage()
- local output = ""
- if SimulationMode == true then
- output = output .. GetHeader("Damage Report (Simulated damage)") .. [[]]
- else
- output = output .. GetHeader("Damage Report") .. [[]]
- end
- output = output .. GetContentDamageScreen()
- return output
-end
-
-function GetContentDamageoutline(screen)
- UpdateDataDamageoutline()
- UpdateViewDamageoutline(screen)
- local output = ""
- output = output .. GetHeader("Damage Ship Outline Report") ..
- GetDamageoutlineShip() ..
- [[]]
-
- if screen.submode=="top" then
- output = output ..
- [[
-
- Top View
-
- Side View
-
- Front View
- ]]
- elseif screen.submode=="side" then
- output = output ..
- [[
-
- Top View
-
- Side View
-
- Front View
- ]]
- elseif screen.submode=="front" then
- output = output ..
- [[
-
- Top View
-
- Side View
-
- Front View
- ]]
- else
- end
- output = output .. [[]]..#dmgoElements..[[ of ]]..ElementCounter..[[ shown]]
- output = output .. [[]]
- if DMGOStretch == true then
- output = output .. [[]]
- end
- output = output .. [[Stretch both axis]]
- return output
-end
-
-function GetContentFuel(screen)
-
- if #FuelAtmosphericTanks < 1 and #FuelSpaceTanks < 1 and #FuelRocketTanks < 1 then return "" end
-
- local FuelTypes = 0
- local output = ""
- local addHeadline = {}
-
- FuelDisplay = { screen.fuelA, screen.fuelS, screen.fuelR }
-
- if FuelDisplay[1] == true and #FuelAtmosphericTanks > 0 then
- table.insert(addHeadline, "Atmospheric")
- FuelTypes = FuelTypes + 1
- end
- if FuelDisplay[2] == true and #FuelSpaceTanks > 0 then
- table.insert(addHeadline, "Space")
- FuelTypes = FuelTypes + 1
- end
- if FuelDisplay[3] == true and #FuelRocketTanks > 0 then
- table.insert(addHeadline, "Rocket")
- FuelTypes = FuelTypes + 1
- end
-
- output = output .. GetHeader("Fuel Report ("..table.concat(addHeadline, ", ")..")") ..
- [[
- ]]
-
- local totalH = 150
- local counter = 0
- local tOffset = 0
-
- if FuelDisplay[1] == true and #FuelAtmosphericTanks > 0 then
-
- if FuelTypes == 1 then tOffset = 50
- elseif FuelTypes == 2 then tOffset = 6
- elseif FuelTypes == 3 then tOffset = 0
- end
-
- output = output .. [[
-
-
-
- ]]
-
- output = output ..
- [[]]..
- GenerateCommaValue(FuelAtmosphericCurrent, true)..
- [[ of ]]..GenerateCommaValue(FuelAtmosphericTotal, true)..
- [[ | Total Atmospheric Fuel in ]]..#FuelAtmosphericTanks..[[ tank]]..(#FuelAtmosphericTanks==1 and "" or "s")..[[ (]]..math.floor(100/FuelAtmosphericTotal*FuelAtmosphericCurrent)..[[%)]]
- counter = counter + 1
- end
-
- if FuelDisplay[2] == true and #FuelSpaceTanks > 0 then
-
- if FuelTypes == 1 then tOffset = 50
- elseif FuelTypes == 2 then tOffset = 6
- elseif FuelTypes == 3 then tOffset = 0
- end
-
- output = output .. [[
-
-
-
- ]]
-
- output = output ..
- [[]]..
- GenerateCommaValue(FuelSpaceCurrent, true)..
- [[ of ]]..GenerateCommaValue(FuelSpaceTotal, true)..
- [[ | Total Space Fuel in ]]..#FuelSpaceTanks..[[ tank]]..(#FuelSpaceTanks==1 and "" or "s")..[[ (]]..math.floor(100/FuelSpaceTotal*FuelSpaceCurrent)..[[%)]]
- counter = counter + 1
- end
-
- if FuelDisplay[3] == true and #FuelRocketTanks > 0 then
-
- if FuelTypes == 1 then tOffset = 50
- elseif FuelTypes == 2 then tOffset = 6
- elseif FuelTypes == 3 then tOffset = 0
- end
-
- output = output .. [[
-
-
-
- ]]
-
- output = output ..
- [[]]..
- GenerateCommaValue(FuelRocketCurrent, true)..
- [[ of ]]..GenerateCommaValue(FuelRocketTotal, true)..
- [[ | Total Rocket Fuel in ]]..#FuelRocketTanks..[[ tank]]..(#FuelRocketTanks==1 and "" or "s")..[[ (]]..math.floor(100/FuelRocketTotal*FuelRocketCurrent)..[[%)]]
- end
-
- output = output .. [[
-
-
-
- ]]
-
- local DisplayTable = {}
- if screen.fuelIndex == nil or screen.fuelIndex < 1 then
- screen.fuelIndex = 1
- end
-
- if FuelDisplay[1] == true then
- for _,v in ipairs(FuelAtmosphericTanks) do
- table.insert(DisplayTable, v)
- end
- end
- if FuelDisplay[2] == true then
- for _,v in ipairs(FuelSpaceTanks) do
- table.insert(DisplayTable, v)
- end
- end
- if FuelDisplay[3] == true then
- for _,v in ipairs(FuelRocketTanks) do
- table.insert(DisplayTable, v)
- end
- end
-
- table.sort(DisplayTable, function(a,b) return a.type
-
-
- ]]
- if tank.hp == 0 then
- output = output .. [[]]
- elseif tank.maxhp - tank.hp > constants.epsilon then
- output = output .. [[]]
- else
- output = output .. [[]]
- end
- if tank.hp == 0 then output = output .. [[]]..tank.size..[[]]
- else output = output .. [[]]..tank.size..[[]]
- end
-
- if tank.hp == 0 then
- output = output .. [[Broken]] ..
- [[0 of ]]..GenerateCommaValue(tank.vol)..[[]]
- elseif tonumber(tank.percent) < 10 then
- output = output .. [[]]..tank.percent..[[%]] ..
- [[]]..GenerateCommaValue(tank.cvol)..[[ of ]]..GenerateCommaValue(tank.vol)..[[]]
- elseif tonumber(tank.percent) < 30 then
- output = output .. [[]]..tank.percent..[[%]] ..
- [[]]..GenerateCommaValue(tank.cvol)..[[ of ]]..GenerateCommaValue(tank.vol)..[[]]
- else output =
- output .. [[]]..tank.percent..[[%]] ..
- [[]]..GenerateCommaValue(tank.cvol)..[[ of ]]..GenerateCommaValue(tank.vol)..[[]]
- end
-
- output = output ..[[]]..tank.name..[[]]
-
- output = output .. [[]]
-
- end
- end
-
-
-
- if #FuelAtmosphericTanks > 0 then
- output = output .. [[]]
- if FuelDisplay[1] == true then
- output = output .. [[]]
- end
- output = output .. [[ATM]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "ToggleDisplayAtmosphere", x1 = 50, x2 = 100, y1 = 270, y2 = 320} )
- end
-
- if #FuelSpaceTanks > 0 then
- output = output .. [[]]
- if FuelDisplay[2] == true then
- output = output .. [[]]
- end
- output = output .. [[SPC]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "ToggleDisplaySpace", x1 = 200, x2 = 250, y1 = 270, y2 = 320} )
- end
-
- if #FuelRocketTanks > 0 then
- output = output .. [[]]
- if FuelDisplay[3] == true then
- output = output .. [[]]
- end
- output = output .. [[RKT]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "ToggleDisplayRocket", x1 = 350, x2 = 400, y1 = 270, y2 = 320} )
- end
-
- if screen.fuelIndex > 1 then
- output = output .. [[
-
-
- ]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "DecreaseFuelIndex", x1 = 1470, x2 = 1670, y1 = 270, y2 = 320} )
- end
-
- if screen.fuelIndex+cCounter-1 < #DisplayTable then
- output = output .. [[
-
-
- ]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "IncreaseFuelIndex", x1 = 1680, x2 = 1880, y1 = 270, y2 = 320} )
- end
-
- if cCounter > 0 then
- output = output .. [[]]..
- #DisplayTable..
- [[ Tank]]..(#DisplayTable == 1 and "" or "s")..
- [[ (Showing ]]..screen.fuelIndex..[[ to ]]..(screen.fuelIndex+cCounter-1)..[[)]]
- end
-
- return output
-end
-
-function GetContentCargo()
- local output = ""
- output = output .. GetHeader("Cargo Report") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentAGG()
- local output = ""
- output = output .. GetHeader("Anti-Grav Control") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentMap()
- local output = ""
- output = output .. GetHeader("Map Overview") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentTime()
- local output = ""
- output = output .. GetHeader("Time") .. epochTime()
- output = output ..
- [[
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetContentSettings1()
- local output = ""
- output = output .. GetHeader("Settings") .. [[]]
- if BackgroundMode=="" then
- output = output ..[[Activate background]]
- else
- output = output ..[[Deactivate background (']]..BackgroundMode..[[', ]]..string.format("%.0f",BackgroundModeOpacity*100)..[[%)]]
- end
- output = output ..[[
-
- Previous background
-
- Next background
-
-
- Decrease Opacity
-
- Increase Opacity
- ]]
-
- output = output ..
- [[]] ..
- [[Reset background and all colors]]
-
- output = output ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Select and change any of the ]]..#colorIDTable..[[ HUD colors]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]]..colorIDTable[colorIDIndex].desc..[[]] ..
- [[]] ..
- [[Current color]] ..
- [[]] ..
-
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
-
- [[#]] ..
-
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,1,1)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,2,2)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,3,3)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,4,4)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,5,5)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,6,6)..[[]] ..
-
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
-
- [[]] ..
- [[]] ..
- [[New color]] ..
- [[]] ..
- [[Apply new color]] ..
- [[]] ..
- [[Reset]] ..
- [[]]
-
- output = output ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Explanation / Hints]] ..
- [[Coming soon.]]
-
-
- output = output .. [[]]
-
- if SimulationMode == true then
- output = output .. [[Simulating Damage to elements]]
- AddClickArea("settings1", { id = "ToggleSimulation", mode ="settings1", x1 = 940, x2 = 1850, y1 = 919, y2 = 969 })
- else
- output = output .. [[Simulate Damage to elements]]
- AddClickArea("settings1", { id = "ToggleSimulation", mode ="settings1", x1 = 940, x2 = 1850, y1 = 919, y2 = 969 })
- end
-
- return output
-end
-
-function GetContentStartup()
- local output = ""
- output = output .. GetElementLogo(812, 380, "f", "f", "f")
- if YourShipsName == "Enter here" then
- output = output .. [[Spaceship ID ]]..ShipID..[[]]
- else
- output = output .. [[]]..YourShipsName..[[]]
- end
- if ShowWelcomeMessage == true then output = output .. [[Greetings, Commander ]]..PlayerName..[[.]] end
- if #Warnings > 0 then
- output = output .. [[Warning: ]]..(table.concat(Warnings, " "))..[[]]
- end
- output = output .. [[Damage Report v]]..VERSION..[[, by Scion Interstellar, DorianGray - Discord: Dorian Gray#2623. Under GNU Public License 3.0.]]
- return output
-end
-
-function RenderScreen(screen, contentToRender)
- if contentToRender == nil then
- PrintConsole("ERROR: contentToRender is nil.")
- unit.exit()
- end
-
- CreateClickAreasForScreen(screen)
-
- local output =""
- output = output .. [[
-
-
- ]]
-
- output = output .. contentToRender
-
- if screen.mode == "startup" then
- output = output .. [[]]
- else
- output = output .. [[]]
- end
-
- output = output .. [[
-
- ]]
- output = output .. [[]]
-
- -- Center:
-
- --
- --
- --
- --
-
- local outputLength = string.len(output)
- -- PrintConsole("Render: "..screen.mode.." ("..outputLength.." chars)")
- screen.element.setSVG(output)
-end
-
-function RenderScreens(onlymode, onlysubmode)
-
- onlymode = onlymode or "all"
- onlysubmode = onlysubmode or "all"
-
- if screens ~= nil and #screens > 0 then
-
- local contentFlight = ""
- local contentDamage = ""
- local contentDamageoutlineTop = ""
- local contentDamageoutlineSide = ""
- local contentDamageoutlineFront = ""
- local contentFuel = ""
- local contentCargo = ""
- local contentAGG = ""
- local contentMap = ""
- local contentTime = ""
- local contentSettings1 = ""
- local contentStartup = ""
-
- for k,screen in pairs(screens) do
- if screen.refresh == true then
- local contentToRender = ""
-
- if screen.mode == "flight" and (onlymode =="flight" or onlymode =="all") then
- if contentFlight == "" then contentFlight = GetContentFlight() end
- contentToRender = contentFlight
- elseif screen.mode == "damage" and (onlymode =="damage" or onlymode =="all") then
- if contentDamage == "" then contentDamage = GetContentDamage() end
- contentToRender = contentDamage
- elseif screen.mode == "damageoutline" and (onlymode =="damageoutline" or onlymode =="all") then
- if screen.submode == "" then
- screen.submode = "top"
- screens[k].submode = "top"
- end
- if screen.submode == "top" and (onlysubmode == "top" or onlysubmode == "all") then
- if contentDamageoutlineTop == "" then contentDamageoutlineTop = GetContentDamageoutline(screen) end
- contentToRender = contentDamageoutlineTop
- end
- if screen.submode == "side" and (onlysubmode == "side" or onlysubmode == "all") then
- if contentDamageoutlineSide == "" then contentDamageoutlineSide = GetContentDamageoutline(screen) end
- contentToRender = contentDamageoutlineSide
- end
- if screen.submode == "front" and (onlysubmode == "front" or onlysubmode == "all") then
- if contentDamageoutlineFront == "" then contentDamageoutlineFront = GetContentDamageoutline(screen) end
- contentToRender = contentDamageoutlineFront
- end
- elseif screen.mode == "fuel" and (onlymode =="fuel" or onlymode =="all") then
- screen = WipeClickAreasForScreen(screens[k])
- contentToRender = GetContentFuel(screen)
- elseif screen.mode == "cargo" and (onlymode =="cargo" or onlymode =="all") then
- if contentCargo == "" then contentCargo = GetContentCargo() end
- contentToRender = contentCargo
- elseif screen.mode == "agg" and (onlymode =="agg" or onlymode =="all") then
- if contentAGG == "" then contentAGG = GetContentAGG() end
- contentToRender = contentAGG
- elseif screen.mode == "map" and (onlymode =="map" or onlymode =="all") then
- if contentMap == "" then contentMap = GetContentMap() end
- contentToRender = contentMap
- elseif screen.mode == "time" and (onlymode =="time" or onlymode =="all") then
- if contentTime == "" then contentTime = GetContentTime() end
- contentToRender = contentTime
- elseif screen.mode == "settings1" and (onlymode =="settings1" or onlymode =="all") then
- if contentSettings1 == "" then contentSettings1 = GetContentSettings1() end
- contentToRender = contentSettings1
- elseif screen.mode == "startup" and (onlymode =="startup" or onlymode =="all") then
- if contentStartup == "" then contentStartup = GetContentStartup() end
- contentToRender = contentStartup
- else
- contentToRender = "Invalid screen mode. ('"..screen.mode.."')"
- end
-
- if contentToRender ~= "" then
- RenderScreen(screen, contentToRender)
- else
- DrawCenteredText("ERROR: No contentToRender delivered for "..screen.mode)
- PrintConsole("ERROR: No contentToRender delivered for "..screen.mode)
- unit.exit()
- end
- screens[k].refresh = false
- end
- end
- end
-
- if HUDMode == true then
- system.setScreen(GetContentDamageHUDOutput())
- system.showScreen(1)
- else
- system.showScreen(0)
- end
-
-end
-
-function OnTickData(initial)
- if formerTime + 60 < system.getTime() then
- SetRefresh("time")
- end
- totalShipMass = core.getConstructMass()
- if formerTotalShipMass ~= totalShipMass then
- UpdateDamageData(true)
- UpdateTypeData()
- SetRefresh()
- formerTotalShipMass = totalShipMass
- else
- UpdateDamageData(initial)
- UpdateTypeData()
- end
- RenderScreens()
-end
-
---[[ 5. EXECUTION ]]
-
-unit.hide()
-ClearConsole()
-PrintConsole("DAMAGE REPORT v"..VERSION.." STARTED", true)
-InitiateSlots()
-LoadFromDatabank()
-SwitchScreens("on")
-InitiateScreens()
-
-if core == nil then
- PrintConsole("ERROR: Connect the core to the programming board.")
- unit.exit()
-else
- OperatorID = unit.getMasterPlayerId()
- OperatorData = database.getPlayer(OperatorID)
- PlayerName = OperatorData["name"]
- ShipID = core.getConstructId()
-end
-
-if db == nil then
- table.insert(Warnings, "No databank connected, won't save/load settings.")
-end
-
-if YourShipsName == "Enter here" then
- table.insert(Warnings, "No ship name set in LUA settings.")
-end
-
-if SkillRepairToolEfficiency == 0 and SkillRepairToolOptimization == 0 and StatFuelTankOptimization == 0 and StatContainerOptimization ==0 and
- StatAtmosphericFuelTankHandling == 0 and StatSpaceFuelTankHandling == 0 and StatRocketFuelTankHandling ==0 then
- table.insert(Warnings, "No talents/stats set in LUA settings.")
-end
-
-if SkillRepairToolEfficiency < 0 or SkillRepairToolOptimization < 0 or StatFuelTankOptimization < 0 or StatContainerOptimization < 0 or
- StatAtmosphericFuelTankHandling < 0 or StatSpaceFuelTankHandling < 0 or StatRocketFuelTankHandling < 0 or
- SkillRepairToolEfficiency > 5 or SkillRepairToolOptimization > 5 or StatFuelTankOptimization > 5 or StatContainerOptimization > 5 or
- StatAtmosphericFuelTankHandling > 5 or StatSpaceFuelTankHandling > 5 or StatRocketFuelTankHandling > 5 then
- PrintConsole("ERROR: Talents/stats can only range from 0 to 5. Please set correctly in LUA settings and reactivate script.")
- unit.exit()
-end
-
-if screens == nil or #screens == 0 then
- HUDMode = true
- PrintConsole("Warning: No screens connected. Entering HUD mode only.")
-end
-
-OnTickData(true)
-
-unit.setTimer('UpdateData', UpdateDataInterval)
-unit.setTimer('UpdateHighlight', HighlightBlinkingInterval)
\ No newline at end of file
diff --git a/src/DamageReport_3_1_UnitStart_1.lua b/src/DamageReport_3_1_UnitStart_1.lua
deleted file mode 100644
index 486cf99..0000000
--- a/src/DamageReport_3_1_UnitStart_1.lua
+++ /dev/null
@@ -1,1277 +0,0 @@
---[[
- Damage Report 3.1
- A LUA script for Dual Universe
-
- Created By Dorian Gray
- Ingame: DorianGray
- Discord: Dorian Gray#2623
-
- You can find/update this script on GitHub. Explanations, installation and usage information as well as screenshots can be found there too.
- GitHub: https://github.com/DorianTheGrey/DU-DamageReport
-
- GNU Public License 3.0. Use whatever you want, be so kind to leave credit.
-
- Credits & thanks:
- Thanks to NovaQuark for creating the MMO of the century.
- Thanks to Jericho, Dmentia and Archaegeo for learning a lot from their fine scripts.
- Thanks to TheBlacklist for testing and wonderful suggestions.
- SVG patterns by Hero Patterns.
- DU atlas data from Jayle Break.
-
-]]
-
---[[ 1. HELPER FUNCTIONS ]]
-
-function GenerateCommaValue(amount, kify, postcomma)
- kify = kify or false
- postcomma = postcomma or 1
- local formatted = amount
- if kify == true then
- if string.len(amount)>=4 then
- formatted = string.format("%."..postcomma.."fk", amount/1000)
- else
- formatted = string.format("%."..postcomma.."f", amount)
- end
- else
- while true do
- formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
- if (k == 0) then break end
- end
- end
- return formatted
-end
-
-function PrintConsole(output, highlight)
- highlight = highlight or false
- if highlight then
- system.print(
- "------------------------------------------------------------------------")
- end
- system.print(output)
- if highlight then
- system.print(
- "------------------------------------------------------------------------")
- end
-end
-
-function DrawCenteredText(output)
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- screens[i].element.setCenteredText(output)
- end
- end
-end
-
-function ClearConsole()
- for i = 1, 10, 1 do
- PrintConsole()
- end
-end
-
-function SwitchScreens(state)
- state = state or "on"
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- if state == "on" then
- screens[i].element.clear()
- screens[i].element.activate()
- screens[i].active = true
- else
- screens[i].element.clear()
- screens[i].element.deactivate()
- screens[i].active = false
- end
- end
- end
-end
-
---[[ Convert seconds to string (by Jericho) ]]
-function GetSecondsString(seconds)
- local seconds = tonumber(seconds)
-
- if seconds == nil or seconds <= 0 then
- return "-";
- else
- days = string.format("%2.f", math.floor(seconds/(3600*24)));
- hours = string.format("%2.f", math.floor(seconds/3600 - (days*24)));
- mins = string.format("%2.f", math.floor(seconds/60 - (hours*60) - (days*24*60)));
- secs = string.format("%2.f", math.floor(seconds - hours*3600 - (days*24*60*60) - mins *60));
- str = ""
- if tonumber(days) > 0 then str = str .. days.."d " end
- if tonumber(hours) > 0 then str = str .. hours.."h " end
- if tonumber(mins) > 0 then str = str .. mins.."m " end
- if tonumber(secs) > 0 then str = str .. secs .."s" end
- return str
- end
-end
-
-function replace_char(pos, str, r)
- return str:sub(1, pos-1) .. r .. str:sub(pos+1)
-end
-
---[[ 2. RENDER HELPER FUNCTIONS ]]
-
---[[ epochTime function by Leodr (clock script), enhanced by Jericho (DU Industry script) ]]
-function epochTime()
- function rZ(a)
- if string.len(a) <= 1 then
- return "0" .. a
- else
- return a
- end
- end
- function dPoint(b)
- if not (b == math.floor(b)) then
- return true
- else
- return false
- end
- end
- function lYear(year)
- if not dPoint(year / 4) then
- if dPoint(year / 100) then
- return true
- else
- if not dPoint(year / 400) then
- return true
- else
- return false
- end
- end
- else
- return false
- end
- end
- local c = 5;
- local d = 3600;
- local e = 86400;
- local f = 31536000;
- local g = 31622400;
- local h = 2419200;
- local i = 2505600;
- local j = 2592000;
- local k = 2678400;
- local l = {4, 6, 9, 11}
- local m = {1, 3, 5, 7, 8, 10, 12}
- local n = 0;
- local o = 1506816000;
- local q = system.getTime()
- _G["formerTime"] = q
- if AddSummertimeHour == true then q = q + 3600 end
- now = math.floor(q + o)
- year = 1970;
- secs = 0;
- n = 0;
- while secs + g < now or secs + f < now do
- if lYear(year + 1) then
- if secs + g < now then
- secs = secs + g;
- year = year + 1;
- n = n + 366
- end
- else
- if secs + f < now then
- secs = secs + f;
- year = year + 1;
- n = n + 365
- end
- end
- end
- secondsRemaining = now - secs;
- monthSecs = 0;
- yearlYear = lYear(year)
- month = 1;
- while monthSecs + h < secondsRemaining or monthSecs + j < secondsRemaining or
- monthSecs + k < secondsRemaining do
- if month == 1 then
- if monthSecs + k < secondsRemaining then
- month = 2;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 2 then
- if not yearlYear then
- if monthSecs + h < secondsRemaining then
- month = 3;
- monthSecs = monthSecs + h;
- n = n + 28
- else
- break
- end
- else
- if monthSecs + i < secondsRemaining then
- month = 3;
- monthSecs = monthSecs + i;
- n = n + 29
- else
- break
- end
- end
- end
- if month == 3 then
- if monthSecs + k < secondsRemaining then
- month = 4;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 4 then
- if monthSecs + j < secondsRemaining then
- month = 5;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- if month == 5 then
- if monthSecs + k < secondsRemaining then
- month = 6;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 6 then
- if monthSecs + j < secondsRemaining then
- month = 7;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- if month == 7 then
- if monthSecs + k < secondsRemaining then
- month = 8;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 8 then
- if monthSecs + k < secondsRemaining then
- month = 9;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 9 then
- if monthSecs + j < secondsRemaining then
- month = 10;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- if month == 10 then
- if monthSecs + k < secondsRemaining then
- month = 11;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 11 then
- if monthSecs + j < secondsRemaining then
- month = 12;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- end
- day = 1;
- daySecs = 0;
- daySecsRemaining = secondsRemaining - monthSecs;
- while daySecs + e < daySecsRemaining do
- day = day + 1;
- daySecs = daySecs + e;
- n = n + 1
- end
- hour = 0;
- hourSecs = 0;
- hourSecsRemaining = daySecsRemaining - daySecs;
- while hourSecs + d < hourSecsRemaining do
- hour = hour + 1;
- hourSecs = hourSecs + d
- end
- minute = 0;
- minuteSecs = 0;
- minuteSecsRemaining = hourSecsRemaining - hourSecs;
- while minuteSecs + 60 < minuteSecsRemaining do
- minute = minute + 1;
- minuteSecs = minuteSecs + 60
- end
- second = math.floor(now % 60)
- year = rZ(year)
- month = rZ(month)
- day = rZ(day)
- hour = rZ(hour)
- minute = rZ(minute)
- second = rZ(second)
-
- return [[]]..hour..":".. minute..[[]]..
- [[]]..year.."/".. month.."/"..day..[[]]
-end
-
-
-function ToggleHUD()
- if HUDMode == true then
- HUDMode = false
- forceDamageRedraw = true
- hudSelectedIndex = 0
- highlightID = 0
- HideHighlight()
- SetRefresh()
- RenderScreens()
- else
- HUDMode = true
- forceDamageRedraw = true
- hudSelectedIndex = 0
- highlightID = 0
- HideHighlight()
- SetRefresh()
- RenderScreens()
- end
-end
-
-function HudDeselectElement()
- hudSelectedIndex = 0
- hudStartIndex = 1
- highlightID = 0
- HideHighlight()
- if HUDMode == true then
- SetRefresh("damage")
- SetRefresh("damageoutline")
- RenderScreens()
- end
-end
-
-function ChangeHudSelectedElement(step)
- if HUDMode == true and #rE > 0 then
-
- hudSelectedIndex = hudSelectedIndex + step
- if hudSelectedIndex < 1 then hudSelectedIndex = 1
- elseif hudSelectedIndex > #rE then hudSelectedIndex = #rE
- end
-
- if hudSelectedIndex > 9 then
- hudStartIndex = hudSelectedIndex-9
- end
- if hudSelectedIndex ~= 0 then
- highlightID = rE[hudSelectedIndex].id
- if highlightID ~=nil and highlightID ~= 0 then
- -- PrintConsole("CHSE: hudSelectedIndex: "..hudSelectedIndex.." / hudStartIndex: "..hudStartIndex.." / highlightID: "..highlightID)
- HideHighlight()
- elementPosition = vec3(rE[hudSelectedIndex].pos)
- highlightX = elementPosition.x - coreWorldOffset
- highlightY = elementPosition.y - coreWorldOffset
- highlightZ = elementPosition.z - coreWorldOffset
- highlightOn = true
- ShowHighlight()
- end
- end
-
- SetRefresh("damage")
- SetRefresh("damageoutline")
- RenderScreens()
-
- end
-end
-
-function HideHighlight()
- if #hudArrowSticker > 0 then
- for i in pairs(hudArrowSticker) do
- core.deleteSticker(hudArrowSticker[i])
- end
- hudArrowSticker = {}
- end
-end
-
-function ShowHighlight()
- if highlightOn == true and highlightID > 0 then
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX + 2, highlightY, highlightZ, "north"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY - 2, highlightZ, "east"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX - 2, highlightY, highlightZ, "south"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY + 2, highlightZ, "west"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY, highlightZ - 2, "up"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY, highlightZ + 2,"down"))
- end
-end
-
-function ToggleHighlight()
- if highlightOn == true then
- highlightOn = false
- HideHighlight()
- else
- highlightOn = true
- ShowHighlight()
- end
-end
-
-function SortDamageTables()
- table.sort(damagedElements, function(a, b) return a.missinghp > b.missinghp end)
- table.sort(brokenElements, function(a, b) return a.maxhp > b.maxhp end)
-end
-
-function getScraps(damage,commaval)
- commaval = commaval or false
- damage = damage - SkillRepairToolOptimization * 0.05 * damage
- local res = math.ceil( damage / ( 10 * 5^(ScrapTier-1) ) )
- if commaval ==true then
- return GenerateCommaValue(string.format("%.0f", res ), false)
- else
- return res
- end
-end
-
-function getRepairTime(damage,buildstring)
- buildstring = buildstring or false
- damage = damage - SkillRepairToolOptimization * 0.05 * damage
- local res = math.ceil(damage / ScrapTierRepairTimes[ScrapTier])
- res = res - ( SkillRepairToolEfficiency * 0.1 * res )
- if buildstring == true then
- return GetSecondsString(string.format("%.0f", res ) )
- else
- return res
- end
-end
-
-function UpdateDataDamageoutline()
-
- dmgoElements = {}
-
- for i,element in ipairs(brokenElements) do
- if #dmgoElements < DMGOMaxElements then
- local elementPosition = vec3(element.pos)
- local x = elementPosition.x - coreWorldOffset
- local y = elementPosition.y - coreWorldOffset
- local z = elementPosition.z - coreWorldOffset
- if x < ShipXmin then ShipXmin = x end
- if y < ShipYmin then ShipYmin = y end
- if z < ShipZmin then ShipZmin = z end
- if x > ShipXmax then ShipXmax = x end
- if y > ShipYmax then ShipYmax = y end
- if z > ShipZmax then ShipZmax = z end
- table.insert( dmgoElements, {
- id = element.id,
- type = "b",
- size = element.maxhp,
- x = x, y = y, z = z,
- xp = 0, yp = 0, zp = 0,
- u = 0, v = 0
- })
- end
- end
-
- if #dmgoElements < DMGOMaxElements then
- for i,element in ipairs(damagedElements) do
- if #dmgoElements < DMGOMaxElements then
- local elementPosition = vec3(element.pos)
- local x = elementPosition.x - coreWorldOffset
- local y = elementPosition.y - coreWorldOffset
- local z = elementPosition.z - coreWorldOffset
- if x < ShipXmin then ShipXmin = x end
- if y < ShipYmin then ShipYmin = y end
- if z < ShipZmin then ShipZmin = z end
- if x > ShipXmax then ShipXmax = x end
- if y > ShipYmax then ShipYmax = y end
- if z > ShipZmax then ShipZmax = z end
- table.insert( dmgoElements, {
- id = element.id,
- type = "d",
- size = element.maxhp,
- x = x, y = y, z = z,
- xp = 0, yp = 0, zp = 0,
- u = 0, v = 0
- })
- end
- end
- end
-
- if #dmgoElements < DMGOMaxElements then
- for i,element in ipairs(healthyElements) do
- if #dmgoElements < DMGOMaxElements then
- local elementPosition = vec3(element.pos)
- local x = elementPosition.x - coreWorldOffset
- local y = elementPosition.y - coreWorldOffset
- local z = elementPosition.z - coreWorldOffset
- if x < ShipXmin then ShipXmin = x end
- if y < ShipYmin then ShipYmin = y end
- if z < ShipZmin then ShipZmin = z end
- if x > ShipXmax then ShipXmax = x end
- if y > ShipYmax then ShipYmax = y end
- if z > ShipZmax then ShipZmax = z end
- table.insert( dmgoElements, {
- id = element.id,
- type = "h",
- size = element.maxhp,
- x = x, y = y, z = z,
- xp = 0, yp = 0, zp = 0,
- u = 0, v = 0
- })
- end
- end
- end
-
- ShipX = math.abs(ShipXmax-ShipXmin)
- ShipY = math.abs(ShipYmax-ShipYmin)
- ShipZ = math.abs(ShipZmax-ShipZmin)
-
- --[[
- PrintConsole(
- "ShipXmin: "..string.format("%.2f",ShipXmin)..
- " - ShipYmin: "..string.format("%.2f",ShipYmin)..
- " - ShipZmin: "..string.format("%.2f",ShipZmin)..
- " - ShipXmax: "..string.format("%.2f",ShipXmax)..
- " - ShipYmax: "..string.format("%.2f",ShipYmax)..
- " - ShipZmax: "..string.format("%.2f",ShipZmax)
- )
-
- PrintConsole(
- "ShipX: "..string.format("%.2f",ShipX)..
- " - ShipY: "..string.format("%.2f",ShipY)..
- " - ShipZ: "..string.format("%.2f",ShipZ)
- )
- ]]
-
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].xp = math.abs(100/(ShipXmax-ShipXmin)*(element.x-ShipXmin))
- dmgoElements[i].yp = math.abs(100/(ShipYmax-ShipYmin)*(element.y-ShipYmin))
- dmgoElements[i].zp = math.abs(100/(ShipZmax-ShipZmin)*(element.z-ShipZmin))
- -- PrintConsole(i..". "..element.id..": "..string.format("%.2f",element.x).."/"..string.format("%.2f",element.y).."/"..string.format("%.2f",element.z).." - XP: "..dmgoElements[i].xp.." - YP: "..dmgoElements[i].yp.." - ZP: "..dmgoElements[i].zp)
- end
-
-end
-
-function UpdateViewDamageoutline(screen)
- -- Full Width of virtual screen:
- -- UStart = 20
- -- VStart = 180
- -- UDim = 1880
- -- VDim = 840
- -- Adding frames:
- UFrame = 40
- VFrame = 40
-
- UStart = 20 + UFrame
- VStart = 180 + VFrame
- UDim = 1880 - 2*UFrame
- VDim = 840 - 2*VFrame
-
- if screen.submode == "top" then
- if DMGOStretch == false then
- local UFactor = UDim/(ShipYmax-ShipYmin)
- local VFactor = VDim/(ShipXmax-ShipXmin)
- if UFactor>=VFactor then
- local cFactor = UFactor/VFactor
- local newUDim = math.floor(UDim/cFactor)
- UStart = UStart+(UDim-newUDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100/cFactor*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*element.xp+VStart)
- end
- else
- local cFactor = VFactor/UFactor
- local newVDim = math.floor(VDim/cFactor)
- VStart = VStart+(VDim-newVDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100/cFactor*element.xp+VStart)
- end
- end
- else
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*element.xp+VStart)
- end
- end
-
-
- elseif screen.submode == "front" then
- if DMGOStretch == false then
- local UFactor = UDim/(ShipXmax-ShipXmin)
- local VFactor = VDim/(ShipZmax-ShipZmin)
- if UFactor>=VFactor then
- local cFactor = UFactor/VFactor
- local newUDim = math.floor(UDim/cFactor)
- UStart = UStart+(UDim-newUDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100/cFactor*element.xp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- else
- local cFactor = VFactor/UFactor
- local newVDim = math.floor(VDim/cFactor)
- VStart = VStart+(VDim-newVDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.xp+UStart)
- dmgoElements[i].v = math.floor(VDim/100/cFactor*(100-element.zp)+VStart)
- end
- end
- else
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.xp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- end
-
- elseif screen.submode == "side" then
- if DMGOStretch == false then
- local UFactor = UDim/(ShipYmax-ShipYmin)
- local VFactor = VDim/(ShipXmax-ShipZmin)
- if UFactor>=VFactor then
- local cFactor = UFactor/VFactor
- local newUDim = math.floor(UDim/cFactor)
- UStart = UStart+(UDim-newUDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100/cFactor*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- else
- local cFactor = VFactor/UFactor
- local newVDim = math.floor(VDim/cFactor)
- VStart = VStart+(VDim-newVDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100/cFactor*(100-element.zp)+VStart)
- end
- end
- else
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- end
- else
- DrawCenteredText("ERROR: non-existing DMGO mode set.")
- PrintConsole("ERROR: non-existing DMGO mode set.")
- unit.exit()
- end
-end
-
-function GetDamageoutlineShip()
- local output = ""
-
- for i,element in ipairs(dmgoElements) do
- local cclass = ""
- local size = 1
-
- if element.type == "h" then
- cclass ="ch"
- elseif element.type == "d" then
- cclass = "cw"
- else
- cclass = "cc"
- end
- if element.id == highlightID then
- cclass = "f2"
- end
-
- if element.size > 0 and element.size < 1000 then
- size = 5
- elseif element.size >= 1000 and element.size < 2000 then
- size = 8
- elseif element.size >= 2000 and element.size < 5000 then
- size = 12
- elseif element.size >= 5000 and element.size < 10000 then
- size = 15
- elseif element.size >= 10000 and element.size < 20000 then
- size = 20
- elseif element.size >= 20000 then
- size = 30
- end
- output = output .. [[]]
- if element.id == highlightID then
- output = output .. [[]]
- output = output .. [[]]
- end
- end
-
- return output
-end
-
-function GetContentClickareas(screen)
- local output = ""
- if screen ~= nil and screen.ClickAreas ~= nil and #screen.ClickAreas > 0 then
- for i,ca in ipairs(screen.ClickAreas) do
- output = output ..
- [[]]
- end
- end
- return output
-end
-
-function GetElement1(x, y, width, height)
- x = x or 0
- y = y or 0
- width = width or 600
- height = height or 600
- local output = ""
- output = output ..
- [[
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetElement2(x, y)
- x = x or 0
- y = y or 0
- local output = ""
- output = output .. [[]]
- return output
-end
-
-function GetElementLogo(x, y, primaryC, secondaryC, tertiaryC)
- x = x or 812
- y = y or 380
- primaryC = primaryC or "f"
- secondaryC = secondaryC or "f2"
- tertiaryC = tertiaryC or "f3"
- local output = ""
- output = output .. [[
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetHeader(headertext)
- headertext = headertext or "ERROR: UNDEFINED"
- local output = ""
- output = output ..
- [[
- ]]..headertext..[[]]
- return output
-end
-
-function GetContentBackground(candidate, bgcolor)
- bgColor = ColorBackgroundPattern
-
- local output = ""
-
- if candidate == "dots" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' viewBox='0 0 4 4'%3E%3Cpath fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' d='M1 3h1v1H1V3zm2-2h1v1H3V1z'%3E%3C/path%3E%3C/svg%3E");]]
- elseif candidate == "rain" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='12' height='16' viewBox='0 0 12 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 .99C4 .445 4.444 0 5 0c.552 0 1 .45 1 .99v4.02C6 5.555 5.556 6 5 6c-.552 0-1-.45-1-.99V.99zm6 8c0-.546.444-.99 1-.99.552 0 1 .45 1 .99v4.02c0 .546-.444.99-1 .99-.552 0-1-.45-1-.99V8.99z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E");]]
- elseif candidate == "plus" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "signal" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='84' height='48' viewBox='0 0 84 48' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h12v6H0V0zm28 8h12v6H28V8zm14-8h12v6H42V0zm14 0h12v6H56V0zm0 8h12v6H56V8zM42 8h12v6H42V8zm0 16h12v6H42v-6zm14-8h12v6H56v-6zm14 0h12v6H70v-6zm0-16h12v6H70V0zM28 32h12v6H28v-6zM14 16h12v6H14v-6zM0 24h12v6H0v-6zm0 8h12v6H0v-6zm14 0h12v6H14v-6zm14 8h12v6H28v-6zm-14 0h12v6H14v-6zm28 0h12v6H42v-6zm14-8h12v6H56v-6zm0-8h12v6H56v-6zm14 8h12v6H70v-6zm0 8h12v6H70v-6zM14 24h12v6H14v-6zm14-8h12v6H28v-6zM14 8h12v6H14V8zM0 8h12v6H0V8z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E");]]
- elseif candidate == "deathstar" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='105' viewBox='0 0 80 105'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M20 10a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm15 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zM20 75a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zm30-65a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm0 65a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zM35 10a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zM5 45a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zm60 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10z' /%3E%3C/g%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "diamond" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='32' viewBox='0 0 16 32'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath fill-rule='evenodd' d='M0 24h4v2H0v-2zm0 4h6v2H0v-2zm0-8h2v2H0v-2zM0 0h4v2H0V0zm0 4h2v2H0V4zm16 20h-6v2h6v-2zm0 4H8v2h8v-2zm0-8h-4v2h4v-2zm0-20h-6v2h6V0zm0 4h-4v2h4V4zm-2 12h2v2h-2v-2zm0-8h2v2h-2V8zM2 8h10v2H2V8zm0 8h10v2H2v-2zm-2-4h14v2H0v-2zm4-8h6v2H4V4zm0 16h6v2H4v-2zM6 0h2v2H6V0zm0 24h2v2H6v-2z'/%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "hexagon" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='49' viewBox='0 0 28 49'%3E%3Cg fill-rule='evenodd'%3E%3Cg id='hexagons' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='nonzero'%3E%3Cpath d='M13.99 9.25l13 7.5v15l-13 7.5L1 31.75v-15l12.99-7.5zM3 17.9v12.7l10.99 6.34 11-6.35V17.9l-11-6.34L3 17.9zM0 15l12.98-7.5V0h-2v6.35L0 12.69v2.3zm0 18.5L12.98 41v8h-2v-6.85L0 35.81v-2.3zM15 0v7.5L27.99 15H28v-2.31h-.01L17 6.35V0h-2zm0 49v-8l12.99-7.5H28v2.31h-.01L17 42.15V49h-2z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "capsule" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='32' height='26' viewBox='0 0 32 26' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M14 0v3.994C14 7.864 10.858 11 7 11c-3.866 0-7-3.138-7-7.006V0h2v4.005C2 6.765 4.24 9 7 9c2.756 0 5-2.236 5-4.995V0h2zm0 26v-5.994C14 16.138 10.866 13 7 13c-3.858 0-7 3.137-7 7.006V26h2v-6.005C2 17.235 4.244 15 7 15c2.76 0 5 2.236 5 4.995V26h2zm2-18.994C16 3.136 19.142 0 23 0c3.866 0 7 3.138 7 7.006v9.988C30 20.864 26.858 24 23 24c-3.866 0-7-3.138-7-7.006V7.006zm2-.01C18 4.235 20.244 2 23 2c2.76 0 5 2.236 5 4.995v10.01C28 19.765 25.756 22 23 22c-2.76 0-5-2.236-5-4.995V6.995z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E");]]
- elseif candidate == "diagonal" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='6' height='6' viewBox='0 0 6 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'%3E%3Cpath d='M5 0h1L0 6V5zM6 5v1H5z'/%3E%3C/g%3E%3C/svg%3E");]]
- end
- return output;
-end
-
-function GetContentDamageHUDOutput()
- local hudWidth = 300
- local hudHeight = 165
- if #damagedElements > 0 or #brokenElements > 0 then hudHeight = 510 end
- local output = ""
-
- output = output .. [[
-
- ]]
- output = output .. [[]] ..
- [[]] ..
- [[]] ..
- [[]]..(YourShipsName=="Enter here" and ("Ship ID "..ShipID) or YourShipsName) .. [[]] ..
- [[]]
- if #brokenElements > 0 then
- output = output .. [[]]
- elseif #damagedElements > 0 then
- output = output .. [[]]
- else
- output = output .. [[]]
- end
-
- if #damagedElements > 0 or #brokenElements > 0 then
-
- output = output .. [[Total Damage]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", totalShipMaxHP - totalShipHP))..[[]]
- output = output .. [[T]]..ScrapTier..[[ Scrap Needed]] ..
- [[]]..getScraps(totalShipMaxHP - totalShipHP, true)..[[]]
- output = output .. [[Repair Time]] ..
- [[]]..getRepairTime(totalShipMaxHP - totalShipHP, true)..[[]]
-
- output = output .. [[]] ..
- [[]] ..
- [[]]..#healthyElements..[[]] ..
- [[]] ..
- [[]]..#damagedElements..[[]] ..
- [[]] ..
- [[]]..#brokenElements..[[]]
- local j=0
-
- for currentIndex=hudStartIndex,hudStartIndex+9,1 do
- if rE[currentIndex] ~= nil then
- v = rE[currentIndex]
- if v.hp > 0 then
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- if v.id == highlightID then
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- end
- else
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- if v.id == highlightID then
- highlightX = elementPosition.x - coreWorldOffset
- highlightY = elementPosition.y - coreWorldOffset
- highlightZ = elementPosition.z - coreWorldOffset
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- end
- end
- j=j+1
- end
- end
- output = output ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Up/down arrows to highlight]] ..
- [[CTRL + arrows to move HUD]] ..
- [[Left arrow to toggle HUD Mode]] ..
- [[ALT+1-4 to set Scrap Tier]] ..
- [[ALT+8 to reset HUD position]] ..
- [[ALT+9 to shut script off]] ..
- [[]] ..
- [[]]
- else
- output = output ..
- [[]] .. OkayCenterMessage .. [[]] ..
- [[]]..#healthyElements..[[ elements / ]] .. GenerateCommaValue(string.format("%.0f", totalShipMaxHP)) .. [[ HP.]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Left arrow to toggle HUD Mode]] ..
- [[CTRL + arrows to move HUD]] ..
- [[ALT+8 to reset HUD position]] ..
- [[ALT+9 to shut script off]] ..
- [[]] ..
- [[]]
- end
- output = output .. [[]]
- return output
-end
-
-function GetContentDamageScreen()
-
- local screenOutput = ""
-
- -- Draw damage elements
- if #damagedElements > 0 then
- local damagedElementsToDraw = #damagedElements
- if damagedElementsToDraw > DamagePageSize then
- damagedElementsToDraw = DamagePageSize
- end
- if CurrentDamagedPage == math.ceil(#damagedElements / DamagePageSize) then
- damagedElementsToDraw = #damagedElements % DamagePageSize + 12
- if damagedElementsToDraw > 12 then damagedElementsToDraw = damagedElementsToDraw - 12 end
- end
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
-
- if UseMyElementNames == true then screenOutput = screenOutput .. [[Damaged Name]]
- else screenOutput = screenOutput .. [[Damaged Type]]
- end
-
- screenOutput = screenOutput .. [[HLTHDMG]]
- screenOutput = screenOutput .. [[T]]..ScrapTier..[[ SCRREPTIME]]
-
- AddClickArea("damage", {
- id = "SwitchScrapTier",
- mode ="damage",
- x1 = 650,
- x2 = 775,
- y1 = 315,
- y2 = 360
- })
-
- local i = 0
- for j = 1 + (CurrentDamagedPage - 1) * DamagePageSize, damagedElementsToDraw + (CurrentDamagedPage - 1) * DamagePageSize, 1 do
- i = i + 1
- local DP = damagedElements[j]
- if UseMyElementNames == true then screenOutput = screenOutput .. [[]] .. string.format("%.23s", DP.name) .. [[]]
- else screenOutput = screenOutput .. [[]] .. string.format("%.23s", DP.type) .. [[]]
- end
- screenOutput = screenOutput .. [[]] .. DP.percent .. [[%]] ..
- [[]] .. GenerateCommaValue(string.format("%.0f", DP.missinghp), true) .. [[]] ..
- [[]] .. getScraps(DP.missinghp, true) .. [[]] ..
- [[]] .. getRepairTime(DP.missinghp, true) .. [[]] ..
- [[]]
- end
-
- if #damagedElements > DamagePageSize then
- screenOutput = screenOutput ..
- [[Page ]] .. CurrentDamagedPage .. " of " .. math.ceil(#damagedElements / DamagePageSize) ..[[]]
-
- if CurrentDamagedPage < math.ceil(#damagedElements / DamagePageSize) then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "DamagedPageDown",
- mode ="damage",
- x1 = 65,
- x2 = 260,
- y1 = 290 + (damagedElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (damagedElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("DamagedPageDown","damage")
- end
-
- if CurrentDamagedPage > 1 then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "DamagedPageUp",
- mode ="damage",
- x1 = 750,
- x2 = 950,
- y1 = 290 + (damagedElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (damagedElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("DamagedPageUp","damage")
- end
- end
- end
-
- -- Draw broken elements
- if #brokenElements > 0 then
- local brokenElementsToDraw = #brokenElements
- if brokenElementsToDraw > DamagePageSize then
- brokenElementsToDraw = DamagePageSize
- end
- if CurrentBrokenPage == math.ceil(#brokenElements / DamagePageSize) then
- brokenElementsToDraw = #brokenElements % DamagePageSize + 12
- if brokenElementsToDraw > 12 then brokenElementsToDraw = brokenElementsToDraw - 12 end
- end
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
-
- if UseMyElementNames == true then screenOutput = screenOutput .. [[Broken Name]]
- else screenOutput = screenOutput .. [[Broken Type]]
- end
-
- screenOutput = screenOutput .. [[DMG]]
- screenOutput = screenOutput .. [[T]]..ScrapTier..[[ SCRREPTIME]]
-
- AddClickArea("damage", {
- id = "SwitchScrapTier2",
- mode ="damage",
- x1 = 1570,
- x2 = 1690,
- y1 = 315,
- y2 = 360
- })
-
- local i = 0
- for j = 1 + (CurrentBrokenPage - 1) * DamagePageSize, brokenElementsToDraw + (CurrentBrokenPage - 1) * DamagePageSize, 1 do
- i = i + 1
- local DP = brokenElements[j]
- if UseMyElementNames == true then screenOutput = screenOutput .. [[]] .. string.format("%.30s", DP.name) .. [[]]
- else screenOutput = screenOutput .. [[]] .. string.format("%.30s", DP.type) .. [[]]
- end
- screenOutput = screenOutput .. [[]] .. GenerateCommaValue(string.format("%.0f", DP.missinghp), true) .. [[]] ..
- [[]] .. getScraps(DP.missinghp, true) .. [[]] ..
- [[]] .. getRepairTime(DP.missinghp, true) .. [[]] ..
- [[]]
- end
-
-
-
- if #brokenElements > DamagePageSize then
- screenOutput = screenOutput ..
- [[Page ]] .. CurrentBrokenPage .. " of " .. math.ceil(#brokenElements / DamagePageSize) .. [[]]
-
- if CurrentBrokenPage > 1 then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "BrokenPageUp",
- mode ="damage",
- x1 = 1665,
- x2 = 1865,
- y1 = 290 + (brokenElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (brokenElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("BrokenPageUp", "damage")
- end
-
- if CurrentBrokenPage < math.ceil(#brokenElements / DamagePageSize) then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "BrokenPageDown",
- mode ="damage",
- x1 = 980,
- x2 = 1180,
- y1 = 290 + (brokenElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (brokenElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("BrokenPageDown", "damage")
- end
- end
-
- end
-
- -- Draw summary
- if #damagedElements > 0 or #brokenElements > 0 then
- local dWidth = math.floor(1878/#elementsIdList*#damagedElements)
- local bWidth = math.floor(1878/#elementsIdList*#brokenElements)
- local hWidth = 1878-dWidth-bWidth+1
-
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
-
- if #damagedElements > 0 then
- screenOutput = screenOutput .. [[]]..#damagedElements..[[]]
- end
- if #healthyElements > 0 then
- screenOutput = screenOutput .. [[]]..#healthyElements..[[]]
- end
- if #brokenElements > 0 then
- screenOutput = screenOutput .. [[]]..#brokenElements..[[]]
- end
-
- screenOutput = screenOutput .. [[]]
-
- screenOutput = screenOutput .. [[]] ..
- GenerateCommaValue(string.format("%.0f", totalShipMaxHP - totalShipHP)) .. [[ HP damage in total ]] ..
- getScraps(totalShipMaxHP - totalShipHP, true) .. [[ T]]..ScrapTier..[[ scraps needed. ]] ..
- getRepairTime(totalShipMaxHP - totalShipHP, true) .. [[ projected repair time.]]
- else
- screenOutput = screenOutput .. GetElementLogo(812, 380, "ch", "ch", "ch") ..
- [[]] .. OkayCenterMessage .. [[]] ..
- [[]]..#healthyElements..[[ elements stand ]] .. GenerateCommaValue(string.format("%.0f", totalShipMaxHP)) .. [[ HP strong.]]
- end
-
- forceDamageRedraw = false
-
- return screenOutput
-end
-
-function ActionStopengines()
- ToggleHUD()
-end
-
-function ActionStrafeRight()
- if KeyCTRLPressed == true then
- if HUDShiftU < 4000 then
- HUDShiftU = HUDShiftU + 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- HudDeselectElement()
- end
-end
-
-function ActionStrafeLeft()
- if KeyCTRLPressed == true then
- if HUDShiftU >= 50 then
- HUDShiftU = HUDShiftU - 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- ToggleHUD()
- end
-end
-
-function ActionDown()
- if KeyCTRLPressed == true then
- if HUDShiftV < 4000 then
- HUDShiftV = HUDShiftV + 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- ChangeHudSelectedElement(1)
- end
-end
-
-function ActionUp()
- if KeyCTRLPressed == true then
- if HUDShiftV >= 50 then
- HUDShiftV = HUDShiftV - 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- ChangeHudSelectedElement(-1)
- end
-end
-
-function ActionOption1()
- ScrapTier = 1
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption2()
- ScrapTier = 2
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption3()
- ScrapTier = 3
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption4()
- ScrapTier = 4
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption8()
- HUDShiftU=0
- HUDShiftV=0
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption9()
- SaveToDatabank()
- SwitchScreens("off")
- unit.exit()
-end
diff --git a/src/DamageReport_3_1_UnitStart_2.lua b/src/DamageReport_3_1_UnitStart_2.lua
deleted file mode 100644
index 688e522..0000000
--- a/src/DamageReport_3_1_UnitStart_2.lua
+++ /dev/null
@@ -1,2048 +0,0 @@
---[[
- Damage Report 3.1
- A LUA script for Dual Universe
-
- Created By Dorian Gray
- Ingame: DorianGray
- Discord: Dorian Gray#2623
-
- You can find/update this script on GitHub. Explanations, installation and usage information as well as screenshots can be found there too.
- GitHub: https://github.com/DorianTheGrey/DU-DamageReport
-
- GNU Public License 3.0. Use whatever you want, be so kind to leave credit.
-
- Credits & thanks:
- Thanks to NovaQuark for creating the MMO of the century.
- Thanks to Jericho, Dmentia and Archaegeo for learning a lot from their fine scripts.
- Thanks to TheBlacklist for testing and wonderful suggestions.
- SVG patterns by Hero Patterns.
- DU atlas data from Jayle Break.
-
-]]
-
---[[ 1. USER DEFINED VARIABLES ]]
-
-YourShipsName = "Enter here" --export Enter your ship name here if you want it displayed instead of the ship's ID. YOU NEED TO LEAVE THE QUOTATION MARKS.
-
-SkillRepairToolEfficiency = 0 --export Enter (0-5) your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency"
-SkillRepairToolOptimization = 0 --export Enter your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Optimization"
-
-StatAtmosphericFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED ATMOSPHERIC FUEL TANKS (from the builders talent "Piloting -> Atmospheric Flight Technician -> Atmospheric Fuel-Tank Handling")
-StatSpaceFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL SPACE TANKS (from the builders talent "Piloting -> Atmospheric Engine Technician -> Space Fuel-Tank Handling")
-StatRocketFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL ROCKET TANKS (from the builders talent "Piloting -> Rocket Scientist -> Rocket Booster Fuel Tank Handling")
-StatContainerOptimization = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL TANKS "from the builders talent Mining and Inventory -> Stock Control -> Container Optimization"
-StatFuelTankOptimization = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL TANKS "from the builders talent Mining and Inventory -> Stock Control -> Fuel Tank Optimization"
-
-ShowWelcomeMessage = true --export Do you want the welcome message on the start screen with your name?
-AddSummertimeHour = false --export: Is summertime currently enabled in your location? (Adds one hour.)
-
--- SkillAtmosphericFuelEfficiency = 0 --export Enter (0-5) your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency"
--- SkillSpaceFuelEfficiency = 0 --export Enter (0-5) your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency"
--- SkillRocketFuelEfficiency = 0 --export Enter (0-5) your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency"
-
---[[ 2. GLOBAL VARIABLES ]]
-
-UpdateDataInterval = 1.0 -- How often shall the data be updated? (Increase if running into CPU issues.)
-HighlightBlinkingInterval = 0.5 -- How fast shall highlight arrows of marked elements blink?
-
-ColorPrimary = "FF6700" -- Enter the hexcode of the main color to be used by all views.
-ColorSecondary = "FFFFFF" -- Enter the hexcode of the secondary color to be used by all views.
-ColorTertiary = "000000" -- Enter the hexcode of the tertiary color to be used by all views.
-ColorHealthy = "00FF00" -- Enter the hexcode of the 'healthy' color to be used by all views.
-ColorWarning = "FFFF00" -- Enter the hexcode of the 'warning' color to be used by all views.
-ColorCritical = "FF0000" -- Enter the hexcode of the 'critical' color to be used by all views.
-ColorBackground = "000000" -- Enter the hexcode of the background color to be used by all views.
-ColorBackgroundPattern = "4F4F4F" -- Enter the hexcode of the background color to be used by all views.
-ColorFuelAtmospheric = "004444" -- Enter the hexcode of the atmospheric fuel color.
-ColorFuelSpace = "444400" -- Enter the hexcode of the space fuel color.
-ColorFuelRocket = "440044" -- Enter the hexcode of the rocket fuel color.
-
-VERSION = 3.1
-DebugMode = false
-DebugRenderClickareas = true
-
-DBData = {}
-
-core = nil
-db = nil
-screens = {}
-dscreens = {}
-
-Warnings = {}
-
-screenModes = {
- ["flight"] = { id="flight" },
- ["damage"] = { id="damage" },
- ["damageoutline"] = { id="damageoutline" },
- ["fuel"] = { id="fuel" },
- ["cargo"] = { id="cargo" },
- ["agg"] = { id="agg" },
- ["map"] = { id="map" },
- ["time"] = { id="time", activetoggle="true" },
- ["settings1"] = { id="settings1" },
- ["startup"] = { id="startup" }
-}
-
-backgroundModes = { "deathstar", "capsule", "rain", "signal", "hexagon", "diagonal", "diamond", "plus", "dots" }
-BackgroundMode ="deathstar"
-BackgroundSelected = 1
-BackgroundModeOpacity = 0.25
-
-SaveVars = { "dscreens",
- "ColorPrimary", "ColorSecondary", "ColorTertiary",
- "ColorHealthy", "ColorWarning", "ColorCritical",
- "ColorBackground", "ColorBackgroundPattern",
- "ScrapTier", "HUDMode", "SimulationMode", "DMGOStretch",
- "HUDShiftU", "HUDShiftV", "colorIDIndex", "colorIDTable",
- "BackgroundMode", "BackgroundSelected", "BackgroundModeOpacity" }
-
-HUDMode = false
-HUDShiftU = 0
-HUDShiftV = 0
-hudSelectedIndex = 0
-hudStartIndex = 1
-hudArrowSticker = {}
-highlightOn = false
-highlightID = 0
-highlightX = 0
-highlightY = 0
-highlightZ = 0
-
-SimulationMode = false
-OkayCenterMessage = "All systems nominal."
-CurrentDamagedPage = 1
-CurrentBrokenPage = 1
-DamagePageSize = 12
-ScrapTier = 1
-totalScraps = 0
-ScrapTierRepairTimes = { 10, 50, 250, 1250 }
-
-coreWorldOffset = 0
-totalShipHP = 0
-formerTotalShipHP = -1
-totalShipMaxHP = 0
-totalShipIntegrity = 100
-elementsId = {}
-elementsIdList = {}
-damagedElements = {}
-brokenElements = {}
-rE = {}
-healthyElements = {}
-typeElements = {}
-ElementCounter = 0
-UseMyElementNames = true
-dmgoElements = {}
-DMGOMaxElements = 250
-DMGOStretch = false
-ShipXmin = 99999999
-ShipXmax = -99999999
-ShipYmin = 99999999
-ShipYmax = -99999999
-ShipZmin = 99999999
-ShipZmax = -99999999
-
-totalShipMass = 0
-formerTotalShipMass = -1
-
-formerTime = -1
-
-FuelAtmosphericTanks = {}
-FuelSpaceTanks = {}
-FuelRocketTanks = {}
-FuelAtmosphericTotal = 0
-FuelSpaceTotal = 0
-FuelRocketTotal = 0
-FuelAtmosphericCurrent = 0
-FuelSpaceTotalCurrent = 0
-FuelRocketTotalCurrent = 0
-formerFuelAtmosphericTotal = -1
-formerFuelSpaceTotal = -1
-formerFuelRocketTotal = -1
-
-hexTable = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"}
-colorIDIndex = 1
-colorIDTable = {
- [1] = {
- id="ColorPrimary",
- desc="Main HUD Color",
- basec = "FF6700",
- newc = "FF6700"
- },
- [2] = {
- id="ColorSecondary",
- desc="Secondary HUD Color",
- basec = "FFFFFF",
- newc = "FFFFFF"
- },
- [3] = {
- id="ColorTertiary",
- desc="Tertiary HUD Color",
- basec = "000000",
- newc = "000000"
- },
- [4] = {
- id="ColorHealthy",
- desc="Color code for Healthy/Okay",
- basec = "00FF00",
- newc = "00FF00"
- },
- [5] = {
- id="ColorWarning",
- desc="Color code for Damaged/Warning",
- basec = "FFFF00",
- newc = "FFFF00"
- },
- [6] = {
- id="ColorCritical",
- desc="Color code for Broken/Critical",
- basec = "FF0000",
- newc = "FF0000"
- },
- [7] = {
- id="ColorBackground",
- desc="Background Color",
- basec = "000000",
- newc = "000000"
- },
- [8] = {
- id="ColorBackgroundPattern",
- desc="Background Pattern Color",
- basec = "4F4F4F",
- newc = "4F4F4F"
- },
- [9] = {
- id="ColorFuelAtmospheric",
- desc="Color for Atmo Fuel/Elements",
- basec = "004444",
- newc = "004444"
- },
- [10] = {
- id="ColorFuelSpace",
- desc="Color for Space Fuel/Elements",
- basec = "444400",
- newc = "444400"
- },
- [11] = {
- id="ColorFuelRocket",
- desc="Color for Rocket Fuel/Elements",
- basec = "440044",
- newc = "440044"
- }
-}
-
-
---[[ 3. PROCESSING FUNCTIONS ]]
-
-function InitiateSlots()
- for slot_name, slot in pairs(unit) do
- if type(slot) == "table" and type(slot.export) == "table" and
- slot.getElementClass then
- local elementClass = slot.getElementClass():lower()
- if elementClass:find("coreunit") then
- core = slot
- local coreHP = core.getMaxHitPoints()
- if coreHP > 10000 then
- coreWorldOffset = 128
- elseif coreHP > 1000 then
- coreWorldOffset = 64
- elseif coreHP > 150 then
- coreWorldOffset = 32
- else
- coreWorldOffset = 16
- end
- elseif elementClass == 'databankunit' then
- db = slot
- elseif elementClass == "screenunit" then
- local iScreenMode = "startup"
- screens[#screens + 1] = {
- element = slot,
- id = slot.getId(),
- mode = iScreenMode,
- submode = "",
- ClickAreas = {},
- refresh = true,
- active = false,
- fuelA = true,
- fuelS = true,
- fuelR = true,
- fuelIndex = 1
- }
- end
- end
- end
-end
-
-function LoadFromDatabank()
- if db == nil then
- return
- else
- for _, data in pairs(SaveVars) do
- if db.hasKey(data) then
- local jData = json.decode( db.getStringValue(data) )
- if jData ~= nil then
- if data == "YourShipsName" or data == "AddSummertimeHour" or data == "UpdateDataInterval" or data == "HighlightBlinkingInterval" or
- data == "SkillRepairToolEfficiency" or data == "SkillRepairToolOptimization" or data == "SkillAtmosphericFuelEfficiency" or
- data == "SkillSpaceFuelEfficiency" or data == "SkillRocketFuelEfficiency" or data == "StatAtmosphericFuelTankHandling" or
- data == "StatSpaceFuelTankHandling" or data == "StatRocketFuelTankHandling"
- then
- -- Nada
- else
- _G[data] = jData
- end
- end
- end
- end
-
- for i,v in ipairs(screens) do
- for j,dv in ipairs(dscreens) do
- if screens[i].id == dscreens[j].id then
- screens[i].mode = dscreens[j].mode
- screens[i].submode = dscreens[j].submode
- screens[i].active = dscreens[j].active
- screens[i].refresh = true
- screens[i].fuelA = dscreens[j].fuelA
- screens[i].fuelS = dscreens[j].fuelS
- screens[i].fuelR = dscreens[j].fuelR
- screens[i].fuelIndex = dscreens[j].fuelIndex
- end
- end
- end
- end
-end
-
-function SaveToDatabank()
- if db == nil then
- return
- else
- dscreens = {}
- for i,screen in ipairs(screens) do
- dscreens[i] = {}
- dscreens[i].id = screen.id
- dscreens[i].mode = screen.mode
- dscreens[i].submode = screen.submode
- dscreens[i].active = screen.active
- dscreens[i].fuelA = screen.fuelA
- dscreens[i].fuelS = screen.fuelS
- dscreens[i].fuelR = screen.fuelR
- dscreens[i].fuelIndex = screen.fuelIndex
- end
-
- db.clear()
-
- for _, data in pairs(SaveVars) do
- db.setStringValue(data, json.encode(_G[data]))
- end
-
- end
-end
-
-function InitiateScreens()
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- screens[i] = CreateClickAreasForScreen(screens[i])
- end
- end
-end
-
-function UpdateTypeData()
- FuelAtmosphericTanks = {}
- FuelSpaceTanks = {}
- FuelRocketTanks = {}
-
- FuelAtmosphericTotal = 0
- FuelAtmosphericCurrent = 0
- FuelSpaceTotal = 0
- FuelSpaceCurrent = 0
- FuelRocketCurrent = 0
- FuelRocketTotal = 0
-
- local weightAtmosphericFuel = 4
- local weightSpaceFuel = 6
- local weightRocketFuel = 0.8
-
- --[[
- (FuelMass * (1-.05 * ) * (1-.05 * )
- It just seems to be that the Container Optimization and Fuel Tank Optimization are not added together so the max is not -50% (25% from each skill from the base mass) but 43.75% So the Fuel Tank Optimization uses the container optimization result as it's base value
- ]]
-
- if StatContainerOptimization > 0 then
- weightAtmosphericFuel = weightAtmosphericFuel - 0.05 * StatContainerOptimization * weightAtmosphericFuel
- weightSpaceFuel = weightSpaceFuel - 0.05 * StatContainerOptimization * weightSpaceFuel
- weightRocketFuel = weightRocketFuel - 0.05 * StatContainerOptimization * weightRocketFuel
- end
- if StatFuelTankOptimization > 0 then
- weightAtmosphericFuel = weightAtmosphericFuel - 0.05 * StatFuelTankOptimization * weightAtmosphericFuel
- weightSpaceFuel = weightSpaceFuel - 0.05 * StatFuelTankOptimization * weightSpaceFuel
- weightRocketFuel = weightRocketFuel - 0.05 * StatFuelTankOptimization * weightRocketFuel
- end
-
- for i, id in ipairs(typeElements) do
- local idName = core.getElementNameById(id) or ""
- local idType = core.getElementTypeById(id) or ""
- -- local idTypeClean = idType:gsub("[%s%-]+", ""):lower()
- local idPos = core.getElementPositionById(id) or 0
- local idHP = core.getElementHitPointsById(id) or 0
- local idMaxHP = core.getElementMaxHitPointsById(id) or 0
- local idMass = core.getElementMassById(id) or 0
-
- local baseSize = ""
- local baseVol = 0
- local baseMass = 0
- local cMass = 0
- local cVol = 0
-
- if idType == "atmospheric fuel-tank" then
- if idMaxHP > 10000 then
- baseSize = "L"
- baseMass = 5480
- baseVol = 12800
- elseif idMaxHP > 1300 then
- baseSize = "M"
- baseMass = 988.67
- baseVol = 1600
- elseif idMaxHP > 150 then
- baseSize = "S"
- baseMass = 182.67
- baseVol = 400
- else
- baseSize = "XS"
- baseMass = 35.03
- baseVol = 100
- end
- if StatAtmosphericFuelTankHandling > 0 then
- baseVol = 0.2 * StatAtmosphericFuelTankHandling * baseVol + baseVol
- end
- cMass = idMass - baseMass
- if cMass <=10 then cMass = 0 end
- cVol = string.format("%.0f", cMass / weightAtmosphericFuel)
- cPercent = string.format("%.1f", math.floor(100/baseVol * tonumber(cVol)))
- table.insert(FuelAtmosphericTanks, {
- type = 1,
- id = id,
- name = idName,
- maxhp = idMaxHP,
- hp = GetHPforElement(id),
- pos = idPos,
- size = baseSize,
- mass = baseMass,
- vol = baseVol,
- cvol = cVol,
- percent = cPercent
- })
- if idHP > 0 then
- FuelAtmosphericCurrent = FuelAtmosphericCurrent + cVol
- end
- FuelAtmosphericTotal = FuelAtmosphericTotal + baseVol
- elseif idType == "space fuel-tank" then
- if idMaxHP > 10000 then
- baseSize = "L"
- baseMass = 5480
- baseVol = 12800
- elseif idMaxHP > 1300 then
- baseSize = "M"
- baseMass = 988.67
- baseVol = 1600
- else
- baseSize = "S"
- baseMass = 182.67
- baseVol = 400
- end
- if StatSpaceFuelTankHandling > 0 then
- baseVol = 0.2 * StatSpaceFuelTankHandling * baseVol + baseVol
- end
- cMass = idMass - baseMass
- if cMass <=10 then cMass = 0 end
- cVol = string.format("%.0f", cMass / weightSpaceFuel)
- cPercent = string.format("%.1f", (100/baseVol * tonumber(cVol)))
- table.insert(FuelSpaceTanks, {
- type = 2,
- id = id,
- name = idName,
- maxhp = idMaxHP,
- hp = GetHPforElement(id),
- pos = idPos,
- size = baseSize,
- mass = baseMass,
- vol = baseVol,
- cvol = cVol,
- percent = cPercent
- })
- if idHP > 0 then
- FuelSpaceCurrent = FuelSpaceCurrent + cVol
- end
- FuelSpaceTotal = FuelSpaceTotal + baseVol
- elseif idType == "rocket fuel-tank" then
- if idMaxHP > 65000 then
- baseSize = "L"
- baseMass = 25740
- baseVol = 50000
- elseif idMaxHP > 6000 then
- baseSize = "M"
- baseMass = 4720
- baseVol = 6400
- elseif idMaxHP > 700 then
- baseSize = "S"
- baseMass = 886.72
- baseVol = 800
- else
- baseSize = "XS"
- baseMass = 173.42
- baseVol = 400
- end
- if StatRocketFuelTankHandling > 0 then
- baseVol = 0.2 * StatRocketFuelTankHandling * baseVol + baseVol
- end
- cMass = idMass - baseMass
- if cMass <=10 then cMass = 0 end
- cVol = string.format("%.0f", cMass / weightRocketFuel)
- cPercent = string.format("%.1f", (100/baseVol * tonumber(cVol)))
- table.insert(FuelRocketTanks, {
- type = 3,
- id = id,
- name = idName,
- maxhp = idMaxHP,
- hp = GetHPforElement(id),
- pos = idPos,
- size = baseSize,
- mass = baseMass,
- vol = baseVol,
- cvol = cVol,
- percent = cPercent
- })
- if idHP > 0 then
- FuelRocketCurrent = FuelRocketCurrent + cVol
- end
- FuelRocketTotal = FuelRocketTotal + baseVol
- end
-
- end
-
- if FuelAtmosphericCurrent ~= formerFuelAtmosphericCurrent then
- SetRefresh("fuel")
- formerFuelAtmosphericCurrent = FuelAtmosphericCurrent
- end
- if FuelSpaceCurrent ~= formerFuelSpaceCurrent then
- SetRefresh("fuel")
- formerFuelSpaceCurrent = FuelSpaceCurrent
- end
- if FuelRocketCurrent ~= formerFuelRocketCurrent then
- SetRefresh("fuel")
- formerFuelRocketCurrent = FuelRocketCurrent
- end
-
-
-
-end
-
-function UpdateDamageData(initial)
-
- initial = initial or false
-
- if SimulationActive == true then return end
-
- local formerTotalShipHP = totalShipHP
- totalShipHP = 0
- totalShipMaxHP = 0
- totalShipIntegrity = 100
- damagedElements = {}
- brokenElements = {}
- healthyElements = {}
- if initial == true then
- typeElements = {}
- end
-
- ElementCounter = 0
-
- elementsIdList = core.getElementIdList()
-
- for i, id in pairs(elementsIdList) do
-
- ElementCounter = ElementCounter + 1
-
- local idName = core.getElementNameById(id)
-
- local idType = core.getElementTypeById(id)
- -- local idTypeClean = idType:gsub("[%s%-]+", ""):lower()
- local idPos = core.getElementPositionById(id)
- local idHP = core.getElementHitPointsById(id)
- local idMaxHP = core.getElementMaxHitPointsById(id)
- -- local idMass = core.getElementMassById(id)
-
- if SimulationMode == true then
- SimulationActive = true
- local dice = math.random(0, 10)
- if dice < 2 and #brokenElements < 30 then
- idHP = 0
- elseif dice >= 2 and dice < 4 and #damagedElements < 30 then
- idHP = math.random(1, math.ceil(idMaxHP))
- else
- idHP = idMaxHP
- end
- end
-
- totalShipHP = totalShipHP + idHP
- totalShipMaxHP = totalShipMaxHP + idMaxHP
-
- if idMaxHP - idHP > constants.epsilon then
-
- if idHP > 0 then
- table.insert(damagedElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP - idHP,
- percent = math.ceil(100 / idMaxHP * idHP),
- pos = idPos
- })
- else
- table.insert(brokenElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP - idHP,
- percent = 0,
- pos = idPos
- })
- end
- else
- table.insert(healthyElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- pos = idPos
- })
- if id == highlightID then
- highlightID = 0
- highlightOn = false
- HideHighlight()
- hudSelectedIndex = 0
- end
- end
-
- if initial == true then
- if
- idType == "atmospheric fuel-tank" or
- idType == "space fuel-tank" or
- idType == "rocket fuel-tank"
- then
- table.insert(typeElements, id)
- end
- end
- end
-
- SortDamageTables()
-
- rE = {}
-
- if #brokenElements > 0 then
- for _,v in ipairs(brokenElements) do
- table.insert(rE, {id=v.id, missinghp=v.missinghp, hp=v.hp, name=v.name, type=v.type, pos=v.pos})
- end
- end
- if #damagedElements > 0 then
- for _,v in ipairs(damagedElements) do
- table.insert(rE, {id=v.id, missinghp=v.missinghp, hp=v.hp, name=v.name, type=v.type, pos=v.pos})
- end
- end
- if #rE > 0 then
- table.sort(rE, function(a,b) return a.missinghp>b.missinghp end)
- end
-
- totalShipIntegrity = string.format("%2.0f", 100 / totalShipMaxHP * totalShipHP)
-
- if formerTotalShipHP ~= totalShipHP then
- forceDamageRedraw = true
- formerTotalShipHP = totalShipHP
- else
- forceDamageRedraw = false
- end
-end
-
-function GetHPforElement(id)
- for i,v in ipairs(brokenElements) do
- if v.id == id then
- return 0
- end
- end
- for i,v in ipairs(damagedElements) do
- if v.id == id then
- return v.hp
- end
- end
- for i,v in ipairs(healthyElements) do
- if v.id == id then
- return v.maxhp
- end
- end
-end
-
-function UpdateClickArea(candidate, newEntry, mode)
- for i, screen in ipairs(screens) do
- for k, v in pairs(screens[i].ClickAreas) do
- if v.id == candidate and v.mode == mode then
- screens[i].ClickAreas[k] = newEntry
- end
- end
- end
-end
-
-function AddClickArea(mode, newEntry)
- for i, screen in ipairs(screens) do
- if screens[i].mode == mode then
- table.insert(screens[i].ClickAreas, newEntry)
- end
- end
-end
-
-function AddClickAreaForScreenID(screenid, newEntry)
- for i, screen in ipairs(screens) do
- if screens[i].id == screenid then
- table.insert(screens[i].ClickAreas, newEntry)
- end
- end
-end
-
-function DisableClickArea(candidate, mode)
- UpdateClickArea(candidate, {
- id = candidate,
- mode = mode,
- x1 = -1,
- x2 = -1,
- y1 = -1,
- y2 = -1
- })
-end
-
-function SetRefresh(mode, submode)
- mode = mode or "all"
- submode = submode or "all"
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- if screens[i].mode == mode or mode == "all" then
- if screens[i].submode == submode or submode =="all" then
- screens[i].refresh = true
- end
- end
- end
- end
-end
-
-function WipeClickAreasForScreen(screen)
- screen.ClickAreas = {}
- return screen
-end
-
-function CreateBaseClickAreas(screen)
- table.insert(screen.ClickAreas, {mode = "all", id = "ToggleHudMode", x1 = 1537, x2 = 1728, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "damage", x1 = 193, x2 = 384, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "damageoutline", x1 = 385, x2 = 576, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "fuel", x1 = 577, x2 = 768, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "flight", x1 = 769, x2 = 960, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "cargo", x1 = 961, x2 = 1152, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "agg", x1 = 1153, x2 = 1344, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "map", x1 = 1345, x2 = 1536, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "time", x1 = 0, x2 = 192, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "settings1", x1 = 1729, x2 = 1920, y1 = 1015, y2 = 1075} )
- return screen
-end
-
-function CreateClickAreasForScreen(screen)
-
- if screen == nil then return {} end
-
- if screen.mode == "flight" then
- elseif screen.mode == "damage" then
- table.insert( screen.ClickAreas, {mode = "damage", id = "ToggleElementLabel", x1 = 70, x2 = 425, y1 = 325, y2 = 355} )
- table.insert( screen.ClickAreas, {mode = "damage", id = "ToggleElementLabel2", x1 = 980, x2 = 1400, y1 = 325, y2 = 355} )
- elseif screen.mode == "damageoutline" then
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeView", param = "top", x1 = 60, x2 = 439, y1 = 150, y2 = 200} )
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeView", param = "side", x1 = 440, x2 = 824, y1 = 150, y2 = 200} )
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeView", param = "front", x1 = 825, x2 = 1215, y1 = 150, y2 = 200} )
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeStretch", x1 = 1530, x2 = 1580, y1 = 150, y2 = 200} )
- elseif screen.mode == "fuel" then
- elseif screen.mode == "cargo" then
- elseif screen.mode == "agg" then
- elseif screen.mode == "map" then
- elseif screen.mode == "time" then
- elseif screen.mode == "settings1" then
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ToggleBackground", x1 = 75, x2 = 860, y1 = 170, y2 = 215} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "PreviousBackground", x1 = 75, x2 = 460, y1 = 235, y2 = 285} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "NextBackground", x1 = 480, x2 = 860, y1 = 235, y2 = 285} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "DecreaseOpacity", x1 = 75, x2 = 460, y1 = 300, y2 = 350} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "IncreaseOpacity", x1 = 480, x2 = 860, y1 = 300, y2 = 350} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ResetColors", x1 = 75, x2 = 860, y1 = 370, y2 = 415} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "PreviousColorID", x1 = 90, x2 = 140, y1 = 500, y2 = 550} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "NextColorID", x1 = 795, x2 = 845, y1 = 500, y2 = 550} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="1", x1 = 210, x2 = 290, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="2", x1 = 300, x2 = 380, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="3", x1 = 385, x2 = 465, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="4", x1 = 470, x2 = 550, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="5", x1 = 560, x2 = 640, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="6", x1 = 645, x2 = 725, y1 = 655, y2 = 700} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="1", x1 = 210, x2 = 290, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="2", x1 = 300, x2 = 380, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="3", x1 = 385, x2 = 465, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="4", x1 = 470, x2 = 550, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="5", x1 = 560, x2 = 640, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="6", x1 = 645, x2 = 725, y1 = 740, y2 = 780} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ResetPosColor", x1 = 160, x2 = 340, y1 = 885, y2 = 935} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ApplyPosColor", x1 = 355, x2 = 780, y1 = 885, y2 = 935} )
-
- elseif screen.mode == "startup" then
- end
-
- screen = CreateBaseClickAreas(screen)
-
- return screen
-end
-
-function CheckClick(x, y, HitTarget)
- x = x*1920
- y = y*1120
- HitTarget = HitTarget or ""
- HitPayload = {}
- -- PrintConsole("Clicked: "..x.." / "..y)
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- if screens[i].active == true and screens[i].element.getMouseX() ~= -1 and screens[i].element.getMouseY() ~= -1 then
- if HitTarget == "" then
- for k, v in pairs(screens[i].ClickAreas) do
- if v ~=nil and x >= v.x1 and x <= v.x2 and y >= v.y1 and y <= v.y2 then
- HitTarget = v.id
- HitPayload = v
- break
- end
- end
- end
- if HitTarget == "ButtonPress" then
- if screens[i].mode == HitPayload.param then
- screens[i].mode = "startup"
- else
- screens[i].mode = HitPayload.param
- end
-
- if screens[i].mode == "damageoutline" then
- if screens[i].submode == "" then
- screens[i].submode = "top"
- end
- end
- screens[i].refresh = true
- screens[i].ClickAreas = {}
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "ToggleBackground" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundMode == "" then
- BackgroundSelected = 1
- BackgroundMode = backgroundModes[BackgroundSelected]
- else
- BackgroundSelected = 1
- BackgroundMode = ""
- end
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "PreviousBackground" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundMode == "" then
- BackgroundSelected = 1
- BackgroundMode = backgroundModes[BackgroundSelected]
- else
- if BackgroundSelected <= 1 then
- BackgroundSelected = #backgroundModes
- else
- BackgroundSelected = BackgroundSelected - 1
- end
- BackgroundMode = backgroundModes[BackgroundSelected]
- end
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "NextBackground" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundMode == "" then
- BackgroundSelected = 1
- BackgroundMode = backgroundModes[BackgroundSelected]
- else
- if BackgroundSelected >= #backgroundModes then
- BackgroundSelected = 1
- else
- BackgroundSelected = BackgroundSelected + 1
- end
- BackgroundMode = backgroundModes[BackgroundSelected]
- end
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "DecreaseOpacity" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundModeOpacity>0.1 then
- BackgroundModeOpacity = BackgroundModeOpacity - 0.05
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- end
- elseif HitTarget == "IncreaseOpacity" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundModeOpacity<1.0 then
- BackgroundModeOpacity = BackgroundModeOpacity + 0.05
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- end
- elseif HitTarget == "ResetColors" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- db.clear()
- ColorPrimary = "FF6700"
- ColorSecondary = "FFFFFF"
- ColorTertiary = "000000"
- ColorHealthy = "00FF00"
- ColorWarning = "FFFF00"
- ColorCritical = "FF0000"
- ColorBackground = "000000"
- ColorBackgroundPattern = "4f4f4f"
- BackgroundMode = "deathstar"
- BackgroundSelected = 1
- BackgroundModeOpacity = 0.25
- colorIDTable = {
- [1] = {
- id="ColorPrimary",
- desc="Main HUD Color",
- basec = "FF6700",
- newc = "FF6700"
- },
- [2] = {
- id="ColorSecondary",
- desc="Secondary HUD Color",
- basec = "FFFFFF",
- newc = "FFFFFF"
- },
- [3] = {
- id="ColorTertiary",
- desc="Tertiary HUD Color",
- basec = "000000",
- newc = "000000"
- },
- [4] = {
- id="ColorHealthy",
- desc="Color code for Healthy/Okay",
- basec = "00FF00",
- newc = "00FF00"
- },
- [5] = {
- id="ColorWarning",
- desc="Color code for Damaged/Warning",
- basec = "FFFF00",
- newc = "FFFF00"
- },
- [6] = {
- id="ColorCritical",
- desc="Color code for Broken/Critical",
- basec = "FF0000",
- newc = "FF0000"
- },
- [7] = {
- id="ColorBackground",
- desc="Background Color",
- basec = "000000",
- newc = "000000"
- },
- [8] = {
- id="ColorBackgroundPattern",
- desc="Background Pattern Color",
- basec = "4F4F4F",
- newc = "4F4F4F"
- },
- [9] = {
- id="ColorFuelAtmospheric",
- desc="Color for Atmo Fuel/Elements",
- basec = "004444",
- newc = "004444"
- },
- [10] = {
- id="ColorFuelSpace",
- desc="Color for Space Fuel/Elements",
- basec = "444400",
- newc = "444400"
- },
- [11] = {
- id="ColorFuelRocket",
- desc="Color for Rocket Fuel/Elements",
- basec = "440044",
- newc = "440044"
- }
- }
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "PreviousColorID" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- colorIDIndex = colorIDIndex - 1
- if colorIDIndex < 1 then colorIDIndex = #colorIDTable end
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "NextColorID" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- colorIDIndex = colorIDIndex + 1
- if colorIDIndex > #colorIDTable then colorIDIndex = 1 end
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "ColorPosUp" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- local s = tonumber(string.sub(colorIDTable[colorIDIndex].newc, HitPayload.param, HitPayload.param),16)
- s = s + 1
- if s > 15 then s = 0 end
- colorIDTable[colorIDIndex].newc = replace_char(HitPayload.param, colorIDTable[colorIDIndex].newc, hexTable[s+1])
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "ColorPosDown" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- local s = tonumber(string.sub(colorIDTable[colorIDIndex].newc, HitPayload.param, HitPayload.param),16)
- s = s - 1
- if s < 0 then s = 15 end
- colorIDTable[colorIDIndex].newc = replace_char(HitPayload.param, colorIDTable[colorIDIndex].newc, hexTable[s+1])
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "ResetPosColor" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- colorIDTable[colorIDIndex].newc = colorIDTable[colorIDIndex].basec
- _G[colorIDTable[colorIDIndex].id] = colorIDTable[colorIDIndex].basec
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "ApplyPosColor" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- _G[colorIDTable[colorIDIndex].id] = colorIDTable[colorIDIndex].newc
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "DamagedPageDown" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentDamagedPage = CurrentDamagedPage + 1
- if CurrentDamagedPage > math.ceil(#damagedElements / DamagePageSize) then
- CurrentDamagedPage = math.ceil(#damagedElements / DamagePageSize)
- end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "DamagedPageUp" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentDamagedPage = CurrentDamagedPage - 1
- if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "BrokenPageDown" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentBrokenPage = CurrentBrokenPage + 1
- if CurrentBrokenPage > math.ceil(#brokenElements / DamagePageSize) then
- CurrentBrokenPage = math.ceil(#brokenElements / DamagePageSize)
- end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "BrokenPageUp" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentBrokenPage = CurrentBrokenPage - 1
- if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "DMGOChangeView" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- screens[i].submode = HitPayload.param
- UpdateViewDamageoutline(screens[i])
- SaveToDatabank()
- SetRefresh("damageoutline", screens[i].submode)
- RenderScreens("damageoutline", screens[i].submode)
- elseif HitTarget == "DMGOChangeStretch" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if DMGOStretch == true then
- DMGOStretch = false
- else
- DMGOStretch = true
- end
- UpdateViewDamageoutline(screens[i])
- SaveToDatabank()
- SetRefresh("damageoutline")
- RenderScreens("damageoutline")
- elseif HitTarget == "ToggleDisplayAtmosphere" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if screens[i].fuelA == true then
- screens[i].fuelA = false
- else
- screens[i].fuelA = true
- end
- screens[i].fuelIndex = 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "ToggleDisplaySpace" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if screens[i].fuelS == true then
- screens[i].fuelS = false
- else
- screens[i].fuelS = true
- end
- screens[i].fuelIndex = 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "ToggleDisplayRocket" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if screens[i].fuelR == true then
- screens[i].fuelR = false
- else
- screens[i].fuelR = true
- end
- screens[i].fuelIndex = 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "DecreaseFuelIndex" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- screens[i].fuelIndex = screens[i].fuelIndex - 1
- if screens[i].fuelIndex < 1 then screens[i].fuelIndex = 1 end
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "IncreaseFuelIndex" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- screens[i].fuelIndex = screens[i].fuelIndex + 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "ToggleHudMode" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if HUDMode == true then
- HUDMode = false
- forceDamageRedraw = true
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- else
- HUDMode = true
- forceDamageRedraw = true
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- end
- elseif HitTarget == "ToggleSimulation" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentDamagedPage = 1
- CurrentBrokenPage = 1
- if SimulationMode == true then
- SimulationMode = false
- SimulationActive = false
- UpdateDamageData()
- UpdateTypeData()
- forceDamageRedraw = true
- HudDeselectElement()
- SetRefresh("damage")
- SetRefresh("damageoutline")
- SetRefresh("settings1")
- SetRefresh("fuel")
- SaveToDatabank()
- RenderScreens()
- else
- SimulationMode = true
- SimulationActive = false
- UpdateDamageData()
- UpdateTypeData()
- forceDamageRedraw = true
- HudDeselectElement()
- SetRefresh("damage")
- SetRefresh("damageoutline")
- SetRefresh("settings1")
- SetRefresh("fuel")
- SaveToDatabank()
- RenderScreens()
- end
- elseif (HitTarget == "ToggleElementLabel" or HitTarget == "ToggleElementLabel2") and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if UseMyElementNames == true then
- UseMyElementNames = false
- SetRefresh("damage")
- RenderScreens("damage")
- else
- UseMyElementNames = true
- SetRefresh("damage")
- RenderScreens("damage")
- end
- elseif (HitTarget == "SwitchScrapTier" or HitTarget == "SwitchScrapTier2") and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- ScrapTier = ScrapTier + 1
- if ScrapTier > 4 then ScrapTier = 1 end
- SetRefresh("damage")
- RenderScreens("damage")
- end
-
-
- end
- end
- end
-end
-
---[[ 4. RENDERING FUNCTIONS ]]
-
-function GetContentFlight()
- local output = ""
- output = output .. GetHeader("Flight Data Report") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentDamage()
- local output = ""
- if SimulationMode == true then
- output = output .. GetHeader("Damage Report (Simulated damage)") .. [[]]
- else
- output = output .. GetHeader("Damage Report") .. [[]]
- end
- output = output .. GetContentDamageScreen()
- return output
-end
-
-function GetContentDamageoutline(screen)
- UpdateDataDamageoutline()
- UpdateViewDamageoutline(screen)
- local output = ""
- output = output .. GetHeader("Damage Ship Outline Report") ..
- GetDamageoutlineShip() ..
- [[]]
-
- if screen.submode=="top" then
- output = output ..
- [[
-
- Top View
-
- Side View
-
- Front View
- ]]
- elseif screen.submode=="side" then
- output = output ..
- [[
-
- Top View
-
- Side View
-
- Front View
- ]]
- elseif screen.submode=="front" then
- output = output ..
- [[
-
- Top View
-
- Side View
-
- Front View
- ]]
- else
- end
- output = output .. [[]]..#dmgoElements..[[ of ]]..ElementCounter..[[ shown]]
- output = output .. [[]]
- if DMGOStretch == true then
- output = output .. [[]]
- end
- output = output .. [[Stretch both axis]]
- return output
-end
-
-function GetContentFuel(screen)
-
- if #FuelAtmosphericTanks < 1 and #FuelSpaceTanks < 1 and #FuelRocketTanks < 1 then return "" end
-
- local FuelTypes = 0
- local output = ""
- local addHeadline = {}
-
- FuelDisplay = { screen.fuelA, screen.fuelS, screen.fuelR }
-
- if FuelDisplay[1] == true and #FuelAtmosphericTanks > 0 then
- table.insert(addHeadline, "Atmospheric")
- FuelTypes = FuelTypes + 1
- end
- if FuelDisplay[2] == true and #FuelSpaceTanks > 0 then
- table.insert(addHeadline, "Space")
- FuelTypes = FuelTypes + 1
- end
- if FuelDisplay[3] == true and #FuelRocketTanks > 0 then
- table.insert(addHeadline, "Rocket")
- FuelTypes = FuelTypes + 1
- end
-
- output = output .. GetHeader("Fuel Report ("..table.concat(addHeadline, ", ")..")") ..
- [[
- ]]
-
- local totalH = 150
- local counter = 0
- local tOffset = 0
-
- if FuelDisplay[1] == true and #FuelAtmosphericTanks > 0 then
-
- if FuelTypes == 1 then tOffset = 50
- elseif FuelTypes == 2 then tOffset = 6
- elseif FuelTypes == 3 then tOffset = 0
- end
-
- output = output .. [[
-
-
-
- ]]
-
- output = output ..
- [[]]..
- GenerateCommaValue(FuelAtmosphericCurrent, true)..
- [[ of ]]..GenerateCommaValue(FuelAtmosphericTotal, true)..
- [[ | Total Atmospheric Fuel in ]]..#FuelAtmosphericTanks..[[ tank]]..(#FuelAtmosphericTanks==1 and "" or "s")..[[ (]]..math.floor(100/FuelAtmosphericTotal*FuelAtmosphericCurrent)..[[%)]]
- counter = counter + 1
- end
-
- if FuelDisplay[2] == true and #FuelSpaceTanks > 0 then
-
- if FuelTypes == 1 then tOffset = 50
- elseif FuelTypes == 2 then tOffset = 6
- elseif FuelTypes == 3 then tOffset = 0
- end
-
- output = output .. [[
-
-
-
- ]]
-
- output = output ..
- [[]]..
- GenerateCommaValue(FuelSpaceCurrent, true)..
- [[ of ]]..GenerateCommaValue(FuelSpaceTotal, true)..
- [[ | Total Space Fuel in ]]..#FuelSpaceTanks..[[ tank]]..(#FuelSpaceTanks==1 and "" or "s")..[[ (]]..math.floor(100/FuelSpaceTotal*FuelSpaceCurrent)..[[%)]]
- counter = counter + 1
- end
-
- if FuelDisplay[3] == true and #FuelRocketTanks > 0 then
-
- if FuelTypes == 1 then tOffset = 50
- elseif FuelTypes == 2 then tOffset = 6
- elseif FuelTypes == 3 then tOffset = 0
- end
-
- output = output .. [[
-
-
-
- ]]
-
- output = output ..
- [[]]..
- GenerateCommaValue(FuelRocketCurrent, true)..
- [[ of ]]..GenerateCommaValue(FuelRocketTotal, true)..
- [[ | Total Rocket Fuel in ]]..#FuelRocketTanks..[[ tank]]..(#FuelRocketTanks==1 and "" or "s")..[[ (]]..math.floor(100/FuelRocketTotal*FuelRocketCurrent)..[[%)]]
- end
-
- output = output .. [[
-
-
-
- ]]
-
- local DisplayTable = {}
- if screen.fuelIndex == nil or screen.fuelIndex < 1 then
- screen.fuelIndex = 1
- end
-
- if FuelDisplay[1] == true then
- for _,v in ipairs(FuelAtmosphericTanks) do
- table.insert(DisplayTable, v)
- end
- end
- if FuelDisplay[2] == true then
- for _,v in ipairs(FuelSpaceTanks) do
- table.insert(DisplayTable, v)
- end
- end
- if FuelDisplay[3] == true then
- for _,v in ipairs(FuelRocketTanks) do
- table.insert(DisplayTable, v)
- end
- end
-
- table.sort(DisplayTable, function(a,b) return a.type
-
-
- ]]
- if tank.hp == 0 then
- output = output .. [[]]
- elseif tank.maxhp - tank.hp > constants.epsilon then
- output = output .. [[]]
- else
- output = output .. [[]]
- end
- if tank.hp == 0 then output = output .. [[]]..tank.size..[[]]
- else output = output .. [[]]..tank.size..[[]]
- end
-
- if tank.hp == 0 then
- output = output .. [[Broken]] ..
- [[0 of ]]..GenerateCommaValue(tank.vol)..[[]]
- elseif tonumber(tank.percent) < 10 then
- output = output .. [[]]..tank.percent..[[%]] ..
- [[]]..GenerateCommaValue(tank.cvol)..[[ of ]]..GenerateCommaValue(tank.vol)..[[]]
- elseif tonumber(tank.percent) < 30 then
- output = output .. [[]]..tank.percent..[[%]] ..
- [[]]..GenerateCommaValue(tank.cvol)..[[ of ]]..GenerateCommaValue(tank.vol)..[[]]
- else output =
- output .. [[]]..tank.percent..[[%]] ..
- [[]]..GenerateCommaValue(tank.cvol)..[[ of ]]..GenerateCommaValue(tank.vol)..[[]]
- end
-
- output = output ..[[]]..tank.name..[[]]
-
- output = output .. [[]]
-
- end
- end
-
-
-
- if #FuelAtmosphericTanks > 0 then
- output = output .. [[]]
- if FuelDisplay[1] == true then
- output = output .. [[]]
- end
- output = output .. [[ATM]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "ToggleDisplayAtmosphere", x1 = 50, x2 = 100, y1 = 270, y2 = 320} )
- end
-
- if #FuelSpaceTanks > 0 then
- output = output .. [[]]
- if FuelDisplay[2] == true then
- output = output .. [[]]
- end
- output = output .. [[SPC]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "ToggleDisplaySpace", x1 = 200, x2 = 250, y1 = 270, y2 = 320} )
- end
-
- if #FuelRocketTanks > 0 then
- output = output .. [[]]
- if FuelDisplay[3] == true then
- output = output .. [[]]
- end
- output = output .. [[RKT]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "ToggleDisplayRocket", x1 = 350, x2 = 400, y1 = 270, y2 = 320} )
- end
-
- if screen.fuelIndex > 1 then
- output = output .. [[
-
-
- ]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "DecreaseFuelIndex", x1 = 1470, x2 = 1670, y1 = 270, y2 = 320} )
- end
-
- if screen.fuelIndex+cCounter-1 < #DisplayTable then
- output = output .. [[
-
-
- ]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "IncreaseFuelIndex", x1 = 1680, x2 = 1880, y1 = 270, y2 = 320} )
- end
-
- if cCounter > 0 then
- output = output .. [[]]..
- #DisplayTable..
- [[ Tank]]..(#DisplayTable == 1 and "" or "s")..
- [[ (Showing ]]..screen.fuelIndex..[[ to ]]..(screen.fuelIndex+cCounter-1)..[[)]]
- end
-
- return output
-end
-
-function GetContentCargo()
- local output = ""
- output = output .. GetHeader("Cargo Report") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentAGG()
- local output = ""
- output = output .. GetHeader("Anti-Grav Control") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentMap()
- local output = ""
- output = output .. GetHeader("Map Overview") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentTime()
- local output = ""
- output = output .. GetHeader("Time") .. epochTime()
- output = output ..
- [[
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetContentSettings1()
- local output = ""
- output = output .. GetHeader("Settings") .. [[]]
- if BackgroundMode=="" then
- output = output ..[[Activate background]]
- else
- output = output ..[[Deactivate background (']]..BackgroundMode..[[', ]]..string.format("%.0f",BackgroundModeOpacity*100)..[[%)]]
- end
- output = output ..[[
-
- Previous background
-
- Next background
-
-
- Decrease Opacity
-
- Increase Opacity
- ]]
-
- output = output ..
- [[]] ..
- [[Reset background and all colors]]
-
- output = output ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Select and change any of the ]]..#colorIDTable..[[ HUD colors]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]]..colorIDTable[colorIDIndex].desc..[[]] ..
- [[]] ..
- [[Current color]] ..
- [[]] ..
-
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
-
- [[#]] ..
-
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,1,1)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,2,2)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,3,3)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,4,4)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,5,5)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,6,6)..[[]] ..
-
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
-
- [[]] ..
- [[]] ..
- [[New color]] ..
- [[]] ..
- [[Apply new color]] ..
- [[]] ..
- [[Reset]] ..
- [[]]
-
- output = output ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Explanation / Hints]] ..
- [[Coming soon.]]
-
-
- output = output .. [[]]
-
- if SimulationMode == true then
- output = output .. [[Simulating Damage to elements]]
- AddClickArea("settings1", { id = "ToggleSimulation", mode ="settings1", x1 = 940, x2 = 1850, y1 = 919, y2 = 969 })
- else
- output = output .. [[Simulate Damage to elements]]
- AddClickArea("settings1", { id = "ToggleSimulation", mode ="settings1", x1 = 940, x2 = 1850, y1 = 919, y2 = 969 })
- end
-
- return output
-end
-
-function GetContentStartup()
- local output = ""
- output = output .. GetElementLogo(812, 380, "f", "f", "f")
- if YourShipsName == "Enter here" then
- output = output .. [[Spaceship ID ]]..ShipID..[[]]
- else
- output = output .. [[]]..YourShipsName..[[]]
- end
- if ShowWelcomeMessage == true then output = output .. [[Greetings, Commander ]]..PlayerName..[[.]] end
- if #Warnings > 0 then
- output = output .. [[Warning: ]]..(table.concat(Warnings, " "))..[[]]
- end
- output = output .. [[Damage Report v]]..VERSION..[[, by Scion Interstellar, DorianGray - Discord: Dorian Gray#2623. Under GNU Public License 3.0.]]
- return output
-end
-
-function RenderScreen(screen, contentToRender)
- if contentToRender == nil then
- PrintConsole("ERROR: contentToRender is nil.")
- unit.exit()
- end
-
- CreateClickAreasForScreen(screen)
-
- local output =""
- output = output .. [[
-
-
- ]]
-
- output = output .. contentToRender
-
- if screen.mode == "startup" then
- output = output .. [[]]
- else
- output = output .. [[]]
- end
-
- output = output .. [[
-
- ]]
- output = output .. [[]]
-
- -- Center:
-
- --
- --
- --
- --
-
- local outputLength = string.len(output)
- -- PrintConsole("Render: "..screen.mode.." ("..outputLength.." chars)")
- screen.element.setSVG(output)
-end
-
-function RenderScreens(onlymode, onlysubmode)
-
- onlymode = onlymode or "all"
- onlysubmode = onlysubmode or "all"
-
- if screens ~= nil and #screens > 0 then
-
- local contentFlight = ""
- local contentDamage = ""
- local contentDamageoutlineTop = ""
- local contentDamageoutlineSide = ""
- local contentDamageoutlineFront = ""
- local contentFuel = ""
- local contentCargo = ""
- local contentAGG = ""
- local contentMap = ""
- local contentTime = ""
- local contentSettings1 = ""
- local contentStartup = ""
-
- for k,screen in pairs(screens) do
- if screen.refresh == true then
- local contentToRender = ""
-
- if screen.mode == "flight" and (onlymode =="flight" or onlymode =="all") then
- if contentFlight == "" then contentFlight = GetContentFlight() end
- contentToRender = contentFlight
- elseif screen.mode == "damage" and (onlymode =="damage" or onlymode =="all") then
- if contentDamage == "" then contentDamage = GetContentDamage() end
- contentToRender = contentDamage
- elseif screen.mode == "damageoutline" and (onlymode =="damageoutline" or onlymode =="all") then
- if screen.submode == "" then
- screen.submode = "top"
- screens[k].submode = "top"
- end
- if screen.submode == "top" and (onlysubmode == "top" or onlysubmode == "all") then
- if contentDamageoutlineTop == "" then contentDamageoutlineTop = GetContentDamageoutline(screen) end
- contentToRender = contentDamageoutlineTop
- end
- if screen.submode == "side" and (onlysubmode == "side" or onlysubmode == "all") then
- if contentDamageoutlineSide == "" then contentDamageoutlineSide = GetContentDamageoutline(screen) end
- contentToRender = contentDamageoutlineSide
- end
- if screen.submode == "front" and (onlysubmode == "front" or onlysubmode == "all") then
- if contentDamageoutlineFront == "" then contentDamageoutlineFront = GetContentDamageoutline(screen) end
- contentToRender = contentDamageoutlineFront
- end
- elseif screen.mode == "fuel" and (onlymode =="fuel" or onlymode =="all") then
- screen = WipeClickAreasForScreen(screens[k])
- contentToRender = GetContentFuel(screen)
- elseif screen.mode == "cargo" and (onlymode =="cargo" or onlymode =="all") then
- if contentCargo == "" then contentCargo = GetContentCargo() end
- contentToRender = contentCargo
- elseif screen.mode == "agg" and (onlymode =="agg" or onlymode =="all") then
- if contentAGG == "" then contentAGG = GetContentAGG() end
- contentToRender = contentAGG
- elseif screen.mode == "map" and (onlymode =="map" or onlymode =="all") then
- if contentMap == "" then contentMap = GetContentMap() end
- contentToRender = contentMap
- elseif screen.mode == "time" and (onlymode =="time" or onlymode =="all") then
- if contentTime == "" then contentTime = GetContentTime() end
- contentToRender = contentTime
- elseif screen.mode == "settings1" and (onlymode =="settings1" or onlymode =="all") then
- if contentSettings1 == "" then contentSettings1 = GetContentSettings1() end
- contentToRender = contentSettings1
- elseif screen.mode == "startup" and (onlymode =="startup" or onlymode =="all") then
- if contentStartup == "" then contentStartup = GetContentStartup() end
- contentToRender = contentStartup
- else
- contentToRender = "Invalid screen mode. ('"..screen.mode.."')"
- end
-
- if contentToRender ~= "" then
- RenderScreen(screen, contentToRender)
- else
- DrawCenteredText("ERROR: No contentToRender delivered for "..screen.mode)
- PrintConsole("ERROR: No contentToRender delivered for "..screen.mode)
- unit.exit()
- end
- screens[k].refresh = false
- end
- end
- end
-
- if HUDMode == true then
- system.setScreen(GetContentDamageHUDOutput())
- system.showScreen(1)
- else
- system.showScreen(0)
- end
-
-end
-
-function OnTickData(initial)
- if formerTime + 60 < system.getTime() then
- SetRefresh("time")
- end
- totalShipMass = core.getConstructMass()
- if formerTotalShipMass ~= totalShipMass then
- UpdateDamageData(true)
- UpdateTypeData()
- SetRefresh()
- formerTotalShipMass = totalShipMass
- else
- UpdateDamageData(initial)
- UpdateTypeData()
- end
- RenderScreens()
-end
-
---[[ 5. EXECUTION ]]
-
-unit.hide()
-ClearConsole()
-PrintConsole("DAMAGE REPORT v"..VERSION.." STARTED", true)
-InitiateSlots()
-LoadFromDatabank()
-SwitchScreens("on")
-InitiateScreens()
-
-if core == nil then
- PrintConsole("ERROR: Connect the core to the programming board.")
- unit.exit()
-else
- OperatorID = unit.getMasterPlayerId()
- OperatorData = database.getPlayer(OperatorID)
- PlayerName = OperatorData["name"]
- ShipID = core.getConstructId()
-end
-
-if db == nil then
- table.insert(Warnings, "No databank connected, won't save/load settings.")
-end
-
-if YourShipsName == "Enter here" then
- table.insert(Warnings, "No ship name set in LUA settings.")
-end
-
-if SkillRepairToolEfficiency == 0 and SkillRepairToolOptimization == 0 and StatFuelTankOptimization == 0 and StatContainerOptimization ==0 and
- StatAtmosphericFuelTankHandling == 0 and StatSpaceFuelTankHandling == 0 and StatRocketFuelTankHandling ==0 then
- table.insert(Warnings, "No talents/stats set in LUA settings.")
-end
-
-if SkillRepairToolEfficiency < 0 or SkillRepairToolOptimization < 0 or StatFuelTankOptimization < 0 or StatContainerOptimization < 0 or
- StatAtmosphericFuelTankHandling < 0 or StatSpaceFuelTankHandling < 0 or StatRocketFuelTankHandling < 0 or
- SkillRepairToolEfficiency > 5 or SkillRepairToolOptimization > 5 or StatFuelTankOptimization > 5 or StatContainerOptimization > 5 or
- StatAtmosphericFuelTankHandling > 5 or StatSpaceFuelTankHandling > 5 or StatRocketFuelTankHandling > 5 then
- PrintConsole("ERROR: Talents/stats can only range from 0 to 5. Please set correctly in LUA settings and reactivate script.")
- unit.exit()
-end
-
-if screens == nil or #screens == 0 then
- HUDMode = true
- PrintConsole("Warning: No screens connected. Entering HUD mode only.")
-end
-
-OnTickData(true)
-
-unit.setTimer('UpdateData', UpdateDataInterval)
-unit.setTimer('UpdateHighlight', HighlightBlinkingInterval)
\ No newline at end of file
diff --git a/src/DamageReport_3_2_UnitStart_1.lua b/src/DamageReport_3_2_UnitStart_1.lua
deleted file mode 100644
index a13fa35..0000000
--- a/src/DamageReport_3_2_UnitStart_1.lua
+++ /dev/null
@@ -1,2362 +0,0 @@
---[[
- Damage Report 3.2
- A LUA script for Dual Universe
-
- Created By Dorian Gray
- Ingame: DorianGray
- Discord: Dorian Gray#2623
-
- You can find/update this script on GitHub. Explanations, installation and usage information as well as screenshots can be found there too.
- GitHub: https://github.com/DorianTheGrey/DU-DamageReport
-
- GNU Public License 3.0. Use whatever you want, be so kind to leave credit.
-
- Credits & thanks:
- Thanks to Bayouking1 and kalazzerx for managing their forks of this script during my long absence to support the community. :)
- Thanks to Bayouking1 for fixing rocket fuel calculations.
- Thanks to NovaQuark for creating the MMO of the century.
- Thanks to Jericho, Dmentia and Archaegeo for learning a lot from their fine scripts.
- Thanks to TheBlacklist for testing and wonderful suggestions.
- SVG patterns by Hero Patterns.
- DU atlas data from Jayle Break.
-
-]]
-
- --[[ 1. USER DEFINED VARIABLES ]] YourShipsName = "Enter here" -- export Enter your ship name here if you want it displayed instead of the ship's ID. YOU NEED TO LEAVE THE QUOTATION MARKS.
-
-SkillRepairToolEfficiency = 0 -- export Enter (0-5) your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency"
-SkillRepairToolOptimization = 0 -- export Enter your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Optimization"
-
-StatAtmosphericFuelTankHandling = 0 -- export (0-5) Enter the LEVEL OF YOUR PLACED ATMOSPHERIC FUEL TANKS (from the builders talent "Piloting -> Atmospheric Flight Technician -> Atmospheric Fuel-Tank Handling")
-StatSpaceFuelTankHandling = 0 -- export (0-5) Enter the LEVEL OF YOUR PLACED FUEL SPACE TANKS (from the builders talent "Piloting -> Atmospheric Engine Technician -> Space Handling")
-StatRocketFuelTankHandling = 0 -- export (0-5) Enter the LEVEL OF YOUR PLACED FUEL ROCKET TANKS (from the builders talent "Piloting -> Rocket Scientist -> Rocket Booster Fuel Tank Handling")
-StatContainerOptimization = 0 -- export (0-5) Enter the LEVEL OF YOUR PLACED FUEL TANKS "from the builders talent Mining and Inventory -> Stock Control -> Container Optimization"
-StatFuelTankOptimization = 0 -- export (0-5) Enter the LEVEL OF YOUR PLACED FUEL TANKS "from the builders talent Mining and Inventory -> Stock Control -> Fuel Tank Optimization"
-
-ShowWelcomeMessage = true -- export Do you want the welcome message on the start screen with your name?
-DisallowKeyPresses = false -- export Need your keys for other scripts/huds and want to prevent Damage Report keypresses to be processed? Then check this. (Usability of the HUD mode will be small.)
-AddSummertimeHour = false -- export: Is summertime currently enabled in your location? (Adds one hour.)
-
-UpdateDataInterval = 1.0;
-HighlightBlinkingInterval = 0.5;
-ColorPrimary = "FF6700"
-ColorSecondary = "FFFFFF"
-ColorTertiary = "000000"
-ColorHealthy = "00FF00"
-ColorWarning = "FFFF00"
-ColorCritical = "FF0000"
-ColorBackground = "000000"
-ColorBackgroundPattern = "4F4F4F"
-ColorFuelAtmospheric = "004444"
-ColorFuelSpace = "444400"
-ColorFuelRocket = "440044"
-VERSION = 3.2;
-DebugMode = false;
-DebugRenderClickareas = true;
-DBData = {}
-core = nil;
-db = nil;
-screens = {}
-dscreens = {}
-Warnings = {}
-screenModes = {
- ["flight"] = {id = "flight"},
- ["damage"] = {id = "damage"},
- ["damageoutline"] = {id = "damageoutline"},
- ["fuel"] = {id = "fuel"},
- ["cargo"] = {id = "cargo"},
- ["agg"] = {id = "agg"},
- ["map"] = {id = "map"},
- ["time"] = {id = "time", activetoggle = "true"},
- ["settings1"] = {id = "settings1"},
- ["startup"] = {id = "startup"}
-}
-backgroundModes = {
- "deathstar", "capsule", "rain", "signal", "hexagon", "diagonal", "diamond",
- "plus", "dots"
-}
-BackgroundMode = "deathstar"
-BackgroundSelected = 1;
-BackgroundModeOpacity = 0.25;
-SaveVars = {
- "dscreens", "ColorPrimary", "ColorSecondary", "ColorTertiary",
- "ColorHealthy", "ColorWarning", "ColorCritical", "ColorBackground",
- "ColorBackgroundPattern", "ColorFuelAtmospheric", "ColorFuelSpace",
- "ColorFuelRocket", "ScrapTier", "HUDMode", "SimulationMode", "DMGOStretch",
- "HUDShiftU", "HUDShiftV", "colorIDIndex", "colorIDTable", "BackgroundMode",
- "BackgroundSelected", "BackgroundModeOpacity"
-}
-HUDMode = false;
-HUDShiftU = 0;
-HUDShiftV = 0;
-hudSelectedIndex = 0;
-hudStartIndex = 1;
-hudArrowSticker = {}
-highlightOn = false;
-highlightID = 0;
-highlightX = 0;
-highlightY = 0;
-highlightZ = 0;
-SimulationMode = false;
-OkayCenterMessage = "All systems nominal."
-CurrentDamagedPage = 1;
-CurrentBrokenPage = 1;
-DamagePageSize = 12;
-ScrapTier = 1;
-totalScraps = 0;
-ScrapTierRepairTimes = {10, 50, 250, 1250}
-coreWorldOffset = 0;
-totalShipHP = 0;
-formerTotalShipHP = -1;
-totalShipMaxHP = 0;
-totalShipIntegrity = 100;
-elementsId = {}
-elementsIdList = {}
-damagedElements = {}
-brokenElements = {}
-rE = {}
-healthyElements = {}
-typeElements = {}
-ElementCounter = 0;
-UseMyElementNames = true;
-dmgoElements = {}
-DMGOMaxElements = 250;
-DMGOStretch = false;
-ShipXmin = 99999999;
-ShipXmax = -99999999;
-ShipYmin = 99999999;
-ShipYmax = -99999999;
-ShipZmin = 99999999;
-ShipZmax = -99999999;
-totalShipMass = 0;
-formerTotalShipMass = -1;
-formerTime = -1;
-FuelAtmosphericTanks = {}
-FuelSpaceTanks = {}
-FuelRocketTanks = {}
-FuelAtmosphericTotal = 0;
-FuelSpaceTotal = 0;
-FuelRocketTotal = 0;
-FuelAtmosphericCurrent = 0;
-FuelSpaceTotalCurrent = 0;
-FuelRocketTotalCurrent = 0;
-formerFuelAtmosphericTotal = -1;
-formerFuelSpaceTotal = -1;
-formerFuelRocketTotal = -1;
-hexTable = {
- "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E",
- "F"
-}
-colorIDIndex = 1;
-colorIDTable = {
- [1] = {
- id = "ColorPrimary",
- desc = "Main HUD Color",
- basec = "FF6700",
- newc = "FF6700"
- },
- [2] = {
- id = "ColorSecondary",
- desc = "Secondary HUD Color",
- basec = "FFFFFF",
- newc = "FFFFFF"
- },
- [3] = {
- id = "ColorTertiary",
- desc = "Tertiary HUD Color",
- basec = "000000",
- newc = "000000"
- },
- [4] = {
- id = "ColorHealthy",
- desc = "Color code for Healthy/Okay",
- basec = "00FF00",
- newc = "00FF00"
- },
- [5] = {
- id = "ColorWarning",
- desc = "Color code for Damaged/Warning",
- basec = "FFFF00",
- newc = "FFFF00"
- },
- [6] = {
- id = "ColorCritical",
- desc = "Color code for Broken/Critical",
- basec = "FF0000",
- newc = "FF0000"
- },
- [7] = {
- id = "ColorBackground",
- desc = "Background Color",
- basec = "000000",
- newc = "000000"
- },
- [8] = {
- id = "ColorBackgroundPattern",
- desc = "Background Pattern Color",
- basec = "4F4F4F",
- newc = "4F4F4F"
- },
- [9] = {
- id = "ColorFuelAtmospheric",
- desc = "Color for Atmo Fuel/Elements",
- basec = "004444",
- newc = "004444"
- },
- [10] = {
- id = "ColorFuelSpace",
- desc = "Color for Space Fuel/Elements",
- basec = "444400",
- newc = "444400"
- },
- [11] = {
- id = "ColorFuelRocket",
- desc = "Color for Rocket Fuel/Elements",
- basec = "440044",
- newc = "440044"
- }
-}
-function InitiateSlots()
- for a, b in pairs(unit) do
- if type(b) == "table" and type(b.export) == "table" and
- b.getElementClass then
- local c = b.getElementClass():lower()
- if c:find("coreunit") then
- core = b;
- local d = core.getMaxHitPoints()
- if d > 10000 then
- coreWorldOffset = 128
- elseif d > 1000 then
- coreWorldOffset = 64
- elseif d > 150 then
- coreWorldOffset = 32
- else
- coreWorldOffset = 16
- end
- elseif c == 'databankunit' then
- db = b
- elseif c == "screenunit" then
- local e = "startup"
- screens[#screens + 1] = {
- element = b,
- id = b.getId(),
- mode = e,
- submode = "",
- ClickAreas = {},
- refresh = true,
- active = false,
- fuelA = true,
- fuelS = true,
- fuelR = true,
- fuelIndex = 1
- }
- end
- end
- end
-end
-function LoadFromDatabank()
- if db == nil then
- return
- else
- for f, g in pairs(SaveVars) do
- if db.hasKey(g) then
- local h = json.decode(db.getStringValue(g))
- if h ~= nil then
- if g == "YourShipsName" or g == "AddSummertimeHour" or g ==
- "UpdateDataInterval" or g == "HighlightBlinkingInterval" or
- g == "SkillRepairToolEfficiency" or g ==
- "SkillRepairToolOptimization" or g ==
- "SkillAtmosphericFuelEfficiency" or g ==
- "SkillSpaceFuelEfficiency" or g ==
- "SkillRocketFuelEfficiency" or g ==
- "StatAtmosphericFuelTankHandling" or g ==
- "StatSpaceFuelTankHandling" or g ==
- "StatRocketFuelTankHandling" then
- else
- _G[g] = h
- end
- end
- end
- end
- for i, j in ipairs(screens) do
- for k, l in ipairs(dscreens) do
- if screens[i].id == dscreens[k].id then
- screens[i].mode = dscreens[k].mode;
- screens[i].submode = dscreens[k].submode;
- screens[i].active = dscreens[k].active;
- screens[i].refresh = true;
- screens[i].fuelA = dscreens[k].fuelA;
- screens[i].fuelS = dscreens[k].fuelS;
- screens[i].fuelR = dscreens[k].fuelR;
- screens[i].fuelIndex = dscreens[k].fuelIndex
- end
- end
- end
- end
-end
-function SaveToDatabank()
- if db == nil then
- return
- else
- dscreens = {}
- for i, m in ipairs(screens) do
- dscreens[i] = {}
- dscreens[i].id = m.id;
- dscreens[i].mode = m.mode;
- dscreens[i].submode = m.submode;
- dscreens[i].active = m.active;
- dscreens[i].fuelA = m.fuelA;
- dscreens[i].fuelS = m.fuelS;
- dscreens[i].fuelR = m.fuelR;
- dscreens[i].fuelIndex = m.fuelIndex
- end
- db.clear()
- for f, g in pairs(SaveVars) do
- db.setStringValue(g, json.encode(_G[g]))
- end
- end
-end
-function InitiateScreens()
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- screens[i] = CreateClickAreasForScreen(screens[i])
- end
- end
-end
-function UpdateTypeData()
- FuelAtmosphericTanks = {}
- FuelSpaceTanks = {}
- FuelRocketTanks = {}
- FuelAtmosphericTotal = 0;
- FuelAtmosphericCurrent = 0;
- FuelSpaceTotal = 0;
- FuelSpaceCurrent = 0;
- FuelRocketCurrent = 0;
- FuelRocketTotal = 0;
- local n = 4;
- local o = 6;
- local p = 0.8;
- if StatContainerOptimization > 0 then
- n = n - 0.05 * StatContainerOptimization * n;
- o = o - 0.05 * StatContainerOptimization * o;
- p = p - 0.05 * StatContainerOptimization * p
- end
- if StatFuelTankOptimization > 0 then
- n = n - 0.05 * StatFuelTankOptimization * n;
- o = o - 0.05 * StatFuelTankOptimization * o;
- p = p - 0.05 * StatFuelTankOptimization * p
- end
- for i, q in ipairs(typeElements) do
- local r = core.getElementNameById(q) or ""
- local s = core.getElementTypeById(q) or ""
- local t = core.getElementPositionById(q) or 0;
- local u = core.getElementHitPointsById(q) or 0;
- local v = core.getElementMaxHitPointsById(q) or 0;
- local w = core.getElementMassById(q) or 0;
- local x = ""
- local y = 0;
- local z = 0;
- local A = 0;
- local B = 0;
- if s == "Atmospheric Fuel Tank" then
- if v > 10000 then
- x = "L"
- z = 5480;
- y = 12800
- elseif v > 1300 then
- x = "M"
- z = 988.67;
- y = 1600
- elseif v > 150 then
- x = "S"
- z = 182.67;
- y = 400
- else
- x = "XS"
- z = 35.03;
- y = 100
- end
- if StatAtmosphericFuelTankHandling > 0 then
- y = 0.2 * StatAtmosphericFuelTankHandling * y + y
- end
- A = w - z;
- if A <= 10 then A = 0 end
- B = string.format("%.0f", A / n)
- cPercent = string.format("%.1f", math.floor(100 / y * tonumber(B)))
- table.insert(FuelAtmosphericTanks, {
- type = 1,
- id = q,
- name = r,
- maxhp = v,
- hp = GetHPforElement(q),
- pos = t,
- size = x,
- mass = z,
- vol = y,
- cvol = B,
- percent = cPercent
- })
- if u > 0 then
- FuelAtmosphericCurrent = FuelAtmosphericCurrent + B
- end
- FuelAtmosphericTotal = FuelAtmosphericTotal + y
- elseif s == "Space Fuel Tank" then
- if v > 10000 then
- x = "L"
- z = 5480;
- y = 12800
- elseif v > 1300 then
- x = "M"
- z = 988.67;
- y = 1600
- else
- x = "S"
- z = 182.67;
- y = 400
- end
- if StatSpaceFuelTankHandling > 0 then
- y = 0.2 * StatSpaceFuelTankHandling * y + y
- end
- A = w - z;
- if A <= 10 then A = 0 end
- B = string.format("%.0f", A / o)
- cPercent = string.format("%.1f", 100 / y * tonumber(B))
- table.insert(FuelSpaceTanks, {
- type = 2,
- id = q,
- name = r,
- maxhp = v,
- hp = GetHPforElement(q),
- pos = t,
- size = x,
- mass = z,
- vol = y,
- cvol = B,
- percent = cPercent
- })
- if u > 0 then FuelSpaceCurrent = FuelSpaceCurrent + B end
- FuelSpaceTotal = FuelSpaceTotal + y
- elseif s == "Rocket Fuel Tank" then
- if v > 65000 then
- x = "L"
- z = 25740;
- y = 50000
- elseif v > 6000 then
- x = "M"
- z = 4720;
- y = 6400
- elseif v > 700 then
- x = "S"
- z = 886.72;
- y = 800
- else
- x = "XS"
- z = 173.42;
- y = 400
- end
- if StatRocketFuelTankHandling > 0 then
- y = 0.1 * StatRocketFuelTankHandling * y + y
- end
- A = w - z;
- if A <= 10 then A = 0 end
- B = string.format("%.0f", A / p)
- cPercent = string.format("%.1f", 100 / y * tonumber(B))
- table.insert(FuelRocketTanks, {
- type = 3,
- id = q,
- name = r,
- maxhp = v,
- hp = GetHPforElement(q),
- pos = t,
- size = x,
- mass = z,
- vol = y,
- cvol = B,
- percent = cPercent
- })
- if u > 0 then FuelRocketCurrent = FuelRocketCurrent + B end
- FuelRocketTotal = FuelRocketTotal + y
- end
- end
- if FuelAtmosphericCurrent ~= formerFuelAtmosphericCurrent then
- SetRefresh("fuel")
- formerFuelAtmosphericCurrent = FuelAtmosphericCurrent
- end
- if FuelSpaceCurrent ~= formerFuelSpaceCurrent then
- SetRefresh("fuel")
- formerFuelSpaceCurrent = FuelSpaceCurrent
- end
- if FuelRocketCurrent ~= formerFuelRocketCurrent then
- SetRefresh("fuel")
- formerFuelRocketCurrent = FuelRocketCurrent
- end
-end
-function UpdateDamageData(C)
- C = C or false;
- if SimulationActive == true then return end
- local formerTotalShipHP = totalShipHP;
- totalShipHP = 0;
- totalShipMaxHP = 0;
- totalShipIntegrity = 100;
- damagedElements = {}
- brokenElements = {}
- healthyElements = {}
- if C == true then typeElements = {} end
- ElementCounter = 0;
- elementsIdList = core.getElementIdList()
- for i, q in pairs(elementsIdList) do
- ElementCounter = ElementCounter + 1;
- local r = core.getElementNameById(q)
- local s = core.getElementTypeById(q)
- local t = core.getElementPositionById(q)
- local u = core.getElementHitPointsById(q)
- local v = core.getElementMaxHitPointsById(q)
- if SimulationMode == true then
- SimulationActive = true;
- local D = math.random(0, 10)
- if D < 2 and #brokenElements < 30 then
- u = 0
- elseif D >= 2 and D < 4 and #damagedElements < 30 then
- u = math.random(1, math.ceil(v))
- else
- u = v
- end
- end
- totalShipHP = totalShipHP + u;
- totalShipMaxHP = totalShipMaxHP + v;
- if v - u > constants.epsilon then
- if u > 0 then
- table.insert(damagedElements, {
- id = q,
- name = r,
- type = s,
- counter = ElementCounter,
- hp = u,
- maxhp = v,
- missinghp = v - u,
- percent = math.ceil(100 / v * u),
- pos = t
- })
- else
- table.insert(brokenElements, {
- id = q,
- name = r,
- type = s,
- counter = ElementCounter,
- hp = u,
- maxhp = v,
- missinghp = v - u,
- percent = 0,
- pos = t
- })
- end
- else
- table.insert(healthyElements, {
- id = q,
- name = r,
- type = s,
- counter = ElementCounter,
- hp = u,
- maxhp = v,
- pos = t
- })
- if q == highlightID then
- highlightID = 0;
- highlightOn = false;
- HideHighlight()
- hudSelectedIndex = 0
- end
- end
- if C == true then
- if s == "Atmospheric Fuel Tank" or s == "Space Fuel Tank" or s ==
- "Rocket Fuel Tank" then table.insert(typeElements, q) end
- end
- end
- SortDamageTables()
- rE = {}
- if #brokenElements > 0 then
- for f, j in ipairs(brokenElements) do
- table.insert(rE, {
- id = j.id,
- missinghp = j.missinghp,
- hp = j.hp,
- name = j.name,
- type = j.type,
- pos = j.pos
- })
- end
- end
- if #damagedElements > 0 then
- for f, j in ipairs(damagedElements) do
- table.insert(rE, {
- id = j.id,
- missinghp = j.missinghp,
- hp = j.hp,
- name = j.name,
- type = j.type,
- pos = j.pos
- })
- end
- end
- if #rE > 0 then
- table.sort(rE, function(E, F) return E.missinghp > F.missinghp end)
- end
- totalShipIntegrity = string.format("%2.0f",
- 100 / totalShipMaxHP * totalShipHP)
- if formerTotalShipHP ~= totalShipHP then
- forceDamageRedraw = true;
- formerTotalShipHP = totalShipHP
- else
- forceDamageRedraw = false
- end
-end
-function GetHPforElement(q)
- for i, j in ipairs(brokenElements) do if j.id == q then return 0 end end
- for i, j in ipairs(damagedElements) do if j.id == q then return j.hp end end
- for i, j in ipairs(healthyElements) do
- if j.id == q then return j.maxhp end
- end
-end
-function UpdateClickArea(G, H, I)
- for i, m in ipairs(screens) do
- for J, j in pairs(screens[i].ClickAreas) do
- if j.id == G and j.mode == I then
- screens[i].ClickAreas[J] = H
- end
- end
- end
-end
-function AddClickArea(I, H)
- for i, m in ipairs(screens) do
- if screens[i].mode == I then
- table.insert(screens[i].ClickAreas, H)
- end
- end
-end
-function AddClickAreaForScreenID(K, H)
- for i, m in ipairs(screens) do
- if screens[i].id == K then table.insert(screens[i].ClickAreas, H) end
- end
-end
-function DisableClickArea(G, I)
- UpdateClickArea(G, {id = G, mode = I, x1 = -1, x2 = -1, y1 = -1, y2 = -1})
-end
-function SetRefresh(I, L)
- I = I or "all"
- L = L or "all"
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- if screens[i].mode == I or I == "all" then
- if screens[i].submode == L or L == "all" then
- screens[i].refresh = true
- end
- end
- end
- end
-end
-function WipeClickAreasForScreen(m)
- m.ClickAreas = {}
- return m
-end
-function CreateBaseClickAreas(m)
- table.insert(m.ClickAreas, {
- mode = "all",
- id = "ToggleHudMode",
- x1 = 1537,
- x2 = 1728,
- y1 = 1015,
- y2 = 1075
- })
- table.insert(m.ClickAreas, {
- mode = "all",
- id = "ButtonPress",
- param = "damage",
- x1 = 193,
- x2 = 384,
- y1 = 1015,
- y2 = 1075
- })
- table.insert(m.ClickAreas, {
- mode = "all",
- id = "ButtonPress",
- param = "damageoutline",
- x1 = 385,
- x2 = 576,
- y1 = 1015,
- y2 = 1075
- })
- table.insert(m.ClickAreas, {
- mode = "all",
- id = "ButtonPress",
- param = "fuel",
- x1 = 577,
- x2 = 768,
- y1 = 1015,
- y2 = 1075
- })
- table.insert(m.ClickAreas, {
- mode = "all",
- id = "ButtonPress",
- param = "time",
- x1 = 0,
- x2 = 192,
- y1 = 1015,
- y2 = 1075
- })
- table.insert(m.ClickAreas, {
- mode = "all",
- id = "ButtonPress",
- param = "settings1",
- x1 = 1729,
- x2 = 1920,
- y1 = 1015,
- y2 = 1075
- })
- return m
-end
-function CreateClickAreasForScreen(m)
- if m == nil then return {} end
- if m.mode == "flight" then
- elseif m.mode == "damage" then
- table.insert(m.ClickAreas, {
- mode = "damage",
- id = "ToggleElementLabel",
- x1 = 70,
- x2 = 425,
- y1 = 325,
- y2 = 355
- })
- table.insert(m.ClickAreas, {
- mode = "damage",
- id = "ToggleElementLabel2",
- x1 = 980,
- x2 = 1400,
- y1 = 325,
- y2 = 355
- })
- elseif m.mode == "damageoutline" then
- table.insert(m.ClickAreas, {
- mode = "damageoutline",
- id = "DMGOChangeView",
- param = "top",
- x1 = 60,
- x2 = 439,
- y1 = 150,
- y2 = 200
- })
- table.insert(m.ClickAreas, {
- mode = "damageoutline",
- id = "DMGOChangeView",
- param = "side",
- x1 = 440,
- x2 = 824,
- y1 = 150,
- y2 = 200
- })
- table.insert(m.ClickAreas, {
- mode = "damageoutline",
- id = "DMGOChangeView",
- param = "front",
- x1 = 825,
- x2 = 1215,
- y1 = 150,
- y2 = 200
- })
- table.insert(m.ClickAreas, {
- mode = "damageoutline",
- id = "DMGOChangeStretch",
- x1 = 1530,
- x2 = 1580,
- y1 = 150,
- y2 = 200
- })
- elseif m.mode == "fuel" then
- elseif m.mode == "cargo" then
- elseif m.mode == "agg" then
- elseif m.mode == "map" then
- elseif m.mode == "time" then
- elseif m.mode == "settings1" then
- table.insert(m.ClickAreas, {
- mode = "settings1",
- id = "ToggleBackground",
- x1 = 75,
- x2 = 860,
- y1 = 170,
- y2 = 215
- })
- table.insert(m.ClickAreas, {
- mode = "settings1",
- id = "PreviousBackground",
- x1 = 75,
- x2 = 460,
- y1 = 235,
- y2 = 285
- })
- table.insert(m.ClickAreas, {
- mode = "settings1",
- id = "NextBackground",
- x1 = 480,
- x2 = 860,
- y1 = 235,
- y2 = 285
- })
- table.insert(m.ClickAreas, {
- mode = "settings1",
- id = "DecreaseOpacity",
- x1 = 75,
- x2 = 460,
- y1 = 300,
- y2 = 350
- })
- table.insert(m.ClickAreas, {
- mode = "settings1",
- id = "IncreaseOpacity",
- x1 = 480,
- x2 = 860,
- y1 = 300,
- y2 = 350
- })
- table.insert(m.ClickAreas, {
- mode = "settings1",
- id = "ResetColors",
- x1 = 75,
- x2 = 860,
- y1 = 370,
- y2 = 415
- })
- table.insert(m.ClickAreas, {
- mode = "settings1",
- id = "PreviousColorID",
- x1 = 90,
- x2 = 140,
- y1 = 500,
- y2 = 550
- })
- table.insert(m.ClickAreas, {
- mode = "settings1",
- id = "NextColorID",
- x1 = 795,
- x2 = 845,
- y1 = 500,
- y2 = 550
- })
- table.insert(m.ClickAreas, {
- mode = "settings1",
- id = "ColorPosUp",
- param = "1",
- x1 = 210,
- x2 = 290,
- y1 = 655,
- y2 = 700
- })
- table.insert(m.ClickAreas, {
- mode = "settings1",
- id = "ColorPosUp",
- param = "2",
- x1 = 300,
- x2 = 380,
- y1 = 655,
- y2 = 700
- })
- table.insert(m.ClickAreas, {
- mode = "settings1",
- id = "ColorPosUp",
- param = "3",
- x1 = 385,
- x2 = 465,
- y1 = 655,
- y2 = 700
- })
- table.insert(m.ClickAreas, {
- mode = "settings1",
- id = "ColorPosUp",
- param = "4",
- x1 = 470,
- x2 = 550,
- y1 = 655,
- y2 = 700
- })
- table.insert(m.ClickAreas, {
- mode = "settings1",
- id = "ColorPosUp",
- param = "5",
- x1 = 560,
- x2 = 640,
- y1 = 655,
- y2 = 700
- })
- table.insert(m.ClickAreas, {
- mode = "settings1",
- id = "ColorPosUp",
- param = "6",
- x1 = 645,
- x2 = 725,
- y1 = 655,
- y2 = 700
- })
- table.insert(m.ClickAreas, {
- mode = "settings1",
- id = "ColorPosDown",
- param = "1",
- x1 = 210,
- x2 = 290,
- y1 = 740,
- y2 = 780
- })
- table.insert(m.ClickAreas, {
- mode = "settings1",
- id = "ColorPosDown",
- param = "2",
- x1 = 300,
- x2 = 380,
- y1 = 740,
- y2 = 780
- })
- table.insert(m.ClickAreas, {
- mode = "settings1",
- id = "ColorPosDown",
- param = "3",
- x1 = 385,
- x2 = 465,
- y1 = 740,
- y2 = 780
- })
- table.insert(m.ClickAreas, {
- mode = "settings1",
- id = "ColorPosDown",
- param = "4",
- x1 = 470,
- x2 = 550,
- y1 = 740,
- y2 = 780
- })
- table.insert(m.ClickAreas, {
- mode = "settings1",
- id = "ColorPosDown",
- param = "5",
- x1 = 560,
- x2 = 640,
- y1 = 740,
- y2 = 780
- })
- table.insert(m.ClickAreas, {
- mode = "settings1",
- id = "ColorPosDown",
- param = "6",
- x1 = 645,
- x2 = 725,
- y1 = 740,
- y2 = 780
- })
- table.insert(m.ClickAreas, {
- mode = "settings1",
- id = "ResetPosColor",
- x1 = 160,
- x2 = 340,
- y1 = 885,
- y2 = 935
- })
- table.insert(m.ClickAreas, {
- mode = "settings1",
- id = "ApplyPosColor",
- x1 = 355,
- x2 = 780,
- y1 = 885,
- y2 = 935
- })
- elseif m.mode == "startup" then
- end
- m = CreateBaseClickAreas(m)
- return m
-end
-function CheckClick(M, N, O)
- M = M * 1920;
- N = N * 1120;
- O = O or ""
- HitPayload = {}
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- if screens[i].active == true and screens[i].element.getMouseX() ~=
- -1 and screens[i].element.getMouseY() ~= -1 then
- if O == "" then
- for J, j in pairs(screens[i].ClickAreas) do
- if j ~= nil and M >= j.x1 and M <= j.x2 and N >= j.y1 and
- N <= j.y2 then
- O = j.id;
- HitPayload = j;
- break
- end
- end
- end
- if O == "ButtonPress" then
- if screens[i].mode == HitPayload.param then
- screens[i].mode = "startup"
- else
- screens[i].mode = HitPayload.param
- end
- if screens[i].mode == "damageoutline" then
- if screens[i].submode == "" then
- screens[i].submode = "top"
- end
- end
- screens[i].refresh = true;
- screens[i].ClickAreas = {}
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif O == "ToggleBackground" and
- (HitPayload.mode == screens[i].mode or HitPayload.mode ==
- "all") then
- if BackgroundMode == "" then
- BackgroundSelected = 1;
- BackgroundMode = backgroundModes[BackgroundSelected]
- else
- BackgroundSelected = 1;
- BackgroundMode = ""
- end
- for J, m in pairs(screens) do
- screens[J].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif O == "PreviousBackground" and
- (HitPayload.mode == screens[i].mode or HitPayload.mode ==
- "all") then
- if BackgroundMode == "" then
- BackgroundSelected = 1;
- BackgroundMode = backgroundModes[BackgroundSelected]
- else
- if BackgroundSelected <= 1 then
- BackgroundSelected = #backgroundModes
- else
- BackgroundSelected = BackgroundSelected - 1
- end
- BackgroundMode = backgroundModes[BackgroundSelected]
- end
- for J, m in pairs(screens) do
- screens[J].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif O == "NextBackground" and
- (HitPayload.mode == screens[i].mode or HitPayload.mode ==
- "all") then
- if BackgroundMode == "" then
- BackgroundSelected = 1;
- BackgroundMode = backgroundModes[BackgroundSelected]
- else
- if BackgroundSelected >= #backgroundModes then
- BackgroundSelected = 1
- else
- BackgroundSelected = BackgroundSelected + 1
- end
- BackgroundMode = backgroundModes[BackgroundSelected]
- end
- for J, m in pairs(screens) do
- screens[J].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif O == "DecreaseOpacity" and
- (HitPayload.mode == screens[i].mode or HitPayload.mode ==
- "all") then
- if BackgroundModeOpacity > 0.1 then
- BackgroundModeOpacity = BackgroundModeOpacity - 0.05;
- for J, m in pairs(screens) do
- screens[J].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- end
- elseif O == "IncreaseOpacity" and
- (HitPayload.mode == screens[i].mode or HitPayload.mode ==
- "all") then
- if BackgroundModeOpacity < 1.0 then
- BackgroundModeOpacity = BackgroundModeOpacity + 0.05;
- for J, m in pairs(screens) do
- screens[J].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- end
- elseif O == "ResetColors" and
- (HitPayload.mode == screens[i].mode or HitPayload.mode ==
- "all") then
- db.clear()
- ColorPrimary = "FF6700"
- ColorSecondary = "FFFFFF"
- ColorTertiary = "000000"
- ColorHealthy = "00FF00"
- ColorWarning = "FFFF00"
- ColorCritical = "FF0000"
- ColorBackground = "000000"
- ColorBackgroundPattern = "4f4f4f"
- ColorFuelAtmospheric = "004444"
- ColorFuelSpace = "444400"
- ColorFuelRocket = "440044"
- BackgroundMode = "deathstar"
- BackgroundSelected = 1;
- BackgroundModeOpacity = 0.25;
- colorIDTable = {
- [1] = {
- id = "ColorPrimary",
- desc = "Main HUD Color",
- basec = "FF6700",
- newc = "FF6700"
- },
- [2] = {
- id = "ColorSecondary",
- desc = "Secondary HUD Color",
- basec = "FFFFFF",
- newc = "FFFFFF"
- },
- [3] = {
- id = "ColorTertiary",
- desc = "Tertiary HUD Color",
- basec = "000000",
- newc = "000000"
- },
- [4] = {
- id = "ColorHealthy",
- desc = "Color code for Healthy/Okay",
- basec = "00FF00",
- newc = "00FF00"
- },
- [5] = {
- id = "ColorWarning",
- desc = "Color code for Damaged/Warning",
- basec = "FFFF00",
- newc = "FFFF00"
- },
- [6] = {
- id = "ColorCritical",
- desc = "Color code for Broken/Critical",
- basec = "FF0000",
- newc = "FF0000"
- },
- [7] = {
- id = "ColorBackground",
- desc = "Background Color",
- basec = "000000",
- newc = "000000"
- },
- [8] = {
- id = "ColorBackgroundPattern",
- desc = "Background Pattern Color",
- basec = "4F4F4F",
- newc = "4F4F4F"
- },
- [9] = {
- id = "ColorFuelAtmospheric",
- desc = "Color for Atmo Fuel/Elements",
- basec = "004444",
- newc = "004444"
- },
- [10] = {
- id = "ColorFuelSpace",
- desc = "Color for Space Fuel/Elements",
- basec = "444400",
- newc = "444400"
- },
- [11] = {
- id = "ColorFuelRocket",
- desc = "Color for Rocket Fuel/Elements",
- basec = "440044",
- newc = "440044"
- }
- }
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif O == "PreviousColorID" and
- (HitPayload.mode == screens[i].mode or HitPayload.mode ==
- "all") then
- colorIDIndex = colorIDIndex - 1;
- if colorIDIndex < 1 then
- colorIDIndex = #colorIDTable
- end
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif O == "NextColorID" and
- (HitPayload.mode == screens[i].mode or HitPayload.mode ==
- "all") then
- colorIDIndex = colorIDIndex + 1;
- if colorIDIndex > #colorIDTable then
- colorIDIndex = 1
- end
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif O == "ColorPosUp" and
- (HitPayload.mode == screens[i].mode or HitPayload.mode ==
- "all") then
- local P = tonumber(string.sub(
- colorIDTable[colorIDIndex].newc,
- HitPayload.param, HitPayload.param),
- 16)
- P = P + 1;
- if P > 15 then P = 0 end
- colorIDTable[colorIDIndex].newc =
- replace_char(HitPayload.param,
- colorIDTable[colorIDIndex].newc,
- hexTable[P + 1])
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif O == "ColorPosDown" and
- (HitPayload.mode == screens[i].mode or HitPayload.mode ==
- "all") then
- local P = tonumber(string.sub(
- colorIDTable[colorIDIndex].newc,
- HitPayload.param, HitPayload.param),
- 16)
- P = P - 1;
- if P < 0 then P = 15 end
- colorIDTable[colorIDIndex].newc =
- replace_char(HitPayload.param,
- colorIDTable[colorIDIndex].newc,
- hexTable[P + 1])
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif O == "ResetPosColor" and
- (HitPayload.mode == screens[i].mode or HitPayload.mode ==
- "all") then
- colorIDTable[colorIDIndex].newc =
- colorIDTable[colorIDIndex].basec;
- _G[colorIDTable[colorIDIndex].id] =
- colorIDTable[colorIDIndex].basec;
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif O == "ApplyPosColor" and
- (HitPayload.mode == screens[i].mode or HitPayload.mode ==
- "all") then
- _G[colorIDTable[colorIDIndex].id] =
- colorIDTable[colorIDIndex].newc;
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif O == "DamagedPageDown" and
- (HitPayload.mode == screens[i].mode or HitPayload.mode ==
- "all") then
- CurrentDamagedPage = CurrentDamagedPage + 1;
- if CurrentDamagedPage >
- math.ceil(#damagedElements / DamagePageSize) then
- CurrentDamagedPage =
- math.ceil(#damagedElements / DamagePageSize)
- end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif O == "DamagedPageUp" and
- (HitPayload.mode == screens[i].mode or HitPayload.mode ==
- "all") then
- CurrentDamagedPage = CurrentDamagedPage - 1;
- if CurrentDamagedPage < 1 then
- CurrentDamagedPage = 1
- end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif O == "BrokenPageDown" and
- (HitPayload.mode == screens[i].mode or HitPayload.mode ==
- "all") then
- CurrentBrokenPage = CurrentBrokenPage + 1;
- if CurrentBrokenPage >
- math.ceil(#brokenElements / DamagePageSize) then
- CurrentBrokenPage =
- math.ceil(#brokenElements / DamagePageSize)
- end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif O == "BrokenPageUp" and
- (HitPayload.mode == screens[i].mode or HitPayload.mode ==
- "all") then
- CurrentBrokenPage = CurrentBrokenPage - 1;
- if CurrentBrokenPage < 1 then
- CurrentBrokenPage = 1
- end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif O == "DMGOChangeView" and
- (HitPayload.mode == screens[i].mode or HitPayload.mode ==
- "all") then
- screens[i].submode = HitPayload.param;
- UpdateViewDamageoutline(screens[i])
- SaveToDatabank()
- SetRefresh("damageoutline", screens[i].submode)
- RenderScreens("damageoutline", screens[i].submode)
- elseif O == "DMGOChangeStretch" and
- (HitPayload.mode == screens[i].mode or HitPayload.mode ==
- "all") then
- if DMGOStretch == true then
- DMGOStretch = false
- else
- DMGOStretch = true
- end
- UpdateViewDamageoutline(screens[i])
- SaveToDatabank()
- SetRefresh("damageoutline")
- RenderScreens("damageoutline")
- elseif O == "ToggleDisplayAtmosphere" and
- (HitPayload.mode == screens[i].mode or HitPayload.mode ==
- "all") then
- if screens[i].fuelA == true then
- screens[i].fuelA = false
- else
- screens[i].fuelA = true
- end
- screens[i].fuelIndex = 1;
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif O == "ToggleDisplaySpace" and
- (HitPayload.mode == screens[i].mode or HitPayload.mode ==
- "all") then
- if screens[i].fuelS == true then
- screens[i].fuelS = false
- else
- screens[i].fuelS = true
- end
- screens[i].fuelIndex = 1;
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif O == "ToggleDisplayRocket" and
- (HitPayload.mode == screens[i].mode or HitPayload.mode ==
- "all") then
- if screens[i].fuelR == true then
- screens[i].fuelR = false
- else
- screens[i].fuelR = true
- end
- screens[i].fuelIndex = 1;
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif O == "DecreaseFuelIndex" and
- (HitPayload.mode == screens[i].mode or HitPayload.mode ==
- "all") then
- screens[i].fuelIndex = screens[i].fuelIndex - 1;
- if screens[i].fuelIndex < 1 then
- screens[i].fuelIndex = 1
- end
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif O == "IncreaseFuelIndex" and
- (HitPayload.mode == screens[i].mode or HitPayload.mode ==
- "all") then
- screens[i].fuelIndex = screens[i].fuelIndex + 1;
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif O == "ToggleHudMode" and
- (HitPayload.mode == screens[i].mode or HitPayload.mode ==
- "all") then
- if HUDMode == true then
- HUDMode = false;
- forceDamageRedraw = true;
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- else
- HUDMode = true;
- forceDamageRedraw = true;
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- end
- elseif O == "ToggleSimulation" and
- (HitPayload.mode == screens[i].mode or HitPayload.mode ==
- "all") then
- CurrentDamagedPage = 1;
- CurrentBrokenPage = 1;
- if SimulationMode == true then
- SimulationMode = false;
- SimulationActive = false;
- UpdateDamageData()
- UpdateTypeData()
- forceDamageRedraw = true;
- HudDeselectElement()
- SetRefresh("damage")
- SetRefresh("damageoutline")
- SetRefresh("settings1")
- SetRefresh("fuel")
- SaveToDatabank()
- RenderScreens()
- else
- SimulationMode = true;
- SimulationActive = false;
- UpdateDamageData()
- UpdateTypeData()
- forceDamageRedraw = true;
- HudDeselectElement()
- SetRefresh("damage")
- SetRefresh("damageoutline")
- SetRefresh("settings1")
- SetRefresh("fuel")
- SaveToDatabank()
- RenderScreens()
- end
- elseif (O == "ToggleElementLabel" or O == "ToggleElementLabel2") and
- (HitPayload.mode == screens[i].mode or HitPayload.mode ==
- "all") then
- if UseMyElementNames == true then
- UseMyElementNames = false;
- SetRefresh("damage")
- RenderScreens("damage")
- else
- UseMyElementNames = true;
- SetRefresh("damage")
- RenderScreens("damage")
- end
- elseif (O == "SwitchScrapTier" or O == "SwitchScrapTier2") and
- (HitPayload.mode == screens[i].mode or HitPayload.mode ==
- "all") then
- ScrapTier = ScrapTier + 1;
- if ScrapTier > 4 then ScrapTier = 1 end
- SetRefresh("damage")
- RenderScreens("damage")
- end
- end
- end
- end
-end
-function GetContentFlight()
- local Q = ""
- Q = Q .. GetHeader("Flight Data Report") .. [[
-
- ]]
- return Q
-end
-function GetContentDamage()
- local Q = ""
- if SimulationMode == true then
- Q = Q .. GetHeader("Damage Report (Simulated damage)") .. [[]]
- else
- Q = Q .. GetHeader("Damage Report") .. [[]]
- end
- Q = Q .. GetContentDamageScreen()
- return Q
-end
-function GetContentDamageoutline(m)
- UpdateDataDamageoutline()
- UpdateViewDamageoutline(m)
- local Q = ""
- Q =
- Q .. GetHeader("Damage Ship Outline Report") .. GetDamageoutlineShip() ..
- [[]]
- if m.submode == "top" then
- Q = Q .. [[
-
- Top View
-
- Side View
-
- Front View
- ]]
- elseif m.submode == "side" then
- Q = Q .. [[
-
- Top View
-
- Side View
-
- Front View
- ]]
- elseif m.submode == "front" then
- Q = Q .. [[
-
- Top View
-
- Side View
-
- Front View
- ]]
- else
- end
- Q =
- Q .. [[]] .. #dmgoElements .. [[ of ]] ..
- ElementCounter .. [[ shown]]
- Q = Q ..
- [[]]
- if DMGOStretch == true then
- Q = Q ..
- [[]]
- end
- Q = Q .. [[Stretch both axis]]
- return Q
-end
-function GetContentFuel(m)
- if #FuelAtmosphericTanks < 1 and #FuelSpaceTanks < 1 and #FuelRocketTanks <
- 1 then return "" end
- local R = 0;
- local Q = ""
- local S = {}
- FuelDisplay = {m.fuelA, m.fuelS, m.fuelR}
- if FuelDisplay[1] == true and #FuelAtmosphericTanks > 0 then
- table.insert(S, "Atmospheric")
- R = R + 1
- end
- if FuelDisplay[2] == true and #FuelSpaceTanks > 0 then
- table.insert(S, "Space")
- R = R + 1
- end
- if FuelDisplay[3] == true and #FuelRocketTanks > 0 then
- table.insert(S, "Rocket")
- R = R + 1
- end
- Q = Q .. GetHeader("Fuel Report (" .. table.concat(S, ", ") .. ")") .. [[
- ]]
- local T = 150;
- local U = 0;
- local V = 0;
- if FuelDisplay[1] == true and #FuelAtmosphericTanks > 0 then
- if R == 1 then
- V = 50
- elseif R == 2 then
- V = 6
- elseif R == 3 then
- V = 0
- end
- Q = Q .. [[
-
-
-
- ]]
- Q =
- Q .. [[]] ..
- GenerateCommaValue(FuelAtmosphericCurrent, true) .. [[ of ]] ..
- GenerateCommaValue(FuelAtmosphericTotal, true) ..
- [[ | Total Atmospheric Fuel in ]] .. #FuelAtmosphericTanks ..
- [[ tank]] .. (#FuelAtmosphericTanks == 1 and "" or "s") ..
- [[ (]] ..
- math.floor(100 / FuelAtmosphericTotal * FuelAtmosphericCurrent) ..
- [[%)]]
- U = U + 1
- end
- if FuelDisplay[2] == true and #FuelSpaceTanks > 0 then
- if R == 1 then
- V = 50
- elseif R == 2 then
- V = 6
- elseif R == 3 then
- V = 0
- end
- Q = Q .. [[
-
-
-
- ]]
- Q =
- Q .. [[]] ..
- GenerateCommaValue(FuelSpaceCurrent, true) .. [[ of ]] ..
- GenerateCommaValue(FuelSpaceTotal, true) ..
- [[ | Total Space Fuel in ]] .. #FuelSpaceTanks .. [[ tank]] ..
- (#FuelSpaceTanks == 1 and "" or "s") .. [[ (]] ..
- math.floor(100 / FuelSpaceTotal * FuelSpaceCurrent) ..
- [[%)]]
- U = U + 1
- end
- if FuelDisplay[3] == true and #FuelRocketTanks > 0 then
- if R == 1 then
- V = 50
- elseif R == 2 then
- V = 6
- elseif R == 3 then
- V = 0
- end
- Q = Q .. [[
-
-
-
- ]]
- Q =
- Q .. [[]] ..
- GenerateCommaValue(FuelRocketCurrent, true) .. [[ of ]] ..
- GenerateCommaValue(FuelRocketTotal, true) ..
- [[ | Total Rocket Fuel in ]] .. #FuelRocketTanks .. [[ tank]] ..
- (#FuelRocketTanks == 1 and "" or "s") .. [[ (]] ..
- math.floor(100 / FuelRocketTotal * FuelRocketCurrent) ..
- [[%)]]
- end
- Q = Q .. [[
-
-
-
- ]]
- local W = {}
- if m.fuelIndex == nil or m.fuelIndex < 1 then m.fuelIndex = 1 end
- if FuelDisplay[1] == true then
- for f, j in ipairs(FuelAtmosphericTanks) do table.insert(W, j) end
- end
- if FuelDisplay[2] == true then
- for f, j in ipairs(FuelSpaceTanks) do table.insert(W, j) end
- end
- if FuelDisplay[3] == true then
- for f, j in ipairs(FuelRocketTanks) do table.insert(W, j) end
- end
- table.sort(W, function(E, F)
- return E.type < F.type or E.type == F.type and E.id < F.id
- end)
- local X = 0;
- for i = m.fuelIndex, m.fuelIndex + 6, 1 do
- if W[i] ~= nil then
- local Y = W[i]
- X = X + 1;
- local Z = ""
- if Y.type == 1 then
- Z = "a"
- elseif Y.type == 2 then
- Z = "s"
- elseif Y.type == 3 then
- Z = "r"
- end
- local _ = 1853 / 100;
- if Y.percent == nil or Y.percent == 0 then
- _ = 0
- else
- _ = _ * Y.percent
- end
- if Y.cvol == nil then Y.cvol = 0 end
- if Y.name == nil then Y.name = "" end
- Q = Q .. [[
-
-
-
- ]]
- if Y.hp == 0 then
- Q = Q ..
- [[]]
- elseif Y.maxhp - Y.hp > constants.epsilon then
- Q = Q ..
- [[]]
- else
- Q = Q ..
- [[]]
- end
- if Y.hp == 0 then
- Q = Q .. [[]] .. Y.size ..
- [[]]
- else
- Q = Q .. [[]] .. Y.size ..
- [[]]
- end
- if Y.hp == 0 then
- Q = Q .. [[Broken]] ..
- [[0 of ]] ..
- GenerateCommaValue(Y.vol) .. [[]]
- elseif tonumber(Y.percent) < 10 then
- Q = Q .. [[]] .. Y.percent ..
- [[%]] .. [[]] ..
- GenerateCommaValue(Y.cvol) .. [[ of ]] ..
- GenerateCommaValue(Y.vol) .. [[]]
- elseif tonumber(Y.percent) < 30 then
- Q = Q .. [[]] .. Y.percent ..
- [[%]] .. [[]] ..
- GenerateCommaValue(Y.cvol) .. [[ of ]] ..
- GenerateCommaValue(Y.vol) .. [[]]
- else
- Q = Q .. [[]] .. Y.percent ..
- [[%]] .. [[]] ..
- GenerateCommaValue(Y.cvol) .. [[ of ]] ..
- GenerateCommaValue(Y.vol) .. [[]]
- end
- Q = Q .. [[]] .. Y.name .. [[]]
- Q = Q .. [[]]
- end
- end
- if #FuelAtmosphericTanks > 0 then
- Q = Q ..
- [[]]
- if FuelDisplay[1] == true then
- Q = Q ..
- [[]]
- end
- Q = Q .. [[ATM]]
- AddClickAreaForScreenID(m.id, {
- mode = "fuel",
- id = "ToggleDisplayAtmosphere",
- x1 = 50,
- x2 = 100,
- y1 = 270,
- y2 = 320
- })
- end
- if #FuelSpaceTanks > 0 then
- Q = Q ..
- [[]]
- if FuelDisplay[2] == true then
- Q = Q ..
- [[]]
- end
- Q = Q .. [[SPC]]
- AddClickAreaForScreenID(m.id, {
- mode = "fuel",
- id = "ToggleDisplaySpace",
- x1 = 200,
- x2 = 250,
- y1 = 270,
- y2 = 320
- })
- end
- if #FuelRocketTanks > 0 then
- Q = Q ..
- [[]]
- if FuelDisplay[3] == true then
- Q = Q ..
- [[]]
- end
- Q = Q .. [[RKT]]
- AddClickAreaForScreenID(m.id, {
- mode = "fuel",
- id = "ToggleDisplayRocket",
- x1 = 350,
- x2 = 400,
- y1 = 270,
- y2 = 320
- })
- end
- if m.fuelIndex > 1 then
- Q = Q .. [[
-
-
- ]]
- AddClickAreaForScreenID(m.id, {
- mode = "fuel",
- id = "DecreaseFuelIndex",
- x1 = 1470,
- x2 = 1670,
- y1 = 270,
- y2 = 320
- })
- end
- if m.fuelIndex + X - 1 < #W then
- Q = Q .. [[
-
-
- ]]
- AddClickAreaForScreenID(m.id, {
- mode = "fuel",
- id = "IncreaseFuelIndex",
- x1 = 1680,
- x2 = 1880,
- y1 = 270,
- y2 = 320
- })
- end
- if X > 0 then
- Q = Q .. [[]] .. #W .. [[ Tank]] ..
- (#W == 1 and "" or "s") .. [[ (Showing ]] .. m.fuelIndex ..
- [[ to ]] .. m.fuelIndex + X - 1 .. [[)]]
- end
- return Q
-end
-function GetContentCargo()
- local Q = ""
- Q = Q .. GetHeader("Cargo Report") .. [[
-
- ]]
- return Q
-end
-function GetContentAGG()
- local Q = ""
- Q = Q .. GetHeader("Anti-Grav Control") .. [[
-
- ]]
- return Q
-end
-function GetContentMap()
- local Q = ""
- Q = Q .. GetHeader("Map Overview") .. [[
-
- ]]
- return Q
-end
-function GetContentTime()
- local Q = ""
- Q = Q .. GetHeader("Time") .. epochTime()
- Q = Q .. [[
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return Q
-end
-function GetContentSettings1()
- local Q = ""
- Q = Q .. GetHeader("Settings") ..
- [[]]
- if BackgroundMode == "" then
- Q = Q ..
- [[Activate background]]
- else
- Q = Q ..
- [[Deactivate background (']] ..
- BackgroundMode .. [[', ]] ..
- string.format("%.0f", BackgroundModeOpacity * 100) ..
- [[%)]]
- end
- Q = Q .. [[
-
- Previous background
-
- Next background
-
-
- Decrease Opacity
-
- Increase Opacity
- ]]
- Q = Q ..
- [[]] ..
- [[Reset background and all colors]]
- Q = Q .. [[]] ..
- [[]] ..
- [[]] ..
- [[Select and change any of the ]] ..
- #colorIDTable .. [[ HUD colors]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- colorIDTable[colorIDIndex].desc .. [[]] ..
- [[]] ..
- [[Current color]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[#]] ..
- [[]] ..
- [[]] ..
- string.sub(colorIDTable[colorIDIndex].newc, 1, 1) .. [[]] ..
- [[]] ..
- [[]] ..
- string.sub(colorIDTable[colorIDIndex].newc, 2, 2) .. [[]] ..
- [[]] ..
- [[]] ..
- string.sub(colorIDTable[colorIDIndex].newc, 3, 3) .. [[]] ..
- [[]] ..
- [[]] ..
- string.sub(colorIDTable[colorIDIndex].newc, 4, 4) .. [[]] ..
- [[]] ..
- [[]] ..
- string.sub(colorIDTable[colorIDIndex].newc, 5, 5) .. [[]] ..
- [[]] ..
- [[]] ..
- string.sub(colorIDTable[colorIDIndex].newc, 6, 6) .. [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] .. [[]] ..
- [[New color]] ..
- [[]] ..
- [[Apply new color]] ..
- [[]] ..
- [[Reset]] .. [[]]
- Q = Q .. [[]] ..
- [[]] ..
- [[]] ..
- [[Explanation / Hints]] ..
- [[Coming soon.]]
- Q = Q .. [[]]
- if SimulationMode == true then
- Q = Q ..
- [[Simulating Damage to elements]]
- AddClickArea("settings1", {
- id = "ToggleSimulation",
- mode = "settings1",
- x1 = 940,
- x2 = 1850,
- y1 = 919,
- y2 = 969
- })
- else
- Q = Q ..
- [[Simulate Damage to elements]]
- AddClickArea("settings1", {
- id = "ToggleSimulation",
- mode = "settings1",
- x1 = 940,
- x2 = 1850,
- y1 = 919,
- y2 = 969
- })
- end
- return Q
-end
-function GetContentStartup()
- local Q = ""
- Q = Q .. GetElementLogo(812, 380, "f", "f", "f")
- if YourShipsName == "Enter here" then
- Q = Q .. [[Spaceship ID ]] ..
- ShipID .. [[]]
- else
- Q = Q .. [[]] .. YourShipsName ..
- [[]]
- end
- if ShowWelcomeMessage == true then
- Q =
- Q .. [[Greetings, Commander ]] ..
- PlayerName .. [[.]]
- end
- if #Warnings > 0 then
- Q = Q .. [[Warning: ]] ..
- table.concat(Warnings, " ") .. [[]]
- end
- Q = Q ..
- [[Damage Report v]] ..
- VERSION ..
- [[, by DorianGray - Discord: Dorian Gray#2623. Under GNU Public License 3.0.]]
- return Q
-end
-function RenderScreen(m, a0)
- if a0 == nil then
- PrintConsole("ERROR: contentToRender is nil.")
- unit.exit()
- end
- CreateClickAreasForScreen(m)
- local Q = ""
- Q = Q .. [[
-
-
- ]]
- Q = Q .. a0;
- if m.mode == "startup" then
- Q = Q ..
- [[]]
- else
- Q = Q ..
- [[]]
- end
- Q = Q .. [[
-
- ]]
- Q = Q .. [[]]
- local a1 = string.len(Q)
- m.element.setSVG(Q)
-end
-function RenderScreens(a2, a3)
- a2 = a2 or "all"
- a3 = a3 or "all"
- if screens ~= nil and #screens > 0 then
- local a4 = ""
- local a5 = ""
- local a6 = ""
- local a7 = ""
- local a8 = ""
- local a9 = ""
- local aa = ""
- local ab = ""
- local ac = ""
- local ad = ""
- local ae = ""
- local af = ""
- for J, m in pairs(screens) do
- if m.refresh == true then
- local a0 = ""
- if m.mode == "flight" and (a2 == "flight" or a2 == "all") then
- if a4 == "" then a4 = GetContentFlight() end
- a0 = a4
- elseif m.mode == "damage" and (a2 == "damage" or a2 == "all") then
- if a5 == "" then a5 = GetContentDamage() end
- a0 = a5
- elseif m.mode == "damageoutline" and
- (a2 == "damageoutline" or a2 == "all") then
- if m.submode == "" then
- m.submode = "top"
- screens[J].submode = "top"
- end
- if m.submode == "top" and (a3 == "top" or a3 == "all") then
- if a6 == "" then
- a6 = GetContentDamageoutline(m)
- end
- a0 = a6
- end
- if m.submode == "side" and (a3 == "side" or a3 == "all") then
- if a7 == "" then
- a7 = GetContentDamageoutline(m)
- end
- a0 = a7
- end
- if m.submode == "front" and (a3 == "front" or a3 == "all") then
- if a8 == "" then
- a8 = GetContentDamageoutline(m)
- end
- a0 = a8
- end
- elseif m.mode == "fuel" and (a2 == "fuel" or a2 == "all") then
- m = WipeClickAreasForScreen(screens[J])
- a0 = GetContentFuel(m)
- elseif m.mode == "cargo" and (a2 == "cargo" or a2 == "all") then
- if aa == "" then aa = GetContentCargo() end
- a0 = aa
- elseif m.mode == "agg" and (a2 == "agg" or a2 == "all") then
- if ab == "" then ab = GetContentAGG() end
- a0 = ab
- elseif m.mode == "map" and (a2 == "map" or a2 == "all") then
- if ac == "" then ac = GetContentMap() end
- a0 = ac
- elseif m.mode == "time" and (a2 == "time" or a2 == "all") then
- if ad == "" then ad = GetContentTime() end
- a0 = ad
- elseif m.mode == "settings1" and
- (a2 == "settings1" or a2 == "all") then
- if ae == "" then
- ae = GetContentSettings1()
- end
- a0 = ae
- elseif m.mode == "startup" and (a2 == "startup" or a2 == "all") then
- if af == "" then af = GetContentStartup() end
- a0 = af
- else
- a0 = "Invalid screen mode. ('" .. m.mode .. "')"
- end
- if a0 ~= "" then
- RenderScreen(m, a0)
- else
- DrawCenteredText(
- "ERROR: No contentToRender delivered for " .. m.mode)
- PrintConsole("ERROR: No contentToRender delivered for " ..
- m.mode)
- unit.exit()
- end
- screens[J].refresh = false
- end
- end
- end
- if HUDMode == true then
- system.setScreen(GetContentDamageHUDOutput())
- system.showScreen(1)
- else
- system.showScreen(0)
- end
-end
-function OnTickData(C)
- if formerTime + 60 < system.getTime() then SetRefresh("time") end
- totalShipMass = core.getConstructMass()
- if formerTotalShipMass ~= totalShipMass then
- UpdateDamageData(true)
- UpdateTypeData()
- SetRefresh()
- formerTotalShipMass = totalShipMass
- else
- UpdateDamageData(C)
- UpdateTypeData()
- end
- RenderScreens()
-end
-unit.hide()
-ClearConsole()
-PrintConsole("DAMAGE REPORT v" .. VERSION .. " STARTED", true)
-InitiateSlots()
-LoadFromDatabank()
-SwitchScreens("on")
-InitiateScreens()
-if core == nil then
- PrintConsole("ERROR: Connect the core to the programming board.")
- unit.exit()
-else
- OperatorID = unit.getMasterPlayerId()
- OperatorData = database.getPlayer(OperatorID)
- PlayerName = OperatorData["name"]
- ShipID = core.getConstructId()
-end
-if db == nil then
- table.insert(Warnings, "No databank connected, won't save/load settings.")
-end
-if YourShipsName == "Enter here" then
- table.insert(Warnings, "No ship name set in LUA settings.")
-end
-if SkillRepairToolEfficiency == 0 and SkillRepairToolOptimization == 0 and
- StatFuelTankOptimization == 0 and StatContainerOptimization == 0 and
- StatAtmosphericFuelTankHandling == 0 and StatSpaceFuelTankHandling == 0 and
- StatRocketFuelTankHandling == 0 then
- table.insert(Warnings, "No talents/stats set in LUA settings.")
-end
-if SkillRepairToolEfficiency < 0 or SkillRepairToolOptimization < 0 or
- StatFuelTankOptimization < 0 or StatContainerOptimization < 0 or
- StatAtmosphericFuelTankHandling < 0 or StatSpaceFuelTankHandling < 0 or
- StatRocketFuelTankHandling < 0 or SkillRepairToolEfficiency > 5 or
- SkillRepairToolOptimization > 5 or StatFuelTankOptimization > 5 or
- StatContainerOptimization > 5 or StatAtmosphericFuelTankHandling > 5 or
- StatSpaceFuelTankHandling > 5 or StatRocketFuelTankHandling > 5 then
- PrintConsole(
- "ERROR: Talents/stats can only range from 0 to 5. Please set correctly in LUA settings and reactivate script.")
- unit.exit()
-end
-if screens == nil or #screens == 0 then
- HUDMode = true;
- PrintConsole("Warning: No screens connected. Entering HUD mode only.")
-end
-OnTickData(true)
-unit.setTimer('UpdateData', UpdateDataInterval)
-unit.setTimer('UpdateHighlight', HighlightBlinkingInterval)
diff --git a/src/DamageReport_3_2_UnitStart_2.lua b/src/DamageReport_3_2_UnitStart_2.lua
deleted file mode 100644
index ccf9c1b..0000000
--- a/src/DamageReport_3_2_UnitStart_2.lua
+++ /dev/null
@@ -1,1471 +0,0 @@
---[[
- Damage Report 3.2
- A LUA script for Dual Universe
-
- Created By Dorian Gray
- Ingame: DorianGray
- Discord: Dorian Gray#2623
-
- You can find/update this script on GitHub. Explanations, installation and usage information as well as screenshots can be found there too.
- GitHub: https://github.com/DorianTheGrey/DU-DamageReport
-
- GNU Public License 3.0. Use whatever you want, be so kind to leave credit.
-
- Credits & thanks:
- Thanks to Bayouking1 and kalazzerx for managing their forks of this script during my long absence to support the community. :)
- Thanks to Bayouking1 for fixing rocket fuel calculations.
- Thanks to NovaQuark for creating the MMO of the century.
- Thanks to Jericho, Dmentia and Archaegeo for learning a lot from their fine scripts.
- Thanks to TheBlacklist for testing and wonderful suggestions.
- SVG patterns by Hero Patterns.
- DU atlas data from Jayle Break.
-
-]]
-
-function GenerateCommaValue(a, b, c)
- b = b or false;
- c = c or 1;
- local d = a;
- if b == true then
- if string.len(a) >= 4 then
- d = string.format("%." .. c .. "fk", a / 1000)
- else
- d = string.format("%." .. c .. "f", a)
- end
- else
- while true do
- d, k = string.gsub(d, "^(-?%d+)(%d%d%d)", '%1,%2')
- if k == 0 then break end
- end
- end
- return d
-end
-function PrintConsole(e, f)
- f = f or false;
- if f then
- system.print(
- "------------------------------------------------------------------------")
- end
- system.print(e)
- if f then
- system.print(
- "------------------------------------------------------------------------")
- end
-end
-function DrawCenteredText(e)
- if screens ~= nil and #screens > 0 then
- for g = 1, #screens, 1 do screens[g].element.setCenteredText(e) end
- end
-end
-function ClearConsole() for g = 1, 10, 1 do PrintConsole() end end
-function SwitchScreens(h)
- h = h or "on"
- if screens ~= nil and #screens > 0 then
- for g = 1, #screens, 1 do
- if h == "on" then
- screens[g].element.clear()
- screens[g].element.activate()
- screens[g].active = true
- else
- screens[g].element.clear()
- screens[g].element.deactivate()
- screens[g].active = false
- end
- end
- end
-end
-function GetSecondsString(i)
- local i = tonumber(i)
- if i == nil or i <= 0 then
- return "-"
- else
- days = string.format("%2.f", math.floor(i / (3600 * 24)))
- hours = string.format("%2.f", math.floor(i / 3600 - days * 24))
- mins = string.format("%2.f",
- math.floor(i / 60 - hours * 60 - days * 24 * 60))
- secs = string.format("%2.f", math.floor(
- i - hours * 3600 - days * 24 * 60 * 60 - mins *
- 60))
- str = ""
- if tonumber(days) > 0 then str = str .. days .. "d " end
- if tonumber(hours) > 0 then str = str .. hours .. "h " end
- if tonumber(mins) > 0 then str = str .. mins .. "m " end
- if tonumber(secs) > 0 then str = str .. secs .. "s" end
- return str
- end
-end
-function replace_char(j, str, l) return str:sub(1, j - 1) .. l .. str:sub(j + 1) end
-function epochTime()
- function rZ(m)
- if string.len(m) <= 1 then
- return "0" .. m
- else
- return m
- end
- end
- function dPoint(n)
- if not (n == math.floor(n)) then
- return true
- else
- return false
- end
- end
- function lYear(year)
- if not dPoint(year / 4) then
- if dPoint(year / 100) then
- return true
- else
- if not dPoint(year / 400) then
- return true
- else
- return false
- end
- end
- else
- return false
- end
- end
- local o = 5;
- local p = 3600;
- local q = 86400;
- local r = 31536000;
- local s = 31622400;
- local t = 2419200;
- local g = 2505600;
- local u = 2592000;
- local k = 2678400;
- local w = {4, 6, 9, 11}
- local x = {1, 3, 5, 7, 8, 10, 12}
- local y = 0;
- local z = 1506816000;
- local A = system.getTime()
- _G["formerTime"] = A;
- if AddSummertimeHour == true then A = A + 3600 end
- now = math.floor(A + z)
- year = 1970;
- secs = 0;
- y = 0;
- while secs + s < now or secs + r < now do
- if lYear(year + 1) then
- if secs + s < now then
- secs = secs + s;
- year = year + 1;
- y = y + 366
- end
- else
- if secs + r < now then
- secs = secs + r;
- year = year + 1;
- y = y + 365
- end
- end
- end
- secondsRemaining = now - secs;
- monthSecs = 0;
- yearlYear = lYear(year)
- month = 1;
- while monthSecs + t < secondsRemaining or monthSecs + u < secondsRemaining or
- monthSecs + k < secondsRemaining do
- if month == 1 then
- if monthSecs + k < secondsRemaining then
- month = 2;
- monthSecs = monthSecs + k;
- y = y + 31
- else
- break
- end
- end
- if month == 2 then
- if not yearlYear then
- if monthSecs + t < secondsRemaining then
- month = 3;
- monthSecs = monthSecs + t;
- y = y + 28
- else
- break
- end
- else
- if monthSecs + g < secondsRemaining then
- month = 3;
- monthSecs = monthSecs + g;
- y = y + 29
- else
- break
- end
- end
- end
- if month == 3 then
- if monthSecs + k < secondsRemaining then
- month = 4;
- monthSecs = monthSecs + k;
- y = y + 31
- else
- break
- end
- end
- if month == 4 then
- if monthSecs + u < secondsRemaining then
- month = 5;
- monthSecs = monthSecs + u;
- y = y + 30
- else
- break
- end
- end
- if month == 5 then
- if monthSecs + k < secondsRemaining then
- month = 6;
- monthSecs = monthSecs + k;
- y = y + 31
- else
- break
- end
- end
- if month == 6 then
- if monthSecs + u < secondsRemaining then
- month = 7;
- monthSecs = monthSecs + u;
- y = y + 30
- else
- break
- end
- end
- if month == 7 then
- if monthSecs + k < secondsRemaining then
- month = 8;
- monthSecs = monthSecs + k;
- y = y + 31
- else
- break
- end
- end
- if month == 8 then
- if monthSecs + k < secondsRemaining then
- month = 9;
- monthSecs = monthSecs + k;
- y = y + 31
- else
- break
- end
- end
- if month == 9 then
- if monthSecs + u < secondsRemaining then
- month = 10;
- monthSecs = monthSecs + u;
- y = y + 30
- else
- break
- end
- end
- if month == 10 then
- if monthSecs + k < secondsRemaining then
- month = 11;
- monthSecs = monthSecs + k;
- y = y + 31
- else
- break
- end
- end
- if month == 11 then
- if monthSecs + u < secondsRemaining then
- month = 12;
- monthSecs = monthSecs + u;
- y = y + 30
- else
- break
- end
- end
- end
- day = 1;
- daySecs = 0;
- daySecsRemaining = secondsRemaining - monthSecs;
- while daySecs + q < daySecsRemaining do
- day = day + 1;
- daySecs = daySecs + q;
- y = y + 1
- end
- hour = 0;
- hourSecs = 0;
- hourSecsRemaining = daySecsRemaining - daySecs;
- while hourSecs + p < hourSecsRemaining do
- hour = hour + 1;
- hourSecs = hourSecs + p
- end
- minute = 0;
- minuteSecs = 0;
- minuteSecsRemaining = hourSecsRemaining - hourSecs;
- while minuteSecs + 60 < minuteSecsRemaining do
- minute = minute + 1;
- minuteSecs = minuteSecs + 60
- end
- second = math.floor(now % 60)
- year = rZ(year)
- month = rZ(month)
- day = rZ(day)
- hour = rZ(hour)
- minute = rZ(minute)
- second = rZ(second)
- return [[]] .. hour .. ":" .. minute ..
- [[]] .. [[]] .. year ..
- "/" .. month .. "/" .. day .. [[]]
-end
-function ToggleHUD()
- if HUDMode == true then
- HUDMode = false;
- forceDamageRedraw = true;
- hudSelectedIndex = 0;
- highlightID = 0;
- HideHighlight()
- SetRefresh()
- RenderScreens()
- else
- HUDMode = true;
- forceDamageRedraw = true;
- hudSelectedIndex = 0;
- highlightID = 0;
- HideHighlight()
- SetRefresh()
- RenderScreens()
- end
-end
-function HudDeselectElement()
- hudSelectedIndex = 0;
- hudStartIndex = 1;
- highlightID = 0;
- HideHighlight()
- if HUDMode == true then
- SetRefresh("damage")
- SetRefresh("damageoutline")
- RenderScreens()
- end
-end
-function ChangeHudSelectedElement(B)
- if HUDMode == true and #rE > 0 then
- hudSelectedIndex = hudSelectedIndex + B;
- if hudSelectedIndex < 1 then
- hudSelectedIndex = 1
- elseif hudSelectedIndex > #rE then
- hudSelectedIndex = #rE
- end
- if hudSelectedIndex > 9 then hudStartIndex = hudSelectedIndex - 9 end
- if hudSelectedIndex ~= 0 then
- highlightID = rE[hudSelectedIndex].id;
- if highlightID ~= nil and highlightID ~= 0 then
- HideHighlight()
- elementPosition = vec3(rE[hudSelectedIndex].pos)
- highlightX = elementPosition.x - coreWorldOffset;
- highlightY = elementPosition.y - coreWorldOffset;
- highlightZ = elementPosition.z - coreWorldOffset;
- highlightOn = true;
- ShowHighlight()
- end
- end
- SetRefresh("damage")
- SetRefresh("damageoutline")
- RenderScreens()
- end
-end
-function HideHighlight()
- if #hudArrowSticker > 0 then
- for g in pairs(hudArrowSticker) do
- core.deleteSticker(hudArrowSticker[g])
- end
- hudArrowSticker = {}
- end
-end
-function ShowHighlight()
- if highlightOn == true and highlightID > 0 then
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX + 2,
- highlightY,
- highlightZ, "north"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,
- highlightY - 2,
- highlightZ, "east"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX - 2,
- highlightY,
- highlightZ, "south"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,
- highlightY + 2,
- highlightZ, "west"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,
- highlightY,
- highlightZ - 2,
- "up"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,
- highlightY,
- highlightZ + 2,
- "down"))
- end
-end
-function ToggleHighlight()
- if highlightOn == true then
- highlightOn = false;
- HideHighlight()
- else
- highlightOn = true;
- ShowHighlight()
- end
-end
-function SortDamageTables()
- table.sort(damagedElements,
- function(m, n) return m.missinghp > n.missinghp end)
- table.sort(brokenElements, function(m, n) return m.maxhp > n.maxhp end)
-end
-function getScraps(C, D)
- D = D or false;
- C = C - SkillRepairToolOptimization * 0.05 * C;
- local E = math.ceil(C / (10 * 5 ^ (ScrapTier - 1)))
- if D == true then
- return GenerateCommaValue(string.format("%.0f", E), false)
- else
- return E
- end
-end
-function getRepairTime(C, F)
- F = F or false;
- C = C - SkillRepairToolOptimization * 0.05 * C;
- local E = math.ceil(C / ScrapTierRepairTimes[ScrapTier])
- E = E - SkillRepairToolEfficiency * 0.1 * E;
- if F == true then
- return GetSecondsString(string.format("%.0f", E))
- else
- return E
- end
-end
-function UpdateDataDamageoutline()
- dmgoElements = {}
- for g, G in ipairs(brokenElements) do
- if #dmgoElements < DMGOMaxElements then
- local elementPosition = vec3(G.pos)
- local H = elementPosition.x - coreWorldOffset;
- local I = elementPosition.y - coreWorldOffset;
- local J = elementPosition.z - coreWorldOffset;
- if H < ShipXmin then ShipXmin = H end
- if I < ShipYmin then ShipYmin = I end
- if J < ShipZmin then ShipZmin = J end
- if H > ShipXmax then ShipXmax = H end
- if I > ShipYmax then ShipYmax = I end
- if J > ShipZmax then ShipZmax = J end
- table.insert(dmgoElements, {
- id = G.id,
- type = "b",
- size = G.maxhp,
- x = H,
- y = I,
- z = J,
- xp = 0,
- yp = 0,
- zp = 0,
- u = 0,
- v = 0
- })
- end
- end
- if #dmgoElements < DMGOMaxElements then
- for g, G in ipairs(damagedElements) do
- if #dmgoElements < DMGOMaxElements then
- local elementPosition = vec3(G.pos)
- local H = elementPosition.x - coreWorldOffset;
- local I = elementPosition.y - coreWorldOffset;
- local J = elementPosition.z - coreWorldOffset;
- if H < ShipXmin then ShipXmin = H end
- if I < ShipYmin then ShipYmin = I end
- if J < ShipZmin then ShipZmin = J end
- if H > ShipXmax then ShipXmax = H end
- if I > ShipYmax then ShipYmax = I end
- if J > ShipZmax then ShipZmax = J end
- table.insert(dmgoElements, {
- id = G.id,
- type = "d",
- size = G.maxhp,
- x = H,
- y = I,
- z = J,
- xp = 0,
- yp = 0,
- zp = 0,
- u = 0,
- v = 0
- })
- end
- end
- end
- if #dmgoElements < DMGOMaxElements then
- for g, G in ipairs(healthyElements) do
- if #dmgoElements < DMGOMaxElements then
- local elementPosition = vec3(G.pos)
- local H = elementPosition.x - coreWorldOffset;
- local I = elementPosition.y - coreWorldOffset;
- local J = elementPosition.z - coreWorldOffset;
- if H < ShipXmin then ShipXmin = H end
- if I < ShipYmin then ShipYmin = I end
- if J < ShipZmin then ShipZmin = J end
- if H > ShipXmax then ShipXmax = H end
- if I > ShipYmax then ShipYmax = I end
- if J > ShipZmax then ShipZmax = J end
- table.insert(dmgoElements, {
- id = G.id,
- type = "h",
- size = G.maxhp,
- x = H,
- y = I,
- z = J,
- xp = 0,
- yp = 0,
- zp = 0,
- u = 0,
- v = 0
- })
- end
- end
- end
- ShipX = math.abs(ShipXmax - ShipXmin)
- ShipY = math.abs(ShipYmax - ShipYmin)
- ShipZ = math.abs(ShipZmax - ShipZmin)
- for g, G in ipairs(dmgoElements) do
- dmgoElements[g].xp = math.abs(100 / (ShipXmax - ShipXmin) *
- (G.x - ShipXmin))
- dmgoElements[g].yp = math.abs(100 / (ShipYmax - ShipYmin) *
- (G.y - ShipYmin))
- dmgoElements[g].zp = math.abs(100 / (ShipZmax - ShipZmin) *
- (G.z - ShipZmin))
- end
-end
-function UpdateViewDamageoutline(K)
- UFrame = 40;
- VFrame = 40;
- UStart = 20 + UFrame;
- VStart = 180 + VFrame;
- UDim = 1880 - 2 * UFrame;
- VDim = 840 - 2 * VFrame;
- if K.submode == "top" then
- if DMGOStretch == false then
- local L = UDim / (ShipYmax - ShipYmin)
- local M = VDim / (ShipXmax - ShipXmin)
- if L >= M then
- local N = L / M;
- local O = math.floor(UDim / N)
- UStart = UStart + (UDim - O) / 2;
- for g, G in ipairs(dmgoElements) do
- dmgoElements[g].u = math.floor(
- UDim / 100 / N * G.yp + UStart)
- dmgoElements[g].v = math.floor(VDim / 100 * G.xp + VStart)
- end
- else
- local N = M / L;
- local P = math.floor(VDim / N)
- VStart = VStart + (VDim - P) / 2;
- for g, G in ipairs(dmgoElements) do
- dmgoElements[g].u = math.floor(UDim / 100 * G.yp + UStart)
- dmgoElements[g].v = math.floor(
- VDim / 100 / N * G.xp + VStart)
- end
- end
- else
- for g, G in ipairs(dmgoElements) do
- dmgoElements[g].u = math.floor(UDim / 100 * G.yp + UStart)
- dmgoElements[g].v = math.floor(VDim / 100 * G.xp + VStart)
- end
- end
- elseif K.submode == "front" then
- if DMGOStretch == false then
- local L = UDim / (ShipXmax - ShipXmin)
- local M = VDim / (ShipZmax - ShipZmin)
- if L >= M then
- local N = L / M;
- local O = math.floor(UDim / N)
- UStart = UStart + (UDim - O) / 2;
- for g, G in ipairs(dmgoElements) do
- dmgoElements[g].u = math.floor(
- UDim / 100 / N * G.xp + UStart)
- dmgoElements[g].v = math.floor(
- VDim / 100 * (100 - G.zp) + VStart)
- end
- else
- local N = M / L;
- local P = math.floor(VDim / N)
- VStart = VStart + (VDim - P) / 2;
- for g, G in ipairs(dmgoElements) do
- dmgoElements[g].u = math.floor(UDim / 100 * G.xp + UStart)
- dmgoElements[g].v = math.floor(
- VDim / 100 / N * (100 - G.zp) +
- VStart)
- end
- end
- else
- for g, G in ipairs(dmgoElements) do
- dmgoElements[g].u = math.floor(UDim / 100 * G.xp + UStart)
- dmgoElements[g].v = math.floor(
- VDim / 100 * (100 - G.zp) + VStart)
- end
- end
- elseif K.submode == "side" then
- if DMGOStretch == false then
- local L = UDim / (ShipYmax - ShipYmin)
- local M = VDim / (ShipXmax - ShipZmin)
- if L >= M then
- local N = L / M;
- local O = math.floor(UDim / N)
- UStart = UStart + (UDim - O) / 2;
- for g, G in ipairs(dmgoElements) do
- dmgoElements[g].u = math.floor(
- UDim / 100 / N * G.yp + UStart)
- dmgoElements[g].v = math.floor(
- VDim / 100 * (100 - G.zp) + VStart)
- end
- else
- local N = M / L;
- local P = math.floor(VDim / N)
- VStart = VStart + (VDim - P) / 2;
- for g, G in ipairs(dmgoElements) do
- dmgoElements[g].u = math.floor(UDim / 100 * G.yp + UStart)
- dmgoElements[g].v = math.floor(
- VDim / 100 / N * (100 - G.zp) +
- VStart)
- end
- end
- else
- for g, G in ipairs(dmgoElements) do
- dmgoElements[g].u = math.floor(UDim / 100 * G.yp + UStart)
- dmgoElements[g].v = math.floor(
- VDim / 100 * (100 - G.zp) + VStart)
- end
- end
- else
- DrawCenteredText("ERROR: non-existing DMGO mode set.")
- PrintConsole("ERROR: non-existing DMGO mode set.")
- unit.exit()
- end
-end
-function GetDamageoutlineShip()
- local e = ""
- for g, G in ipairs(dmgoElements) do
- local Q = ""
- local R = 1;
- if G.type == "h" then
- Q = "ch"
- elseif G.type == "d" then
- Q = "cw"
- else
- Q = "cc"
- end
- if G.id == highlightID then Q = "f2" end
- if G.size > 0 and G.size < 1000 then
- R = 5
- elseif G.size >= 1000 and G.size < 2000 then
- R = 8
- elseif G.size >= 2000 and G.size < 5000 then
- R = 12
- elseif G.size >= 5000 and G.size < 10000 then
- R = 15
- elseif G.size >= 10000 and G.size < 20000 then
- R = 20
- elseif G.size >= 20000 then
- R = 30
- end
- e = e .. [[]]
- if G.id == highlightID then
- e =
- e .. [[]]
- e =
- e .. [[]]
- end
- end
- return e
-end
-function GetContentClickareas(K)
- local e = ""
- if K ~= nil and K.ClickAreas ~= nil and #K.ClickAreas > 0 then
- for g, S in ipairs(K.ClickAreas) do
- e =
- e .. [[]]
- end
- end
- return e
-end
-function GetElement1(H, I, T, U)
- H = H or 0;
- I = I or 0;
- T = T or 600;
- U = U or 600;
- local e = ""
- e = e .. [[
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return e
-end
-function GetElement2(H, I)
- H = H or 0;
- I = I or 0;
- local e = ""
- e = e .. [[]]
- return e
-end
-function GetElementLogo(H, I, V, W, X)
- H = H or 812;
- I = I or 380;
- V = V or "f"
- W = W or "f2"
- X = X or "f3"
- local e = ""
- e = e .. [[
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return e
-end
-function GetHeader(Y)
- Y = Y or "ERROR: UNDEFINED"
- local e = ""
- e = e ..
- [[
- ]] .. Y .. [[]]
- return e
-end
-function GetContentBackground(Z, _)
- bgColor = ColorBackgroundPattern;
- local e = ""
- if Z == "dots" then
- e =
- [[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' viewBox='0 0 4 4'%3E%3Cpath fill='%23]] ..
- bgColor .. [[' fill-opacity=']] .. BackgroundModeOpacity ..
- [[' d='M1 3h1v1H1V3zm2-2h1v1H3V1z'%3E%3C/path%3E%3C/svg%3E");]]
- elseif Z == "rain" then
- e =
- [[background-image: url("data:image/svg+xml,%3Csvg width='12' height='16' viewBox='0 0 12 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 .99C4 .445 4.444 0 5 0c.552 0 1 .45 1 .99v4.02C6 5.555 5.556 6 5 6c-.552 0-1-.45-1-.99V.99zm6 8c0-.546.444-.99 1-.99.552 0 1 .45 1 .99v4.02c0 .546-.444.99-1 .99-.552 0-1-.45-1-.99V8.99z' fill='%23]] ..
- bgColor .. [[' fill-opacity=']] .. BackgroundModeOpacity ..
- [[' fill-rule='evenodd'/%3E%3C/svg%3E");]]
- elseif Z == "plus" then
- e =
- [[background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23]] ..
- bgColor .. [[' fill-opacity=']] .. BackgroundModeOpacity ..
- [['%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");]]
- elseif Z == "signal" then
- e =
- [[background-image: url("data:image/svg+xml,%3Csvg width='84' height='48' viewBox='0 0 84 48' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h12v6H0V0zm28 8h12v6H28V8zm14-8h12v6H42V0zm14 0h12v6H56V0zm0 8h12v6H56V8zM42 8h12v6H42V8zm0 16h12v6H42v-6zm14-8h12v6H56v-6zm14 0h12v6H70v-6zm0-16h12v6H70V0zM28 32h12v6H28v-6zM14 16h12v6H14v-6zM0 24h12v6H0v-6zm0 8h12v6H0v-6zm14 0h12v6H14v-6zm14 8h12v6H28v-6zm-14 0h12v6H14v-6zm28 0h12v6H42v-6zm14-8h12v6H56v-6zm0-8h12v6H56v-6zm14 8h12v6H70v-6zm0 8h12v6H70v-6zM14 24h12v6H14v-6zm14-8h12v6H28v-6zM14 8h12v6H14V8zM0 8h12v6H0V8z' fill='%23]] ..
- bgColor .. [[' fill-opacity=']] .. BackgroundModeOpacity ..
- [[' fill-rule='evenodd'/%3E%3C/svg%3E");]]
- elseif Z == "deathstar" then
- e =
- [[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='105' viewBox='0 0 80 105'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%23]] ..
- bgColor .. [[' fill-opacity=']] .. BackgroundModeOpacity ..
- [['%3E%3Cpath d='M20 10a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm15 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zM20 75a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zm30-65a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm0 65a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zM35 10a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zM5 45a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zm60 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10z' /%3E%3C/g%3E%3C/g%3E%3C/svg%3E");]]
- elseif Z == "diamond" then
- e =
- [[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='32' viewBox='0 0 16 32'%3E%3Cg fill='%23]] ..
- bgColor .. [[' fill-opacity=']] .. BackgroundModeOpacity ..
- [['%3E%3Cpath fill-rule='evenodd' d='M0 24h4v2H0v-2zm0 4h6v2H0v-2zm0-8h2v2H0v-2zM0 0h4v2H0V0zm0 4h2v2H0V4zm16 20h-6v2h6v-2zm0 4H8v2h8v-2zm0-8h-4v2h4v-2zm0-20h-6v2h6V0zm0 4h-4v2h4V4zm-2 12h2v2h-2v-2zm0-8h2v2h-2V8zM2 8h10v2H2V8zm0 8h10v2H2v-2zm-2-4h14v2H0v-2zm4-8h6v2H4V4zm0 16h6v2H4v-2zM6 0h2v2H6V0zm0 24h2v2H6v-2z'/%3E%3C/g%3E%3C/svg%3E");]]
- elseif Z == "hexagon" then
- e =
- [[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='49' viewBox='0 0 28 49'%3E%3Cg fill-rule='evenodd'%3E%3Cg id='hexagons' fill='%23]] ..
- bgColor .. [[' fill-opacity=']] .. BackgroundModeOpacity ..
- [[' fill-rule='nonzero'%3E%3Cpath d='M13.99 9.25l13 7.5v15l-13 7.5L1 31.75v-15l12.99-7.5zM3 17.9v12.7l10.99 6.34 11-6.35V17.9l-11-6.34L3 17.9zM0 15l12.98-7.5V0h-2v6.35L0 12.69v2.3zm0 18.5L12.98 41v8h-2v-6.85L0 35.81v-2.3zM15 0v7.5L27.99 15H28v-2.31h-.01L17 6.35V0h-2zm0 49v-8l12.99-7.5H28v2.31h-.01L17 42.15V49h-2z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");]]
- elseif Z == "capsule" then
- e =
- [[background-image: url("data:image/svg+xml,%3Csvg width='32' height='26' viewBox='0 0 32 26' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M14 0v3.994C14 7.864 10.858 11 7 11c-3.866 0-7-3.138-7-7.006V0h2v4.005C2 6.765 4.24 9 7 9c2.756 0 5-2.236 5-4.995V0h2zm0 26v-5.994C14 16.138 10.866 13 7 13c-3.858 0-7 3.137-7 7.006V26h2v-6.005C2 17.235 4.244 15 7 15c2.76 0 5 2.236 5 4.995V26h2zm2-18.994C16 3.136 19.142 0 23 0c3.866 0 7 3.138 7 7.006v9.988C30 20.864 26.858 24 23 24c-3.866 0-7-3.138-7-7.006V7.006zm2-.01C18 4.235 20.244 2 23 2c2.76 0 5 2.236 5 4.995v10.01C28 19.765 25.756 22 23 22c-2.76 0-5-2.236-5-4.995V6.995z' fill='%23]] ..
- bgColor .. [[' fill-opacity=']] .. BackgroundModeOpacity ..
- [[' fill-rule='evenodd'/%3E%3C/svg%3E");]]
- elseif Z == "diagonal" then
- e =
- [[background-image: url("data:image/svg+xml,%3Csvg width='6' height='6' viewBox='0 0 6 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23]] ..
- bgColor .. [[' fill-opacity=']] .. BackgroundModeOpacity ..
- [[' fill-rule='evenodd'%3E%3Cpath d='M5 0h1L0 6V5zM6 5v1H5z'/%3E%3C/g%3E%3C/svg%3E");]]
- end
- return e
-end
-function GetContentDamageHUDOutput()
- local a0 = 300;
- local a1 = 165;
- if #damagedElements > 0 or #brokenElements > 0 then a1 = 510 end
- local e = ""
- e =
- e .. [[
-
- ]]
- e = e .. [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- (YourShipsName == "Enter here" and "Ship ID " .. ShipID or
- YourShipsName) .. [[]] ..
- [[]]
- if #brokenElements > 0 then
- e = e ..
- [[]]
- elseif #damagedElements > 0 then
- e = e ..
- [[]]
- else
- e = e ..
- [[]]
- end
- if #damagedElements > 0 or #brokenElements > 0 then
- e = e .. [[Total Damage]] ..
- [[]] ..
- GenerateCommaValue(string.format("%.0f",
- totalShipMaxHP - totalShipHP)) ..
- [[]]
- e = e .. [[T]] .. ScrapTier ..
- [[ Scrap Needed]] ..
- [[]] ..
- getScraps(totalShipMaxHP - totalShipHP, true) .. [[]]
- e = e .. [[Repair Time]] ..
- [[]] ..
- getRepairTime(totalShipMaxHP - totalShipHP, true) .. [[]]
- e = e ..
- [[]] ..
- [[]] ..
- [[]] .. #healthyElements ..
- [[]] .. [[]] ..
- [[]] .. #damagedElements ..
- [[]] .. [[]] ..
- [[]] .. #brokenElements ..
- [[]]
- local u = 0;
- for a2 = hudStartIndex, hudStartIndex + 9, 1 do
- if rE[a2] ~= nil then
- v = rE[a2]
- if v.hp > 0 then
- e = e .. [[]] .. [[]] ..
- string.format("%.30s", v.name) .. [[]] ..
- [[]] ..
- GenerateCommaValue(
- string.format("%.0f", v.missinghp)) ..
- [[]]
- if v.id == highlightID then
- e = e .. [[]] .. [[]] ..
- string.format("%.30s", v.name) .. [[]] ..
- [[]] ..
- GenerateCommaValue(
- string.format("%.0f", v.missinghp)) ..
- [[]]
- end
- else
- e = e .. [[]] ..
- [[]] ..
- string.format("%.30s", v.name) .. [[]] ..
- [[]] ..
- GenerateCommaValue(
- string.format("%.0f", v.missinghp)) ..
- [[]]
- if v.id == highlightID then
- highlightX = elementPosition.x - coreWorldOffset;
- highlightY = elementPosition.y - coreWorldOffset;
- highlightZ = elementPosition.z - coreWorldOffset;
- e = e .. [[]] ..
- [[]] ..
- string.format("%.30s", v.name) .. [[]] ..
- [[]] ..
- GenerateCommaValue(
- string.format("%.0f", v.missinghp)) ..
- [[]]
- end
- end
- u = u + 1
- end
- end
- if DisallowKeyPresses == true then
- e = e .. [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Keypresses disabled.]] ..
- [[Change in LUA parameters]] ..
- [[by unchecking DisallowKeyPresses.]] ..
- [[]] .. [[]] ..
- [[]]
- else
- e = e .. [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Up/down arrows to highlight]] ..
- [[CTRL + arrows to move HUD]] ..
- [[Left arrow to toggle HUD Mode]] ..
- [[ALT+1-4 to set Scrap Tier]] ..
- [[ALT+8 to reset HUD position]] ..
- [[ALT+9 to shut script off]] ..
- [[]] .. [[]]
- end
- else
- if DisallowKeyPresses == true then
- e = e .. [[]] .. OkayCenterMessage .. [[]] ..
- [[]] .. #healthyElements ..
- [[ elements / ]] ..
- GenerateCommaValue(string.format("%.0f", totalShipMaxHP)) ..
- [[ HP.]] .. [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Keypresses disabled.]] ..
- [[Change in LUA parameters]] ..
- [[by unchecking DisallowKeyPresses.]] ..
- [[]] .. [[]] ..
- [[]]
- else
- e = e .. [[]] .. OkayCenterMessage .. [[]] ..
- [[]] .. #healthyElements ..
- [[ elements / ]] ..
- GenerateCommaValue(string.format("%.0f", totalShipMaxHP)) ..
- [[ HP.]] .. [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Left arrow to toggle HUD Mode]] ..
- [[CTRL + arrows to move HUD]] ..
- [[ALT+8 to reset HUD position]] ..
- [[ALT+9 to shut script off]] ..
- [[]] .. [[]]
- end
- end
- e = e .. [[]]
- return e
-end
-function GetContentDamageScreen()
- local a3 = ""
- if #damagedElements > 0 then
- local a4 = #damagedElements;
- if a4 > DamagePageSize then a4 = DamagePageSize end
- if CurrentDamagedPage == math.ceil(#damagedElements / DamagePageSize) then
- a4 = #damagedElements % DamagePageSize + 12;
- if a4 > 12 then a4 = a4 - 12 end
- end
- a3 =
- a3 .. [[]]
- a3 = a3 ..
- [[]]
- if UseMyElementNames == true then
- a3 = a3 ..
- [[Damaged Name]]
- else
- a3 = a3 ..
- [[Damaged Type]]
- end
- a3 = a3 ..
- [[HLTHDMG]]
- a3 = a3 .. [[T]] .. ScrapTier ..
- [[ SCRREPTIME]]
- AddClickArea("damage", {
- id = "SwitchScrapTier",
- mode = "damage",
- x1 = 650,
- x2 = 775,
- y1 = 315,
- y2 = 360
- })
- local g = 0;
- for u = 1 + (CurrentDamagedPage - 1) * DamagePageSize, a4 +
- (CurrentDamagedPage - 1) * DamagePageSize, 1 do
- g = g + 1;
- local a5 = damagedElements[u]
- if UseMyElementNames == true then
- a3 = a3 .. [[]] ..
- string.format("%.23s", a5.name) .. [[]]
- else
- a3 = a3 .. [[]] ..
- string.format("%.23s", a5.type) .. [[]]
- end
- a3 = a3 .. [[]] .. a5.percent .. [[%]] ..
- [[]] ..
- GenerateCommaValue(string.format("%.0f", a5.missinghp),
- true) .. [[]] ..
- [[]] .. getScraps(a5.missinghp, true) ..
- [[]] .. [[]] .. getRepairTime(a5.missinghp, true) ..
- [[]] .. [[]]
- end
- if #damagedElements > DamagePageSize then
- a3 = a3 .. [[Page ]] .. CurrentDamagedPage .. " of " ..
- math.ceil(#damagedElements / DamagePageSize) .. [[]]
- if CurrentDamagedPage < math.ceil(#damagedElements / DamagePageSize) then
- a3 = a3 .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "DamagedPageDown",
- mode = "damage",
- x1 = 65,
- x2 = 260,
- y1 = 290 + (a4 + 1) * 50,
- y2 = 290 + 50 + (a4 + 1) * 50
- })
- else
- DisableClickArea("DamagedPageDown", "damage")
- end
- if CurrentDamagedPage > 1 then
- a3 = a3 .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "DamagedPageUp",
- mode = "damage",
- x1 = 750,
- x2 = 950,
- y1 = 290 + (a4 + 1) * 50,
- y2 = 290 + 50 + (a4 + 1) * 50
- })
- else
- DisableClickArea("DamagedPageUp", "damage")
- end
- end
- end
- if #brokenElements > 0 then
- local a6 = #brokenElements;
- if a6 > DamagePageSize then a6 = DamagePageSize end
- if CurrentBrokenPage == math.ceil(#brokenElements / DamagePageSize) then
- a6 = #brokenElements % DamagePageSize + 12;
- if a6 > 12 then a6 = a6 - 12 end
- end
- a3 =
- a3 .. [[]]
- a3 = a3 ..
- [[]]
- if UseMyElementNames == true then
- a3 = a3 ..
- [[Broken Name]]
- else
- a3 = a3 ..
- [[Broken Type]]
- end
- a3 = a3 .. [[DMG]]
- a3 = a3 .. [[T]] .. ScrapTier ..
- [[ SCRREPTIME]]
- AddClickArea("damage", {
- id = "SwitchScrapTier2",
- mode = "damage",
- x1 = 1570,
- x2 = 1690,
- y1 = 315,
- y2 = 360
- })
- local g = 0;
- for u = 1 + (CurrentBrokenPage - 1) * DamagePageSize, a6 +
- (CurrentBrokenPage - 1) * DamagePageSize, 1 do
- g = g + 1;
- local a5 = brokenElements[u]
- if UseMyElementNames == true then
- a3 = a3 .. [[]] ..
- string.format("%.30s", a5.name) .. [[]]
- else
- a3 = a3 .. [[]] ..
- string.format("%.30s", a5.type) .. [[]]
- end
- a3 = a3 .. [[]] ..
- GenerateCommaValue(string.format("%.0f", a5.missinghp),
- true) .. [[]] ..
- [[]] .. getScraps(a5.missinghp, true) ..
- [[]] .. [[]] .. getRepairTime(a5.missinghp, true) ..
- [[]] .. [[]]
- end
- if #brokenElements > DamagePageSize then
- a3 =
- a3 .. [[Page ]] .. CurrentBrokenPage .. " of " ..
- math.ceil(#brokenElements / DamagePageSize) .. [[]]
- if CurrentBrokenPage > 1 then
- a3 = a3 .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "BrokenPageUp",
- mode = "damage",
- x1 = 1665,
- x2 = 1865,
- y1 = 290 + (a6 + 1) * 50,
- y2 = 290 + 50 + (a6 + 1) * 50
- })
- else
- DisableClickArea("BrokenPageUp", "damage")
- end
- if CurrentBrokenPage < math.ceil(#brokenElements / DamagePageSize) then
- a3 = a3 .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "BrokenPageDown",
- mode = "damage",
- x1 = 980,
- x2 = 1180,
- y1 = 290 + (a6 + 1) * 50,
- y2 = 290 + 50 + (a6 + 1) * 50
- })
- else
- DisableClickArea("BrokenPageDown", "damage")
- end
- end
- end
- if #damagedElements > 0 or #brokenElements > 0 then
- local a7 = math.floor(1878 / #elementsIdList * #damagedElements)
- local a8 = math.floor(1878 / #elementsIdList * #brokenElements)
- local a9 = 1878 - a7 - a8 + 1;
- a3 = a3 ..
- [[]]
- a3 = a3 .. [[]]
- a3 = a3 .. [[]]
- a3 = a3 .. [[]]
- if #damagedElements > 0 then
- a3 = a3 .. [[]] .. #damagedElements .. [[]]
- end
- if #healthyElements > 0 then
- a3 = a3 .. [[]] .. #healthyElements .. [[]]
- end
- if #brokenElements > 0 then
- a3 = a3 .. [[]] .. #brokenElements .. [[]]
- end
- a3 = a3 ..
- [[]]
- a3 = a3 .. [[]] ..
- GenerateCommaValue(string.format("%.0f",
- totalShipMaxHP - totalShipHP)) ..
- [[ HP damage in total ]] ..
- getScraps(totalShipMaxHP - totalShipHP, true) .. [[ T]] ..
- ScrapTier .. [[ scraps needed. ]] ..
- getRepairTime(totalShipMaxHP - totalShipHP, true) ..
- [[ projected repair time.]]
- else
- a3 = a3 .. GetElementLogo(812, 380, "ch", "ch", "ch") ..
- [[]] .. OkayCenterMessage .. [[]] ..
- [[]] .. #healthyElements .. [[ elements stand ]] ..
- GenerateCommaValue(string.format("%.0f", totalShipMaxHP)) ..
- [[ HP strong.]]
- end
- forceDamageRedraw = false;
- return a3
-end
-function ActionStopengines()
- if DisallowKeyPresses == true then return end
- ToggleHUD()
-end
-function ActionStrafeRight()
- if DisallowKeyPresses == true then return end
- if KeyCTRLPressed == true then
- if HUDShiftU < 4000 then
- HUDShiftU = HUDShiftU + 50;
- SaveToDatabank()
- RenderScreens()
- end
- else
- HudDeselectElement()
- end
-end
-function ActionStrafeLeft()
- if DisallowKeyPresses == true then return end
- if KeyCTRLPressed == true then
- if HUDShiftU >= 50 then
- HUDShiftU = HUDShiftU - 50;
- SaveToDatabank()
- RenderScreens()
- end
- else
- ToggleHUD()
- end
-end
-function ActionDown()
- if DisallowKeyPresses == true then return end
- if KeyCTRLPressed == true then
- if HUDShiftV < 4000 then
- HUDShiftV = HUDShiftV + 50;
- SaveToDatabank()
- RenderScreens()
- end
- else
- ChangeHudSelectedElement(1)
- end
-end
-function ActionUp()
- if DisallowKeyPresses == true then return end
- if KeyCTRLPressed == true then
- if HUDShiftV >= 50 then
- HUDShiftV = HUDShiftV - 50;
- SaveToDatabank()
- RenderScreens()
- end
- else
- ChangeHudSelectedElement(-1)
- end
-end
-function ActionOption1()
- if DisallowKeyPresses == true then return end
- ScrapTier = 1;
- SetRefresh("damage")
- RenderScreens("damage")
-end
-function ActionOption2()
- if DisallowKeyPresses == true then return end
- ScrapTier = 2;
- SetRefresh("damage")
- RenderScreens("damage")
-end
-function ActionOption3()
- if DisallowKeyPresses == true then return end
- ScrapTier = 3;
- SetRefresh("damage")
- RenderScreens("damage")
-end
-function ActionOption4()
- if DisallowKeyPresses == true then return end
- ScrapTier = 4;
- SetRefresh("damage")
- RenderScreens("damage")
-end
-function ActionOption8()
- if DisallowKeyPresses == true then return end
- HUDShiftU = 0;
- HUDShiftV = 0;
- SetRefresh("damage")
- RenderScreens("damage")
-end
-function ActionOption9()
- if DisallowKeyPresses == true then return end
- SaveToDatabank()
- SwitchScreens("off")
- unit.exit()
-end
diff --git a/src/DamageReport_3_31_UnitStart_1.lua b/src/DamageReport_3_31_UnitStart_1.lua
deleted file mode 100644
index 34808a4..0000000
--- a/src/DamageReport_3_31_UnitStart_1.lua
+++ /dev/null
@@ -1,1304 +0,0 @@
---[[
- Damage Report 3.31
- A LUA script for Dual Universe
-
- Created By Dorian Gray
- Ingame: DorianGray
- Discord: Dorian Gray#2623
-
- You can find/update this script on GitHub. Explanations, installation and usage information as well as screenshots can be found there too.
- GitHub: https://github.com/DorianTheGrey/DU-DamageReport
-
- GNU Public License 3.0. Use whatever you want, be so kind to leave credit.
-
- Credits & thanks:
- Thanks to Bayouking1 and kalazzerx for managing their forks of this script during my long absence to support the community. :)
- Thanks to Bayouking1 for fixing rocket fuel calculations.
- Thanks to NovaQuark for creating the MMO of the century.
- Thanks to Jericho, Dmentia and Archaegeo for learning a lot from their fine scripts.
- Thanks to TheBlacklist for testing and wonderful suggestions.
- SVG patterns by Hero Patterns.
- DU atlas data from Jayle Break.
-
-]]
-
---[[ 1. HELPER FUNCTIONS ]]
-
-function GenerateCommaValue(amount, kify, postcomma)
- kify = kify or false
- postcomma = postcomma or 1
- local formatted = amount
- if kify == true then
- if string.len(amount)>=4 then
- formatted = string.format("%."..postcomma.."fk", amount/1000)
- else
- formatted = string.format("%."..postcomma.."f", amount)
- end
- else
- while true do
- formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
- if (k == 0) then break end
- end
- end
- return formatted
-end
-
-function PrintConsole(output, highlight)
- highlight = highlight or false
- if highlight then
- system.print(
- "------------------------------------------------------------------------")
- end
- system.print(output)
- if highlight then
- system.print(
- "------------------------------------------------------------------------")
- end
-end
-
-function DrawCenteredText(output)
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- screens[i].element.setCenteredText(output)
- end
- end
-end
-
-function ClearConsole()
- for i = 1, 10, 1 do
- PrintConsole()
- end
-end
-
-function SwitchScreens(state)
- state = state or "on"
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- if state == "on" then
- screens[i].element.clear()
- screens[i].element.activate()
- screens[i].active = true
- else
- screens[i].element.clear()
- screens[i].element.deactivate()
- screens[i].active = false
- end
- end
- end
-end
-
---[[ Convert seconds to string (by Jericho) ]]
-function GetSecondsString(seconds)
- local seconds = tonumber(seconds)
-
- if seconds == nil or seconds <= 0 then
- return "-";
- else
- days = string.format("%2.f", math.floor(seconds/(3600*24)));
- hours = string.format("%2.f", math.floor(seconds/3600 - (days*24)));
- mins = string.format("%2.f", math.floor(seconds/60 - (hours*60) - (days*24*60)));
- secs = string.format("%2.f", math.floor(seconds - hours*3600 - (days*24*60*60) - mins *60));
- str = ""
- if tonumber(days) > 0 then str = str .. days.."d " end
- if tonumber(hours) > 0 then str = str .. hours.."h " end
- if tonumber(mins) > 0 then str = str .. mins.."m " end
- if tonumber(secs) > 0 then str = str .. secs .."s" end
- return str
- end
-end
-
-function replace_char(pos, str, r)
- return str:sub(1, pos-1) .. r .. str:sub(pos+1)
-end
-
---[[ 2. RENDER HELPER FUNCTIONS ]]
-
---[[ epochTime function by Leodr (clock script), enhanced by Jericho (DU Industry script) ]]
-function epochTime()
- function rZ(a)
- if string.len(a) <= 1 then
- return "0" .. a
- else
- return a
- end
- end
- function dPoint(b)
- if not (b == math.floor(b)) then
- return true
- else
- return false
- end
- end
- function lYear(year)
- if not dPoint(year / 4) then
- if dPoint(year / 100) then
- return true
- else
- if not dPoint(year / 400) then
- return true
- else
- return false
- end
- end
- else
- return false
- end
- end
- local c = 5;
- local d = 3600;
- local e = 86400;
- local f = 31536000;
- local g = 31622400;
- local h = 2419200;
- local i = 2505600;
- local j = 2592000;
- local k = 2678400;
- local l = {4, 6, 9, 11}
- local m = {1, 3, 5, 7, 8, 10, 12}
- local n = 0;
- local o = 1506816000;
- local q = system.getTime()
- _G["formerTime"] = q
- if AddSummertimeHour == true then q = q + 3600 end
- now = math.floor(q + o)
- year = 1970;
- secs = 0;
- n = 0;
- while secs + g < now or secs + f < now do
- if lYear(year + 1) then
- if secs + g < now then
- secs = secs + g;
- year = year + 1;
- n = n + 366
- end
- else
- if secs + f < now then
- secs = secs + f;
- year = year + 1;
- n = n + 365
- end
- end
- end
- secondsRemaining = now - secs;
- monthSecs = 0;
- yearlYear = lYear(year)
- month = 1;
- while monthSecs + h < secondsRemaining or monthSecs + j < secondsRemaining or
- monthSecs + k < secondsRemaining do
- if month == 1 then
- if monthSecs + k < secondsRemaining then
- month = 2;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 2 then
- if not yearlYear then
- if monthSecs + h < secondsRemaining then
- month = 3;
- monthSecs = monthSecs + h;
- n = n + 28
- else
- break
- end
- else
- if monthSecs + i < secondsRemaining then
- month = 3;
- monthSecs = monthSecs + i;
- n = n + 29
- else
- break
- end
- end
- end
- if month == 3 then
- if monthSecs + k < secondsRemaining then
- month = 4;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 4 then
- if monthSecs + j < secondsRemaining then
- month = 5;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- if month == 5 then
- if monthSecs + k < secondsRemaining then
- month = 6;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 6 then
- if monthSecs + j < secondsRemaining then
- month = 7;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- if month == 7 then
- if monthSecs + k < secondsRemaining then
- month = 8;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 8 then
- if monthSecs + k < secondsRemaining then
- month = 9;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 9 then
- if monthSecs + j < secondsRemaining then
- month = 10;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- if month == 10 then
- if monthSecs + k < secondsRemaining then
- month = 11;
- monthSecs = monthSecs + k;
- n = n + 31
- else
- break
- end
- end
- if month == 11 then
- if monthSecs + j < secondsRemaining then
- month = 12;
- monthSecs = monthSecs + j;
- n = n + 30
- else
- break
- end
- end
- end
- day = 1;
- daySecs = 0;
- daySecsRemaining = secondsRemaining - monthSecs;
- while daySecs + e < daySecsRemaining do
- day = day + 1;
- daySecs = daySecs + e;
- n = n + 1
- end
- hour = 0;
- hourSecs = 0;
- hourSecsRemaining = daySecsRemaining - daySecs;
- while hourSecs + d < hourSecsRemaining do
- hour = hour + 1;
- hourSecs = hourSecs + d
- end
- minute = 0;
- minuteSecs = 0;
- minuteSecsRemaining = hourSecsRemaining - hourSecs;
- while minuteSecs + 60 < minuteSecsRemaining do
- minute = minute + 1;
- minuteSecs = minuteSecs + 60
- end
- second = math.floor(now % 60)
- year = rZ(year)
- month = rZ(month)
- day = rZ(day)
- hour = rZ(hour)
- minute = rZ(minute)
- second = rZ(second)
-
- return [[]]..hour..":".. minute..[[]]..
- [[]]..year.."/".. month.."/"..day..[[]]
-end
-
-
-function ToggleHUD()
- if HUDMode == true then
- HUDMode = false
- forceDamageRedraw = true
- hudSelectedIndex = 0
- highlightID = 0
- HideHighlight()
- SetRefresh()
- RenderScreens()
- else
- HUDMode = true
- forceDamageRedraw = true
- hudSelectedIndex = 0
- highlightID = 0
- HideHighlight()
- SetRefresh()
- RenderScreens()
- end
-end
-
-function HudDeselectElement()
- hudSelectedIndex = 0
- hudStartIndex = 1
- highlightID = 0
- HideHighlight()
- if HUDMode == true then
- SetRefresh("damage")
- SetRefresh("damageoutline")
- RenderScreens()
- end
-end
-
-function ChangeHudSelectedElement(step)
- if HUDMode == true and #rE > 0 then
-
- hudSelectedIndex = hudSelectedIndex + step
- if hudSelectedIndex < 1 then hudSelectedIndex = 1
- elseif hudSelectedIndex > #rE then hudSelectedIndex = #rE
- end
-
- if hudSelectedIndex > 9 then
- hudStartIndex = hudSelectedIndex-9
- end
- if hudSelectedIndex ~= 0 then
- highlightID = rE[hudSelectedIndex].id
- if highlightID ~=nil and highlightID ~= 0 then
- -- PrintConsole("CHSE: hudSelectedIndex: "..hudSelectedIndex.." / hudStartIndex: "..hudStartIndex.." / highlightID: "..highlightID)
- HideHighlight()
- elementPosition = vec3(rE[hudSelectedIndex].pos)
- highlightX = elementPosition.x - coreWorldOffset
- highlightY = elementPosition.y - coreWorldOffset
- highlightZ = elementPosition.z - coreWorldOffset
- highlightOn = true
- ShowHighlight()
- end
- end
-
- SetRefresh("damage")
- SetRefresh("damageoutline")
- RenderScreens()
-
- end
-end
-
-function HideHighlight()
- if #hudArrowSticker > 0 then
- for i in pairs(hudArrowSticker) do
- core.deleteSticker(hudArrowSticker[i])
- end
- hudArrowSticker = {}
- end
-end
-
-function ShowHighlight()
- if highlightOn == true and highlightID > 0 then
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX + 2, highlightY, highlightZ, "north"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY - 2, highlightZ, "east"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX - 2, highlightY, highlightZ, "south"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY + 2, highlightZ, "west"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY, highlightZ - 2, "up"))
- table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX, highlightY, highlightZ + 2,"down"))
- end
-end
-
-function ToggleHighlight()
- if highlightOn == true then
- highlightOn = false
- HideHighlight()
- else
- highlightOn = true
- ShowHighlight()
- end
-end
-
-function SortDamageTables()
- table.sort(damagedElements, function(a, b) return a.missinghp > b.missinghp end)
- table.sort(brokenElements, function(a, b) return a.maxhp > b.maxhp end)
-end
-
-function getScraps(damage,commaval)
- commaval = commaval or false
- damage = damage - SkillRepairToolOptimization * 0.05 * damage
- local res = math.ceil( damage / ( 10 * 5^(ScrapTier-1) ) )
- if commaval ==true then
- return GenerateCommaValue(string.format("%.0f", res ), false)
- else
- return res
- end
-end
-
-function getRepairTime(damage,buildstring)
- buildstring = buildstring or false
- damage = damage - SkillRepairToolOptimization * 0.05 * damage
- local res = math.ceil(damage / ScrapTierRepairTimes[ScrapTier])
- res = res - ( SkillRepairToolEfficiency * 0.1 * res )
- if buildstring == true then
- return GetSecondsString(string.format("%.0f", res ) )
- else
- return res
- end
-end
-
-function UpdateDataDamageoutline()
-
- dmgoElements = {}
-
- for i,element in ipairs(brokenElements) do
- if #dmgoElements < DMGOMaxElements then
- local elementPosition = vec3(element.pos)
- local x = elementPosition.x - coreWorldOffset
- local y = elementPosition.y - coreWorldOffset
- local z = elementPosition.z - coreWorldOffset
- if x < ShipXmin then ShipXmin = x end
- if y < ShipYmin then ShipYmin = y end
- if z < ShipZmin then ShipZmin = z end
- if x > ShipXmax then ShipXmax = x end
- if y > ShipYmax then ShipYmax = y end
- if z > ShipZmax then ShipZmax = z end
- table.insert( dmgoElements, {
- id = element.id,
- type = "b",
- size = element.maxhp,
- x = x, y = y, z = z,
- xp = 0, yp = 0, zp = 0,
- u = 0, v = 0
- })
- end
- end
-
- if #dmgoElements < DMGOMaxElements then
- for i,element in ipairs(damagedElements) do
- if #dmgoElements < DMGOMaxElements then
- local elementPosition = vec3(element.pos)
- local x = elementPosition.x - coreWorldOffset
- local y = elementPosition.y - coreWorldOffset
- local z = elementPosition.z - coreWorldOffset
- if x < ShipXmin then ShipXmin = x end
- if y < ShipYmin then ShipYmin = y end
- if z < ShipZmin then ShipZmin = z end
- if x > ShipXmax then ShipXmax = x end
- if y > ShipYmax then ShipYmax = y end
- if z > ShipZmax then ShipZmax = z end
- table.insert( dmgoElements, {
- id = element.id,
- type = "d",
- size = element.maxhp,
- x = x, y = y, z = z,
- xp = 0, yp = 0, zp = 0,
- u = 0, v = 0
- })
- end
- end
- end
-
- if #dmgoElements < DMGOMaxElements then
- for i,element in ipairs(healthyElements) do
- if #dmgoElements < DMGOMaxElements then
- local elementPosition = vec3(element.pos)
- local x = elementPosition.x - coreWorldOffset
- local y = elementPosition.y - coreWorldOffset
- local z = elementPosition.z - coreWorldOffset
- if x < ShipXmin then ShipXmin = x end
- if y < ShipYmin then ShipYmin = y end
- if z < ShipZmin then ShipZmin = z end
- if x > ShipXmax then ShipXmax = x end
- if y > ShipYmax then ShipYmax = y end
- if z > ShipZmax then ShipZmax = z end
- table.insert( dmgoElements, {
- id = element.id,
- type = "h",
- size = element.maxhp,
- x = x, y = y, z = z,
- xp = 0, yp = 0, zp = 0,
- u = 0, v = 0
- })
- end
- end
- end
-
- ShipX = math.abs(ShipXmax-ShipXmin)
- ShipY = math.abs(ShipYmax-ShipYmin)
- ShipZ = math.abs(ShipZmax-ShipZmin)
-
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].xp = math.abs(100/(ShipXmax-ShipXmin)*(element.x-ShipXmin))
- dmgoElements[i].yp = math.abs(100/(ShipYmax-ShipYmin)*(element.y-ShipYmin))
- dmgoElements[i].zp = math.abs(100/(ShipZmax-ShipZmin)*(element.z-ShipZmin))
- end
-
-end
-
-function UpdateViewDamageoutline(screen)
- -- Full Width of virtual screen:
- -- UStart = 20
- -- VStart = 180
- -- UDim = 1880
- -- VDim = 840
- -- Adding frames:
- UFrame = 40
- VFrame = 40
-
- UStart = 20 + UFrame
- VStart = 180 + VFrame
- UDim = 1880 - 2*UFrame
- VDim = 840 - 2*VFrame
-
- if screen.submode == "top" then
- if DMGOStretch == false then
- local UFactor = UDim/(ShipYmax-ShipYmin)
- local VFactor = VDim/(ShipXmax-ShipXmin)
- if UFactor>=VFactor then
- local cFactor = UFactor/VFactor
- local newUDim = math.floor(UDim/cFactor)
- UStart = UStart+(UDim-newUDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100/cFactor*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*element.xp+VStart)
- end
- else
- local cFactor = VFactor/UFactor
- local newVDim = math.floor(VDim/cFactor)
- VStart = VStart+(VDim-newVDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100/cFactor*element.xp+VStart)
- end
- end
- else
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*element.xp+VStart)
- end
- end
-
-
- elseif screen.submode == "front" then
- if DMGOStretch == false then
- local UFactor = UDim/(ShipXmax-ShipXmin)
- local VFactor = VDim/(ShipZmax-ShipZmin)
- if UFactor>=VFactor then
- local cFactor = UFactor/VFactor
- local newUDim = math.floor(UDim/cFactor)
- UStart = UStart+(UDim-newUDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100/cFactor*element.xp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- else
- local cFactor = VFactor/UFactor
- local newVDim = math.floor(VDim/cFactor)
- VStart = VStart+(VDim-newVDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.xp+UStart)
- dmgoElements[i].v = math.floor(VDim/100/cFactor*(100-element.zp)+VStart)
- end
- end
- else
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.xp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- end
-
- elseif screen.submode == "side" then
- if DMGOStretch == false then
- local UFactor = UDim/(ShipYmax-ShipYmin)
- local VFactor = VDim/(ShipXmax-ShipZmin)
- if UFactor>=VFactor then
- local cFactor = UFactor/VFactor
- local newUDim = math.floor(UDim/cFactor)
- UStart = UStart+(UDim-newUDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100/cFactor*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- else
- local cFactor = VFactor/UFactor
- local newVDim = math.floor(VDim/cFactor)
- VStart = VStart+(VDim-newVDim)/2
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100/cFactor*(100-element.zp)+VStart)
- end
- end
- else
- for i,element in ipairs(dmgoElements) do
- dmgoElements[i].u = math.floor(UDim/100*element.yp+UStart)
- dmgoElements[i].v = math.floor(VDim/100*(100-element.zp)+VStart)
- end
- end
- else
- DrawCenteredText("ERROR: non-existing DMGO mode set.")
- PrintConsole("ERROR: non-existing DMGO mode set.")
- unit.exit()
- end
-end
-
-function GetDamageoutlineShip()
- local output = ""
-
- for i,element in ipairs(dmgoElements) do
- local cclass = ""
- local size = 1
-
- if element.type == "h" then
- cclass ="ch"
- elseif element.type == "d" then
- cclass = "cw"
- else
- cclass = "cc"
- end
- if element.id == highlightID then
- cclass = "f2"
- end
-
- if element.size > 0 and element.size < 1000 then
- size = 5
- elseif element.size >= 1000 and element.size < 2000 then
- size = 8
- elseif element.size >= 2000 and element.size < 5000 then
- size = 12
- elseif element.size >= 5000 and element.size < 10000 then
- size = 15
- elseif element.size >= 10000 and element.size < 20000 then
- size = 20
- elseif element.size >= 20000 then
- size = 30
- end
- output = output .. [[]]
- if element.id == highlightID then
- output = output .. [[]]
- output = output .. [[]]
- end
- end
-
- return output
-end
-
-function GetContentClickareas(screen)
- local output = ""
- if screen ~= nil and screen.ClickAreas ~= nil and #screen.ClickAreas > 0 then
- for i,ca in ipairs(screen.ClickAreas) do
- output = output ..
- [[]]
- end
- end
- return output
-end
-
-function GetElement1(x, y, width, height)
- x = x or 0
- y = y or 0
- width = width or 600
- height = height or 600
- local output = ""
- output = output ..
- [[
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetElement2(x, y)
- x = x or 0
- y = y or 0
- local output = ""
- output = output .. [[]]
- return output
-end
-
-function GetElementLogo(x, y, primaryC, secondaryC, tertiaryC)
- x = x or 812
- y = y or 380
- primaryC = primaryC or "f"
- secondaryC = secondaryC or "f2"
- tertiaryC = tertiaryC or "f3"
- local output = ""
- output = output .. [[
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetHeader(headertext)
- headertext = headertext or "ERROR: UNDEFINED"
- local output = ""
- output = output ..
- [[
- ]]..headertext..[[]]
- return output
-end
-
-function GetContentBackground(candidate, bgcolor)
- bgColor = ColorBackgroundPattern
-
- local output = ""
-
- if candidate == "dots" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' viewBox='0 0 4 4'%3E%3Cpath fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' d='M1 3h1v1H1V3zm2-2h1v1H3V1z'%3E%3C/path%3E%3C/svg%3E");]]
- elseif candidate == "rain" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='12' height='16' viewBox='0 0 12 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 .99C4 .445 4.444 0 5 0c.552 0 1 .45 1 .99v4.02C6 5.555 5.556 6 5 6c-.552 0-1-.45-1-.99V.99zm6 8c0-.546.444-.99 1-.99.552 0 1 .45 1 .99v4.02c0 .546-.444.99-1 .99-.552 0-1-.45-1-.99V8.99z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E");]]
- elseif candidate == "plus" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "signal" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='84' height='48' viewBox='0 0 84 48' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h12v6H0V0zm28 8h12v6H28V8zm14-8h12v6H42V0zm14 0h12v6H56V0zm0 8h12v6H56V8zM42 8h12v6H42V8zm0 16h12v6H42v-6zm14-8h12v6H56v-6zm14 0h12v6H70v-6zm0-16h12v6H70V0zM28 32h12v6H28v-6zM14 16h12v6H14v-6zM0 24h12v6H0v-6zm0 8h12v6H0v-6zm14 0h12v6H14v-6zm14 8h12v6H28v-6zm-14 0h12v6H14v-6zm28 0h12v6H42v-6zm14-8h12v6H56v-6zm0-8h12v6H56v-6zm14 8h12v6H70v-6zm0 8h12v6H70v-6zM14 24h12v6H14v-6zm14-8h12v6H28v-6zM14 8h12v6H14V8zM0 8h12v6H0V8z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E");]]
- elseif candidate == "deathstar" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='105' viewBox='0 0 80 105'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M20 10a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm15 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zM20 75a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zm30-65a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm0 65a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zM35 10a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zM5 45a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zm60 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10z' /%3E%3C/g%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "diamond" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='32' viewBox='0 0 16 32'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath fill-rule='evenodd' d='M0 24h4v2H0v-2zm0 4h6v2H0v-2zm0-8h2v2H0v-2zM0 0h4v2H0V0zm0 4h2v2H0V4zm16 20h-6v2h6v-2zm0 4H8v2h8v-2zm0-8h-4v2h4v-2zm0-20h-6v2h6V0zm0 4h-4v2h4V4zm-2 12h2v2h-2v-2zm0-8h2v2h-2V8zM2 8h10v2H2V8zm0 8h10v2H2v-2zm-2-4h14v2H0v-2zm4-8h6v2H4V4zm0 16h6v2H4v-2zM6 0h2v2H6V0zm0 24h2v2H6v-2z'/%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "hexagon" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='49' viewBox='0 0 28 49'%3E%3Cg fill-rule='evenodd'%3E%3Cg id='hexagons' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='nonzero'%3E%3Cpath d='M13.99 9.25l13 7.5v15l-13 7.5L1 31.75v-15l12.99-7.5zM3 17.9v12.7l10.99 6.34 11-6.35V17.9l-11-6.34L3 17.9zM0 15l12.98-7.5V0h-2v6.35L0 12.69v2.3zm0 18.5L12.98 41v8h-2v-6.85L0 35.81v-2.3zM15 0v7.5L27.99 15H28v-2.31h-.01L17 6.35V0h-2zm0 49v-8l12.99-7.5H28v2.31h-.01L17 42.15V49h-2z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");]]
- elseif candidate == "capsule" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='32' height='26' viewBox='0 0 32 26' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M14 0v3.994C14 7.864 10.858 11 7 11c-3.866 0-7-3.138-7-7.006V0h2v4.005C2 6.765 4.24 9 7 9c2.756 0 5-2.236 5-4.995V0h2zm0 26v-5.994C14 16.138 10.866 13 7 13c-3.858 0-7 3.137-7 7.006V26h2v-6.005C2 17.235 4.244 15 7 15c2.76 0 5 2.236 5 4.995V26h2zm2-18.994C16 3.136 19.142 0 23 0c3.866 0 7 3.138 7 7.006v9.988C30 20.864 26.858 24 23 24c-3.866 0-7-3.138-7-7.006V7.006zm2-.01C18 4.235 20.244 2 23 2c2.76 0 5 2.236 5 4.995v10.01C28 19.765 25.756 22 23 22c-2.76 0-5-2.236-5-4.995V6.995z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E");]]
- elseif candidate == "diagonal" then
- output=[[background-image: url("data:image/svg+xml,%3Csvg width='6' height='6' viewBox='0 0 6 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'%3E%3Cpath d='M5 0h1L0 6V5zM6 5v1H5z'/%3E%3C/g%3E%3C/svg%3E");]]
- end
- return output;
-end
-
-function GetContentDamageHUDOutput()
- local hudWidth = 300
- local hudHeight = 165
- if #damagedElements > 0 or #brokenElements > 0 then hudHeight = 510 end
- local output = ""
-
- output = output .. [[
-
- ]]
- output = output .. [[]] ..
- [[]] ..
- [[]] ..
- [[]]..(YourShipsName=="Enter here" and ("Ship ID "..ShipID) or YourShipsName) .. [[]] ..
- [[]]
- if #brokenElements > 0 then
- output = output .. [[]]
- elseif #damagedElements > 0 then
- output = output .. [[]]
- else
- output = output .. [[]]
- end
-
- if #damagedElements > 0 or #brokenElements > 0 then
-
- output = output .. [[Total Damage]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", totalShipMaxHP - totalShipHP))..[[]]
- output = output .. [[T]]..ScrapTier..[[ Scrap Needed]] ..
- [[]]..getScraps(totalShipMaxHP - totalShipHP, true)..[[]]
- output = output .. [[Repair Time]] ..
- [[]]..getRepairTime(totalShipMaxHP - totalShipHP, true)..[[]]
-
- output = output .. [[]] ..
- [[]] ..
- [[]]..#healthyElements..[[]] ..
- [[]] ..
- [[]]..#damagedElements..[[]] ..
- [[]] ..
- [[]]..#brokenElements..[[]]
- local j=0
-
- for currentIndex=hudStartIndex,hudStartIndex+9,1 do
- if rE[currentIndex] ~= nil then
- v = rE[currentIndex]
- if v.hp > 0 then
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- if v.id == highlightID then
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- end
- else
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- if v.id == highlightID then
- highlightX = elementPosition.x - coreWorldOffset
- highlightY = elementPosition.y - coreWorldOffset
- highlightZ = elementPosition.z - coreWorldOffset
- output = output .. [[]] ..
- [[]]..string.format("%.30s", v.name)..[[]] ..
- [[]]..GenerateCommaValue(string.format("%.0f", v.missinghp))..[[]]
- end
- end
- j=j+1
- end
- end
- if DisallowKeyPresses == true then
- output = output ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Keypresses disabled.]] ..
- [[Change in LUA parameters]] ..
- [[by unchecking DisallowKeyPresses.]] ..
- [[]] ..
- [[]] ..
- [[]]
- else
- output = output ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Up/down arrows to highlight]] ..
- [[CTRL + arrows to move HUD]] ..
- [[Left arrow to toggle HUD Mode]] ..
- [[ALT+1-4 to set Scrap Tier]] ..
- [[ALT+8 to reset HUD position]] ..
- [[ALT+9 to shut script off]] ..
- [[]] ..
- [[]]
- end
- else
- if DisallowKeyPresses == true then
- output = output ..
- [[]] .. OkayCenterMessage .. [[]] ..
- [[]]..#healthyElements..[[ elements / ]] .. GenerateCommaValue(string.format("%.0f", totalShipMaxHP)) .. [[ HP.]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Keypresses disabled.]] ..
- [[Change in LUA parameters]] ..
- [[by unchecking DisallowKeyPresses.]] ..
- [[]] ..
- [[]] ..
- [[]]
- else
- output = output ..
- [[]] .. OkayCenterMessage .. [[]] ..
- [[]]..#healthyElements..[[ elements / ]] .. GenerateCommaValue(string.format("%.0f", totalShipMaxHP)) .. [[ HP.]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Left arrow to toggle HUD Mode]] ..
- [[CTRL + arrows to move HUD]] ..
- [[ALT+8 to reset HUD position]] ..
- [[ALT+9 to shut script off]] ..
- [[]] ..
- [[]]
- end
- end
- output = output .. [[]]
- return output
-end
-
-function GetContentDamageScreen()
-
- local screenOutput = ""
-
- -- Draw damage elements
- if #damagedElements > 0 then
- local damagedElementsToDraw = #damagedElements
- if damagedElementsToDraw > DamagePageSize then
- damagedElementsToDraw = DamagePageSize
- end
- if CurrentDamagedPage == math.ceil(#damagedElements / DamagePageSize) then
- damagedElementsToDraw = #damagedElements % DamagePageSize + 12
- if damagedElementsToDraw > 12 then damagedElementsToDraw = damagedElementsToDraw - 12 end
- end
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
-
- if UseMyElementNames == true then screenOutput = screenOutput .. [[Damaged Name]]
- else screenOutput = screenOutput .. [[Damaged Type]]
- end
-
- screenOutput = screenOutput .. [[HLTHDMG]]
- screenOutput = screenOutput .. [[T]]..ScrapTier..[[ SCRREPTIME]]
-
- AddClickArea("damage", {
- id = "SwitchScrapTier",
- mode ="damage",
- x1 = 650,
- x2 = 775,
- y1 = 315,
- y2 = 360
- })
-
- local i = 0
- for j = 1 + (CurrentDamagedPage - 1) * DamagePageSize, damagedElementsToDraw + (CurrentDamagedPage - 1) * DamagePageSize, 1 do
- i = i + 1
- local DP = damagedElements[j]
- if UseMyElementNames == true then screenOutput = screenOutput .. [[]] .. string.format("%.23s", DP.name) .. [[]]
- else screenOutput = screenOutput .. [[]] .. string.format("%.23s", DP.type) .. [[]]
- end
- screenOutput = screenOutput .. [[]] .. DP.percent .. [[%]] ..
- [[]] .. GenerateCommaValue(string.format("%.0f", DP.missinghp), true) .. [[]] ..
- [[]] .. getScraps(DP.missinghp, true) .. [[]] ..
- [[]] .. getRepairTime(DP.missinghp, true) .. [[]] ..
- [[]]
- end
-
- if #damagedElements > DamagePageSize then
- screenOutput = screenOutput ..
- [[Page ]] .. CurrentDamagedPage .. " of " .. math.ceil(#damagedElements / DamagePageSize) ..[[]]
-
- if CurrentDamagedPage < math.ceil(#damagedElements / DamagePageSize) then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "DamagedPageDown",
- mode ="damage",
- x1 = 65,
- x2 = 260,
- y1 = 290 + (damagedElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (damagedElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("DamagedPageDown","damage")
- end
-
- if CurrentDamagedPage > 1 then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "DamagedPageUp",
- mode ="damage",
- x1 = 750,
- x2 = 950,
- y1 = 290 + (damagedElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (damagedElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("DamagedPageUp","damage")
- end
- end
- end
-
- -- Draw broken elements
- if #brokenElements > 0 then
- local brokenElementsToDraw = #brokenElements
- if brokenElementsToDraw > DamagePageSize then
- brokenElementsToDraw = DamagePageSize
- end
- if CurrentBrokenPage == math.ceil(#brokenElements / DamagePageSize) then
- brokenElementsToDraw = #brokenElements % DamagePageSize + 12
- if brokenElementsToDraw > 12 then brokenElementsToDraw = brokenElementsToDraw - 12 end
- end
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
-
- if UseMyElementNames == true then screenOutput = screenOutput .. [[Broken Name]]
- else screenOutput = screenOutput .. [[Broken Type]]
- end
-
- screenOutput = screenOutput .. [[DMG]]
- screenOutput = screenOutput .. [[T]]..ScrapTier..[[ SCRREPTIME]]
-
- AddClickArea("damage", {
- id = "SwitchScrapTier2",
- mode ="damage",
- x1 = 1570,
- x2 = 1690,
- y1 = 315,
- y2 = 360
- })
-
- local i = 0
- for j = 1 + (CurrentBrokenPage - 1) * DamagePageSize, brokenElementsToDraw + (CurrentBrokenPage - 1) * DamagePageSize, 1 do
- i = i + 1
- local DP = brokenElements[j]
- if UseMyElementNames == true then screenOutput = screenOutput .. [[]] .. string.format("%.30s", DP.name) .. [[]]
- else screenOutput = screenOutput .. [[]] .. string.format("%.30s", DP.type) .. [[]]
- end
- screenOutput = screenOutput .. [[]] .. GenerateCommaValue(string.format("%.0f", DP.missinghp), true) .. [[]] ..
- [[]] .. getScraps(DP.missinghp, true) .. [[]] ..
- [[]] .. getRepairTime(DP.missinghp, true) .. [[]] ..
- [[]]
- end
-
-
-
- if #brokenElements > DamagePageSize then
- screenOutput = screenOutput ..
- [[Page ]] .. CurrentBrokenPage .. " of " .. math.ceil(#brokenElements / DamagePageSize) .. [[]]
-
- if CurrentBrokenPage > 1 then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "BrokenPageUp",
- mode ="damage",
- x1 = 1665,
- x2 = 1865,
- y1 = 290 + (brokenElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (brokenElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("BrokenPageUp", "damage")
- end
-
- if CurrentBrokenPage < math.ceil(#brokenElements / DamagePageSize) then
- screenOutput = screenOutput .. [[
-
-
- ]]
- AddClickArea("damage", {
- id = "BrokenPageDown",
- mode ="damage",
- x1 = 980,
- x2 = 1180,
- y1 = 290 + (brokenElementsToDraw + 1) * 50,
- y2 = 290 + 50 + (brokenElementsToDraw + 1) * 50
- })
- else
- DisableClickArea("BrokenPageDown", "damage")
- end
- end
-
- end
-
- -- Draw summary
- if #damagedElements > 0 or #brokenElements > 0 then
- local dWidth = math.floor(1878/#elementsIdList*#damagedElements)
- local bWidth = math.floor(1878/#elementsIdList*#brokenElements)
- local hWidth = 1878-dWidth-bWidth+1
-
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
- screenOutput = screenOutput .. [[]]
-
- if #damagedElements > 0 then
- screenOutput = screenOutput .. [[]]..#damagedElements..[[]]
- end
- if #healthyElements > 0 then
- screenOutput = screenOutput .. [[]]..#healthyElements..[[]]
- end
- if #brokenElements > 0 then
- screenOutput = screenOutput .. [[]]..#brokenElements..[[]]
- end
-
- screenOutput = screenOutput .. [[]]
-
- screenOutput = screenOutput .. [[]] ..
- GenerateCommaValue(string.format("%.0f", totalShipMaxHP - totalShipHP)) .. [[ HP damage in total ]] ..
- getScraps(totalShipMaxHP - totalShipHP, true) .. [[ T]]..ScrapTier..[[ scraps needed. ]] ..
- getRepairTime(totalShipMaxHP - totalShipHP, true) .. [[ projected repair time.]]
- else
- screenOutput = screenOutput .. GetElementLogo(812, 380, "ch", "ch", "ch") ..
- [[]] .. OkayCenterMessage .. [[]] ..
- [[]]..#healthyElements..[[ elements stand ]] .. GenerateCommaValue(string.format("%.0f", totalShipMaxHP)) .. [[ HP strong.]]
- end
-
- forceDamageRedraw = false
-
- return screenOutput
-end
-
-function ActionStopengines()
- if DisallowKeyPresses == true then return end
- ToggleHUD()
-end
-
-function ActionStrafeRight()
- if DisallowKeyPresses == true then return end
- if KeyCTRLPressed == true then
- if HUDShiftU < 4000 then
- HUDShiftU = HUDShiftU + 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- HudDeselectElement()
- end
-end
-
-function ActionStrafeLeft()
- if DisallowKeyPresses == true then return end
- if KeyCTRLPressed == true then
- if HUDShiftU >= 50 then
- HUDShiftU = HUDShiftU - 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- ToggleHUD()
- end
-end
-
-function ActionDown()
- if DisallowKeyPresses == true then return end
- if KeyCTRLPressed == true then
- if HUDShiftV < 4000 then
- HUDShiftV = HUDShiftV + 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- ChangeHudSelectedElement(1)
- end
-end
-
-function ActionUp()
- if DisallowKeyPresses == true then return end
- if KeyCTRLPressed == true then
- if HUDShiftV >= 50 then
- HUDShiftV = HUDShiftV - 50
- SaveToDatabank()
- RenderScreens()
- end
- else
- ChangeHudSelectedElement(-1)
- end
-end
-
-function ActionOption1()
- if DisallowKeyPresses == true then return end
- ScrapTier = 1
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption2()
- if DisallowKeyPresses == true then return end
- ScrapTier = 2
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption3()
- if DisallowKeyPresses == true then return end
- ScrapTier = 3
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption4()
- if DisallowKeyPresses == true then return end
- ScrapTier = 4
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption8()
- if DisallowKeyPresses == true then return end
- HUDShiftU=0
- HUDShiftV=0
- SetRefresh("damage")
- RenderScreens("damage")
-end
-
-function ActionOption9()
- if DisallowKeyPresses == true then return end
- SaveToDatabank()
- SwitchScreens("off")
- unit.exit()
-end
diff --git a/src/DamageReport_3_31_UnitStart_2.lua b/src/DamageReport_3_31_UnitStart_2.lua
deleted file mode 100644
index d718831..0000000
--- a/src/DamageReport_3_31_UnitStart_2.lua
+++ /dev/null
@@ -1,2047 +0,0 @@
---[[
- Damage Report 3.31
- A LUA script for Dual Universe
-
- Created By Dorian Gray
- Ingame: DorianGray
- Discord: Dorian Gray#2623
-
- You can find/update this script on GitHub. Explanations, installation and usage information as well as screenshots can be found there too.
- GitHub: https://github.com/DorianTheGrey/DU-DamageReport
-
- GNU Public License 3.0. Use whatever you want, be so kind to leave credit.
-
- Credits & thanks:
- Thanks to Bayouking1 and kalazzerx for managing their forks of this script during my long absence to support the community. :)
- Thanks to Bayouking1 for fixing rocket fuel calculations.
- Thanks to NovaQuark for creating the MMO of the century.
- Thanks to Jericho, Dmentia and Archaegeo for learning a lot from their fine scripts.
- Thanks to TheBlacklist for testing and wonderful suggestions.
- SVG patterns by Hero Patterns.
- DU atlas data from Jayle Break.
-
-]]
-
---[[ 1. USER DEFINED VARIABLES ]]
-
-YourShipsName = "Enter here" --export Enter your ship name here if you want it displayed instead of the ship's ID. YOU NEED TO LEAVE THE QUOTATION MARKS.
-
-SkillRepairToolEfficiency = 0 --export Enter (0-5) your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency"
-SkillRepairToolOptimization = 0 --export Enter your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Optimization"
-
-StatAtmosphericFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED ATMOSPHERIC FUEL TANKS (from the builders talent "Piloting -> Atmospheric Flight Technician -> Atmospheric Fuel-Tank Handling")
-StatSpaceFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL SPACE TANKS (from the builders talent "Piloting -> Atmospheric Engine Technician -> Space Fuel-Tank Handling")
-StatRocketFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL ROCKET TANKS (from the builders talent "Piloting -> Rocket Scientist -> Rocket Booster Fuel Tank Handling")
-StatContainerOptimization = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL TANKS "from the builders talent Mining and Inventory -> Stock Control -> Container Optimization"
-StatFuelTankOptimization = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL TANKS "from the builders talent Mining and Inventory -> Stock Control -> Fuel Tank Optimization"
-
-ShowWelcomeMessage = true --export Do you want the welcome message on the start screen with your name?
-DisallowKeyPresses = false --export Need your keys for other scripts/huds and want to prevent Damage Report keypresses to be processed? Then check this. (Usability of the HUD mode will be small.)
-AddSummertimeHour = false --export: Is summertime currently enabled in your location? (Adds one hour.)
-
--- SkillAtmosphericFuelEfficiency = 0 --export Enter (0-5) your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency"
--- SkillSpaceFuelEfficiency = 0 --export Enter (0-5) your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency"
--- SkillRocketFuelEfficiency = 0 --export Enter (0-5) your talent "Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency"
-
---[[ 2. GLOBAL VARIABLES ]]
-
-UpdateDataInterval = 1.0 -- How often shall the data be updated? (Increase if running into CPU issues.)
-HighlightBlinkingInterval = 0.5 -- How fast shall highlight arrows of marked elements blink?
-
-ColorPrimary = "FF6700" -- Enter the hexcode of the main color to be used by all views.
-ColorSecondary = "FFFFFF" -- Enter the hexcode of the secondary color to be used by all views.
-ColorTertiary = "000000" -- Enter the hexcode of the tertiary color to be used by all views.
-ColorHealthy = "00FF00" -- Enter the hexcode of the 'healthy' color to be used by all views.
-ColorWarning = "FFFF00" -- Enter the hexcode of the 'warning' color to be used by all views.
-ColorCritical = "FF0000" -- Enter the hexcode of the 'critical' color to be used by all views.
-ColorBackground = "000000" -- Enter the hexcode of the background color to be used by all views.
-ColorBackgroundPattern = "4F4F4F" -- Enter the hexcode of the background color to be used by all views.
-ColorFuelAtmospheric = "004444" -- Enter the hexcode of the atmospheric fuel color.
-ColorFuelSpace = "444400" -- Enter the hexcode of the space fuel color.
-ColorFuelRocket = "440044" -- Enter the hexcode of the rocket fuel color.
-
-VERSION = 3.31
-DebugMode = false
-DebugRenderClickareas = true
-
-DBData = {}
-
-core = nil
-db = nil
-screens = {}
-dscreens = {}
-
-Warnings = {}
-
-screenModes = {
- ["flight"] = { id="flight" },
- ["damage"] = { id="damage" },
- ["damageoutline"] = { id="damageoutline" },
- ["fuel"] = { id="fuel" },
- ["cargo"] = { id="cargo" },
- ["agg"] = { id="agg" },
- ["map"] = { id="map" },
- ["time"] = { id="time", activetoggle="true" },
- ["settings1"] = { id="settings1" },
- ["startup"] = { id="startup" }
-}
-
-backgroundModes = { "deathstar", "capsule", "rain", "signal", "hexagon", "diagonal", "diamond", "plus", "dots" }
-BackgroundMode ="deathstar"
-BackgroundSelected = 1
-BackgroundModeOpacity = 0.25
-
-SaveVars = { "dscreens",
- "ColorPrimary", "ColorSecondary", "ColorTertiary",
- "ColorHealthy", "ColorWarning", "ColorCritical",
- "ColorBackground", "ColorBackgroundPattern",
- "ColorFuelAtmospheric", "ColorFuelSpace", "ColorFuelRocket",
- "ScrapTier", "HUDMode", "SimulationMode", "DMGOStretch",
- "HUDShiftU", "HUDShiftV", "colorIDIndex", "colorIDTable",
- "BackgroundMode", "BackgroundSelected", "BackgroundModeOpacity" }
-
-HUDMode = false
-HUDShiftU = 0
-HUDShiftV = 0
-hudSelectedIndex = 0
-hudStartIndex = 1
-hudArrowSticker = {}
-highlightOn = false
-highlightID = 0
-highlightX = 0
-highlightY = 0
-highlightZ = 0
-
-SimulationMode = false
-OkayCenterMessage = "All systems nominal."
-CurrentDamagedPage = 1
-CurrentBrokenPage = 1
-DamagePageSize = 12
-ScrapTier = 1
-totalScraps = 0
-ScrapTierRepairTimes = { 10, 50, 250, 1250 }
-
-coreWorldOffset = 0
-totalShipHP = 0
-formerTotalShipHP = -1
-totalShipMaxHP = 0
-totalShipIntegrity = 100
-elementsId = {}
-elementsIdList = {}
-damagedElements = {}
-brokenElements = {}
-rE = {}
-healthyElements = {}
-typeElements = {}
-ElementCounter = 0
-UseMyElementNames = true
-dmgoElements = {}
-DMGOMaxElements = 250
-DMGOStretch = false
-ShipXmin = 99999999
-ShipXmax = -99999999
-ShipYmin = 99999999
-ShipYmax = -99999999
-ShipZmin = 99999999
-ShipZmax = -99999999
-
-totalShipMass = 0
-formerTotalShipMass = -1
-
-formerTime = -1
-
-FuelAtmosphericTanks = {}
-FuelSpaceTanks = {}
-FuelRocketTanks = {}
-FuelAtmosphericTotal = 0
-FuelSpaceTotal = 0
-FuelRocketTotal = 0
-FuelAtmosphericCurrent = 0
-FuelSpaceTotalCurrent = 0
-FuelRocketTotalCurrent = 0
-formerFuelAtmosphericTotal = -1
-formerFuelSpaceTotal = -1
-formerFuelRocketTotal = -1
-
-hexTable = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"}
-colorIDIndex = 1
-colorIDTable = {
- [1] = {
- id="ColorPrimary",
- desc="Main HUD Color",
- basec = "FF6700",
- newc = "FF6700"
- },
- [2] = {
- id="ColorSecondary",
- desc="Secondary HUD Color",
- basec = "FFFFFF",
- newc = "FFFFFF"
- },
- [3] = {
- id="ColorTertiary",
- desc="Tertiary HUD Color",
- basec = "000000",
- newc = "000000"
- },
- [4] = {
- id="ColorHealthy",
- desc="Color code for Healthy/Okay",
- basec = "00FF00",
- newc = "00FF00"
- },
- [5] = {
- id="ColorWarning",
- desc="Color code for Damaged/Warning",
- basec = "FFFF00",
- newc = "FFFF00"
- },
- [6] = {
- id="ColorCritical",
- desc="Color code for Broken/Critical",
- basec = "FF0000",
- newc = "FF0000"
- },
- [7] = {
- id="ColorBackground",
- desc="Background Color",
- basec = "000000",
- newc = "000000"
- },
- [8] = {
- id="ColorBackgroundPattern",
- desc="Background Pattern Color",
- basec = "4F4F4F",
- newc = "4F4F4F"
- },
- [9] = {
- id="ColorFuelAtmospheric",
- desc="Color for Atmo Fuel/Elements",
- basec = "004444",
- newc = "004444"
- },
- [10] = {
- id="ColorFuelSpace",
- desc="Color for Space Fuel/Elements",
- basec = "444400",
- newc = "444400"
- },
- [11] = {
- id="ColorFuelRocket",
- desc="Color for Rocket Fuel/Elements",
- basec = "440044",
- newc = "440044"
- }
-}
-
-
---[[ 3. PROCESSING FUNCTIONS ]]
-
-function InitiateSlots()
- for slot_name, slot in pairs(unit) do
- if type(slot) == "table" and type(slot.export) == "table" and
- slot.getElementClass then
- local elementClass = slot.getElementClass():lower()
- if elementClass:find("coreunit") then
- core = slot
- local coreHP = core.getMaxHitPoints()
- if coreHP > 10000 then
- coreWorldOffset = 128
- elseif coreHP > 1000 then
- coreWorldOffset = 64
- elseif coreHP > 150 then
- coreWorldOffset = 32
- else
- coreWorldOffset = 16
- end
- elseif elementClass == 'databankunit' then
- db = slot
- elseif elementClass == "screenunit" then
- local iScreenMode = "startup"
- screens[#screens + 1] = {
- element = slot,
- id = slot.getId(),
- mode = iScreenMode,
- submode = "",
- ClickAreas = {},
- refresh = true,
- active = false,
- fuelA = true,
- fuelS = true,
- fuelR = true,
- fuelIndex = 1
- }
- end
- end
- end
-end
-
-function LoadFromDatabank()
- if db == nil then
- return
- else
- for _, data in pairs(SaveVars) do
- if db.hasKey(data) then
- local jData = json.decode( db.getStringValue(data) )
- if jData ~= nil then
- if data == "YourShipsName" or data == "AddSummertimeHour" or data == "UpdateDataInterval" or data == "HighlightBlinkingInterval" or
- data == "SkillRepairToolEfficiency" or data == "SkillRepairToolOptimization" or data == "SkillAtmosphericFuelEfficiency" or
- data == "SkillSpaceFuelEfficiency" or data == "SkillRocketFuelEfficiency" or data == "StatAtmosphericFuelTankHandling" or
- data == "StatSpaceFuelTankHandling" or data == "StatRocketFuelTankHandling"
- then
- -- Nada
- else
- _G[data] = jData
- end
- end
- end
- end
-
- for i,v in ipairs(screens) do
- for j,dv in ipairs(dscreens) do
- if screens[i].id == dscreens[j].id then
- screens[i].mode = dscreens[j].mode
- screens[i].submode = dscreens[j].submode
- screens[i].active = dscreens[j].active
- screens[i].refresh = true
- screens[i].fuelA = dscreens[j].fuelA
- screens[i].fuelS = dscreens[j].fuelS
- screens[i].fuelR = dscreens[j].fuelR
- screens[i].fuelIndex = dscreens[j].fuelIndex
- end
- end
- end
- end
-end
-
-function SaveToDatabank()
- if db == nil then
- return
- else
- dscreens = {}
- for i,screen in ipairs(screens) do
- dscreens[i] = {}
- dscreens[i].id = screen.id
- dscreens[i].mode = screen.mode
- dscreens[i].submode = screen.submode
- dscreens[i].active = screen.active
- dscreens[i].fuelA = screen.fuelA
- dscreens[i].fuelS = screen.fuelS
- dscreens[i].fuelR = screen.fuelR
- dscreens[i].fuelIndex = screen.fuelIndex
- end
-
- db.clear()
-
- for _, data in pairs(SaveVars) do
- db.setStringValue(data, json.encode(_G[data]))
- end
-
- end
-end
-
-function InitiateScreens()
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- screens[i] = CreateClickAreasForScreen(screens[i])
- end
- end
-end
-
-function UpdateTypeData()
- FuelAtmosphericTanks = {}
- FuelSpaceTanks = {}
- FuelRocketTanks = {}
-
- FuelAtmosphericTotal = 0
- FuelAtmosphericCurrent = 0
- FuelSpaceTotal = 0
- FuelSpaceCurrent = 0
- FuelRocketCurrent = 0
- FuelRocketTotal = 0
-
- local weightAtmosphericFuel = 4
- local weightSpaceFuel = 6
- local weightRocketFuel = 0.8
-
- if StatContainerOptimization > 0 then
- weightAtmosphericFuel = weightAtmosphericFuel - 0.05 * StatContainerOptimization * weightAtmosphericFuel
- weightSpaceFuel = weightSpaceFuel - 0.05 * StatContainerOptimization * weightSpaceFuel
- weightRocketFuel = weightRocketFuel - 0.05 * StatContainerOptimization * weightRocketFuel
- end
- if StatFuelTankOptimization > 0 then
- weightAtmosphericFuel = weightAtmosphericFuel - 0.05 * StatFuelTankOptimization * weightAtmosphericFuel
- weightSpaceFuel = weightSpaceFuel - 0.05 * StatFuelTankOptimization * weightSpaceFuel
- weightRocketFuel = weightRocketFuel - 0.05 * StatFuelTankOptimization * weightRocketFuel
- end
-
- for i, id in ipairs(typeElements) do
- local idName = core.getElementNameById(id) or ""
- local idType = core.getElementTypeById(id) or ""
- local idPos = core.getElementPositionById(id) or 0
- local idHP = core.getElementHitPointsById(id) or 0
- local idMaxHP = core.getElementMaxHitPointsById(id) or 0
- local idMass = core.getElementMassById(id) or 0
-
- local baseSize = ""
- local baseVol = 0
- local baseMass = 0
- local cMass = 0
- local cVol = 0
-
- if idType == "Atmospheric Fuel Tank" then
- if idMaxHP > 10000 then
- baseSize = "L"
- baseMass = 5480
- baseVol = 12800
- elseif idMaxHP > 1300 then
- baseSize = "M"
- baseMass = 988.67
- baseVol = 1600
- elseif idMaxHP > 150 then
- baseSize = "S"
- baseMass = 182.67
- baseVol = 400
- else
- baseSize = "XS"
- baseMass = 35.03
- baseVol = 100
- end
- if StatAtmosphericFuelTankHandling > 0 then
- baseVol = 0.2 * StatAtmosphericFuelTankHandling * baseVol + baseVol
- end
- cMass = idMass - baseMass
- if cMass <=10 then cMass = 0 end
- cVol = string.format("%.0f", cMass / weightAtmosphericFuel)
- cPercent = string.format("%.1f", math.floor(100/baseVol * tonumber(cVol)))
- table.insert(FuelAtmosphericTanks, {
- type = 1,
- id = id,
- name = idName,
- maxhp = idMaxHP,
- hp = GetHPforElement(id),
- pos = idPos,
- size = baseSize,
- mass = baseMass,
- vol = baseVol,
- cvol = cVol,
- percent = cPercent
- })
- if idHP > 0 then
- FuelAtmosphericCurrent = FuelAtmosphericCurrent + cVol
- end
- FuelAtmosphericTotal = FuelAtmosphericTotal + baseVol
- elseif idType == "Space Fuel Tank" then
- if idMaxHP > 10000 then
- baseSize = "L"
- baseMass = 5480
- baseVol = 12800
- elseif idMaxHP > 1300 then
- baseSize = "M"
- baseMass = 988.67
- baseVol = 1600
- else
- baseSize = "S"
- baseMass = 182.67
- baseVol = 400
- end
- if StatSpaceFuelTankHandling > 0 then
- baseVol = 0.2 * StatSpaceFuelTankHandling * baseVol + baseVol
- end
- cMass = idMass - baseMass
- if cMass <=10 then cMass = 0 end
- cVol = string.format("%.0f", cMass / weightSpaceFuel)
- cPercent = string.format("%.1f", (100/baseVol * tonumber(cVol)))
- table.insert(FuelSpaceTanks, {
- type = 2,
- id = id,
- name = idName,
- maxhp = idMaxHP,
- hp = GetHPforElement(id),
- pos = idPos,
- size = baseSize,
- mass = baseMass,
- vol = baseVol,
- cvol = cVol,
- percent = cPercent
- })
- if idHP > 0 then
- FuelSpaceCurrent = FuelSpaceCurrent + cVol
- end
- FuelSpaceTotal = FuelSpaceTotal + baseVol
- elseif idType == "Rocket Fuel Tank" then
- if idMaxHP > 65000 then
- baseSize = "L"
- baseMass = 25740
- baseVol = 50000
- elseif idMaxHP > 6000 then
- baseSize = "M"
- baseMass = 4720
- baseVol = 6400
- elseif idMaxHP > 700 then
- baseSize = "S"
- baseMass = 886.72
- baseVol = 800
- else
- baseSize = "XS"
- baseMass = 173.42
- baseVol = 400
- end
- if StatRocketFuelTankHandling > 0 then
- baseVol = 0.1 * StatRocketFuelTankHandling * baseVol + baseVol
- end
- cMass = idMass - baseMass
- if cMass <=10 then cMass = 0 end
- cVol = string.format("%.0f", cMass / weightRocketFuel)
- cPercent = string.format("%.1f", (100/baseVol * tonumber(cVol)))
- table.insert(FuelRocketTanks, {
- type = 3,
- id = id,
- name = idName,
- maxhp = idMaxHP,
- hp = GetHPforElement(id),
- pos = idPos,
- size = baseSize,
- mass = baseMass,
- vol = baseVol,
- cvol = cVol,
- percent = cPercent
- })
- if idHP > 0 then
- FuelRocketCurrent = FuelRocketCurrent + cVol
- end
- FuelRocketTotal = FuelRocketTotal + baseVol
- end
-
- end
-
- if FuelAtmosphericCurrent ~= formerFuelAtmosphericCurrent then
- SetRefresh("fuel")
- formerFuelAtmosphericCurrent = FuelAtmosphericCurrent
- end
- if FuelSpaceCurrent ~= formerFuelSpaceCurrent then
- SetRefresh("fuel")
- formerFuelSpaceCurrent = FuelSpaceCurrent
- end
- if FuelRocketCurrent ~= formerFuelRocketCurrent then
- SetRefresh("fuel")
- formerFuelRocketCurrent = FuelRocketCurrent
- end
-
-
-
-end
-
-function UpdateDamageData(initial)
-
- initial = initial or false
-
- if SimulationActive == true then return end
-
- local formerTotalShipHP = totalShipHP
- totalShipHP = 0
- totalShipMaxHP = 0
- totalShipIntegrity = 100
- damagedElements = {}
- brokenElements = {}
- healthyElements = {}
- if initial == true then
- typeElements = {}
- end
-
- ElementCounter = 0
-
- elementsIdList = core.getElementIdList()
-
- for i, id in pairs(elementsIdList) do
-
- ElementCounter = ElementCounter + 1
-
- local idName = core.getElementNameById(id)
-
- local idType = core.getElementTypeById(id)
- local idPos = core.getElementPositionById(id)
- local idHP = core.getElementHitPointsById(id)
- local idMaxHP = core.getElementMaxHitPointsById(id)
-
- if SimulationMode == true then
- SimulationActive = true
- local dice = math.random(0, 10)
- if dice < 2 and #brokenElements < 30 then
- idHP = 0
- elseif dice >= 2 and dice < 4 and #damagedElements < 30 then
- idHP = math.random(1, math.ceil(idMaxHP))
- else
- idHP = idMaxHP
- end
- end
-
- totalShipHP = totalShipHP + idHP
- totalShipMaxHP = totalShipMaxHP + idMaxHP
-
- if idMaxHP - idHP > constants.epsilon then
-
- if idHP > 0 then
- table.insert(damagedElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP - idHP,
- percent = math.ceil(100 / idMaxHP * idHP),
- pos = idPos
- })
- else
- table.insert(brokenElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- missinghp = idMaxHP - idHP,
- percent = 0,
- pos = idPos
- })
- end
- else
- table.insert(healthyElements, {
- id = id,
- name = idName,
- type = idType,
- counter = ElementCounter,
- hp = idHP,
- maxhp = idMaxHP,
- pos = idPos
- })
- if id == highlightID then
- highlightID = 0
- highlightOn = false
- HideHighlight()
- hudSelectedIndex = 0
- end
- end
-
- if initial == true then
- if
- idType == "Atmospheric Fuel Tank" or
- idType == "Space Fuel Tank" or
- idType == "Rocket Fuel Tank"
- then
- table.insert(typeElements, id)
- end
- end
- end
-
- SortDamageTables()
-
- rE = {}
-
- if #brokenElements > 0 then
- for _,v in ipairs(brokenElements) do
- table.insert(rE, {id=v.id, missinghp=v.missinghp, hp=v.hp, name=v.name, type=v.type, pos=v.pos})
- end
- end
- if #damagedElements > 0 then
- for _,v in ipairs(damagedElements) do
- table.insert(rE, {id=v.id, missinghp=v.missinghp, hp=v.hp, name=v.name, type=v.type, pos=v.pos})
- end
- end
- if #rE > 0 then
- table.sort(rE, function(a,b) return a.missinghp>b.missinghp end)
- end
-
- totalShipIntegrity = string.format("%2.0f", 100 / totalShipMaxHP * totalShipHP)
-
- if formerTotalShipHP ~= totalShipHP then
- forceDamageRedraw = true
- formerTotalShipHP = totalShipHP
- else
- forceDamageRedraw = false
- end
-end
-
-function GetHPforElement(id)
- for i,v in ipairs(brokenElements) do
- if v.id == id then
- return 0
- end
- end
- for i,v in ipairs(damagedElements) do
- if v.id == id then
- return v.hp
- end
- end
- for i,v in ipairs(healthyElements) do
- if v.id == id then
- return v.maxhp
- end
- end
-end
-
-function UpdateClickArea(candidate, newEntry, mode)
- for i, screen in ipairs(screens) do
- for k, v in pairs(screens[i].ClickAreas) do
- if v.id == candidate and v.mode == mode then
- screens[i].ClickAreas[k] = newEntry
- end
- end
- end
-end
-
-function AddClickArea(mode, newEntry)
- for i, screen in ipairs(screens) do
- if screens[i].mode == mode then
- table.insert(screens[i].ClickAreas, newEntry)
- end
- end
-end
-
-function AddClickAreaForScreenID(screenid, newEntry)
- for i, screen in ipairs(screens) do
- if screens[i].id == screenid then
- table.insert(screens[i].ClickAreas, newEntry)
- end
- end
-end
-
-function DisableClickArea(candidate, mode)
- UpdateClickArea(candidate, {
- id = candidate,
- mode = mode,
- x1 = -1,
- x2 = -1,
- y1 = -1,
- y2 = -1
- })
-end
-
-function SetRefresh(mode, submode)
- mode = mode or "all"
- submode = submode or "all"
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- if screens[i].mode == mode or mode == "all" then
- if screens[i].submode == submode or submode =="all" then
- screens[i].refresh = true
- end
- end
- end
- end
-end
-
-function WipeClickAreasForScreen(screen)
- screen.ClickAreas = {}
- return screen
-end
-
-function CreateBaseClickAreas(screen)
- table.insert(screen.ClickAreas, {mode = "all", id = "ToggleHudMode", x1 = 1537, x2 = 1728, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "damage", x1 = 193, x2 = 384, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "damageoutline", x1 = 385, x2 = 576, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "fuel", x1 = 577, x2 = 768, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "flight", x1 = 769, x2 = 960, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "cargo", x1 = 961, x2 = 1152, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "agg", x1 = 1153, x2 = 1344, y1 = 1015, y2 = 1075} )
- -- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "map", x1 = 1345, x2 = 1536, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "time", x1 = 0, x2 = 192, y1 = 1015, y2 = 1075} )
- table.insert(screen.ClickAreas, {mode = "all", id = "ButtonPress", param = "settings1", x1 = 1729, x2 = 1920, y1 = 1015, y2 = 1075} )
- return screen
-end
-
-function CreateClickAreasForScreen(screen)
-
- if screen == nil then return {} end
-
- if screen.mode == "flight" then
- elseif screen.mode == "damage" then
- table.insert( screen.ClickAreas, {mode = "damage", id = "ToggleElementLabel", x1 = 70, x2 = 425, y1 = 325, y2 = 355} )
- table.insert( screen.ClickAreas, {mode = "damage", id = "ToggleElementLabel2", x1 = 980, x2 = 1400, y1 = 325, y2 = 355} )
- elseif screen.mode == "damageoutline" then
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeView", param = "top", x1 = 60, x2 = 439, y1 = 150, y2 = 200} )
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeView", param = "side", x1 = 440, x2 = 824, y1 = 150, y2 = 200} )
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeView", param = "front", x1 = 825, x2 = 1215, y1 = 150, y2 = 200} )
- table.insert(screen.ClickAreas, {mode = "damageoutline", id = "DMGOChangeStretch", x1 = 1530, x2 = 1580, y1 = 150, y2 = 200} )
- elseif screen.mode == "fuel" then
- elseif screen.mode == "cargo" then
- elseif screen.mode == "agg" then
- elseif screen.mode == "map" then
- elseif screen.mode == "time" then
- elseif screen.mode == "settings1" then
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ToggleBackground", x1 = 75, x2 = 860, y1 = 170, y2 = 215} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "PreviousBackground", x1 = 75, x2 = 460, y1 = 235, y2 = 285} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "NextBackground", x1 = 480, x2 = 860, y1 = 235, y2 = 285} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "DecreaseOpacity", x1 = 75, x2 = 460, y1 = 300, y2 = 350} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "IncreaseOpacity", x1 = 480, x2 = 860, y1 = 300, y2 = 350} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ResetColors", x1 = 75, x2 = 860, y1 = 370, y2 = 415} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "PreviousColorID", x1 = 90, x2 = 140, y1 = 500, y2 = 550} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "NextColorID", x1 = 795, x2 = 845, y1 = 500, y2 = 550} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="1", x1 = 210, x2 = 290, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="2", x1 = 300, x2 = 380, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="3", x1 = 385, x2 = 465, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="4", x1 = 470, x2 = 550, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="5", x1 = 560, x2 = 640, y1 = 655, y2 = 700} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosUp", param="6", x1 = 645, x2 = 725, y1 = 655, y2 = 700} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="1", x1 = 210, x2 = 290, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="2", x1 = 300, x2 = 380, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="3", x1 = 385, x2 = 465, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="4", x1 = 470, x2 = 550, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="5", x1 = 560, x2 = 640, y1 = 740, y2 = 780} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ColorPosDown", param="6", x1 = 645, x2 = 725, y1 = 740, y2 = 780} )
-
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ResetPosColor", x1 = 160, x2 = 340, y1 = 885, y2 = 935} )
- table.insert( screen.ClickAreas, {mode = "settings1", id = "ApplyPosColor", x1 = 355, x2 = 780, y1 = 885, y2 = 935} )
-
- elseif screen.mode == "startup" then
- end
-
- screen = CreateBaseClickAreas(screen)
-
- return screen
-end
-
-function CheckClick(x, y, HitTarget)
- x = x*1920
- y = y*1120
- HitTarget = HitTarget or ""
- HitPayload = {}
- -- PrintConsole("Clicked: "..x.." / "..y)
- if screens ~= nil and #screens > 0 then
- for i = 1, #screens, 1 do
- if screens[i].active == true and screens[i].element.getMouseX() ~= -1 and screens[i].element.getMouseY() ~= -1 then
- if HitTarget == "" then
- for k, v in pairs(screens[i].ClickAreas) do
- if v ~=nil and x >= v.x1 and x <= v.x2 and y >= v.y1 and y <= v.y2 then
- HitTarget = v.id
- HitPayload = v
- break
- end
- end
- end
- if HitTarget == "ButtonPress" then
- if screens[i].mode == HitPayload.param then
- screens[i].mode = "startup"
- else
- screens[i].mode = HitPayload.param
- end
-
- if screens[i].mode == "damageoutline" then
- if screens[i].submode == "" then
- screens[i].submode = "top"
- end
- end
- screens[i].refresh = true
- screens[i].ClickAreas = {}
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "ToggleBackground" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundMode == "" then
- BackgroundSelected = 1
- BackgroundMode = backgroundModes[BackgroundSelected]
- else
- BackgroundSelected = 1
- BackgroundMode = ""
- end
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "PreviousBackground" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundMode == "" then
- BackgroundSelected = 1
- BackgroundMode = backgroundModes[BackgroundSelected]
- else
- if BackgroundSelected <= 1 then
- BackgroundSelected = #backgroundModes
- else
- BackgroundSelected = BackgroundSelected - 1
- end
- BackgroundMode = backgroundModes[BackgroundSelected]
- end
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "NextBackground" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundMode == "" then
- BackgroundSelected = 1
- BackgroundMode = backgroundModes[BackgroundSelected]
- else
- if BackgroundSelected >= #backgroundModes then
- BackgroundSelected = 1
- else
- BackgroundSelected = BackgroundSelected + 1
- end
- BackgroundMode = backgroundModes[BackgroundSelected]
- end
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "DecreaseOpacity" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundModeOpacity>0.1 then
- BackgroundModeOpacity = BackgroundModeOpacity - 0.05
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- end
- elseif HitTarget == "IncreaseOpacity" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if BackgroundModeOpacity<1.0 then
- BackgroundModeOpacity = BackgroundModeOpacity + 0.05
- for k, screen in pairs(screens) do
- screens[k].refresh = true
- end
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- end
- elseif HitTarget == "ResetColors" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- db.clear()
- ColorPrimary = "FF6700"
- ColorSecondary = "FFFFFF"
- ColorTertiary = "000000"
- ColorHealthy = "00FF00"
- ColorWarning = "FFFF00"
- ColorCritical = "FF0000"
- ColorBackground = "000000"
- ColorBackgroundPattern = "4f4f4f"
- ColorFuelAtmospheric = "004444"
- ColorFuelSpace = "444400"
- ColorFuelRocket = "440044"
- BackgroundMode = "deathstar"
- BackgroundSelected = 1
- BackgroundModeOpacity = 0.25
- colorIDTable = {
- [1] = {
- id="ColorPrimary",
- desc="Main HUD Color",
- basec = "FF6700",
- newc = "FF6700"
- },
- [2] = {
- id="ColorSecondary",
- desc="Secondary HUD Color",
- basec = "FFFFFF",
- newc = "FFFFFF"
- },
- [3] = {
- id="ColorTertiary",
- desc="Tertiary HUD Color",
- basec = "000000",
- newc = "000000"
- },
- [4] = {
- id="ColorHealthy",
- desc="Color code for Healthy/Okay",
- basec = "00FF00",
- newc = "00FF00"
- },
- [5] = {
- id="ColorWarning",
- desc="Color code for Damaged/Warning",
- basec = "FFFF00",
- newc = "FFFF00"
- },
- [6] = {
- id="ColorCritical",
- desc="Color code for Broken/Critical",
- basec = "FF0000",
- newc = "FF0000"
- },
- [7] = {
- id="ColorBackground",
- desc="Background Color",
- basec = "000000",
- newc = "000000"
- },
- [8] = {
- id="ColorBackgroundPattern",
- desc="Background Pattern Color",
- basec = "4F4F4F",
- newc = "4F4F4F"
- },
- [9] = {
- id="ColorFuelAtmospheric",
- desc="Color for Atmo Fuel/Elements",
- basec = "004444",
- newc = "004444"
- },
- [10] = {
- id="ColorFuelSpace",
- desc="Color for Space Fuel/Elements",
- basec = "444400",
- newc = "444400"
- },
- [11] = {
- id="ColorFuelRocket",
- desc="Color for Rocket Fuel/Elements",
- basec = "440044",
- newc = "440044"
- }
- }
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "PreviousColorID" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- colorIDIndex = colorIDIndex - 1
- if colorIDIndex < 1 then colorIDIndex = #colorIDTable end
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "NextColorID" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- colorIDIndex = colorIDIndex + 1
- if colorIDIndex > #colorIDTable then colorIDIndex = 1 end
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "ColorPosUp" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- local s = tonumber(string.sub(colorIDTable[colorIDIndex].newc, HitPayload.param, HitPayload.param),16)
- s = s + 1
- if s > 15 then s = 0 end
- colorIDTable[colorIDIndex].newc = replace_char(HitPayload.param, colorIDTable[colorIDIndex].newc, hexTable[s+1])
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "ColorPosDown" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- local s = tonumber(string.sub(colorIDTable[colorIDIndex].newc, HitPayload.param, HitPayload.param),16)
- s = s - 1
- if s < 0 then s = 15 end
- colorIDTable[colorIDIndex].newc = replace_char(HitPayload.param, colorIDTable[colorIDIndex].newc, hexTable[s+1])
- SaveToDatabank()
- SetRefresh("settings1")
- RenderScreens("settings1")
- elseif HitTarget == "ResetPosColor" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- colorIDTable[colorIDIndex].newc = colorIDTable[colorIDIndex].basec
- _G[colorIDTable[colorIDIndex].id] = colorIDTable[colorIDIndex].basec
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "ApplyPosColor" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- _G[colorIDTable[colorIDIndex].id] = colorIDTable[colorIDIndex].newc
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- elseif HitTarget == "DamagedPageDown" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentDamagedPage = CurrentDamagedPage + 1
- if CurrentDamagedPage > math.ceil(#damagedElements / DamagePageSize) then
- CurrentDamagedPage = math.ceil(#damagedElements / DamagePageSize)
- end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "DamagedPageUp" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentDamagedPage = CurrentDamagedPage - 1
- if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "BrokenPageDown" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentBrokenPage = CurrentBrokenPage + 1
- if CurrentBrokenPage > math.ceil(#brokenElements / DamagePageSize) then
- CurrentBrokenPage = math.ceil(#brokenElements / DamagePageSize)
- end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "BrokenPageUp" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentBrokenPage = CurrentBrokenPage - 1
- if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh("damage")
- RenderScreens("damage")
- elseif HitTarget == "DMGOChangeView" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- screens[i].submode = HitPayload.param
- UpdateViewDamageoutline(screens[i])
- SaveToDatabank()
- SetRefresh("damageoutline", screens[i].submode)
- RenderScreens("damageoutline", screens[i].submode)
- elseif HitTarget == "DMGOChangeStretch" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if DMGOStretch == true then
- DMGOStretch = false
- else
- DMGOStretch = true
- end
- UpdateViewDamageoutline(screens[i])
- SaveToDatabank()
- SetRefresh("damageoutline")
- RenderScreens("damageoutline")
- elseif HitTarget == "ToggleDisplayAtmosphere" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if screens[i].fuelA == true then
- screens[i].fuelA = false
- else
- screens[i].fuelA = true
- end
- screens[i].fuelIndex = 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "ToggleDisplaySpace" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if screens[i].fuelS == true then
- screens[i].fuelS = false
- else
- screens[i].fuelS = true
- end
- screens[i].fuelIndex = 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "ToggleDisplayRocket" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if screens[i].fuelR == true then
- screens[i].fuelR = false
- else
- screens[i].fuelR = true
- end
- screens[i].fuelIndex = 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "DecreaseFuelIndex" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- screens[i].fuelIndex = screens[i].fuelIndex - 1
- if screens[i].fuelIndex < 1 then screens[i].fuelIndex = 1 end
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "IncreaseFuelIndex" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- screens[i].fuelIndex = screens[i].fuelIndex + 1
- SaveToDatabank()
- SetRefresh("fuel")
- RenderScreens("fuel")
- elseif HitTarget == "ToggleHudMode" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if HUDMode == true then
- HUDMode = false
- forceDamageRedraw = true
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- else
- HUDMode = true
- forceDamageRedraw = true
- HudDeselectElement()
- SaveToDatabank()
- SetRefresh()
- RenderScreens()
- end
- elseif HitTarget == "ToggleSimulation" and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- CurrentDamagedPage = 1
- CurrentBrokenPage = 1
- if SimulationMode == true then
- SimulationMode = false
- SimulationActive = false
- UpdateDamageData()
- UpdateTypeData()
- forceDamageRedraw = true
- HudDeselectElement()
- SetRefresh("damage")
- SetRefresh("damageoutline")
- SetRefresh("settings1")
- SetRefresh("fuel")
- SaveToDatabank()
- RenderScreens()
- else
- SimulationMode = true
- SimulationActive = false
- UpdateDamageData()
- UpdateTypeData()
- forceDamageRedraw = true
- HudDeselectElement()
- SetRefresh("damage")
- SetRefresh("damageoutline")
- SetRefresh("settings1")
- SetRefresh("fuel")
- SaveToDatabank()
- RenderScreens()
- end
- elseif (HitTarget == "ToggleElementLabel" or HitTarget == "ToggleElementLabel2") and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- if UseMyElementNames == true then
- UseMyElementNames = false
- SetRefresh("damage")
- RenderScreens("damage")
- else
- UseMyElementNames = true
- SetRefresh("damage")
- RenderScreens("damage")
- end
- elseif (HitTarget == "SwitchScrapTier" or HitTarget == "SwitchScrapTier2") and (HitPayload.mode == screens[i].mode or HitPayload.mode == "all") then
- ScrapTier = ScrapTier + 1
- if ScrapTier > 4 then ScrapTier = 1 end
- SetRefresh("damage")
- RenderScreens("damage")
- end
-
-
- end
- end
- end
-end
-
---[[ 4. RENDERING FUNCTIONS ]]
-
-function GetContentFlight()
- local output = ""
- output = output .. GetHeader("Flight Data Report") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentDamage()
- local output = ""
- if SimulationMode == true then
- output = output .. GetHeader("Damage Report (Simulated damage)") .. [[]]
- else
- output = output .. GetHeader("Damage Report") .. [[]]
- end
- output = output .. GetContentDamageScreen()
- return output
-end
-
-function GetContentDamageoutline(screen)
- UpdateDataDamageoutline()
- UpdateViewDamageoutline(screen)
- local output = ""
- output = output .. GetHeader("Damage Ship Outline Report") ..
- GetDamageoutlineShip() ..
- [[]]
-
- if screen.submode=="top" then
- output = output ..
- [[
-
- Top View
-
- Side View
-
- Front View
- ]]
- elseif screen.submode=="side" then
- output = output ..
- [[
-
- Top View
-
- Side View
-
- Front View
- ]]
- elseif screen.submode=="front" then
- output = output ..
- [[
-
- Top View
-
- Side View
-
- Front View
- ]]
- else
- end
- output = output .. [[]]..#dmgoElements..[[ of ]]..ElementCounter..[[ shown]]
- output = output .. [[]]
- if DMGOStretch == true then
- output = output .. [[]]
- end
- output = output .. [[Stretch both axis]]
- return output
-end
-
-function GetContentFuel(screen)
-
- if #FuelAtmosphericTanks < 1 and #FuelSpaceTanks < 1 and #FuelRocketTanks < 1 then return "" end
-
- local FuelTypes = 0
- local output = ""
- local addHeadline = {}
-
- FuelDisplay = { screen.fuelA, screen.fuelS, screen.fuelR }
-
- if FuelDisplay[1] == true and #FuelAtmosphericTanks > 0 then
- table.insert(addHeadline, "Atmospheric")
- FuelTypes = FuelTypes + 1
- end
- if FuelDisplay[2] == true and #FuelSpaceTanks > 0 then
- table.insert(addHeadline, "Space")
- FuelTypes = FuelTypes + 1
- end
- if FuelDisplay[3] == true and #FuelRocketTanks > 0 then
- table.insert(addHeadline, "Rocket")
- FuelTypes = FuelTypes + 1
- end
-
- output = output .. GetHeader("Fuel Report ("..table.concat(addHeadline, ", ")..")") ..
- [[
- ]]
-
- local totalH = 150
- local counter = 0
- local tOffset = 0
-
- if FuelDisplay[1] == true and #FuelAtmosphericTanks > 0 then
-
- if FuelTypes == 1 then tOffset = 50
- elseif FuelTypes == 2 then tOffset = 6
- elseif FuelTypes == 3 then tOffset = 0
- end
-
- output = output .. [[
-
-
-
- ]]
-
- output = output ..
- [[]]..
- GenerateCommaValue(FuelAtmosphericCurrent, true)..
- [[ of ]]..GenerateCommaValue(FuelAtmosphericTotal, true)..
- [[ | Total Atmospheric Fuel in ]]..#FuelAtmosphericTanks..[[ tank]]..(#FuelAtmosphericTanks==1 and "" or "s")..[[ (]]..math.floor(100/FuelAtmosphericTotal*FuelAtmosphericCurrent)..[[%)]]
- counter = counter + 1
- end
-
- if FuelDisplay[2] == true and #FuelSpaceTanks > 0 then
-
- if FuelTypes == 1 then tOffset = 50
- elseif FuelTypes == 2 then tOffset = 6
- elseif FuelTypes == 3 then tOffset = 0
- end
-
- output = output .. [[
-
-
-
- ]]
-
- output = output ..
- [[]]..
- GenerateCommaValue(FuelSpaceCurrent, true)..
- [[ of ]]..GenerateCommaValue(FuelSpaceTotal, true)..
- [[ | Total Space Fuel in ]]..#FuelSpaceTanks..[[ tank]]..(#FuelSpaceTanks==1 and "" or "s")..[[ (]]..math.floor(100/FuelSpaceTotal*FuelSpaceCurrent)..[[%)]]
- counter = counter + 1
- end
-
- if FuelDisplay[3] == true and #FuelRocketTanks > 0 then
-
- if FuelTypes == 1 then tOffset = 50
- elseif FuelTypes == 2 then tOffset = 6
- elseif FuelTypes == 3 then tOffset = 0
- end
-
- output = output .. [[
-
-
-
- ]]
-
- output = output ..
- [[]]..
- GenerateCommaValue(FuelRocketCurrent, true)..
- [[ of ]]..GenerateCommaValue(FuelRocketTotal, true)..
- [[ | Total Rocket Fuel in ]]..#FuelRocketTanks..[[ tank]]..(#FuelRocketTanks==1 and "" or "s")..[[ (]]..math.floor(100/FuelRocketTotal*FuelRocketCurrent)..[[%)]]
- end
-
- output = output .. [[
-
-
-
- ]]
-
- local DisplayTable = {}
- if screen.fuelIndex == nil or screen.fuelIndex < 1 then
- screen.fuelIndex = 1
- end
-
- if FuelDisplay[1] == true then
- for _,v in ipairs(FuelAtmosphericTanks) do
- table.insert(DisplayTable, v)
- end
- end
- if FuelDisplay[2] == true then
- for _,v in ipairs(FuelSpaceTanks) do
- table.insert(DisplayTable, v)
- end
- end
- if FuelDisplay[3] == true then
- for _,v in ipairs(FuelRocketTanks) do
- table.insert(DisplayTable, v)
- end
- end
-
- table.sort(DisplayTable, function(a,b) return a.type
-
-
- ]]
- if tank.hp == 0 then
- output = output .. [[]]
- elseif tank.maxhp - tank.hp > constants.epsilon then
- output = output .. [[]]
- else
- output = output .. [[]]
- end
- if tank.hp == 0 then output = output .. [[]]..tank.size..[[]]
- else output = output .. [[]]..tank.size..[[]]
- end
-
- if tank.hp == 0 then
- output = output .. [[Broken]] ..
- [[0 of ]]..GenerateCommaValue(tank.vol)..[[]]
- elseif tonumber(tank.percent) < 10 then
- output = output .. [[]]..tank.percent..[[%]] ..
- [[]]..GenerateCommaValue(tank.cvol)..[[ of ]]..GenerateCommaValue(tank.vol)..[[]]
- elseif tonumber(tank.percent) < 30 then
- output = output .. [[]]..tank.percent..[[%]] ..
- [[]]..GenerateCommaValue(tank.cvol)..[[ of ]]..GenerateCommaValue(tank.vol)..[[]]
- else output =
- output .. [[]]..tank.percent..[[%]] ..
- [[]]..GenerateCommaValue(tank.cvol)..[[ of ]]..GenerateCommaValue(tank.vol)..[[]]
- end
-
- output = output ..[[]]..tank.name..[[]]
-
- output = output .. [[]]
-
- end
- end
-
-
-
- if #FuelAtmosphericTanks > 0 then
- output = output .. [[]]
- if FuelDisplay[1] == true then
- output = output .. [[]]
- end
- output = output .. [[ATM]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "ToggleDisplayAtmosphere", x1 = 50, x2 = 100, y1 = 270, y2 = 320} )
- end
-
- if #FuelSpaceTanks > 0 then
- output = output .. [[]]
- if FuelDisplay[2] == true then
- output = output .. [[]]
- end
- output = output .. [[SPC]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "ToggleDisplaySpace", x1 = 200, x2 = 250, y1 = 270, y2 = 320} )
- end
-
- if #FuelRocketTanks > 0 then
- output = output .. [[]]
- if FuelDisplay[3] == true then
- output = output .. [[]]
- end
- output = output .. [[RKT]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "ToggleDisplayRocket", x1 = 350, x2 = 400, y1 = 270, y2 = 320} )
- end
-
- if screen.fuelIndex > 1 then
- output = output .. [[
-
-
- ]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "DecreaseFuelIndex", x1 = 1470, x2 = 1670, y1 = 270, y2 = 320} )
- end
-
- if screen.fuelIndex+cCounter-1 < #DisplayTable then
- output = output .. [[
-
-
- ]]
- AddClickAreaForScreenID(screen.id, {mode = "fuel", id = "IncreaseFuelIndex", x1 = 1680, x2 = 1880, y1 = 270, y2 = 320} )
- end
-
- if cCounter > 0 then
- output = output .. [[]]..
- #DisplayTable..
- [[ Tank]]..(#DisplayTable == 1 and "" or "s")..
- [[ (Showing ]]..screen.fuelIndex..[[ to ]]..(screen.fuelIndex+cCounter-1)..[[)]]
- end
-
- return output
-end
-
-function GetContentCargo()
- local output = ""
- output = output .. GetHeader("Cargo Report") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentAGG()
- local output = ""
- output = output .. GetHeader("Anti-Grav Control") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentMap()
- local output = ""
- output = output .. GetHeader("Map Overview") ..
- [[
-
- ]]
- return output
-end
-
-function GetContentTime()
- local output = ""
- output = output .. GetHeader("Time") .. epochTime()
- output = output ..
- [[
-
-
-
-
-
-
-
-
-
-
-
-
- ]]
- return output
-end
-
-function GetContentSettings1()
- local output = ""
- output = output .. GetHeader("Settings") .. [[]]
- if BackgroundMode=="" then
- output = output ..[[Activate background]]
- else
- output = output ..[[Deactivate background (']]..BackgroundMode..[[', ]]..string.format("%.0f",BackgroundModeOpacity*100)..[[%)]]
- end
- output = output ..[[
-
- Previous background
-
- Next background
-
-
- Decrease Opacity
-
- Increase Opacity
- ]]
-
- output = output ..
- [[]] ..
- [[Reset background and all colors]]
-
- output = output ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Select and change any of the ]]..#colorIDTable..[[ HUD colors]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]]..colorIDTable[colorIDIndex].desc..[[]] ..
- [[]] ..
- [[Current color]] ..
- [[]] ..
-
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
-
- [[#]] ..
-
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,1,1)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,2,2)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,3,3)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,4,4)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,5,5)..[[]] ..
- [[]] ..
- [[]]..string.sub(colorIDTable[colorIDIndex].newc,6,6)..[[]] ..
-
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[]] ..
-
- [[]] ..
- [[]] ..
- [[New color]] ..
- [[]] ..
- [[Apply new color]] ..
- [[]] ..
- [[Reset]] ..
- [[]]
-
- output = output ..
- [[]] ..
- [[]] ..
- [[]] ..
- [[Explanation / Hints]] ..
- [[Coming soon.]]
-
-
- output = output .. [[]]
-
- if SimulationMode == true then
- output = output .. [[Simulating Damage to elements]]
- AddClickArea("settings1", { id = "ToggleSimulation", mode ="settings1", x1 = 940, x2 = 1850, y1 = 919, y2 = 969 })
- else
- output = output .. [[Simulate Damage to elements]]
- AddClickArea("settings1", { id = "ToggleSimulation", mode ="settings1", x1 = 940, x2 = 1850, y1 = 919, y2 = 969 })
- end
-
- return output
-end
-
-function GetContentStartup()
- local output = ""
- output = output .. GetElementLogo(812, 380, "f", "f", "f")
- if YourShipsName == "Enter here" then
- output = output .. [[Spaceship ID ]]..ShipID..[[]]
- else
- output = output .. [[]]..YourShipsName..[[]]
- end
- if ShowWelcomeMessage == true then output = output .. [[Greetings, Commander ]]..PlayerName..[[.]] end
- if #Warnings > 0 then
- output = output .. [[Warning: ]]..(table.concat(Warnings, " "))..[[]]
- end
- output = output .. [[Damage Report v]]..VERSION..[[, by DorianGray - Discord: Dorian Gray#2623.]]
- return output
-end
-
-function RenderScreen(screen, contentToRender)
- if contentToRender == nil then
- PrintConsole("ERROR: contentToRender is nil.")
- unit.exit()
- end
-
- CreateClickAreasForScreen(screen)
-
- local output =""
- output = output .. [[
-
-
- ]]
-
- output = output .. contentToRender
-
- if screen.mode == "startup" then
- output = output .. [[]]
- else
- output = output .. [[]]
- end
-
- output = output .. [[
-
- ]]
- output = output .. [[]]
-
- -- Center:
-
- --
- --
- --
- --
-
- local outputLength = string.len(output)
- -- PrintConsole("Render: "..screen.mode.." ("..outputLength.." chars)")
- screen.element.setSVG(output)
-end
-
-function RenderScreens(onlymode, onlysubmode)
-
- onlymode = onlymode or "all"
- onlysubmode = onlysubmode or "all"
-
- if screens ~= nil and #screens > 0 then
-
- local contentFlight = ""
- local contentDamage = ""
- local contentDamageoutlineTop = ""
- local contentDamageoutlineSide = ""
- local contentDamageoutlineFront = ""
- local contentFuel = ""
- local contentCargo = ""
- local contentAGG = ""
- local contentMap = ""
- local contentTime = ""
- local contentSettings1 = ""
- local contentStartup = ""
-
- for k,screen in pairs(screens) do
- if screen.refresh == true then
- local contentToRender = ""
-
- if screen.mode == "flight" and (onlymode =="flight" or onlymode =="all") then
- if contentFlight == "" then contentFlight = GetContentFlight() end
- contentToRender = contentFlight
- elseif screen.mode == "damage" and (onlymode =="damage" or onlymode =="all") then
- if contentDamage == "" then contentDamage = GetContentDamage() end
- contentToRender = contentDamage
- elseif screen.mode == "damageoutline" and (onlymode =="damageoutline" or onlymode =="all") then
- if screen.submode == "" then
- screen.submode = "top"
- screens[k].submode = "top"
- end
- if screen.submode == "top" and (onlysubmode == "top" or onlysubmode == "all") then
- if contentDamageoutlineTop == "" then contentDamageoutlineTop = GetContentDamageoutline(screen) end
- contentToRender = contentDamageoutlineTop
- end
- if screen.submode == "side" and (onlysubmode == "side" or onlysubmode == "all") then
- if contentDamageoutlineSide == "" then contentDamageoutlineSide = GetContentDamageoutline(screen) end
- contentToRender = contentDamageoutlineSide
- end
- if screen.submode == "front" and (onlysubmode == "front" or onlysubmode == "all") then
- if contentDamageoutlineFront == "" then contentDamageoutlineFront = GetContentDamageoutline(screen) end
- contentToRender = contentDamageoutlineFront
- end
- elseif screen.mode == "fuel" and (onlymode =="fuel" or onlymode =="all") then
- screen = WipeClickAreasForScreen(screens[k])
- contentToRender = GetContentFuel(screen)
- elseif screen.mode == "cargo" and (onlymode =="cargo" or onlymode =="all") then
- if contentCargo == "" then contentCargo = GetContentCargo() end
- contentToRender = contentCargo
- elseif screen.mode == "agg" and (onlymode =="agg" or onlymode =="all") then
- if contentAGG == "" then contentAGG = GetContentAGG() end
- contentToRender = contentAGG
- elseif screen.mode == "map" and (onlymode =="map" or onlymode =="all") then
- if contentMap == "" then contentMap = GetContentMap() end
- contentToRender = contentMap
- elseif screen.mode == "time" and (onlymode =="time" or onlymode =="all") then
- if contentTime == "" then contentTime = GetContentTime() end
- contentToRender = contentTime
- elseif screen.mode == "settings1" and (onlymode =="settings1" or onlymode =="all") then
- if contentSettings1 == "" then contentSettings1 = GetContentSettings1() end
- contentToRender = contentSettings1
- elseif screen.mode == "startup" and (onlymode =="startup" or onlymode =="all") then
- if contentStartup == "" then contentStartup = GetContentStartup() end
- contentToRender = contentStartup
- else
- contentToRender = "Invalid screen mode. ('"..screen.mode.."')"
- end
-
- if contentToRender ~= "" then
- RenderScreen(screen, contentToRender)
- else
- DrawCenteredText("ERROR: No contentToRender delivered for "..screen.mode)
- PrintConsole("ERROR: No contentToRender delivered for "..screen.mode)
- unit.exit()
- end
- screens[k].refresh = false
- end
- end
- end
-
- if HUDMode == true then
- system.setScreen(GetContentDamageHUDOutput())
- system.showScreen(1)
- else
- system.showScreen(0)
- end
-
-end
-
-function OnTickData(initial)
- if formerTime + 60 < system.getTime() then
- SetRefresh("time")
- end
- totalShipMass = core.getConstructMass()
- if formerTotalShipMass ~= totalShipMass then
- UpdateDamageData(true)
- UpdateTypeData()
- SetRefresh()
- formerTotalShipMass = totalShipMass
- else
- UpdateDamageData(initial)
- UpdateTypeData()
- end
- RenderScreens()
-end
-
---[[ 5. EXECUTION ]]
-
-unit.hide()
-ClearConsole()
-PrintConsole("DAMAGE REPORT v"..VERSION.." STARTED", true)
-InitiateSlots()
-LoadFromDatabank()
-SwitchScreens("on")
-InitiateScreens()
-
-if core == nil then
- PrintConsole("ERROR: Connect the core to the programming board.")
- unit.exit()
-else
- OperatorID = unit.getMasterPlayerId()
- OperatorData = database.getPlayer(OperatorID)
- PlayerName = OperatorData["name"]
- ShipID = core.getConstructId()
-end
-
-if db == nil then
- table.insert(Warnings, "No databank connected, won't save/load settings.")
-end
-
-if YourShipsName == "Enter here" then
- table.insert(Warnings, "No ship name set in LUA settings.")
-end
-
-if SkillRepairToolEfficiency == 0 and SkillRepairToolOptimization == 0 and StatFuelTankOptimization == 0 and StatContainerOptimization ==0 and
- StatAtmosphericFuelTankHandling == 0 and StatSpaceFuelTankHandling == 0 and StatRocketFuelTankHandling ==0 then
- table.insert(Warnings, "No talents/stats set in LUA settings.")
-end
-
-if SkillRepairToolEfficiency < 0 or SkillRepairToolOptimization < 0 or StatFuelTankOptimization < 0 or StatContainerOptimization < 0 or
- StatAtmosphericFuelTankHandling < 0 or StatSpaceFuelTankHandling < 0 or StatRocketFuelTankHandling < 0 or
- SkillRepairToolEfficiency > 5 or SkillRepairToolOptimization > 5 or StatFuelTankOptimization > 5 or StatContainerOptimization > 5 or
- StatAtmosphericFuelTankHandling > 5 or StatSpaceFuelTankHandling > 5 or StatRocketFuelTankHandling > 5 then
- PrintConsole("ERROR: Talents/stats can only range from 0 to 5. Please set correctly in LUA settings and reactivate script.")
- unit.exit()
-end
-
-if screens == nil or #screens == 0 then
- HUDMode = true
- PrintConsole("Warning: No screens connected. Entering HUD mode only.")
-end
-
-OnTickData(true)
-
-unit.setTimer('UpdateData', UpdateDataInterval)
-unit.setTimer('UpdateHighlight', HighlightBlinkingInterval)
\ No newline at end of file
diff --git a/versions/DamageReport_1_0.json b/versions/DamageReport_1_0.json
deleted file mode 100644
index 1b5aac1..0000000
--- a/versions/DamageReport_1_0.json
+++ /dev/null
@@ -1 +0,0 @@
-{"slots":{"0":{"name":"core","type":{"events":[],"methods":[]}},"1":{"name":"slot2","type":{"events":[],"methods":[]}},"2":{"name":"slot3","type":{"events":[],"methods":[]}},"3":{"name":"slot4","type":{"events":[],"methods":[]}},"4":{"name":"slot5","type":{"events":[],"methods":[]}},"5":{"name":"slot6","type":{"events":[],"methods":[]}},"6":{"name":"slot7","type":{"events":[],"methods":[]}},"7":{"name":"slot8","type":{"events":[],"methods":[]}},"8":{"name":"slot9","type":{"events":[],"methods":[]}},"9":{"name":"slot10","type":{"events":[],"methods":[]}},"-1":{"name":"unit","type":{"events":[],"methods":[]}},"-2":{"name":"system","type":{"events":[],"methods":[]}},"-3":{"name":"library","type":{"events":[],"methods":[]}}},"handlers":[{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"1"},"key":"0"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"2"},"key":"1"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"3"},"key":"2"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"4"},"key":"3"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"5"},"key":"4"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"6"},"key":"5"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"7"},"key":"6"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"8"},"key":"7"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"9"},"key":"8"},{"code":"--[[\n DamageReport v1.0\n\n Created By Dorian Gray\n\n Discord: Dorian Gray#2623\n InGame: DorianGray\n GitHub: https://github.com/DorianTheGrey/DU-DamageReport\n\n GNU Public License 3.0. Use whatever you want, be so kind to leave credit.\n\n Thanks to Jericho, Dmentia and Archaegeo for learning from their fine scripts.\n]]\n\n-----------------------------------------------\n-- CONFIG\n-----------------------------------------------\n\nUpdateInterval = 1 --export: Interval in seconds between updates of the calculations and (if anything changed) redrawing to the screen(s). You need to restart the script after changing this value.\nSimulationMode = false --export Randomize simluated damage on elements to check out the functionality of this script. And, no, your elements won't be harmed in the process :) You need to restart the script after changing this value.\n\nDebugMode = false -- Activate if you want some console messages\nVersionNumber = 1.0 -- Version number\n\ncore = nil \nscreens = {}\n\nshipID = 0\nforceRedraw = false\nSimulationActive=false\n\nclickAreas = {}\nDamagedSortingMode = 1 -- Define default sorting mode for damaged elements. 1 to sort by damage amount, 2 to sort by element id, 3 to sort by damage percent, \nBrokenSortingMode = 1 -- Define default sorting mode for broken elements. 1 to sort by damage amount, 2 to sort by element id\n\ntotalShipHP = 0\ntotalShipMaxHP = 0\ntotalShipIntegrity = 100\nelementsId = {}\ndamagedElements = {}\nbrokenElements = {}\nElementCounter = 0\nhealthyElements = 0\n\n-----------------------------------------------\n-- FUNCTIONS\n-----------------------------------------------\n\n\nfunction GenerateCommaValue(amount)\n local formatted = amount\n while true do \n formatted, k = string.gsub(formatted, \"^(-?%d+)(%d%d%d)\", '%1,%2')\n if (k==0) then break end\n end\n return formatted\nend\n\nfunction PrintDebug(output, highlight) \n highlight = highlight or false\n if DebugMode then\n if highlight then system.print(\"------------------------------------------------------------------------\") end\n system.print(output)\n if highlight then system.print(\"------------------------------------------------------------------------\") end\n end\nend\n\nfunction PrintError(output) \n system.print(output)\nend\n\nfunction DrawCenteredText(output)\n for i=1,#screens,1 do\n screens[i].setCenteredText(output)\n end\nend\n\nfunction DrawSVG(output)\n for i=1,#screens,1 do\n screens[i].setSVG(output)\n end\nend\n\nfunction ClearConsole()\n for i=1,10,1 do\n PrintDebug()\n end\nend\n\nfunction SwitchScreens(state)\n state = state or true\n if #screens > 0 then\n for i=1,#screens,1 do\n if state then\n screens[i].clear()\n screens[i].activate()\n else\n screens[i].deactivate()\n screens[i].clear()\n end\n end\n end\nend\n\nfunction InitiateSlots()\n for slot_name, slot in pairs(unit) do\n if\n type(slot) == \"table\"\n and type(slot.export) == \"table\"\n and slot.getElementClass\n then\n if slot.getElementClass():lower():find(\"coreunit\") then\n core = slot\n end\n if slot.getElementClass():lower():find(\"screenunit\") then\n screens[#screens + 1] = slot\n end\n end\n end\nend\n\nfunction InitiateClickAreas()\n table.insert( clickAreas, { id = \"DamagedDamage\", x1 = 725, x2 = 870, y1 = 380, y2 = 415 } )\n table.insert( clickAreas, { id = \"DamagedHealth\", x1 = 520, x2 = 655, y1 = 380, y2 = 415 } )\n table.insert( clickAreas, { id = \"DamagedID\", x1 = 90, x2 = 150, y1 = 380, y2 = 415 } )\n table.insert( clickAreas, { id = \"BrokenDamage\", x1 = 1675, x2 = 1835, y1 = 380, y2 = 415 } )\n table.insert( clickAreas, { id = \"BrokenID\", x1 = 1050, x2 = 1110, y1 = 380, y2 = 415 } )\n table.insert( clickAreas, { id = \"ToggleSimulation\", x1 = 65, x2 = 660, y1 = 100, y2 = 145 } )\nend\n\nfunction CheckClick(x, y)\n local HitTarget=\"\"\n for k, v in pairs(clickAreas) do\n if x>=v.x1 and x<=v.x2 and y>=v.y1 and y<=v.y2 then\n HitTarget=v.id\n break\n end\n end\n if HitTarget==\"DamagedDamage\" then\n DamagedSortingMode=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"DamagedHealth\" then\n DamagedSortingMode=3\n SortTables()\n DrawScreens()\n elseif HitTarget==\"DamagedID\" then\n DamagedSortingMode=2\n SortTables()\n DrawScreens()\n elseif HitTarget==\"BrokenDamage\" then\n BrokenSortingMode=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"BrokenID\" then\n BrokenSortingMode=2\n SortTables()\n DrawScreens()\n elseif HitTarget==\"ToggleSimulation\" then\n if SimulationMode == true then\n SimulationMode = false\n SimulationActive = false\n forceRedraw = true\n GenerateDamageData()\n DrawScreens()\n else\n SimulationMode = true\n SimulationActive = false\n forceRedraw = true\n GenerateDamageData()\n DrawScreens()\n end\n end\nend\n\nfunction SortTables()\n -- Sort damaged elements descending by percent damaged according to setting\n if DamagedSortingMode==1 then table.sort(damagedElements, function(a,b) return a.missinghp > b.missinghp end)\n elseif DamagedSortingMode==2 then table.sort(damagedElements, function(a,b) return a.id < b.id end)\n else table.sort(damagedElements, function(a,b) return a.percent < b.percent end)\n end\n\n -- Sort broken elements descending according to setting\n if BrokenSortingMode==1 then table.sort(brokenElements, function(a,b) return a.maxhp > b.maxhp end)\n else table.sort(brokenElements, function(a,b) return a.id < b.id end)\n end\nend\n\nfunction GenerateDamageData()\n if SimulationActive==true then\n return\n end\n\n local formerTotalShipHP = totalShipHP\n totalShipHP = 0\n totalShipMaxHP = 0\n totalShipIntegrity = 100\n elementsId = {}\n damagedElements = {}\n brokenElements = {}\n ElementCounter = 0\n healthyElements = 0\n\n elementsIdList = core.getElementIdList()\n\n for _,id in pairs(elementsIdList) do\n ElementCounter = ElementCounter + 1\n idHP = core.getElementHitPointsById(id) or 0\n idMaxHP = core.getElementMaxHitPointsById(id) or 0\n\n if SimulationMode then\n SimulationActive=true\n local dice =math.random(0,10)\n if dice < 2 then idHP = 0\n elseif dice >=2 and dice < 5 then idHP = idMaxHP\n else \n idHP = math.random(1, math.ceil(idMaxHP))\n end\n end\n\n totalShipHP = totalShipHP+idHP\n totalShipMaxHP = totalShipMaxHP+idMaxHP\n\n -- Is element damaged?\n if idMaxHP > idHP then\n idPos = core.getElementPositionById(id)\n idName = core.getElementNameById(id)\n idType = core.getElementTypeById(id)\n if idHP>0 then\n table.insert(damagedElements,\n {\n id = id,\n name = idName,\n type = idType,\n counter = ElementCounter,\n hp = idHP,\n maxhp = idMaxHP,\n missinghp = idMaxHP-idHP,\n percent = math.ceil(100/idMaxHP*idHP),\n pos =idPos\n }\n )\n if DebugMode then PrintDebug(\"Damaged: \"..idName..\" --- Type: \"..idType..\"\") end\n -- Is element broken?\n else\n table.insert(brokenElements,\n {\n id = id,\n name = idName,\n type = idType,\n counter = ElementCounter,\n hp = idHP,\n maxhp = idMaxHP,\n missinghp = idMaxHP-idHP,\n percent = 0,\n pos =idPos\n }\n )\n if DebugMode then PrintDebug(\"Broken: \"..idName..\" --- Type: \"..idType..\"\") end\n end\n else\n healthyElements = healthyElements + 1\n end\n end\n \n SortTables()\n\n -- Determine total ship integrity\n totalShipIntegrity = string.format(\"%2.0f\", 100/totalShipMaxHP*totalShipHP)\n\n -- Has anything changes since last check? If yes, force redrawing the screens\n if formerTotalShipHP ~= totalShipHP then\n forceRedraw=true\n formerTotalShipHP = totalShipHP\n else forceRedraw=false\n end \nend\n\nfunction DrawScreens()\n if #screens > 0 then\n\n local healthyColor = \"#00aa00\"\n local brokenColor = \"#aa0000\"\n local damagedColor = \"#aaaa00\"\n local integrityColor = \"#aaaaaa\"\n local healthyTextColor = \"white\"\n local brokenTextColor = \"#ff4444\"\n local damagedTextColor = \"#ffff44\"\n local integrityTextColor = \"white\"\n\n if #damagedElements ==0 then\n damagedColor = \"#aaaaaa\"\n damagedTextColor = \"white\"\n end\n if #brokenElements == 0 then \n brokenColor = \"#aaaaaa\"\n brokenTextColor = \"white\"\n end\n \n -- Draw Header\n screenOutput = [[\n ]]\n \n -- Draw main background\n screenOutput = screenOutput..\n [[\n \n \n \n \n \n \n \n \n \n \n \n ]]\n\n -- Draw Title and summary\n if SimulationActive==true then\n screenOutput = screenOutput..[[Simulated Report]]\n else\n screenOutput = screenOutput..[[Damage Report]]\n end\n screenOutput = screenOutput..\n [[SHIP ID ]]..shipID..[[\n\n Healthy\n ]]..healthyElements..[[\n\n Damaged\n ]]..#damagedElements..[[\n\n Broken\n ]]..#brokenElements..[[\n\n Integrity\n ]]..totalShipIntegrity..[[%]]\n\n -- Draw damage elements\n if #damagedElements > 0 then\n local damagedElementsToDraw = #damagedElements\n if damagedElementsToDraw>12 then damagedElementsToDraw=12 end\n screenOutput = screenOutput..\n [[]]\n screenOutput = screenOutput .. [[]]\n if (DamagedSortingMode==2) then \n screenOutput = screenOutput ..[[ID]]\n else\n screenOutput = screenOutput ..[[ID]]\n end\n screenOutput = screenOutput ..[[Element Type]]\n if (DamagedSortingMode==3) then \n screenOutput = screenOutput ..[[Health]]\n else\n screenOutput = screenOutput ..[[Health]]\n end\n if (DamagedSortingMode==1) then \n screenOutput = screenOutput ..[[Damage]]\n else\n screenOutput = screenOutput ..[[Damage]]\n end\n for i=1,damagedElementsToDraw,1 do\n local DP = damagedElements[i]\n screenOutput = screenOutput ..\n [[]]..string.format(\"%03.0f\",DP.id)..[[]]..\n [[]]..string.format(\"%.25s\", DP.type)..[[]]..\n [[]]..DP.percent..[[%]]..\n [[]]..GenerateCommaValue(string.format(\"%.0f\", DP.missinghp))..[[]]..\n [[]]\n end\n screenOutput = screenOutput ..\n [[\n \n ]]\n end\n\n -- Draw broken elements\n if #brokenElements > 0 then\n local brokenElementsToDraw = #brokenElements\n if brokenElementsToDraw>12 then brokenElementsToDraw=12 end\n screenOutput = screenOutput..\n [[]]\n screenOutput = screenOutput .. [[]]\n if (BrokenSortingMode==2) then \n screenOutput = screenOutput ..[[ID]]\n else\n screenOutput = screenOutput ..[[ID]]\n end\n screenOutput = screenOutput .. [[Element Type]]\n if (BrokenSortingMode==1) then \n screenOutput = screenOutput ..[[Damage]]\n else\n screenOutput = screenOutput ..[[Damage]]\n end\n\n for i=1,brokenElementsToDraw,1 do\n local DP = brokenElements[i]\n screenOutput = screenOutput ..\n [[]]..string.format(\"%03.0f\",DP.id)..[[]]..\n [[]]..string.format(\"%.25s\", DP.type)..[[]]..\n [[]]..GenerateCommaValue(string.format(\"%.0f\", DP.missinghp))..[[]]..\n [[]]\n end\n\n screenOutput = screenOutput.. \n [[\n \n ]]\n end\n\n -- Draw damage summary\n if #damagedElements>0 or #brokenElements > 0 then\n screenOutput = screenOutput..\n [[]]..GenerateCommaValue(string.format(\"%.0f\", totalShipMaxHP-totalShipHP))..[[ HP damage in total]]\n\n end\n\n screenOutput = screenOutput..[[]]\n\n DrawSVG(screenOutput)\n end\nend\n\n-----------------------------------------------\n-- Execute\n-----------------------------------------------\n\nunit.hide()\nClearConsole()\nPrintDebug(\"SCRIPT STARTED\", true)\n\nInitiateSlots()\nSwitchScreens(true)\nInitiateClickAreas()\n\nif core == nil then\n DrawCenteredText(\"ERROR: No core connected.\")\n PrintError(\"ERROR: No core connected.\")\n goto exit\nelse\n shipID = core.getConstructId()\nend\n\nGenerateDamageData()\nif forceRedraw then\n DrawScreens()\nend\n\nunit.setTimer('UpdateData', UpdateInterval)\n\n::exit::","filter":{"args":[],"signature":"start()","slotKey":"-1"},"key":"9"},{"code":"if #screens > 0 then\n for i=1,#screens,1 do\n screens[i].deactivate()\n screens[i].clear()\n end\nend","filter":{"args":[],"signature":"stop()","slotKey":"-1"},"key":"10"},{"code":"GenerateDamageData()\nif forceRedraw then\n DrawScreens()\nend","filter":{"args":[{"value":"UpdateData"}],"signature":"tick(timerId)","slotKey":"-1"},"key":"11"}],"methods":[],"events":[]}
\ No newline at end of file
diff --git a/versions/DamageReport_1_1.json b/versions/DamageReport_1_1.json
deleted file mode 100644
index fe6de17..0000000
--- a/versions/DamageReport_1_1.json
+++ /dev/null
@@ -1 +0,0 @@
-{"slots":{"0":{"name":"core","type":{"events":[],"methods":[]}},"1":{"name":"slot2","type":{"events":[],"methods":[]}},"2":{"name":"slot3","type":{"events":[],"methods":[]}},"3":{"name":"slot4","type":{"events":[],"methods":[]}},"4":{"name":"slot5","type":{"events":[],"methods":[]}},"5":{"name":"slot6","type":{"events":[],"methods":[]}},"6":{"name":"slot7","type":{"events":[],"methods":[]}},"7":{"name":"slot8","type":{"events":[],"methods":[]}},"8":{"name":"slot9","type":{"events":[],"methods":[]}},"9":{"name":"slot10","type":{"events":[],"methods":[]}},"-1":{"name":"unit","type":{"events":[],"methods":[]}},"-2":{"name":"system","type":{"events":[],"methods":[]}},"-3":{"name":"library","type":{"events":[],"methods":[]}}},"handlers":[{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"1"},"key":"0"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"2"},"key":"1"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"3"},"key":"2"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"4"},"key":"3"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"5"},"key":"4"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"6"},"key":"5"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"7"},"key":"6"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"8"},"key":"7"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"9"},"key":"8"},{"code":"--[[\n DamageReport v1.1\n\n Created By Dorian Gray\n\n Discord: Dorian Gray#2623\n InGame: DorianGray\n GitHub: https://github.com/DorianTheGrey/DU-DamageReport\n\n GNU Public License 3.0. Use whatever you want, be so kind to leave credit.\n\n Thanks to Jericho, Dmentia and Archaegeo for learning from their fine scripts.\n]]\n\n-----------------------------------------------\n-- CONFIG\n-----------------------------------------------\n\nUpdateInterval = 1 --export: Interval in seconds between updates of the calculations and (if anything changed) redrawing to the screen(s). You need to restart the script after changing this value.\nSimulationMode = false --export Randomize simluated damage on elements to check out the functionality of this script. And, no, your elements won't be harmed in the process :) You need to restart the script after changing this value.\n\nDebugMode = false -- Activate if you want some console messages\nVersionNumber = 1.1 -- Version number\n\ncore = nil \nscreens = {}\n\nshipID = 0\nforceRedraw = false\nSimulationActive=false\n\nclickAreas = {}\nDamagedSortingMode = 1 -- Define default sorting mode for damaged elements. 1 to sort by damage amount, 2 to sort by element id, 3 to sort by damage percent, \nBrokenSortingMode = 1 -- Define default sorting mode for broken elements. 1 to sort by damage amount, 2 to sort by element id\n\nCurrentDamagedPage = 1\nCurrentBrokenPage = 1\n\ntotalShipHP = 0\ntotalShipMaxHP = 0\ntotalShipIntegrity = 100\nelementsId = {}\ndamagedElements = {}\nbrokenElements = {}\nElementCounter = 0\nhealthyElements = 0\n\n-----------------------------------------------\n-- FUNCTIONS\n-----------------------------------------------\n\n\nfunction GenerateCommaValue(amount)\n local formatted = amount\n while true do \n formatted, k = string.gsub(formatted, \"^(-?%d+)(%d%d%d)\", '%1,%2')\n if (k==0) then break end\n end\n return formatted\nend\n\nfunction PrintDebug(output, highlight) \n highlight = highlight or false\n if DebugMode then\n if highlight then system.print(\"------------------------------------------------------------------------\") end\n system.print(output)\n if highlight then system.print(\"------------------------------------------------------------------------\") end\n end\nend\n\nfunction PrintError(output) \n system.print(output)\nend\n\nfunction DrawCenteredText(output)\n for i=1,#screens,1 do\n screens[i].setCenteredText(output)\n end\nend\n\nfunction DrawSVG(output)\n for i=1,#screens,1 do\n screens[i].setSVG(output)\n end\nend\n\nfunction ClearConsole()\n for i=1,10,1 do\n PrintDebug()\n end\nend\n\nfunction SwitchScreens(state)\n state = state or true\n if #screens > 0 then\n for i=1,#screens,1 do\n if state then\n screens[i].clear()\n screens[i].activate()\n else\n screens[i].deactivate()\n screens[i].clear()\n end\n end\n end\nend\n\nfunction InitiateSlots()\n for slot_name, slot in pairs(unit) do\n if\n type(slot) == \"table\"\n and type(slot.export) == \"table\"\n and slot.getElementClass\n then\n if slot.getElementClass():lower():find(\"coreunit\") then\n core = slot\n end\n if slot.getElementClass():lower():find(\"screenunit\") then\n screens[#screens + 1] = slot\n end\n end\n end\nend\n\nfunction AddClickArea(newEntry)\n table.insert(clickAreas, newEntry)\nend\n\nfunction RemoveFromClickAreas(candidate)\n for k, v in pairs(clickAreas) do\n if v.id==candidate then\n clickAreas[k]=nil\n break\n end\n end\nend\n\nfunction UpdateClickArea(candidate, newEntry)\n for k, v in pairs(clickAreas) do\n if v.id==candidate then\n clickAreas[k]=newEntry\n break\n end\n end\nend\n\nfunction DisableClickArea(candidate)\n for k, v in pairs(clickAreas) do\n if v.id==candidate then\n UpdateClickArea(candidate, { id = candidate, x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n break\n end\n end\nend\n\nfunction InitiateClickAreas()\n clickAreas = {}\n AddClickArea( { id = \"DamagedDamage\", x1 = 725, x2 = 870, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"DamagedHealth\", x1 = 520, x2 = 655, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"DamagedID\", x1 = 90, x2 = 150, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"BrokenDamage\", x1 = 1675, x2 = 1835, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"BrokenID\", x1 = 1050, x2 = 1110, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"ToggleSimulation\", x1 = 65, x2 = 660, y1 = 100, y2 = 145 } )\n AddClickArea( { id = \"DamagedPageDown\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n AddClickArea( { id = \"DamagedPageUp\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n AddClickArea( { id = \"BrokenPageDown\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n AddClickArea( { id = \"BrokenPageUp\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\nend\n\nfunction CheckClick(x, y)\n PrintDebug(\"Clicked at \"..x..\" / \"..y)\n local HitTarget=\"\"\n for k, v in pairs(clickAreas) do\n if v and x>=v.x1 and x<=v.x2 and y>=v.y1 and y<=v.y2 then\n HitTarget=v.id\n break\n end\n end\n if HitTarget==\"DamagedDamage\" then\n DamagedSortingMode=1\n CurrentDamagedPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"DamagedHealth\" then\n DamagedSortingMode=3\n CurrentDamagedPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"DamagedID\" then\n DamagedSortingMode=2\n CurrentDamagedPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"BrokenDamage\" then\n BrokenSortingMode=1\n CurrentBrokenPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"BrokenID\" then\n BrokenSortingMode=2\n CurrentBrokenPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"DamagedPageDown\" then\n CurrentDamagedPage = CurrentDamagedPage + 1\n if CurrentDamagedPage > math.ceil(#damagedElements/12) then CurrentDamagedPage = math.ceil(#damagedElements/12) end\n DrawScreens()\n elseif HitTarget==\"DamagedPageUp\" then\n CurrentDamagedPage = CurrentDamagedPage - 1\n if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end\n DrawScreens()\n elseif HitTarget==\"BrokenPageDown\" then\n CurrentBrokenPage = CurrentBrokenPage + 1\n if CurrentBrokenPage > math.ceil(#brokenElements/12) then CurrentBrokenPage = math.ceil(#brokenElements/12) end\n DrawScreens()\n elseif HitTarget==\"BrokenPageUp\" then\n CurrentBrokenPage = CurrentBrokenPage - 1\n if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end\n DrawScreens()\n elseif HitTarget==\"ToggleSimulation\" then\n CurrentDamagedPage=1\n CurrentBrokenPage=1\n if SimulationMode == true then\n SimulationMode = false\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n DrawScreens()\n else\n SimulationMode = true\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n DrawScreens()\n end\n\n end\nend\n\nfunction SortTables()\n -- Sort damaged elements descending by percent damaged according to setting\n if DamagedSortingMode==1 then table.sort(damagedElements, function(a,b) return a.missinghp > b.missinghp end)\n elseif DamagedSortingMode==2 then table.sort(damagedElements, function(a,b) return a.id < b.id end)\n else table.sort(damagedElements, function(a,b) return a.percent < b.percent end)\n end\n\n -- Sort broken elements descending according to setting\n if BrokenSortingMode==1 then table.sort(brokenElements, function(a,b) return a.maxhp > b.maxhp end)\n else table.sort(brokenElements, function(a,b) return a.id < b.id end)\n end\nend\n\nfunction GenerateDamageData()\n if SimulationActive==true then\n return\n end\n\n local formerTotalShipHP = totalShipHP\n totalShipHP = 0\n totalShipMaxHP = 0\n totalShipIntegrity = 100\n elementsId = {}\n damagedElements = {}\n brokenElements = {}\n ElementCounter = 0\n healthyElements = 0\n\n elementsIdList = core.getElementIdList()\n\n for _,id in pairs(elementsIdList) do\n ElementCounter = ElementCounter + 1\n idHP = core.getElementHitPointsById(id) or 0\n idMaxHP = core.getElementMaxHitPointsById(id) or 0\n\n if SimulationMode then\n SimulationActive=true\n local dice =math.random(0,10)\n if dice < 2 then idHP = 0\n elseif dice >=2 and dice < 5 then idHP = idMaxHP\n else \n idHP = math.random(1, math.ceil(idMaxHP))\n end\n end\n\n totalShipHP = totalShipHP+idHP\n totalShipMaxHP = totalShipMaxHP+idMaxHP\n\n -- Is element damaged?\n if idMaxHP > idHP then\n idPos = core.getElementPositionById(id)\n idName = core.getElementNameById(id)\n idType = core.getElementTypeById(id)\n if idHP>0 then\n table.insert(damagedElements,\n {\n id = id,\n name = idName,\n type = idType,\n counter = ElementCounter,\n hp = idHP,\n maxhp = idMaxHP,\n missinghp = idMaxHP-idHP,\n percent = math.ceil(100/idMaxHP*idHP),\n pos =idPos\n }\n )\n if DebugMode then PrintDebug(\"Damaged: \"..idName..\" --- Type: \"..idType..\"\") end\n -- Is element broken?\n else\n table.insert(brokenElements,\n {\n id = id,\n name = idName,\n type = idType,\n counter = ElementCounter,\n hp = idHP,\n maxhp = idMaxHP,\n missinghp = idMaxHP-idHP,\n percent = 0,\n pos =idPos\n }\n )\n if DebugMode then PrintDebug(\"Broken: \"..idName..\" --- Type: \"..idType..\"\") end\n end\n else\n healthyElements = healthyElements + 1\n end\n end\n\n -- Sort tables by current settings \n SortTables()\n\n -- Update clickAreas\n\n\n -- Determine total ship integrity\n totalShipIntegrity = string.format(\"%2.0f\", 100/totalShipMaxHP*totalShipHP)\n\n -- Has anything changes since last check? If yes, force redrawing the screens\n if formerTotalShipHP ~= totalShipHP then\n forceRedraw=true\n formerTotalShipHP = totalShipHP\n else forceRedraw=false\n end \nend\n\nfunction DrawScreens()\n if #screens > 0 then\n\n local healthyColor = \"#00aa00\"\n local brokenColor = \"#aa0000\"\n local damagedColor = \"#aaaa00\"\n local integrityColor = \"#aaaaaa\"\n local healthyTextColor = \"white\"\n local brokenTextColor = \"#ff4444\"\n local damagedTextColor = \"#ffff44\"\n local integrityTextColor = \"white\"\n\n if #damagedElements ==0 then\n damagedColor = \"#aaaaaa\"\n damagedTextColor = \"white\"\n end\n if #brokenElements == 0 then \n brokenColor = \"#aaaaaa\"\n brokenTextColor = \"white\"\n end\n \n -- Draw Header\n screenOutput = [[\n ]]\n \n -- Draw main background\n screenOutput = screenOutput..\n [[\n \n \n \n \n \n \n \n \n \n \n \n ]]\n\n -- Draw Title and summary\n if SimulationActive==true then\n screenOutput = screenOutput..[[Simulated Report]]\n else\n screenOutput = screenOutput..[[Damage Report]]\n end\n screenOutput = screenOutput..\n [[SHIP ID ]]..shipID..[[\n\n Healthy\n ]]..healthyElements..[[\n\n Damaged\n ]]..#damagedElements..[[\n\n Broken\n ]]..#brokenElements..[[\n\n Integrity\n ]]..totalShipIntegrity..[[%]]\n\n -- Draw damage elements\n if #damagedElements > 0 then\n local damagedElementsToDraw = #damagedElements\n if damagedElementsToDraw>12 then damagedElementsToDraw=12 end\n if CurrentDamagedPage==math.ceil(#damagedElements/12) then damagedElementsToDraw = #damagedElements%12 end\n screenOutput = screenOutput..\n [[]]\n screenOutput = screenOutput .. [[]]\n if (DamagedSortingMode==2) then \n screenOutput = screenOutput ..[[ID]]\n else\n screenOutput = screenOutput ..[[ID]]\n end\n screenOutput = screenOutput ..[[Element Type]]\n if (DamagedSortingMode==3) then \n screenOutput = screenOutput ..[[Health]]\n else\n screenOutput = screenOutput ..[[Health]]\n end\n if (DamagedSortingMode==1) then \n screenOutput = screenOutput ..[[Damage]]\n else\n screenOutput = screenOutput ..[[Damage]]\n end\n\n local i=0\n for j=1+(CurrentDamagedPage-1)*12,damagedElementsToDraw+(CurrentDamagedPage-1)*12,1 do\n i = i + 1\n local DP = damagedElements[j]\n screenOutput = screenOutput ..\n [[]]..string.format(\"%03.0f\",DP.id)..[[]]..\n [[]]..string.format(\"%.25s\", DP.type)..[[]]..\n [[]]..DP.percent..[[%]]..\n [[]]..GenerateCommaValue(string.format(\"%.0f\", DP.missinghp))..[[]]..\n [[]]\n end\n screenOutput = screenOutput ..\n [[\n \n ]]\n\n if #damagedElements>12 then\n screenOutput = screenOutput ..\n [[Page ]]..CurrentDamagedPage..\" of \"..math.ceil(#damagedElements/12)..[[]]\n\n if CurrentDamagedPage < math.ceil(#damagedElements/12) then\n screenOutput = screenOutput ..\n [[\n \n \n ]]\n UpdateClickArea( \"DamagedPageDown\", { id = \"DamagedPageDown\", x1 = 70, x2 = 270, y1 = 350+11+(damagedElementsToDraw+1)*50, y2 = 350+11+50+(damagedElementsToDraw+1)*50 } )\n else\n DisableClickArea( \"DamagedPageDown\" )\n end\n \n if CurrentDamagedPage > 1 then\n screenOutput = screenOutput ..\n [[\n \n \n ]]\n UpdateClickArea( \"DamagedPageUp\", { id = \"DamagedPageUp\", x1 = 280, x2 = 480, y1 = 350+11+(damagedElementsToDraw+1)*50, y2 = 350+11+50+(damagedElementsToDraw+1)*50 } )\n else\n DisableClickArea( \"DamagedPageUp\" )\n end\n end\n\n\n\n\n end\n\n -- Draw broken elements\n if #brokenElements > 0 then\n local brokenElementsToDraw = #brokenElements\n if brokenElementsToDraw>12 then brokenElementsToDraw=12 end\n if CurrentBrokenPage==math.ceil(#brokenElements/12) then brokenElementsToDraw = #brokenElements%12 end\n screenOutput = screenOutput..\n [[]]\n screenOutput = screenOutput .. [[]]\n if (BrokenSortingMode==2) then \n screenOutput = screenOutput ..[[ID]]\n else\n screenOutput = screenOutput ..[[ID]]\n end\n screenOutput = screenOutput .. [[Element Type]]\n if (BrokenSortingMode==1) then \n screenOutput = screenOutput ..[[Damage]]\n else\n screenOutput = screenOutput ..[[Damage]]\n end\n\n local i=0\n for j=1+(CurrentBrokenPage-1)*12,brokenElementsToDraw+(CurrentBrokenPage-1)*12,1 do\n i = i + 1\n local DP = brokenElements[j]\n screenOutput = screenOutput ..\n [[]]..string.format(\"%03.0f\",DP.id)..[[]]..\n [[]]..string.format(\"%.25s\", DP.type)..[[]]..\n [[]]..GenerateCommaValue(string.format(\"%.0f\", DP.missinghp))..[[]]..\n [[]]\n end\n\n screenOutput = screenOutput.. \n [[\n \n ]]\n\n\n if #brokenElements>12 then\n screenOutput = screenOutput ..\n [[Page ]]..CurrentBrokenPage..\" of \"..math.ceil(#brokenElements/12)..[[]]\n\n if CurrentBrokenPage > 1 then\n screenOutput = screenOutput ..\n [[\n \n \n ]]\n UpdateClickArea( \"BrokenPageUp\", { id = \"BrokenPageUp\", x1 = 1442, x2 = 1642, y1 = 350+11+(brokenElementsToDraw+1)*50, y2 = 350+11+50+(brokenElementsToDraw+1)*50 } )\n else\n DisableClickArea( \"BrokenPageUp\" )\n end\n \n if CurrentBrokenPage < math.ceil(#brokenElements/12) then\n screenOutput = screenOutput ..\n [[\n \n \n ]]\n UpdateClickArea( \"BrokenPageDown\", { id = \"BrokenPageDown\", x1 = 1652, x2 = 1852, y1 = 350+11+(brokenElementsToDraw+1)*50, y2 = 350+11+50+(brokenElementsToDraw+1)*50 } )\n else\n DisableClickArea( \"BrokenPageDown\" )\n end\n end\n\n\n\n end\n\n -- Draw damage summary\n if #damagedElements>0 or #brokenElements > 0 then\n screenOutput = screenOutput..\n [[]]..GenerateCommaValue(string.format(\"%.0f\", totalShipMaxHP-totalShipHP))..[[ HP damage in total]]\n\n end\n\n screenOutput = screenOutput..[[]]\n\n DrawSVG(screenOutput)\n\n forceRedraw=false\n end\nend\n\n-----------------------------------------------\n-- Execute\n-----------------------------------------------\n\nunit.hide()\nClearConsole()\nPrintDebug(\"SCRIPT STARTED\", true)\n\nInitiateSlots()\nSwitchScreens(true)\nInitiateClickAreas()\n\nif core == nil then\n DrawCenteredText(\"ERROR: No core connected.\")\n PrintError(\"ERROR: No core connected.\")\n goto exit\nelse\n shipID = core.getConstructId()\nend\n\nGenerateDamageData()\nif forceRedraw then\n DrawScreens()\nend\n\nunit.setTimer('UpdateData', UpdateInterval)\n\n::exit::","filter":{"args":[],"signature":"start()","slotKey":"-1"},"key":"9"},{"code":"if #screens > 0 then\n for i=1,#screens,1 do\n screens[i].deactivate()\n screens[i].clear()\n end\nend","filter":{"args":[],"signature":"stop()","slotKey":"-1"},"key":"10"},{"code":"GenerateDamageData()\nif forceRedraw then\n DrawScreens()\nend","filter":{"args":[{"value":"UpdateData"}],"signature":"tick(timerId)","slotKey":"-1"},"key":"11"}],"methods":[],"events":[]}
\ No newline at end of file
diff --git a/versions/DamageReport_1_2.json b/versions/DamageReport_1_2.json
deleted file mode 100644
index 97255ea..0000000
--- a/versions/DamageReport_1_2.json
+++ /dev/null
@@ -1 +0,0 @@
-{"slots":{"0":{"name":"core","type":{"events":[],"methods":[]}},"1":{"name":"slot2","type":{"events":[],"methods":[]}},"2":{"name":"slot3","type":{"events":[],"methods":[]}},"3":{"name":"slot4","type":{"events":[],"methods":[]}},"4":{"name":"slot5","type":{"events":[],"methods":[]}},"5":{"name":"slot6","type":{"events":[],"methods":[]}},"6":{"name":"slot7","type":{"events":[],"methods":[]}},"7":{"name":"slot8","type":{"events":[],"methods":[]}},"8":{"name":"slot9","type":{"events":[],"methods":[]}},"9":{"name":"slot10","type":{"events":[],"methods":[]}},"-1":{"name":"unit","type":{"events":[],"methods":[]}},"-2":{"name":"system","type":{"events":[],"methods":[]}},"-3":{"name":"library","type":{"events":[],"methods":[]}}},"handlers":[{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"1"},"key":"0"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"2"},"key":"1"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"3"},"key":"2"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"4"},"key":"3"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"5"},"key":"4"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"6"},"key":"5"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"7"},"key":"6"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"8"},"key":"7"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"9"},"key":"8"},{"code":"--[[\n DamageReport v1.21\n\n Created By Dorian Gray\n\n Discord: Dorian Gray#2623\n InGame: DorianGray\n GitHub: https://github.com/DorianTheGrey/DU-DamageReport\n\n GNU Public License 3.0. Use whatever you want, be so kind to leave credit.\n\n Thanks to Jericho, Dmentia and Archaegeo for learning from their fine scripts.\n]]\n\n-----------------------------------------------\n-- CONFIG\n-----------------------------------------------\n\nUseMyElementNames = true --export: If you active this, the display will not show the element type of damaged/broken elements but the name you gave them (truncated to 25 characters)\nUpdateInterval = 1 --export: Interval in seconds between updates of the calculations and (if anything changed) redrawing to the screen(s). You need to restart the script after changing this value.\nSimulationMode = false --export Randomize simluated damage on elements to check out the functionality of this script. And, no, your elements won't be harmed in the process :) You need to restart the script after changing this value.\n\nDebugMode = false -- Activate if you want some console messages\nVersionNumber = 1.2 -- Version number\n\ncore = nil \nscreens = {}\n\nshipID = 0\nforceRedraw = false\nSimulationActive=false\n\nclickAreas = {}\nDamagedSortingMode = 1 -- Define default sorting mode for damaged elements. 1 to sort by damage amount, 2 to sort by element id, 3 to sort by damage percent, \nBrokenSortingMode = 1 -- Define default sorting mode for broken elements. 1 to sort by damage amount, 2 to sort by element id\n\nCurrentDamagedPage = 1\nCurrentBrokenPage = 1\n\ntotalShipHP = 0\ntotalShipMaxHP = 0\ntotalShipIntegrity = 100\nelementsId = {}\ndamagedElements = {}\nbrokenElements = {}\nElementCounter = 0\nhealthyElements = 0\n\n-----------------------------------------------\n-- FUNCTIONS\n-----------------------------------------------\n\n\nfunction GenerateCommaValue(amount)\n local formatted = amount\n while true do \n formatted, k = string.gsub(formatted, \"^(-?%d+)(%d%d%d)\", '%1,%2')\n if (k==0) then break end\n end\n return formatted\nend\n\nfunction PrintDebug(output, highlight) \n highlight = highlight or false\n if DebugMode then\n if highlight then system.print(\"------------------------------------------------------------------------\") end\n system.print(output)\n if highlight then system.print(\"------------------------------------------------------------------------\") end\n end\nend\n\nfunction PrintError(output) \n system.print(output)\nend\n\nfunction DrawCenteredText(output)\n for i=1,#screens,1 do\n screens[i].setCenteredText(output)\n end\nend\n\nfunction DrawSVG(output)\n for i=1,#screens,1 do\n screens[i].setSVG(output)\n end\nend\n\nfunction ClearConsole()\n for i=1,10,1 do\n PrintDebug()\n end\nend\n\nfunction SwitchScreens(state)\n state = state or true\n if #screens > 0 then\n for i=1,#screens,1 do\n if state then\n screens[i].clear()\n screens[i].activate()\n else\n screens[i].deactivate()\n screens[i].clear()\n end\n end\n end\nend\n\nfunction InitiateSlots()\n for slot_name, slot in pairs(unit) do\n if\n type(slot) == \"table\"\n and type(slot.export) == \"table\"\n and slot.getElementClass\n then\n if slot.getElementClass():lower():find(\"coreunit\") then\n core = slot\n end\n if slot.getElementClass():lower():find(\"screenunit\") then\n screens[#screens + 1] = slot\n end\n end\n end\nend\n\nfunction AddClickArea(newEntry)\n table.insert(clickAreas, newEntry)\nend\n\nfunction RemoveFromClickAreas(candidate)\n for k, v in pairs(clickAreas) do\n if v.id==candidate then\n clickAreas[k]=nil\n break\n end\n end\nend\n\nfunction UpdateClickArea(candidate, newEntry)\n for k, v in pairs(clickAreas) do\n if v.id==candidate then\n clickAreas[k]=newEntry\n break\n end\n end\nend\n\nfunction DisableClickArea(candidate)\n for k, v in pairs(clickAreas) do\n if v.id==candidate then\n UpdateClickArea(candidate, { id = candidate, x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n break\n end\n end\nend\n\nfunction InitiateClickAreas()\n clickAreas = {}\n AddClickArea( { id = \"DamagedDamage\", x1 = 725, x2 = 870, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"DamagedHealth\", x1 = 520, x2 = 655, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"DamagedID\", x1 = 90, x2 = 150, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"BrokenDamage\", x1 = 1675, x2 = 1835, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"BrokenID\", x1 = 1050, x2 = 1110, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"ToggleSimulation\", x1 = 65, x2 = 660, y1 = 100, y2 = 145 } )\n AddClickArea( { id = \"DamagedPageDown\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n AddClickArea( { id = \"DamagedPageUp\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n AddClickArea( { id = \"BrokenPageDown\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n AddClickArea( { id = \"BrokenPageUp\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\nend\n\nfunction CheckClick(x, y)\n PrintDebug(\"Clicked at \"..x..\" / \"..y)\n local HitTarget=\"\"\n for k, v in pairs(clickAreas) do\n if v and x>=v.x1 and x<=v.x2 and y>=v.y1 and y<=v.y2 then\n HitTarget=v.id\n break\n end\n end\n if HitTarget==\"DamagedDamage\" then\n DamagedSortingMode=1\n CurrentDamagedPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"DamagedHealth\" then\n DamagedSortingMode=3\n CurrentDamagedPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"DamagedID\" then\n DamagedSortingMode=2\n CurrentDamagedPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"BrokenDamage\" then\n BrokenSortingMode=1\n CurrentBrokenPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"BrokenID\" then\n BrokenSortingMode=2\n CurrentBrokenPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"DamagedPageDown\" then\n CurrentDamagedPage = CurrentDamagedPage + 1\n if CurrentDamagedPage > math.ceil(#damagedElements/12) then CurrentDamagedPage = math.ceil(#damagedElements/12) end\n DrawScreens()\n elseif HitTarget==\"DamagedPageUp\" then\n CurrentDamagedPage = CurrentDamagedPage - 1\n if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end\n DrawScreens()\n elseif HitTarget==\"BrokenPageDown\" then\n CurrentBrokenPage = CurrentBrokenPage + 1\n if CurrentBrokenPage > math.ceil(#brokenElements/12) then CurrentBrokenPage = math.ceil(#brokenElements/12) end\n DrawScreens()\n elseif HitTarget==\"BrokenPageUp\" then\n CurrentBrokenPage = CurrentBrokenPage - 1\n if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end\n DrawScreens()\n elseif HitTarget==\"ToggleSimulation\" then\n CurrentDamagedPage=1\n CurrentBrokenPage=1\n if SimulationMode == true then\n SimulationMode = false\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n DrawScreens()\n else\n SimulationMode = true\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n DrawScreens()\n end\n\n end\nend\n\nfunction SortTables()\n -- Sort damaged elements descending by percent damaged according to setting\n if DamagedSortingMode==1 then table.sort(damagedElements, function(a,b) return a.missinghp > b.missinghp end)\n elseif DamagedSortingMode==2 then table.sort(damagedElements, function(a,b) return a.id < b.id end)\n else table.sort(damagedElements, function(a,b) return a.percent < b.percent end)\n end\n\n -- Sort broken elements descending according to setting\n if BrokenSortingMode==1 then table.sort(brokenElements, function(a,b) return a.maxhp > b.maxhp end)\n else table.sort(brokenElements, function(a,b) return a.id < b.id end)\n end\nend\n\nfunction GenerateDamageData()\n if SimulationActive==true then\n return\n end\n\n local formerTotalShipHP = totalShipHP\n totalShipHP = 0\n totalShipMaxHP = 0\n totalShipIntegrity = 100\n elementsId = {}\n damagedElements = {}\n brokenElements = {}\n ElementCounter = 0\n healthyElements = 0\n\n elementsIdList = core.getElementIdList()\n\n for _,id in pairs(elementsIdList) do\n ElementCounter = ElementCounter + 1\n idHP = core.getElementHitPointsById(id) or 0\n idMaxHP = core.getElementMaxHitPointsById(id) or 0\n\n if SimulationMode then\n SimulationActive=true\n local dice =math.random(0,10)\n if dice < 2 then idHP = 0\n elseif dice >=2 and dice < 5 then idHP = idMaxHP\n else \n idHP = math.random(1, math.ceil(idMaxHP))\n end\n end\n\n totalShipHP = totalShipHP+idHP\n totalShipMaxHP = totalShipMaxHP+idMaxHP\n\n -- Is element damaged?\n if idMaxHP > idHP then\n idPos = core.getElementPositionById(id)\n idName = core.getElementNameById(id)\n idType = core.getElementTypeById(id)\n if idHP>0 then\n table.insert(damagedElements,\n {\n id = id,\n name = idName,\n type = idType,\n counter = ElementCounter,\n hp = idHP,\n maxhp = idMaxHP,\n missinghp = idMaxHP-idHP,\n percent = math.ceil(100/idMaxHP*idHP),\n pos =idPos\n }\n )\n if DebugMode then PrintDebug(\"Damaged: \"..idName..\" --- Type: \"..idType..\"\") end\n -- Is element broken?\n else\n table.insert(brokenElements,\n {\n id = id,\n name = idName,\n type = idType,\n counter = ElementCounter,\n hp = idHP,\n maxhp = idMaxHP,\n missinghp = idMaxHP-idHP,\n percent = 0,\n pos =idPos\n }\n )\n if DebugMode then PrintDebug(\"Broken: \"..idName..\" --- Type: \"..idType..\"\") end\n end\n else\n healthyElements = healthyElements + 1\n end\n end\n\n -- Sort tables by current settings \n SortTables()\n\n -- Update clickAreas\n\n\n -- Determine total ship integrity\n totalShipIntegrity = string.format(\"%2.0f\", 100/totalShipMaxHP*totalShipHP)\n\n -- Has anything changes since last check? If yes, force redrawing the screens\n if formerTotalShipHP ~= totalShipHP then\n forceRedraw=true\n formerTotalShipHP = totalShipHP\n else forceRedraw=false\n end \nend\n\nfunction DrawScreens()\n if #screens > 0 then\n\n local healthyColor = \"#00aa00\"\n local brokenColor = \"#aa0000\"\n local damagedColor = \"#aaaa00\"\n local integrityColor = \"#aaaaaa\"\n local healthyTextColor = \"white\"\n local brokenTextColor = \"#ff4444\"\n local damagedTextColor = \"#ffff44\"\n local integrityTextColor = \"white\"\n\n if #damagedElements ==0 then\n damagedColor = \"#aaaaaa\"\n damagedTextColor = \"white\"\n end\n if #brokenElements == 0 then \n brokenColor = \"#aaaaaa\"\n brokenTextColor = \"white\"\n end\n \n -- Draw Header\n screenOutput = [[\n ]]\n \n -- Draw main background\n screenOutput = screenOutput..\n [[\n \n \n \n \n \n \n \n \n \n \n \n ]]\n\n -- Draw Title and summary\n if SimulationActive==true then\n screenOutput = screenOutput..[[Simulated Report]]\n else\n screenOutput = screenOutput..[[Damage Report]]\n end\n screenOutput = screenOutput..\n [[SHIP ID ]]..shipID..[[\n\n Healthy\n ]]..healthyElements..[[\n\n Damaged\n ]]..#damagedElements..[[\n\n Broken\n ]]..#brokenElements..[[\n\n Integrity\n ]]..totalShipIntegrity..[[%]]\n\n -- Draw damage elements\n if #damagedElements > 0 then\n local damagedElementsToDraw = #damagedElements\n if damagedElementsToDraw>12 then damagedElementsToDraw=12 end\n if CurrentDamagedPage==math.ceil(#damagedElements/12) then damagedElementsToDraw = #damagedElements%12 end\n screenOutput = screenOutput..\n [[]]\n screenOutput = screenOutput .. [[]]\n if (DamagedSortingMode==2) then \n screenOutput = screenOutput ..[[ID]]\n else\n screenOutput = screenOutput ..[[ID]]\n end\n if UseMyElementNames==true then screenOutput = screenOutput ..[[Element Name]]\n else screenOutput = screenOutput ..[[Element Type]]\n end\n \n if (DamagedSortingMode==3) then \n screenOutput = screenOutput ..[[Health]]\n else\n screenOutput = screenOutput ..[[Health]]\n end\n if (DamagedSortingMode==1) then \n screenOutput = screenOutput ..[[Damage]]\n else\n screenOutput = screenOutput ..[[Damage]]\n end\n\n local i=0\n for j=1+(CurrentDamagedPage-1)*12,damagedElementsToDraw+(CurrentDamagedPage-1)*12,1 do\n i = i + 1\n local DP = damagedElements[j]\n screenOutput = screenOutput ..\n [[]]..string.format(\"%03.0f\",DP.id)..[[]]\n if UseMyElementNames==true then\n screenOutput = screenOutput .. [[]]..string.format(\"%.25s\", DP.name)..[[]]\n else\n screenOutput = screenOutput .. [[]]..string.format(\"%.25s\", DP.type)..[[]]\n end\n screenOutput = screenOutput ..\n [[]]..DP.percent..[[%]]..\n [[]]..GenerateCommaValue(string.format(\"%.0f\", DP.missinghp))..[[]]..\n [[]]\n end\n screenOutput = screenOutput ..\n [[\n \n ]]\n\n if #damagedElements>12 then\n screenOutput = screenOutput ..\n [[Page ]]..CurrentDamagedPage..\" of \"..math.ceil(#damagedElements/12)..[[]]\n\n if CurrentDamagedPage < math.ceil(#damagedElements/12) then\n screenOutput = screenOutput ..\n [[\n \n \n ]]\n UpdateClickArea( \"DamagedPageDown\", { id = \"DamagedPageDown\", x1 = 70, x2 = 270, y1 = 350+11+(damagedElementsToDraw+1)*50, y2 = 350+11+50+(damagedElementsToDraw+1)*50 } )\n else\n DisableClickArea( \"DamagedPageDown\" )\n end\n \n if CurrentDamagedPage > 1 then\n screenOutput = screenOutput ..\n [[\n \n \n ]]\n UpdateClickArea( \"DamagedPageUp\", { id = \"DamagedPageUp\", x1 = 280, x2 = 480, y1 = 350+11+(damagedElementsToDraw+1)*50, y2 = 350+11+50+(damagedElementsToDraw+1)*50 } )\n else\n DisableClickArea( \"DamagedPageUp\" )\n end\n end\n\n\n\n\n end\n\n -- Draw broken elements\n if #brokenElements > 0 then\n local brokenElementsToDraw = #brokenElements\n if brokenElementsToDraw>12 then brokenElementsToDraw=12 end\n if CurrentBrokenPage==math.ceil(#brokenElements/12) then brokenElementsToDraw = #brokenElements%12 end\n screenOutput = screenOutput..\n [[]]\n screenOutput = screenOutput .. [[]]\n if (BrokenSortingMode==2) then \n screenOutput = screenOutput ..[[ID]]\n else\n screenOutput = screenOutput ..[[ID]]\n end\n if UseMyElementNames==true then screenOutput = screenOutput .. [[Element Name]]\n else screenOutput = screenOutput .. [[Element Type]]\n end\n if (BrokenSortingMode==1) then \n screenOutput = screenOutput ..[[Damage]]\n else\n screenOutput = screenOutput ..[[Damage]]\n end\n\n local i=0\n for j=1+(CurrentBrokenPage-1)*12,brokenElementsToDraw+(CurrentBrokenPage-1)*12,1 do\n i = i + 1\n local DP = brokenElements[j]\n screenOutput = screenOutput ..\n [[]]..string.format(\"%03.0f\",DP.id)..[[]]\n if UseMyElementNames==true then\n screenOutput = screenOutput .. [[]]..string.format(\"%.25s\", DP.name)..[[]]\n else\n screenOutput = screenOutput .. [[]]..string.format(\"%.25s\", DP.type)..[[]]\n end\n screenOutput = screenOutput ..\n [[]]..GenerateCommaValue(string.format(\"%.0f\", DP.missinghp))..[[]]..\n [[]]\n end\n\n screenOutput = screenOutput.. \n [[\n \n ]]\n\n\n if #brokenElements>12 then\n screenOutput = screenOutput ..\n [[Page ]]..CurrentBrokenPage..\" of \"..math.ceil(#brokenElements/12)..[[]]\n\n if CurrentBrokenPage > 1 then\n screenOutput = screenOutput ..\n [[\n \n \n ]]\n UpdateClickArea( \"BrokenPageUp\", { id = \"BrokenPageUp\", x1 = 1442, x2 = 1642, y1 = 350+11+(brokenElementsToDraw+1)*50, y2 = 350+11+50+(brokenElementsToDraw+1)*50 } )\n else\n DisableClickArea( \"BrokenPageUp\" )\n end\n \n if CurrentBrokenPage < math.ceil(#brokenElements/12) then\n screenOutput = screenOutput ..\n [[\n \n \n ]]\n UpdateClickArea( \"BrokenPageDown\", { id = \"BrokenPageDown\", x1 = 1652, x2 = 1852, y1 = 350+11+(brokenElementsToDraw+1)*50, y2 = 350+11+50+(brokenElementsToDraw+1)*50 } )\n else\n DisableClickArea( \"BrokenPageDown\" )\n end\n end\n\n\n\n end\n\n -- Draw damage summary\n if #damagedElements>0 or #brokenElements > 0 then\n screenOutput = screenOutput..\n [[]]..GenerateCommaValue(string.format(\"%.0f\", totalShipMaxHP-totalShipHP))..[[ HP damage in total]]\n\n end\n\n screenOutput = screenOutput..[[]]\n\n DrawSVG(screenOutput)\n\n forceRedraw=false\n end\nend\n\n-----------------------------------------------\n-- Execute\n-----------------------------------------------\n\nunit.hide()\nClearConsole()\nPrintDebug(\"SCRIPT STARTED\", true)\n\nInitiateSlots()\nSwitchScreens(true)\nInitiateClickAreas()\n\nif core == nil then\n DrawCenteredText(\"ERROR: No core connected.\")\n PrintError(\"ERROR: No core connected.\")\n goto exit\nelse\n shipID = core.getConstructId()\nend\n\nGenerateDamageData()\nif forceRedraw then\n DrawScreens()\nend\n\nunit.setTimer('UpdateData', UpdateInterval)\n\n::exit::","filter":{"args":[],"signature":"start()","slotKey":"-1"},"key":"9"},{"code":"if #screens > 0 then\n for i=1,#screens,1 do\n screens[i].deactivate()\n screens[i].clear()\n end\nend","filter":{"args":[],"signature":"stop()","slotKey":"-1"},"key":"10"},{"code":"GenerateDamageData()\nif forceRedraw then\n DrawScreens()\nend","filter":{"args":[{"value":"UpdateData"}],"signature":"tick(timerId)","slotKey":"-1"},"key":"11"}],"methods":[],"events":[]}
\ No newline at end of file
diff --git a/versions/DamageReport_1_21.json b/versions/DamageReport_1_21.json
deleted file mode 100644
index 97255ea..0000000
--- a/versions/DamageReport_1_21.json
+++ /dev/null
@@ -1 +0,0 @@
-{"slots":{"0":{"name":"core","type":{"events":[],"methods":[]}},"1":{"name":"slot2","type":{"events":[],"methods":[]}},"2":{"name":"slot3","type":{"events":[],"methods":[]}},"3":{"name":"slot4","type":{"events":[],"methods":[]}},"4":{"name":"slot5","type":{"events":[],"methods":[]}},"5":{"name":"slot6","type":{"events":[],"methods":[]}},"6":{"name":"slot7","type":{"events":[],"methods":[]}},"7":{"name":"slot8","type":{"events":[],"methods":[]}},"8":{"name":"slot9","type":{"events":[],"methods":[]}},"9":{"name":"slot10","type":{"events":[],"methods":[]}},"-1":{"name":"unit","type":{"events":[],"methods":[]}},"-2":{"name":"system","type":{"events":[],"methods":[]}},"-3":{"name":"library","type":{"events":[],"methods":[]}}},"handlers":[{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"1"},"key":"0"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"2"},"key":"1"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"3"},"key":"2"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"4"},"key":"3"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"5"},"key":"4"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"6"},"key":"5"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"7"},"key":"6"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"8"},"key":"7"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"9"},"key":"8"},{"code":"--[[\n DamageReport v1.21\n\n Created By Dorian Gray\n\n Discord: Dorian Gray#2623\n InGame: DorianGray\n GitHub: https://github.com/DorianTheGrey/DU-DamageReport\n\n GNU Public License 3.0. Use whatever you want, be so kind to leave credit.\n\n Thanks to Jericho, Dmentia and Archaegeo for learning from their fine scripts.\n]]\n\n-----------------------------------------------\n-- CONFIG\n-----------------------------------------------\n\nUseMyElementNames = true --export: If you active this, the display will not show the element type of damaged/broken elements but the name you gave them (truncated to 25 characters)\nUpdateInterval = 1 --export: Interval in seconds between updates of the calculations and (if anything changed) redrawing to the screen(s). You need to restart the script after changing this value.\nSimulationMode = false --export Randomize simluated damage on elements to check out the functionality of this script. And, no, your elements won't be harmed in the process :) You need to restart the script after changing this value.\n\nDebugMode = false -- Activate if you want some console messages\nVersionNumber = 1.2 -- Version number\n\ncore = nil \nscreens = {}\n\nshipID = 0\nforceRedraw = false\nSimulationActive=false\n\nclickAreas = {}\nDamagedSortingMode = 1 -- Define default sorting mode for damaged elements. 1 to sort by damage amount, 2 to sort by element id, 3 to sort by damage percent, \nBrokenSortingMode = 1 -- Define default sorting mode for broken elements. 1 to sort by damage amount, 2 to sort by element id\n\nCurrentDamagedPage = 1\nCurrentBrokenPage = 1\n\ntotalShipHP = 0\ntotalShipMaxHP = 0\ntotalShipIntegrity = 100\nelementsId = {}\ndamagedElements = {}\nbrokenElements = {}\nElementCounter = 0\nhealthyElements = 0\n\n-----------------------------------------------\n-- FUNCTIONS\n-----------------------------------------------\n\n\nfunction GenerateCommaValue(amount)\n local formatted = amount\n while true do \n formatted, k = string.gsub(formatted, \"^(-?%d+)(%d%d%d)\", '%1,%2')\n if (k==0) then break end\n end\n return formatted\nend\n\nfunction PrintDebug(output, highlight) \n highlight = highlight or false\n if DebugMode then\n if highlight then system.print(\"------------------------------------------------------------------------\") end\n system.print(output)\n if highlight then system.print(\"------------------------------------------------------------------------\") end\n end\nend\n\nfunction PrintError(output) \n system.print(output)\nend\n\nfunction DrawCenteredText(output)\n for i=1,#screens,1 do\n screens[i].setCenteredText(output)\n end\nend\n\nfunction DrawSVG(output)\n for i=1,#screens,1 do\n screens[i].setSVG(output)\n end\nend\n\nfunction ClearConsole()\n for i=1,10,1 do\n PrintDebug()\n end\nend\n\nfunction SwitchScreens(state)\n state = state or true\n if #screens > 0 then\n for i=1,#screens,1 do\n if state then\n screens[i].clear()\n screens[i].activate()\n else\n screens[i].deactivate()\n screens[i].clear()\n end\n end\n end\nend\n\nfunction InitiateSlots()\n for slot_name, slot in pairs(unit) do\n if\n type(slot) == \"table\"\n and type(slot.export) == \"table\"\n and slot.getElementClass\n then\n if slot.getElementClass():lower():find(\"coreunit\") then\n core = slot\n end\n if slot.getElementClass():lower():find(\"screenunit\") then\n screens[#screens + 1] = slot\n end\n end\n end\nend\n\nfunction AddClickArea(newEntry)\n table.insert(clickAreas, newEntry)\nend\n\nfunction RemoveFromClickAreas(candidate)\n for k, v in pairs(clickAreas) do\n if v.id==candidate then\n clickAreas[k]=nil\n break\n end\n end\nend\n\nfunction UpdateClickArea(candidate, newEntry)\n for k, v in pairs(clickAreas) do\n if v.id==candidate then\n clickAreas[k]=newEntry\n break\n end\n end\nend\n\nfunction DisableClickArea(candidate)\n for k, v in pairs(clickAreas) do\n if v.id==candidate then\n UpdateClickArea(candidate, { id = candidate, x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n break\n end\n end\nend\n\nfunction InitiateClickAreas()\n clickAreas = {}\n AddClickArea( { id = \"DamagedDamage\", x1 = 725, x2 = 870, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"DamagedHealth\", x1 = 520, x2 = 655, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"DamagedID\", x1 = 90, x2 = 150, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"BrokenDamage\", x1 = 1675, x2 = 1835, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"BrokenID\", x1 = 1050, x2 = 1110, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"ToggleSimulation\", x1 = 65, x2 = 660, y1 = 100, y2 = 145 } )\n AddClickArea( { id = \"DamagedPageDown\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n AddClickArea( { id = \"DamagedPageUp\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n AddClickArea( { id = \"BrokenPageDown\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n AddClickArea( { id = \"BrokenPageUp\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\nend\n\nfunction CheckClick(x, y)\n PrintDebug(\"Clicked at \"..x..\" / \"..y)\n local HitTarget=\"\"\n for k, v in pairs(clickAreas) do\n if v and x>=v.x1 and x<=v.x2 and y>=v.y1 and y<=v.y2 then\n HitTarget=v.id\n break\n end\n end\n if HitTarget==\"DamagedDamage\" then\n DamagedSortingMode=1\n CurrentDamagedPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"DamagedHealth\" then\n DamagedSortingMode=3\n CurrentDamagedPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"DamagedID\" then\n DamagedSortingMode=2\n CurrentDamagedPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"BrokenDamage\" then\n BrokenSortingMode=1\n CurrentBrokenPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"BrokenID\" then\n BrokenSortingMode=2\n CurrentBrokenPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"DamagedPageDown\" then\n CurrentDamagedPage = CurrentDamagedPage + 1\n if CurrentDamagedPage > math.ceil(#damagedElements/12) then CurrentDamagedPage = math.ceil(#damagedElements/12) end\n DrawScreens()\n elseif HitTarget==\"DamagedPageUp\" then\n CurrentDamagedPage = CurrentDamagedPage - 1\n if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end\n DrawScreens()\n elseif HitTarget==\"BrokenPageDown\" then\n CurrentBrokenPage = CurrentBrokenPage + 1\n if CurrentBrokenPage > math.ceil(#brokenElements/12) then CurrentBrokenPage = math.ceil(#brokenElements/12) end\n DrawScreens()\n elseif HitTarget==\"BrokenPageUp\" then\n CurrentBrokenPage = CurrentBrokenPage - 1\n if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end\n DrawScreens()\n elseif HitTarget==\"ToggleSimulation\" then\n CurrentDamagedPage=1\n CurrentBrokenPage=1\n if SimulationMode == true then\n SimulationMode = false\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n DrawScreens()\n else\n SimulationMode = true\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n DrawScreens()\n end\n\n end\nend\n\nfunction SortTables()\n -- Sort damaged elements descending by percent damaged according to setting\n if DamagedSortingMode==1 then table.sort(damagedElements, function(a,b) return a.missinghp > b.missinghp end)\n elseif DamagedSortingMode==2 then table.sort(damagedElements, function(a,b) return a.id < b.id end)\n else table.sort(damagedElements, function(a,b) return a.percent < b.percent end)\n end\n\n -- Sort broken elements descending according to setting\n if BrokenSortingMode==1 then table.sort(brokenElements, function(a,b) return a.maxhp > b.maxhp end)\n else table.sort(brokenElements, function(a,b) return a.id < b.id end)\n end\nend\n\nfunction GenerateDamageData()\n if SimulationActive==true then\n return\n end\n\n local formerTotalShipHP = totalShipHP\n totalShipHP = 0\n totalShipMaxHP = 0\n totalShipIntegrity = 100\n elementsId = {}\n damagedElements = {}\n brokenElements = {}\n ElementCounter = 0\n healthyElements = 0\n\n elementsIdList = core.getElementIdList()\n\n for _,id in pairs(elementsIdList) do\n ElementCounter = ElementCounter + 1\n idHP = core.getElementHitPointsById(id) or 0\n idMaxHP = core.getElementMaxHitPointsById(id) or 0\n\n if SimulationMode then\n SimulationActive=true\n local dice =math.random(0,10)\n if dice < 2 then idHP = 0\n elseif dice >=2 and dice < 5 then idHP = idMaxHP\n else \n idHP = math.random(1, math.ceil(idMaxHP))\n end\n end\n\n totalShipHP = totalShipHP+idHP\n totalShipMaxHP = totalShipMaxHP+idMaxHP\n\n -- Is element damaged?\n if idMaxHP > idHP then\n idPos = core.getElementPositionById(id)\n idName = core.getElementNameById(id)\n idType = core.getElementTypeById(id)\n if idHP>0 then\n table.insert(damagedElements,\n {\n id = id,\n name = idName,\n type = idType,\n counter = ElementCounter,\n hp = idHP,\n maxhp = idMaxHP,\n missinghp = idMaxHP-idHP,\n percent = math.ceil(100/idMaxHP*idHP),\n pos =idPos\n }\n )\n if DebugMode then PrintDebug(\"Damaged: \"..idName..\" --- Type: \"..idType..\"\") end\n -- Is element broken?\n else\n table.insert(brokenElements,\n {\n id = id,\n name = idName,\n type = idType,\n counter = ElementCounter,\n hp = idHP,\n maxhp = idMaxHP,\n missinghp = idMaxHP-idHP,\n percent = 0,\n pos =idPos\n }\n )\n if DebugMode then PrintDebug(\"Broken: \"..idName..\" --- Type: \"..idType..\"\") end\n end\n else\n healthyElements = healthyElements + 1\n end\n end\n\n -- Sort tables by current settings \n SortTables()\n\n -- Update clickAreas\n\n\n -- Determine total ship integrity\n totalShipIntegrity = string.format(\"%2.0f\", 100/totalShipMaxHP*totalShipHP)\n\n -- Has anything changes since last check? If yes, force redrawing the screens\n if formerTotalShipHP ~= totalShipHP then\n forceRedraw=true\n formerTotalShipHP = totalShipHP\n else forceRedraw=false\n end \nend\n\nfunction DrawScreens()\n if #screens > 0 then\n\n local healthyColor = \"#00aa00\"\n local brokenColor = \"#aa0000\"\n local damagedColor = \"#aaaa00\"\n local integrityColor = \"#aaaaaa\"\n local healthyTextColor = \"white\"\n local brokenTextColor = \"#ff4444\"\n local damagedTextColor = \"#ffff44\"\n local integrityTextColor = \"white\"\n\n if #damagedElements ==0 then\n damagedColor = \"#aaaaaa\"\n damagedTextColor = \"white\"\n end\n if #brokenElements == 0 then \n brokenColor = \"#aaaaaa\"\n brokenTextColor = \"white\"\n end\n \n -- Draw Header\n screenOutput = [[\n ]]\n \n -- Draw main background\n screenOutput = screenOutput..\n [[\n \n \n \n \n \n \n \n \n \n \n \n ]]\n\n -- Draw Title and summary\n if SimulationActive==true then\n screenOutput = screenOutput..[[Simulated Report]]\n else\n screenOutput = screenOutput..[[Damage Report]]\n end\n screenOutput = screenOutput..\n [[SHIP ID ]]..shipID..[[\n\n Healthy\n ]]..healthyElements..[[\n\n Damaged\n ]]..#damagedElements..[[\n\n Broken\n ]]..#brokenElements..[[\n\n Integrity\n ]]..totalShipIntegrity..[[%]]\n\n -- Draw damage elements\n if #damagedElements > 0 then\n local damagedElementsToDraw = #damagedElements\n if damagedElementsToDraw>12 then damagedElementsToDraw=12 end\n if CurrentDamagedPage==math.ceil(#damagedElements/12) then damagedElementsToDraw = #damagedElements%12 end\n screenOutput = screenOutput..\n [[]]\n screenOutput = screenOutput .. [[]]\n if (DamagedSortingMode==2) then \n screenOutput = screenOutput ..[[ID]]\n else\n screenOutput = screenOutput ..[[ID]]\n end\n if UseMyElementNames==true then screenOutput = screenOutput ..[[Element Name]]\n else screenOutput = screenOutput ..[[Element Type]]\n end\n \n if (DamagedSortingMode==3) then \n screenOutput = screenOutput ..[[Health]]\n else\n screenOutput = screenOutput ..[[Health]]\n end\n if (DamagedSortingMode==1) then \n screenOutput = screenOutput ..[[Damage]]\n else\n screenOutput = screenOutput ..[[Damage]]\n end\n\n local i=0\n for j=1+(CurrentDamagedPage-1)*12,damagedElementsToDraw+(CurrentDamagedPage-1)*12,1 do\n i = i + 1\n local DP = damagedElements[j]\n screenOutput = screenOutput ..\n [[]]..string.format(\"%03.0f\",DP.id)..[[]]\n if UseMyElementNames==true then\n screenOutput = screenOutput .. [[]]..string.format(\"%.25s\", DP.name)..[[]]\n else\n screenOutput = screenOutput .. [[]]..string.format(\"%.25s\", DP.type)..[[]]\n end\n screenOutput = screenOutput ..\n [[]]..DP.percent..[[%]]..\n [[]]..GenerateCommaValue(string.format(\"%.0f\", DP.missinghp))..[[]]..\n [[]]\n end\n screenOutput = screenOutput ..\n [[\n \n ]]\n\n if #damagedElements>12 then\n screenOutput = screenOutput ..\n [[Page ]]..CurrentDamagedPage..\" of \"..math.ceil(#damagedElements/12)..[[]]\n\n if CurrentDamagedPage < math.ceil(#damagedElements/12) then\n screenOutput = screenOutput ..\n [[\n \n \n ]]\n UpdateClickArea( \"DamagedPageDown\", { id = \"DamagedPageDown\", x1 = 70, x2 = 270, y1 = 350+11+(damagedElementsToDraw+1)*50, y2 = 350+11+50+(damagedElementsToDraw+1)*50 } )\n else\n DisableClickArea( \"DamagedPageDown\" )\n end\n \n if CurrentDamagedPage > 1 then\n screenOutput = screenOutput ..\n [[\n \n \n ]]\n UpdateClickArea( \"DamagedPageUp\", { id = \"DamagedPageUp\", x1 = 280, x2 = 480, y1 = 350+11+(damagedElementsToDraw+1)*50, y2 = 350+11+50+(damagedElementsToDraw+1)*50 } )\n else\n DisableClickArea( \"DamagedPageUp\" )\n end\n end\n\n\n\n\n end\n\n -- Draw broken elements\n if #brokenElements > 0 then\n local brokenElementsToDraw = #brokenElements\n if brokenElementsToDraw>12 then brokenElementsToDraw=12 end\n if CurrentBrokenPage==math.ceil(#brokenElements/12) then brokenElementsToDraw = #brokenElements%12 end\n screenOutput = screenOutput..\n [[]]\n screenOutput = screenOutput .. [[]]\n if (BrokenSortingMode==2) then \n screenOutput = screenOutput ..[[ID]]\n else\n screenOutput = screenOutput ..[[ID]]\n end\n if UseMyElementNames==true then screenOutput = screenOutput .. [[Element Name]]\n else screenOutput = screenOutput .. [[Element Type]]\n end\n if (BrokenSortingMode==1) then \n screenOutput = screenOutput ..[[Damage]]\n else\n screenOutput = screenOutput ..[[Damage]]\n end\n\n local i=0\n for j=1+(CurrentBrokenPage-1)*12,brokenElementsToDraw+(CurrentBrokenPage-1)*12,1 do\n i = i + 1\n local DP = brokenElements[j]\n screenOutput = screenOutput ..\n [[]]..string.format(\"%03.0f\",DP.id)..[[]]\n if UseMyElementNames==true then\n screenOutput = screenOutput .. [[]]..string.format(\"%.25s\", DP.name)..[[]]\n else\n screenOutput = screenOutput .. [[]]..string.format(\"%.25s\", DP.type)..[[]]\n end\n screenOutput = screenOutput ..\n [[]]..GenerateCommaValue(string.format(\"%.0f\", DP.missinghp))..[[]]..\n [[]]\n end\n\n screenOutput = screenOutput.. \n [[\n \n ]]\n\n\n if #brokenElements>12 then\n screenOutput = screenOutput ..\n [[Page ]]..CurrentBrokenPage..\" of \"..math.ceil(#brokenElements/12)..[[]]\n\n if CurrentBrokenPage > 1 then\n screenOutput = screenOutput ..\n [[\n \n \n ]]\n UpdateClickArea( \"BrokenPageUp\", { id = \"BrokenPageUp\", x1 = 1442, x2 = 1642, y1 = 350+11+(brokenElementsToDraw+1)*50, y2 = 350+11+50+(brokenElementsToDraw+1)*50 } )\n else\n DisableClickArea( \"BrokenPageUp\" )\n end\n \n if CurrentBrokenPage < math.ceil(#brokenElements/12) then\n screenOutput = screenOutput ..\n [[\n \n \n ]]\n UpdateClickArea( \"BrokenPageDown\", { id = \"BrokenPageDown\", x1 = 1652, x2 = 1852, y1 = 350+11+(brokenElementsToDraw+1)*50, y2 = 350+11+50+(brokenElementsToDraw+1)*50 } )\n else\n DisableClickArea( \"BrokenPageDown\" )\n end\n end\n\n\n\n end\n\n -- Draw damage summary\n if #damagedElements>0 or #brokenElements > 0 then\n screenOutput = screenOutput..\n [[]]..GenerateCommaValue(string.format(\"%.0f\", totalShipMaxHP-totalShipHP))..[[ HP damage in total]]\n\n end\n\n screenOutput = screenOutput..[[]]\n\n DrawSVG(screenOutput)\n\n forceRedraw=false\n end\nend\n\n-----------------------------------------------\n-- Execute\n-----------------------------------------------\n\nunit.hide()\nClearConsole()\nPrintDebug(\"SCRIPT STARTED\", true)\n\nInitiateSlots()\nSwitchScreens(true)\nInitiateClickAreas()\n\nif core == nil then\n DrawCenteredText(\"ERROR: No core connected.\")\n PrintError(\"ERROR: No core connected.\")\n goto exit\nelse\n shipID = core.getConstructId()\nend\n\nGenerateDamageData()\nif forceRedraw then\n DrawScreens()\nend\n\nunit.setTimer('UpdateData', UpdateInterval)\n\n::exit::","filter":{"args":[],"signature":"start()","slotKey":"-1"},"key":"9"},{"code":"if #screens > 0 then\n for i=1,#screens,1 do\n screens[i].deactivate()\n screens[i].clear()\n end\nend","filter":{"args":[],"signature":"stop()","slotKey":"-1"},"key":"10"},{"code":"GenerateDamageData()\nif forceRedraw then\n DrawScreens()\nend","filter":{"args":[{"value":"UpdateData"}],"signature":"tick(timerId)","slotKey":"-1"},"key":"11"}],"methods":[],"events":[]}
\ No newline at end of file
diff --git a/versions/DamageReport_1_3.json b/versions/DamageReport_1_3.json
deleted file mode 100644
index 03a5b6a..0000000
--- a/versions/DamageReport_1_3.json
+++ /dev/null
@@ -1 +0,0 @@
-{"slots":{"0":{"name":"core","type":{"events":[],"methods":[]}},"1":{"name":"slot2","type":{"events":[],"methods":[]}},"2":{"name":"slot3","type":{"events":[],"methods":[]}},"3":{"name":"slot4","type":{"events":[],"methods":[]}},"4":{"name":"slot5","type":{"events":[],"methods":[]}},"5":{"name":"slot6","type":{"events":[],"methods":[]}},"6":{"name":"slot7","type":{"events":[],"methods":[]}},"7":{"name":"slot8","type":{"events":[],"methods":[]}},"8":{"name":"slot9","type":{"events":[],"methods":[]}},"9":{"name":"slot10","type":{"events":[],"methods":[]}},"-1":{"name":"unit","type":{"events":[],"methods":[]}},"-2":{"name":"system","type":{"events":[],"methods":[]}},"-3":{"name":"library","type":{"events":[],"methods":[]}}},"handlers":[{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"1"},"key":"0"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"2"},"key":"1"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"3"},"key":"2"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"4"},"key":"3"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"5"},"key":"4"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"6"},"key":"5"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"7"},"key":"6"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"8"},"key":"7"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"9"},"key":"8"},{"code":"--[[\n DamageReport v1.3\n\n Created By Dorian Gray\n\n Discord: Dorian Gray#2623\n InGame: DorianGray\n GitHub: https://github.com/DorianTheGrey/DU-DamageReport\n\n GNU Public License 3.0. Use whatever you want, be so kind to leave credit.\n\n Thanks to Jericho, Dmentia and Archaegeo for learning from their fine scripts.\n]]\n\n-----------------------------------------------\n-- CONFIG\n-----------------------------------------------\n\nUseMyElementNames = false --export: If you active this, the display will not show the element type of damaged/broken elements but the name you gave them (truncated to 25 characters)\nUpdateInterval = 1 --export: Interval in seconds between updates of the calculations and (if anything changed) redrawing to the screen(s). You need to restart the script after changing this value.\nSimulationMode = false --export Randomize simluated damage on elements to check out the functionality of this script. And, no, your elements won't be harmed in the process :) You need to restart the script after changing this value.\n\nDebugMode = false -- Activate if you want some console messages\nVersionNumber = 1.3 -- Version number\n\ncore = nil \nscreens = {}\n\nshipID = 0\nforceRedraw = false\nSimulationActive=false\n\nclickAreas = {}\nDamagedSortingMode = 1 -- Define default sorting mode for damaged elements. 1 to sort by damage amount, 2 to sort by element id, 3 to sort by damage percent, \nBrokenSortingMode = 1 -- Define default sorting mode for broken elements. 1 to sort by damage amount, 2 to sort by element id\n\nHUDMode = false\nCurrentDamagedPage = 1\nCurrentBrokenPage = 1\n\ntotalShipHP = 0\ntotalShipMaxHP = 0\ntotalShipIntegrity = 100\nelementsId = {}\ndamagedElements = {}\nbrokenElements = {}\nElementCounter = 0\nhealthyElements = 0\n\n-----------------------------------------------\n-- FUNCTIONS\n-----------------------------------------------\n\n\nfunction GenerateCommaValue(amount)\n local formatted = amount\n while true do \n formatted, k = string.gsub(formatted, \"^(-?%d+)(%d%d%d)\", '%1,%2')\n if (k==0) then break end\n end\n return formatted\nend\n\nfunction PrintDebug(output, highlight) \n highlight = highlight or false\n if DebugMode then\n if highlight then system.print(\"------------------------------------------------------------------------\") end\n system.print(output)\n if highlight then system.print(\"------------------------------------------------------------------------\") end\n end\nend\n\nfunction PrintError(output) \n system.print(output)\nend\n\nfunction DrawCenteredText(output)\n for i=1,#screens,1 do\n screens[i].setCenteredText(output)\n end\nend\n\nfunction DrawSVG(output)\n for i=1,#screens,1 do\n screens[i].setSVG(output)\n end\nend\n\nfunction ClearConsole()\n for i=1,10,1 do\n PrintDebug()\n end\nend\n\nfunction SwitchScreens(state)\n state = state or true\n if #screens > 0 then\n for i=1,#screens,1 do\n if state then\n screens[i].clear()\n screens[i].activate()\n else\n screens[i].deactivate()\n screens[i].clear()\n end\n end\n end\nend\n\nfunction InitiateSlots()\n for slot_name, slot in pairs(unit) do\n if\n type(slot) == \"table\"\n and type(slot.export) == \"table\"\n and slot.getElementClass\n then\n if slot.getElementClass():lower():find(\"coreunit\") then\n core = slot\n end\n if slot.getElementClass():lower():find(\"screenunit\") then\n screens[#screens + 1] = slot\n end\n end\n end\nend\n\nfunction AddClickArea(newEntry)\n table.insert(clickAreas, newEntry)\nend\n\nfunction RemoveFromClickAreas(candidate)\n for k, v in pairs(clickAreas) do\n if v.id==candidate then\n clickAreas[k]=nil\n break\n end\n end\nend\n\nfunction UpdateClickArea(candidate, newEntry)\n for k, v in pairs(clickAreas) do\n if v.id==candidate then\n clickAreas[k]=newEntry\n break\n end\n end\nend\n\nfunction DisableClickArea(candidate)\n for k, v in pairs(clickAreas) do\n if v.id==candidate then\n UpdateClickArea(candidate, { id = candidate, x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n break\n end\n end\nend\n\nfunction InitiateClickAreas()\n clickAreas = {}\n AddClickArea( { id = \"DamagedDamage\", x1 = 725, x2 = 870, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"DamagedHealth\", x1 = 520, x2 = 655, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"DamagedID\", x1 = 90, x2 = 150, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"BrokenDamage\", x1 = 1675, x2 = 1835, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"BrokenID\", x1 = 1050, x2 = 1110, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"ToggleSimulation\", x1 = 65, x2 = 660, y1 = 100, y2 = 145 } )\n AddClickArea( { id = \"ToggleElementLabel\", x1 = 225, x2 = 460, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"DamagedPageDown\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n AddClickArea( { id = \"DamagedPageUp\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n AddClickArea( { id = \"BrokenPageDown\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n AddClickArea( { id = \"BrokenPageUp\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\nend\n\nfunction FlushClickAreas()\n clickAreas = {}\nend\n\nfunction CheckClick(x, y)\n PrintDebug(\"Clicked at \"..x..\" / \"..y)\n local HitTarget=\"\"\n for k, v in pairs(clickAreas) do\n if v and x>=v.x1 and x<=v.x2 and y>=v.y1 and y<=v.y2 then\n HitTarget=v.id\n break\n end\n end\n if HitTarget==\"DamagedDamage\" then\n DamagedSortingMode=1\n CurrentDamagedPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"DamagedHealth\" then\n DamagedSortingMode=3\n CurrentDamagedPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"DamagedID\" then\n DamagedSortingMode=2\n CurrentDamagedPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"BrokenDamage\" then\n BrokenSortingMode=1\n CurrentBrokenPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"BrokenID\" then\n BrokenSortingMode=2\n CurrentBrokenPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"DamagedPageDown\" then\n CurrentDamagedPage = CurrentDamagedPage + 1\n if CurrentDamagedPage > math.ceil(#damagedElements/12) then CurrentDamagedPage = math.ceil(#damagedElements/12) end\n DrawScreens()\n elseif HitTarget==\"DamagedPageUp\" then\n CurrentDamagedPage = CurrentDamagedPage - 1\n if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end\n DrawScreens()\n elseif HitTarget==\"BrokenPageDown\" then\n CurrentBrokenPage = CurrentBrokenPage + 1\n if CurrentBrokenPage > math.ceil(#brokenElements/12) then CurrentBrokenPage = math.ceil(#brokenElements/12) end\n DrawScreens()\n elseif HitTarget==\"BrokenPageUp\" then\n CurrentBrokenPage = CurrentBrokenPage - 1\n if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end\n DrawScreens()\n elseif HitTarget==\"ToggleSimulation\" then\n CurrentDamagedPage=1\n CurrentBrokenPage=1\n if SimulationMode == true then\n SimulationMode = false\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n DrawScreens()\n else\n SimulationMode = true\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n DrawScreens()\n end\n elseif HitTarget==\"ToggleElementLabel\" then\n if UseMyElementNames == true then\n UseMyElementNames = false\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n DrawScreens()\n else\n UseMyElementNames = true\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n DrawScreens()\n end\n end\nend\n\nfunction SortTables()\n -- Sort damaged elements descending by percent damaged according to setting\n if DamagedSortingMode==1 then table.sort(damagedElements, function(a,b) return a.missinghp > b.missinghp end)\n elseif DamagedSortingMode==2 then table.sort(damagedElements, function(a,b) return a.id < b.id end)\n else table.sort(damagedElements, function(a,b) return a.percent < b.percent end)\n end\n\n -- Sort broken elements descending according to setting\n if BrokenSortingMode==1 then table.sort(brokenElements, function(a,b) return a.maxhp > b.maxhp end)\n else table.sort(brokenElements, function(a,b) return a.id < b.id end)\n end\nend\n\nfunction GenerateDamageData()\n if SimulationActive==true then\n return\n end\n\n local formerTotalShipHP = totalShipHP\n totalShipHP = 0\n totalShipMaxHP = 0\n totalShipIntegrity = 100\n elementsId = {}\n damagedElements = {}\n brokenElements = {}\n ElementCounter = 0\n healthyElements = 0\n\n elementsIdList = core.getElementIdList()\n\n for _,id in pairs(elementsIdList) do\n ElementCounter = ElementCounter + 1\n idHP = core.getElementHitPointsById(id) or 0\n idMaxHP = core.getElementMaxHitPointsById(id) or 0\n\n if SimulationMode then\n SimulationActive=true\n local dice =math.random(0,10)\n if dice < 2 then idHP = 0\n elseif dice >=2 and dice < 5 then idHP = idMaxHP\n else \n idHP = math.random(1, math.ceil(idMaxHP))\n end\n end\n\n totalShipHP = totalShipHP+idHP\n totalShipMaxHP = totalShipMaxHP+idMaxHP\n\n -- Is element damaged?\n if idMaxHP > idHP then\n idPos = core.getElementPositionById(id)\n idName = core.getElementNameById(id)\n idType = core.getElementTypeById(id)\n if idHP>0 then\n table.insert(damagedElements,\n {\n id = id,\n name = idName,\n type = idType,\n counter = ElementCounter,\n hp = idHP,\n maxhp = idMaxHP,\n missinghp = idMaxHP-idHP,\n percent = math.ceil(100/idMaxHP*idHP),\n pos =idPos\n }\n )\n -- if DebugMode then PrintDebug(\"Damaged: \"..idName..\" --- Type: \"..idType..\"\") end\n -- Is element broken?\n else\n table.insert(brokenElements,\n {\n id = id,\n name = idName,\n type = idType,\n counter = ElementCounter,\n hp = idHP,\n maxhp = idMaxHP,\n missinghp = idMaxHP-idHP,\n percent = 0,\n pos =idPos\n }\n )\n -- if DebugMode then PrintDebug(\"Broken: \"..idName..\" --- Type: \"..idType..\"\") end\n end\n else\n healthyElements = healthyElements + 1\n end\n end\n\n -- Sort tables by current settings \n SortTables()\n\n -- Update clickAreas\n\n\n -- Determine total ship integrity\n totalShipIntegrity = string.format(\"%2.0f\", 100/totalShipMaxHP*totalShipHP)\n\n -- Has anything changes since last check? If yes, force redrawing the screens\n if formerTotalShipHP ~= totalShipHP then\n forceRedraw=true\n formerTotalShipHP = totalShipHP\n else forceRedraw=false\n end \nend\n\nfunction DrawScreens()\n if #screens > 0 then\n\n local healthyColor = \"#00aa00\"\n local brokenColor = \"#aa0000\"\n local damagedColor = \"#aaaa00\"\n local integrityColor = \"#aaaaaa\"\n local healthyTextColor = \"white\"\n local brokenTextColor = \"#ff4444\"\n local damagedTextColor = \"#ffff44\"\n local integrityTextColor = \"white\"\n\n if #damagedElements ==0 then\n damagedColor = \"#aaaaaa\"\n damagedTextColor = \"white\"\n end\n if #brokenElements == 0 then \n brokenColor = \"#aaaaaa\"\n brokenTextColor = \"white\"\n end\n \n -- Draw Header\n screenOutput = [[\n ]]\n \n -- Draw main background\n screenOutput = screenOutput..\n [[\n \n \n \n \n \n \n \n \n \n \n \n ]]\n\n -- Draw Title and summary\n if SimulationActive==true then\n screenOutput = screenOutput..[[Simulated Report]]\n else\n screenOutput = screenOutput..[[Damage Report]]\n end\n screenOutput = screenOutput..\n [[SHIP ID ]]..shipID..[[\n\n Healthy\n ]]..healthyElements..[[\n\n Damaged\n ]]..#damagedElements..[[\n\n Broken\n ]]..#brokenElements..[[\n\n Integrity\n ]]..totalShipIntegrity..[[%]]\n\n -- Draw damage elements\n if #damagedElements > 0 then\n local damagedElementsToDraw = #damagedElements\n if damagedElementsToDraw>12 then damagedElementsToDraw=12 end\n if CurrentDamagedPage==math.ceil(#damagedElements/12) then damagedElementsToDraw = #damagedElements%12 end\n screenOutput = screenOutput..\n [[]]\n screenOutput = screenOutput .. [[]]\n if (DamagedSortingMode==2) then \n screenOutput = screenOutput ..[[ID]]\n else\n screenOutput = screenOutput ..[[ID]]\n end\n if UseMyElementNames==true then screenOutput = screenOutput ..[[Element Name]]\n else screenOutput = screenOutput ..[[Element Type]]\n end\n \n if (DamagedSortingMode==3) then \n screenOutput = screenOutput ..[[Health]]\n else\n screenOutput = screenOutput ..[[Health]]\n end\n if (DamagedSortingMode==1) then \n screenOutput = screenOutput ..[[Damage]]\n else\n screenOutput = screenOutput ..[[Damage]]\n end\n\n local i=0\n for j=1+(CurrentDamagedPage-1)*12,damagedElementsToDraw+(CurrentDamagedPage-1)*12,1 do\n i = i + 1\n local DP = damagedElements[j]\n screenOutput = screenOutput ..\n [[]]..string.format(\"%03.0f\",DP.id)..[[]]\n if UseMyElementNames==true then\n screenOutput = screenOutput .. [[]]..string.format(\"%.25s\", DP.name)..[[]]\n else\n screenOutput = screenOutput .. [[]]..string.format(\"%.25s\", DP.type)..[[]]\n end\n screenOutput = screenOutput ..\n [[]]..DP.percent..[[%]]..\n [[]]..GenerateCommaValue(string.format(\"%.0f\", DP.missinghp))..[[]]..\n [[]]\n end\n screenOutput = screenOutput ..\n [[\n \n ]]\n\n if #damagedElements>12 then\n screenOutput = screenOutput ..\n [[Page ]]..CurrentDamagedPage..\" of \"..math.ceil(#damagedElements/12)..[[]]\n\n if CurrentDamagedPage < math.ceil(#damagedElements/12) then\n screenOutput = screenOutput ..\n [[\n \n \n ]]\n UpdateClickArea( \"DamagedPageDown\", { id = \"DamagedPageDown\", x1 = 70, x2 = 270, y1 = 350+11+(damagedElementsToDraw+1)*50, y2 = 350+11+50+(damagedElementsToDraw+1)*50 } )\n else\n DisableClickArea( \"DamagedPageDown\" )\n end\n \n if CurrentDamagedPage > 1 then\n screenOutput = screenOutput ..\n [[\n \n \n ]]\n UpdateClickArea( \"DamagedPageUp\", { id = \"DamagedPageUp\", x1 = 280, x2 = 480, y1 = 350+11+(damagedElementsToDraw+1)*50, y2 = 350+11+50+(damagedElementsToDraw+1)*50 } )\n else\n DisableClickArea( \"DamagedPageUp\" )\n end\n end\n\n\n\n\n end\n\n -- Draw broken elements\n if #brokenElements > 0 then\n local brokenElementsToDraw = #brokenElements\n if brokenElementsToDraw>12 then brokenElementsToDraw=12 end\n if CurrentBrokenPage==math.ceil(#brokenElements/12) then brokenElementsToDraw = #brokenElements%12 end\n screenOutput = screenOutput..\n [[]]\n screenOutput = screenOutput .. [[]]\n if (BrokenSortingMode==2) then \n screenOutput = screenOutput ..[[ID]]\n else\n screenOutput = screenOutput ..[[ID]]\n end\n if UseMyElementNames==true then screenOutput = screenOutput .. [[Element Name]]\n else screenOutput = screenOutput .. [[Element Type]]\n end\n if (BrokenSortingMode==1) then \n screenOutput = screenOutput ..[[Damage]]\n else\n screenOutput = screenOutput ..[[Damage]]\n end\n\n local i=0\n for j=1+(CurrentBrokenPage-1)*12,brokenElementsToDraw+(CurrentBrokenPage-1)*12,1 do\n i = i + 1\n local DP = brokenElements[j]\n screenOutput = screenOutput ..\n [[]]..string.format(\"%03.0f\",DP.id)..[[]]\n if UseMyElementNames==true then\n screenOutput = screenOutput .. [[]]..string.format(\"%.25s\", DP.name)..[[]]\n else\n screenOutput = screenOutput .. [[]]..string.format(\"%.25s\", DP.type)..[[]]\n end\n screenOutput = screenOutput ..\n [[]]..GenerateCommaValue(string.format(\"%.0f\", DP.missinghp))..[[]]..\n [[]]\n end\n\n screenOutput = screenOutput.. \n [[\n \n ]]\n\n\n if #brokenElements>12 then\n screenOutput = screenOutput ..\n [[Page ]]..CurrentBrokenPage..\" of \"..math.ceil(#brokenElements/12)..[[]]\n\n if CurrentBrokenPage > 1 then\n screenOutput = screenOutput ..\n [[\n \n \n ]]\n UpdateClickArea( \"BrokenPageUp\", { id = \"BrokenPageUp\", x1 = 1442, x2 = 1642, y1 = 350+11+(brokenElementsToDraw+1)*50, y2 = 350+11+50+(brokenElementsToDraw+1)*50 } )\n else\n DisableClickArea( \"BrokenPageUp\" )\n end\n \n if CurrentBrokenPage < math.ceil(#brokenElements/12) then\n screenOutput = screenOutput ..\n [[\n \n \n ]]\n UpdateClickArea( \"BrokenPageDown\", { id = \"BrokenPageDown\", x1 = 1652, x2 = 1852, y1 = 350+11+(brokenElementsToDraw+1)*50, y2 = 350+11+50+(brokenElementsToDraw+1)*50 } )\n else\n DisableClickArea( \"BrokenPageDown\" )\n end\n end\n\n\n\n end\n\n -- Draw damage summary\n if #damagedElements>0 or #brokenElements > 0 then\n screenOutput = screenOutput..\n [[]]..GenerateCommaValue(string.format(\"%.0f\", totalShipMaxHP-totalShipHP))..[[ HP damage in total]]\n\n end\n\n screenOutput = screenOutput..[[]]\n\n DrawSVG(screenOutput)\n\n forceRedraw=false\n end\nend\n\n-----------------------------------------------\n-- Execute\n-----------------------------------------------\n\nunit.hide()\nClearConsole()\nPrintDebug(\"SCRIPT STARTED\", true)\n\nInitiateSlots()\nSwitchScreens(true)\nInitiateClickAreas()\n\nif core == nil then\n DrawCenteredText(\"ERROR: No core connected.\")\n PrintError(\"ERROR: No core connected.\")\n goto exit\nelse\n shipID = core.getConstructId()\nend\n\nGenerateDamageData()\nif forceRedraw then\n DrawScreens()\nend\n\nunit.setTimer('UpdateData', UpdateInterval)\n\n::exit::","filter":{"args":[],"signature":"start()","slotKey":"-1"},"key":"9"},{"code":"if #screens > 0 then\n for i=1,#screens,1 do\n screens[i].deactivate()\n screens[i].clear()\n end\nend","filter":{"args":[],"signature":"stop()","slotKey":"-1"},"key":"10"},{"code":"GenerateDamageData()\nif forceRedraw then\n DrawScreens()\nend","filter":{"args":[{"value":"UpdateData"}],"signature":"tick(timerId)","slotKey":"-1"},"key":"11"}],"methods":[],"events":[]}
\ No newline at end of file
diff --git a/versions/DamageReport_1_31.json b/versions/DamageReport_1_31.json
deleted file mode 100644
index 1f7dbc3..0000000
--- a/versions/DamageReport_1_31.json
+++ /dev/null
@@ -1 +0,0 @@
-{"slots":{"0":{"name":"core","type":{"events":[],"methods":[]}},"1":{"name":"slot2","type":{"events":[],"methods":[]}},"2":{"name":"slot3","type":{"events":[],"methods":[]}},"3":{"name":"slot4","type":{"events":[],"methods":[]}},"4":{"name":"slot5","type":{"events":[],"methods":[]}},"5":{"name":"slot6","type":{"events":[],"methods":[]}},"6":{"name":"slot7","type":{"events":[],"methods":[]}},"7":{"name":"slot8","type":{"events":[],"methods":[]}},"8":{"name":"slot9","type":{"events":[],"methods":[]}},"9":{"name":"slot10","type":{"events":[],"methods":[]}},"-1":{"name":"unit","type":{"events":[],"methods":[]}},"-2":{"name":"system","type":{"events":[],"methods":[]}},"-3":{"name":"library","type":{"events":[],"methods":[]}}},"handlers":[{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"1"},"key":"0"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"2"},"key":"1"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"3"},"key":"2"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"4"},"key":"3"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"5"},"key":"4"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"6"},"key":"5"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"7"},"key":"6"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"8"},"key":"7"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"9"},"key":"8"},{"code":"--[[\n DamageReport v1.31\n\n Created By Dorian Gray\n\n Discord: Dorian Gray#2623\n InGame: DorianGray\n GitHub: https://github.com/DorianTheGrey/DU-DamageReport\n\n GNU Public License 3.0. Use whatever you want, be so kind to leave credit.\n\n Thanks to Jericho, Dmentia and Archaegeo for learning from their fine scripts.\n]]\n\n-----------------------------------------------\n-- CONFIG\n-----------------------------------------------\n\nUseMyElementNames = false --export: If you active this, the display will not show the element type of damaged/broken elements but the name you gave them (truncated to 25 characters)\nUpdateInterval = 1 --export: Interval in seconds between updates of the calculations and (if anything changed) redrawing to the screen(s). You need to restart the script after changing this value.\nSimulationMode = false --export Randomize simluated damage on elements to check out the functionality of this script. And, no, your elements won't be harmed in the process :) You need to restart the script after changing this value.\n\nDebugMode = false -- Activate if you want some console messages\nVersionNumber = 1.31 -- Version number\n\ncore = nil \nscreens = {}\n\nshipID = 0\nforceRedraw = false\nSimulationActive=false\n\nclickAreas = {}\nDamagedSortingMode = 1 -- Define default sorting mode for damaged elements. 1 to sort by damage amount, 2 to sort by element id, 3 to sort by damage percent, \nBrokenSortingMode = 1 -- Define default sorting mode for broken elements. 1 to sort by damage amount, 2 to sort by element id\n\nHUDMode = false\nCurrentDamagedPage = 1\nCurrentBrokenPage = 1\n\ntotalShipHP = 0\ntotalShipMaxHP = 0\ntotalShipIntegrity = 100\nelementsId = {}\ndamagedElements = {}\nbrokenElements = {}\nElementCounter = 0\nhealthyElements = 0\n\n-----------------------------------------------\n-- FUNCTIONS\n-----------------------------------------------\n\n\nfunction GenerateCommaValue(amount)\n local formatted = amount\n while true do \n formatted, k = string.gsub(formatted, \"^(-?%d+)(%d%d%d)\", '%1,%2')\n if (k==0) then break end\n end\n return formatted\nend\n\nfunction PrintDebug(output, highlight) \n highlight = highlight or false\n if DebugMode then\n if highlight then system.print(\"------------------------------------------------------------------------\") end\n system.print(output)\n if highlight then system.print(\"------------------------------------------------------------------------\") end\n end\nend\n\nfunction PrintError(output) \n system.print(output)\nend\n\nfunction DrawCenteredText(output)\n for i=1,#screens,1 do\n screens[i].setCenteredText(output)\n end\nend\n\nfunction DrawSVG(output)\n for i=1,#screens,1 do\n screens[i].setSVG(output)\n end\nend\n\nfunction ClearConsole()\n for i=1,10,1 do\n PrintDebug()\n end\nend\n\nfunction SwitchScreens(state)\n state = state or true\n if #screens > 0 then\n for i=1,#screens,1 do\n if state then\n screens[i].clear()\n screens[i].activate()\n else\n screens[i].deactivate()\n screens[i].clear()\n end\n end\n end\nend\n\nfunction InitiateSlots()\n for slot_name, slot in pairs(unit) do\n if\n type(slot) == \"table\"\n and type(slot.export) == \"table\"\n and slot.getElementClass\n then\n if slot.getElementClass():lower():find(\"coreunit\") then\n core = slot\n end\n if slot.getElementClass():lower():find(\"screenunit\") then\n screens[#screens + 1] = slot\n end\n end\n end\nend\n\nfunction AddClickArea(newEntry)\n table.insert(clickAreas, newEntry)\nend\n\nfunction RemoveFromClickAreas(candidate)\n for k, v in pairs(clickAreas) do\n if v.id==candidate then\n clickAreas[k]=nil\n break\n end\n end\nend\n\nfunction UpdateClickArea(candidate, newEntry)\n for k, v in pairs(clickAreas) do\n if v.id==candidate then\n clickAreas[k]=newEntry\n break\n end\n end\nend\n\nfunction DisableClickArea(candidate)\n for k, v in pairs(clickAreas) do\n if v.id==candidate then\n UpdateClickArea(candidate, { id = candidate, x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n break\n end\n end\nend\n\nfunction InitiateClickAreas()\n clickAreas = {}\n AddClickArea( { id = \"DamagedDamage\", x1 = 725, x2 = 870, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"DamagedHealth\", x1 = 520, x2 = 655, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"DamagedID\", x1 = 90, x2 = 150, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"BrokenDamage\", x1 = 1675, x2 = 1835, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"BrokenID\", x1 = 1050, x2 = 1110, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"ToggleSimulation\", x1 = 65, x2 = 660, y1 = 100, y2 = 145 } )\n AddClickArea( { id = \"ToggleElementLabel\", x1 = 225, x2 = 460, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"ToggleElementLabel2\", x1 = 1185, x2 = 1440, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"DamagedPageDown\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n AddClickArea( { id = \"DamagedPageUp\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n AddClickArea( { id = \"BrokenPageDown\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n AddClickArea( { id = \"BrokenPageUp\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\nend\n\nfunction FlushClickAreas()\n clickAreas = {}\nend\n\nfunction CheckClick(x, y)\n PrintDebug(\"Clicked at \"..x..\" / \"..y)\n local HitTarget=\"\"\n for k, v in pairs(clickAreas) do\n if v and x>=v.x1 and x<=v.x2 and y>=v.y1 and y<=v.y2 then\n HitTarget=v.id\n break\n end\n end\n if HitTarget==\"DamagedDamage\" then\n DamagedSortingMode=1\n CurrentDamagedPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"DamagedHealth\" then\n DamagedSortingMode=3\n CurrentDamagedPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"DamagedID\" then\n DamagedSortingMode=2\n CurrentDamagedPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"BrokenDamage\" then\n BrokenSortingMode=1\n CurrentBrokenPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"BrokenID\" then\n BrokenSortingMode=2\n CurrentBrokenPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"DamagedPageDown\" then\n CurrentDamagedPage = CurrentDamagedPage + 1\n if CurrentDamagedPage > math.ceil(#damagedElements/12) then CurrentDamagedPage = math.ceil(#damagedElements/12) end\n DrawScreens()\n elseif HitTarget==\"DamagedPageUp\" then\n CurrentDamagedPage = CurrentDamagedPage - 1\n if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end\n DrawScreens()\n elseif HitTarget==\"BrokenPageDown\" then\n CurrentBrokenPage = CurrentBrokenPage + 1\n if CurrentBrokenPage > math.ceil(#brokenElements/12) then CurrentBrokenPage = math.ceil(#brokenElements/12) end\n DrawScreens()\n elseif HitTarget==\"BrokenPageUp\" then\n CurrentBrokenPage = CurrentBrokenPage - 1\n if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end\n DrawScreens()\n elseif HitTarget==\"ToggleSimulation\" then\n CurrentDamagedPage=1\n CurrentBrokenPage=1\n if SimulationMode == true then\n SimulationMode = false\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n DrawScreens()\n else\n SimulationMode = true\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n DrawScreens()\n end\n elseif HitTarget==\"ToggleElementLabel\" or HitTarget==\"ToggleElementLabel2\" then\n if UseMyElementNames == true then\n UseMyElementNames = false\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n DrawScreens()\n else\n UseMyElementNames = true\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n DrawScreens()\n end\n end\nend\n\nfunction SortTables()\n -- Sort damaged elements descending by percent damaged according to setting\n if DamagedSortingMode==1 then table.sort(damagedElements, function(a,b) return a.missinghp > b.missinghp end)\n elseif DamagedSortingMode==2 then table.sort(damagedElements, function(a,b) return a.id < b.id end)\n else table.sort(damagedElements, function(a,b) return a.percent < b.percent end)\n end\n\n -- Sort broken elements descending according to setting\n if BrokenSortingMode==1 then table.sort(brokenElements, function(a,b) return a.maxhp > b.maxhp end)\n else table.sort(brokenElements, function(a,b) return a.id < b.id end)\n end\nend\n\nfunction GenerateDamageData()\n if SimulationActive==true then\n return\n end\n\n local formerTotalShipHP = totalShipHP\n totalShipHP = 0\n totalShipMaxHP = 0\n totalShipIntegrity = 100\n elementsId = {}\n damagedElements = {}\n brokenElements = {}\n ElementCounter = 0\n healthyElements = 0\n\n elementsIdList = core.getElementIdList()\n\n for _,id in pairs(elementsIdList) do\n ElementCounter = ElementCounter + 1\n idHP = core.getElementHitPointsById(id) or 0\n idMaxHP = core.getElementMaxHitPointsById(id) or 0\n\n if SimulationMode then\n SimulationActive=true\n local dice =math.random(0,10)\n if dice < 2 then idHP = 0\n elseif dice >=2 and dice < 5 then idHP = idMaxHP\n else \n idHP = math.random(1, math.ceil(idMaxHP))\n end\n end\n\n totalShipHP = totalShipHP+idHP\n totalShipMaxHP = totalShipMaxHP+idMaxHP\n\n -- Is element damaged?\n if idMaxHP > idHP then\n idPos = core.getElementPositionById(id)\n idName = core.getElementNameById(id)\n idType = core.getElementTypeById(id)\n if idHP>0 then\n table.insert(damagedElements,\n {\n id = id,\n name = idName,\n type = idType,\n counter = ElementCounter,\n hp = idHP,\n maxhp = idMaxHP,\n missinghp = idMaxHP-idHP,\n percent = math.ceil(100/idMaxHP*idHP),\n pos =idPos\n }\n )\n -- if DebugMode then PrintDebug(\"Damaged: \"..idName..\" --- Type: \"..idType..\"\") end\n -- Is element broken?\n else\n table.insert(brokenElements,\n {\n id = id,\n name = idName,\n type = idType,\n counter = ElementCounter,\n hp = idHP,\n maxhp = idMaxHP,\n missinghp = idMaxHP-idHP,\n percent = 0,\n pos =idPos\n }\n )\n -- if DebugMode then PrintDebug(\"Broken: \"..idName..\" --- Type: \"..idType..\"\") end\n end\n else\n healthyElements = healthyElements + 1\n end\n end\n\n -- Sort tables by current settings \n SortTables()\n\n -- Update clickAreas\n\n\n -- Determine total ship integrity\n totalShipIntegrity = string.format(\"%2.0f\", 100/totalShipMaxHP*totalShipHP)\n\n -- Has anything changes since last check? If yes, force redrawing the screens\n if formerTotalShipHP ~= totalShipHP then\n forceRedraw=true\n formerTotalShipHP = totalShipHP\n else forceRedraw=false\n end \nend\n\nfunction DrawScreens()\n if #screens > 0 then\n\n local healthyColor = \"#00aa00\"\n local brokenColor = \"#aa0000\"\n local damagedColor = \"#aaaa00\"\n local integrityColor = \"#aaaaaa\"\n local healthyTextColor = \"white\"\n local brokenTextColor = \"#ff4444\"\n local damagedTextColor = \"#ffff44\"\n local integrityTextColor = \"white\"\n\n if #damagedElements ==0 then\n damagedColor = \"#aaaaaa\"\n damagedTextColor = \"white\"\n end\n if #brokenElements == 0 then \n brokenColor = \"#aaaaaa\"\n brokenTextColor = \"white\"\n end\n \n -- Draw Header\n screenOutput = [[\n ]]\n \n -- Draw main background\n screenOutput = screenOutput..\n [[\n \n \n \n \n \n \n \n \n \n \n \n ]]\n\n -- Draw Title and summary\n if SimulationActive==true then\n screenOutput = screenOutput..[[Simulated Report]]\n else\n screenOutput = screenOutput..[[Damage Report]]\n end\n screenOutput = screenOutput..\n [[SHIP ID ]]..shipID..[[\n\n Healthy\n ]]..healthyElements..[[\n\n Damaged\n ]]..#damagedElements..[[\n\n Broken\n ]]..#brokenElements..[[\n\n Integrity\n ]]..totalShipIntegrity..[[%]]\n\n -- Draw damage elements\n if #damagedElements > 0 then\n local damagedElementsToDraw = #damagedElements\n if damagedElementsToDraw>12 then damagedElementsToDraw=12 end\n if CurrentDamagedPage==math.ceil(#damagedElements/12) then damagedElementsToDraw = #damagedElements%12 end\n screenOutput = screenOutput..\n [[]]\n screenOutput = screenOutput .. [[]]\n if (DamagedSortingMode==2) then \n screenOutput = screenOutput ..[[ID]]\n else\n screenOutput = screenOutput ..[[ID]]\n end\n if UseMyElementNames==true then screenOutput = screenOutput ..[[Element Name]]\n else screenOutput = screenOutput ..[[Element Type]]\n end\n \n if (DamagedSortingMode==3) then \n screenOutput = screenOutput ..[[Health]]\n else\n screenOutput = screenOutput ..[[Health]]\n end\n if (DamagedSortingMode==1) then \n screenOutput = screenOutput ..[[Damage]]\n else\n screenOutput = screenOutput ..[[Damage]]\n end\n\n local i=0\n for j=1+(CurrentDamagedPage-1)*12,damagedElementsToDraw+(CurrentDamagedPage-1)*12,1 do\n i = i + 1\n local DP = damagedElements[j]\n screenOutput = screenOutput ..\n [[]]..string.format(\"%03.0f\",DP.id)..[[]]\n if UseMyElementNames==true then\n screenOutput = screenOutput .. [[]]..string.format(\"%.25s\", DP.name)..[[]]\n else\n screenOutput = screenOutput .. [[]]..string.format(\"%.25s\", DP.type)..[[]]\n end\n screenOutput = screenOutput ..\n [[]]..DP.percent..[[%]]..\n [[]]..GenerateCommaValue(string.format(\"%.0f\", DP.missinghp))..[[]]..\n [[]]\n end\n screenOutput = screenOutput ..\n [[\n \n ]]\n\n if #damagedElements>12 then\n screenOutput = screenOutput ..\n [[Page ]]..CurrentDamagedPage..\" of \"..math.ceil(#damagedElements/12)..[[]]\n\n if CurrentDamagedPage < math.ceil(#damagedElements/12) then\n screenOutput = screenOutput ..\n [[\n \n \n ]]\n UpdateClickArea( \"DamagedPageDown\", { id = \"DamagedPageDown\", x1 = 70, x2 = 270, y1 = 350+11+(damagedElementsToDraw+1)*50, y2 = 350+11+50+(damagedElementsToDraw+1)*50 } )\n else\n DisableClickArea( \"DamagedPageDown\" )\n end\n \n if CurrentDamagedPage > 1 then\n screenOutput = screenOutput ..\n [[\n \n \n ]]\n UpdateClickArea( \"DamagedPageUp\", { id = \"DamagedPageUp\", x1 = 280, x2 = 480, y1 = 350+11+(damagedElementsToDraw+1)*50, y2 = 350+11+50+(damagedElementsToDraw+1)*50 } )\n else\n DisableClickArea( \"DamagedPageUp\" )\n end\n end\n\n\n\n\n end\n\n -- Draw broken elements\n if #brokenElements > 0 then\n local brokenElementsToDraw = #brokenElements\n if brokenElementsToDraw>12 then brokenElementsToDraw=12 end\n if CurrentBrokenPage==math.ceil(#brokenElements/12) then brokenElementsToDraw = #brokenElements%12 end\n screenOutput = screenOutput..\n [[]]\n screenOutput = screenOutput .. [[]]\n if (BrokenSortingMode==2) then \n screenOutput = screenOutput ..[[ID]]\n else\n screenOutput = screenOutput ..[[ID]]\n end\n if UseMyElementNames==true then screenOutput = screenOutput .. [[Element Name]]\n else screenOutput = screenOutput .. [[Element Type]]\n end\n if (BrokenSortingMode==1) then \n screenOutput = screenOutput ..[[Damage]]\n else\n screenOutput = screenOutput ..[[Damage]]\n end\n\n local i=0\n for j=1+(CurrentBrokenPage-1)*12,brokenElementsToDraw+(CurrentBrokenPage-1)*12,1 do\n i = i + 1\n local DP = brokenElements[j]\n screenOutput = screenOutput ..\n [[]]..string.format(\"%03.0f\",DP.id)..[[]]\n if UseMyElementNames==true then\n screenOutput = screenOutput .. [[]]..string.format(\"%.25s\", DP.name)..[[]]\n else\n screenOutput = screenOutput .. [[]]..string.format(\"%.25s\", DP.type)..[[]]\n end\n screenOutput = screenOutput ..\n [[]]..GenerateCommaValue(string.format(\"%.0f\", DP.missinghp))..[[]]..\n [[]]\n end\n\n screenOutput = screenOutput.. \n [[\n \n ]]\n\n\n if #brokenElements>12 then\n screenOutput = screenOutput ..\n [[Page ]]..CurrentBrokenPage..\" of \"..math.ceil(#brokenElements/12)..[[]]\n\n if CurrentBrokenPage > 1 then\n screenOutput = screenOutput ..\n [[\n \n \n ]]\n UpdateClickArea( \"BrokenPageUp\", { id = \"BrokenPageUp\", x1 = 1442, x2 = 1642, y1 = 350+11+(brokenElementsToDraw+1)*50, y2 = 350+11+50+(brokenElementsToDraw+1)*50 } )\n else\n DisableClickArea( \"BrokenPageUp\" )\n end\n \n if CurrentBrokenPage < math.ceil(#brokenElements/12) then\n screenOutput = screenOutput ..\n [[\n \n \n ]]\n UpdateClickArea( \"BrokenPageDown\", { id = \"BrokenPageDown\", x1 = 1652, x2 = 1852, y1 = 350+11+(brokenElementsToDraw+1)*50, y2 = 350+11+50+(brokenElementsToDraw+1)*50 } )\n else\n DisableClickArea( \"BrokenPageDown\" )\n end\n end\n\n\n\n end\n\n -- Draw damage summary\n if #damagedElements>0 or #brokenElements > 0 then\n screenOutput = screenOutput..\n [[]]..GenerateCommaValue(string.format(\"%.0f\", totalShipMaxHP-totalShipHP))..[[ HP damage in total]]\n\n end\n\n screenOutput = screenOutput..[[]]\n\n DrawSVG(screenOutput)\n\n forceRedraw=false\n end\nend\n\n-----------------------------------------------\n-- Execute\n-----------------------------------------------\n\nunit.hide()\nClearConsole()\nPrintDebug(\"SCRIPT STARTED\", true)\n\nInitiateSlots()\nSwitchScreens(true)\nInitiateClickAreas()\n\nif core == nil then\n DrawCenteredText(\"ERROR: No core connected.\")\n PrintError(\"ERROR: No core connected.\")\n goto exit\nelse\n shipID = core.getConstructId()\nend\n\nGenerateDamageData()\nif forceRedraw then\n DrawScreens()\nend\n\nunit.setTimer('UpdateData', UpdateInterval)\n\n::exit::","filter":{"args":[],"signature":"start()","slotKey":"-1"},"key":"9"},{"code":"if #screens > 0 then\n for i=1,#screens,1 do\n screens[i].deactivate()\n screens[i].clear()\n end\nend","filter":{"args":[],"signature":"stop()","slotKey":"-1"},"key":"10"},{"code":"GenerateDamageData()\nif forceRedraw then\n DrawScreens()\nend","filter":{"args":[{"value":"UpdateData"}],"signature":"tick(timerId)","slotKey":"-1"},"key":"11"}],"methods":[],"events":[]}
\ No newline at end of file
diff --git a/versions/DamageReport_1_4.json b/versions/DamageReport_1_4.json
deleted file mode 100644
index a0432a0..0000000
--- a/versions/DamageReport_1_4.json
+++ /dev/null
@@ -1 +0,0 @@
-{"slots":{"0":{"name":"core","type":{"events":[],"methods":[]}},"1":{"name":"slot2","type":{"events":[],"methods":[]}},"2":{"name":"slot3","type":{"events":[],"methods":[]}},"3":{"name":"slot4","type":{"events":[],"methods":[]}},"4":{"name":"slot5","type":{"events":[],"methods":[]}},"5":{"name":"slot6","type":{"events":[],"methods":[]}},"6":{"name":"slot7","type":{"events":[],"methods":[]}},"7":{"name":"slot8","type":{"events":[],"methods":[]}},"8":{"name":"slot9","type":{"events":[],"methods":[]}},"9":{"name":"slot10","type":{"events":[],"methods":[]}},"-1":{"name":"unit","type":{"events":[],"methods":[]}},"-2":{"name":"system","type":{"events":[],"methods":[]}},"-3":{"name":"library","type":{"events":[],"methods":[]}}},"handlers":[{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"1"},"key":"0"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"2"},"key":"1"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"3"},"key":"2"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"4"},"key":"3"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"5"},"key":"4"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"6"},"key":"5"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"7"},"key":"6"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"8"},"key":"7"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"9"},"key":"8"},{"code":"--[[\n DamageReport v1.4\n\n Created By Dorian Gray\n\n Discord: Dorian Gray#2623\n InGame: DorianGray\n GitHub: https://github.com/DorianTheGrey/DU-DamageReport\n\n GNU Public License 3.0. Use whatever you want, be so kind to leave credit.\n\n Thanks to Jericho, Dmentia and Archaegeo for learning from their fine scripts.\n]]\n\n-----------------------------------------------\n-- CONFIG\n-----------------------------------------------\n\nUseMyElementNames = false --export: If you active this, the display will not show the element type of damaged/broken elements but the name you gave them (truncated to 25 characters)\nUpdateInterval = 1 --export: Interval in seconds between updates of the calculations and (if anything changed) redrawing to the screen(s). You need to restart the script after changing this value.\nSimulationMode = false --export Randomize simluated damage on elements to check out the functionality of this script. And, no, your elements won't be harmed in the process :) You need to restart the script after changing this value.\n\nDebugMode = false -- Activate if you want some console messages\nVersionNumber = 1.4 -- Version number\n\ncore = nil \nscreens = {}\n\nshipID = 0\nforceRedraw = false\nSimulationActive=false\n\nclickAreas = {}\nDamagedSortingMode = 1 -- Define default sorting mode for damaged elements. 1 to sort by damage amount, 2 to sort by element id, 3 to sort by damage percent, \nBrokenSortingMode = 1 -- Define default sorting mode for broken elements. 1 to sort by damage amount, 2 to sort by element id\n\nHUDMode = false\nCurrentDamagedPage = 1\nCurrentBrokenPage = 1\n\ntotalShipHP = 0\ntotalShipMaxHP = 0\ntotalShipIntegrity = 100\nelementsId = {}\ndamagedElements = {}\nbrokenElements = {}\nElementCounter = 0\nhealthyElements = 0\n\nOkayCenterMessage = \"All systems nominal.\"\n\n-----------------------------------------------\n-- FUNCTIONS\n-----------------------------------------------\n\n\nfunction GenerateCommaValue(amount)\n local formatted = amount\n while true do \n formatted, k = string.gsub(formatted, \"^(-?%d+)(%d%d%d)\", '%1,%2')\n if (k==0) then break end\n end\n return formatted\nend\n\nfunction PrintDebug(output, highlight) \n highlight = highlight or false\n if DebugMode then\n if highlight then system.print(\"------------------------------------------------------------------------\") end\n system.print(output)\n if highlight then system.print(\"------------------------------------------------------------------------\") end\n end\nend\n\nfunction PrintError(output) \n system.print(output)\nend\n\nfunction DrawCenteredText(output)\n for i=1,#screens,1 do\n screens[i].setCenteredText(output)\n end\nend\n\nfunction DrawSVG(output)\n for i=1,#screens,1 do\n screens[i].setSVG(output)\n end\nend\n\nfunction ClearConsole()\n for i=1,10,1 do\n PrintDebug()\n end\nend\n\nfunction SwitchScreens(state)\n state = state or true\n if #screens > 0 then\n for i=1,#screens,1 do\n if state then\n screens[i].clear()\n screens[i].activate()\n else\n screens[i].deactivate()\n screens[i].clear()\n end\n end\n end\nend\n\nfunction InitiateSlots()\n for slot_name, slot in pairs(unit) do\n if\n type(slot) == \"table\"\n and type(slot.export) == \"table\"\n and slot.getElementClass\n then\n if slot.getElementClass():lower():find(\"coreunit\") then\n core = slot\n end\n if slot.getElementClass():lower():find(\"screenunit\") then\n screens[#screens + 1] = slot\n end\n end\n end\nend\n\nfunction AddClickArea(newEntry)\n table.insert(clickAreas, newEntry)\nend\n\nfunction RemoveFromClickAreas(candidate)\n for k, v in pairs(clickAreas) do\n if v.id==candidate then\n clickAreas[k]=nil\n break\n end\n end\nend\n\nfunction UpdateClickArea(candidate, newEntry)\n for k, v in pairs(clickAreas) do\n if v.id==candidate then\n clickAreas[k]=newEntry\n break\n end\n end\nend\n\nfunction DisableClickArea(candidate)\n for k, v in pairs(clickAreas) do\n if v.id==candidate then\n UpdateClickArea(candidate, { id = candidate, x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n break\n end\n end\nend\n\nfunction InitiateClickAreas()\n clickAreas = {}\n AddClickArea( { id = \"DamagedDamage\", x1 = 725, x2 = 870, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"DamagedHealth\", x1 = 520, x2 = 655, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"DamagedID\", x1 = 90, x2 = 150, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"BrokenDamage\", x1 = 1675, x2 = 1835, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"BrokenID\", x1 = 1050, x2 = 1110, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"ToggleSimulation\", x1 = 65, x2 = 660, y1 = 100, y2 = 145 } )\n AddClickArea( { id = \"ToggleElementLabel\", x1 = 225, x2 = 460, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"ToggleElementLabel2\", x1 = 1185, x2 = 1440, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"DamagedPageDown\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n AddClickArea( { id = \"DamagedPageUp\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n AddClickArea( { id = \"BrokenPageDown\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n AddClickArea( { id = \"BrokenPageUp\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\nend\n\nfunction FlushClickAreas()\n clickAreas = {}\nend\n\nfunction CheckClick(x, y)\n PrintDebug(\"Clicked at \"..x..\" / \"..y)\n local HitTarget=\"\"\n for k, v in pairs(clickAreas) do\n if v and x>=v.x1 and x<=v.x2 and y>=v.y1 and y<=v.y2 then\n HitTarget=v.id\n break\n end\n end\n if HitTarget==\"DamagedDamage\" then\n DamagedSortingMode=1\n CurrentDamagedPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"DamagedHealth\" then\n DamagedSortingMode=3\n CurrentDamagedPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"DamagedID\" then\n DamagedSortingMode=2\n CurrentDamagedPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"BrokenDamage\" then\n BrokenSortingMode=1\n CurrentBrokenPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"BrokenID\" then\n BrokenSortingMode=2\n CurrentBrokenPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"DamagedPageDown\" then\n CurrentDamagedPage = CurrentDamagedPage + 1\n if CurrentDamagedPage > math.ceil(#damagedElements/12) then CurrentDamagedPage = math.ceil(#damagedElements/12) end\n DrawScreens()\n elseif HitTarget==\"DamagedPageUp\" then\n CurrentDamagedPage = CurrentDamagedPage - 1\n if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end\n DrawScreens()\n elseif HitTarget==\"BrokenPageDown\" then\n CurrentBrokenPage = CurrentBrokenPage + 1\n if CurrentBrokenPage > math.ceil(#brokenElements/12) then CurrentBrokenPage = math.ceil(#brokenElements/12) end\n DrawScreens()\n elseif HitTarget==\"BrokenPageUp\" then\n CurrentBrokenPage = CurrentBrokenPage - 1\n if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end\n DrawScreens()\n elseif HitTarget==\"ToggleSimulation\" then\n CurrentDamagedPage=1\n CurrentBrokenPage=1\n if SimulationMode == true then\n SimulationMode = false\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n DrawScreens()\n else\n SimulationMode = true\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n DrawScreens()\n end\n elseif HitTarget==\"ToggleElementLabel\" or HitTarget==\"ToggleElementLabel2\" then\n if UseMyElementNames == true then\n UseMyElementNames = false\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n DrawScreens()\n else\n UseMyElementNames = true\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n DrawScreens()\n end\n end\nend\n\nfunction SortTables()\n -- Sort damaged elements descending by percent damaged according to setting\n if DamagedSortingMode==1 then table.sort(damagedElements, function(a,b) return a.missinghp > b.missinghp end)\n elseif DamagedSortingMode==2 then table.sort(damagedElements, function(a,b) return a.id < b.id end)\n else table.sort(damagedElements, function(a,b) return a.percent < b.percent end)\n end\n\n -- Sort broken elements descending according to setting\n if BrokenSortingMode==1 then table.sort(brokenElements, function(a,b) return a.maxhp > b.maxhp end)\n else table.sort(brokenElements, function(a,b) return a.id < b.id end)\n end\nend\n\nfunction GenerateDamageData()\n if SimulationActive==true then\n return\n end\n\n local formerTotalShipHP = totalShipHP\n totalShipHP = 0\n totalShipMaxHP = 0\n totalShipIntegrity = 100\n elementsId = {}\n damagedElements = {}\n brokenElements = {}\n ElementCounter = 0\n healthyElements = 0\n\n elementsIdList = core.getElementIdList()\n\n for _,id in pairs(elementsIdList) do\n ElementCounter = ElementCounter + 1\n idHP = core.getElementHitPointsById(id) or 0\n idMaxHP = core.getElementMaxHitPointsById(id) or 0\n\n if SimulationMode then\n SimulationActive=true\n local dice =math.random(0,10)\n if dice < 2 then idHP = 0\n elseif dice >=2 and dice < 5 then idHP = idMaxHP\n else \n idHP = math.random(1, math.ceil(idMaxHP))\n end\n end\n\n totalShipHP = totalShipHP+idHP\n totalShipMaxHP = totalShipMaxHP+idMaxHP\n\n -- Is element damaged?\n if idMaxHP > idHP then\n idPos = core.getElementPositionById(id)\n idName = core.getElementNameById(id)\n idType = core.getElementTypeById(id)\n if idHP>0 then\n table.insert(damagedElements,\n {\n id = id,\n name = idName,\n type = idType,\n counter = ElementCounter,\n hp = idHP,\n maxhp = idMaxHP,\n missinghp = idMaxHP-idHP,\n percent = math.ceil(100/idMaxHP*idHP),\n pos =idPos\n }\n )\n -- if DebugMode then PrintDebug(\"Damaged: \"..idName..\" --- Type: \"..idType..\"\") end\n -- Is element broken?\n else\n table.insert(brokenElements,\n {\n id = id,\n name = idName,\n type = idType,\n counter = ElementCounter,\n hp = idHP,\n maxhp = idMaxHP,\n missinghp = idMaxHP-idHP,\n percent = 0,\n pos =idPos\n }\n )\n -- if DebugMode then PrintDebug(\"Broken: \"..idName..\" --- Type: \"..idType..\"\") end\n end\n else\n healthyElements = healthyElements + 1\n end\n end\n\n -- Sort tables by current settings \n SortTables()\n\n -- Update clickAreas\n\n\n -- Determine total ship integrity\n totalShipIntegrity = string.format(\"%2.0f\", 100/totalShipMaxHP*totalShipHP)\n\n -- Has anything changes since last check? If yes, force redrawing the screens\n if formerTotalShipHP ~= totalShipHP then\n forceRedraw=true\n formerTotalShipHP = totalShipHP\n else forceRedraw=false\n end \nend\n\nfunction GetAllSystemsNominalBackground()\n local output=\"\"\n output = output..\n [[\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ]]\n return output\nend\n\nfunction DrawScreens()\n if #screens > 0 then\n\n local healthyColor = \"#00aa00\"\n local brokenColor = \"#aa0000\"\n local damagedColor = \"#aaaa00\"\n local integrityColor = \"#aaaaaa\"\n local healthyTextColor = \"white\"\n local brokenTextColor = \"#ff4444\"\n local damagedTextColor = \"#ffff44\"\n local integrityTextColor = \"white\"\n\n if #damagedElements ==0 then\n damagedColor = \"#aaaaaa\"\n damagedTextColor = \"white\"\n end\n if #brokenElements == 0 then \n brokenColor = \"#aaaaaa\"\n brokenTextColor = \"white\"\n end\n \n -- Draw Header\n screenOutput = [[\n ]]\n \n -- Draw main background\n screenOutput = screenOutput..\n [[\n \n \n \n \n \n \n \n \n \n \n \n ]]\n\n -- Draw Title and summary\n if SimulationActive==true then\n screenOutput = screenOutput..[[Simulated Report]]\n else\n screenOutput = screenOutput..[[Damage Report]]\n end\n screenOutput = screenOutput..\n [[SHIP ID ]]..shipID..[[\n\n Healthy\n ]]..healthyElements..[[\n\n Damaged\n ]]..#damagedElements..[[\n\n Broken\n ]]..#brokenElements..[[\n\n Integrity\n ]]..totalShipIntegrity..[[%]]\n\n -- Draw damage elements\n\n if #damagedElements > 0 then\n local damagedElementsToDraw = #damagedElements\n if damagedElementsToDraw>12 then damagedElementsToDraw=12 end\n if CurrentDamagedPage==math.ceil(#damagedElements/12) then damagedElementsToDraw = #damagedElements%12 end\n screenOutput = screenOutput..\n [[]]\n screenOutput = screenOutput .. [[]]\n if (DamagedSortingMode==2) then \n screenOutput = screenOutput ..[[ID]]\n else\n screenOutput = screenOutput ..[[ID]]\n end\n if UseMyElementNames==true then screenOutput = screenOutput ..[[Element Name]]\n else screenOutput = screenOutput ..[[Element Type]]\n end\n \n if (DamagedSortingMode==3) then \n screenOutput = screenOutput ..[[Health]]\n else\n screenOutput = screenOutput ..[[Health]]\n end\n if (DamagedSortingMode==1) then \n screenOutput = screenOutput ..[[Damage]]\n else\n screenOutput = screenOutput ..[[Damage]]\n end\n\n local i=0\n for j=1+(CurrentDamagedPage-1)*12,damagedElementsToDraw+(CurrentDamagedPage-1)*12,1 do\n i = i + 1\n local DP = damagedElements[j]\n screenOutput = screenOutput ..\n [[]]..string.format(\"%03.0f\",DP.id)..[[]]\n if UseMyElementNames==true then\n screenOutput = screenOutput .. [[]]..string.format(\"%.25s\", DP.name)..[[]]\n else\n screenOutput = screenOutput .. [[]]..string.format(\"%.25s\", DP.type)..[[]]\n end\n screenOutput = screenOutput ..\n [[]]..DP.percent..[[%]]..\n [[]]..GenerateCommaValue(string.format(\"%.0f\", DP.missinghp))..[[]]..\n [[]]\n end\n screenOutput = screenOutput ..\n [[\n \n ]]\n\n if #damagedElements>12 then\n screenOutput = screenOutput ..\n [[Page ]]..CurrentDamagedPage..\" of \"..math.ceil(#damagedElements/12)..[[]]\n\n if CurrentDamagedPage < math.ceil(#damagedElements/12) then\n screenOutput = screenOutput ..\n [[\n \n \n ]]\n UpdateClickArea( \"DamagedPageDown\", { id = \"DamagedPageDown\", x1 = 70, x2 = 270, y1 = 350+11+(damagedElementsToDraw+1)*50, y2 = 350+11+50+(damagedElementsToDraw+1)*50 } )\n else\n DisableClickArea( \"DamagedPageDown\" )\n end\n \n if CurrentDamagedPage > 1 then\n screenOutput = screenOutput ..\n [[\n \n \n ]]\n UpdateClickArea( \"DamagedPageUp\", { id = \"DamagedPageUp\", x1 = 280, x2 = 480, y1 = 350+11+(damagedElementsToDraw+1)*50, y2 = 350+11+50+(damagedElementsToDraw+1)*50 } )\n else\n DisableClickArea( \"DamagedPageUp\" )\n end\n end\n\n\n\n\n end\n\n -- Draw broken elements\n if #brokenElements > 0 then\n local brokenElementsToDraw = #brokenElements\n if brokenElementsToDraw>12 then brokenElementsToDraw=12 end\n if CurrentBrokenPage==math.ceil(#brokenElements/12) then brokenElementsToDraw = #brokenElements%12 end\n screenOutput = screenOutput..\n [[]]\n screenOutput = screenOutput .. [[]]\n if (BrokenSortingMode==2) then \n screenOutput = screenOutput ..[[ID]]\n else\n screenOutput = screenOutput ..[[ID]]\n end\n if UseMyElementNames==true then screenOutput = screenOutput .. [[Element Name]]\n else screenOutput = screenOutput .. [[Element Type]]\n end\n if (BrokenSortingMode==1) then \n screenOutput = screenOutput ..[[Damage]]\n else\n screenOutput = screenOutput ..[[Damage]]\n end\n\n local i=0\n for j=1+(CurrentBrokenPage-1)*12,brokenElementsToDraw+(CurrentBrokenPage-1)*12,1 do\n i = i + 1\n local DP = brokenElements[j]\n screenOutput = screenOutput ..\n [[]]..string.format(\"%03.0f\",DP.id)..[[]]\n if UseMyElementNames==true then\n screenOutput = screenOutput .. [[]]..string.format(\"%.25s\", DP.name)..[[]]\n else\n screenOutput = screenOutput .. [[]]..string.format(\"%.25s\", DP.type)..[[]]\n end\n screenOutput = screenOutput ..\n [[]]..GenerateCommaValue(string.format(\"%.0f\", DP.missinghp))..[[]]..\n [[]]\n end\n\n screenOutput = screenOutput.. \n [[\n \n ]]\n\n\n if #brokenElements>12 then\n screenOutput = screenOutput ..\n [[Page ]]..CurrentBrokenPage..\" of \"..math.ceil(#brokenElements/12)..[[]]\n\n if CurrentBrokenPage > 1 then\n screenOutput = screenOutput ..\n [[\n \n \n ]]\n UpdateClickArea( \"BrokenPageUp\", { id = \"BrokenPageUp\", x1 = 1442, x2 = 1642, y1 = 350+11+(brokenElementsToDraw+1)*50, y2 = 350+11+50+(brokenElementsToDraw+1)*50 } )\n else\n DisableClickArea( \"BrokenPageUp\" )\n end\n \n if CurrentBrokenPage < math.ceil(#brokenElements/12) then\n screenOutput = screenOutput ..\n [[\n \n \n ]]\n UpdateClickArea( \"BrokenPageDown\", { id = \"BrokenPageDown\", x1 = 1652, x2 = 1852, y1 = 350+11+(brokenElementsToDraw+1)*50, y2 = 350+11+50+(brokenElementsToDraw+1)*50 } )\n else\n DisableClickArea( \"BrokenPageDown\" )\n end\n end\n\n\n\n end\n\n -- Draw damage summary\n if #damagedElements>0 or #brokenElements > 0 then\n screenOutput = screenOutput..\n [[]]..GenerateCommaValue(string.format(\"%.0f\", totalShipMaxHP-totalShipHP))..[[ HP damage in total]]\n else\n screenOutput = screenOutput..\n [[]]..\n GetAllSystemsNominalBackground()..\n [[]]..\n [[]]..OkayCenterMessage..[[]]\n end\n\n -- Draw HUD Mode button\n screenOutput = screenOutput..[[]]\n\n DrawSVG(screenOutput)\n\n forceRedraw=false\n end\nend\n\n-----------------------------------------------\n-- Execute\n-----------------------------------------------\n\nunit.hide()\nClearConsole()\nPrintDebug(\"SCRIPT STARTED\", true)\n\nInitiateSlots()\nSwitchScreens(true)\nInitiateClickAreas()\n\nif core == nil then\n DrawCenteredText(\"ERROR: No core connected.\")\n PrintError(\"ERROR: No core connected.\")\n goto exit\nelse\n shipID = core.getConstructId()\nend\n\nGenerateDamageData()\nif forceRedraw then\n DrawScreens()\nend\n\nunit.setTimer('UpdateData', UpdateInterval)\n\n::exit::","filter":{"args":[],"signature":"start()","slotKey":"-1"},"key":"9"},{"code":"if #screens > 0 then\n for i=1,#screens,1 do\n screens[i].deactivate()\n screens[i].clear()\n end\nend","filter":{"args":[],"signature":"stop()","slotKey":"-1"},"key":"10"},{"code":"GenerateDamageData()\nif forceRedraw then\n DrawScreens()\nend","filter":{"args":[{"value":"UpdateData"}],"signature":"tick(timerId)","slotKey":"-1"},"key":"11"}],"methods":[],"events":[]}
\ No newline at end of file
diff --git a/versions/DamageReport_1_5.json b/versions/DamageReport_1_5.json
deleted file mode 100644
index aad73c7..0000000
--- a/versions/DamageReport_1_5.json
+++ /dev/null
@@ -1 +0,0 @@
-{"slots":{"0":{"name":"core","type":{"events":[],"methods":[]}},"1":{"name":"slot2","type":{"events":[],"methods":[]}},"2":{"name":"slot3","type":{"events":[],"methods":[]}},"3":{"name":"slot4","type":{"events":[],"methods":[]}},"4":{"name":"slot5","type":{"events":[],"methods":[]}},"5":{"name":"slot6","type":{"events":[],"methods":[]}},"6":{"name":"slot7","type":{"events":[],"methods":[]}},"7":{"name":"slot8","type":{"events":[],"methods":[]}},"8":{"name":"slot9","type":{"events":[],"methods":[]}},"9":{"name":"slot10","type":{"events":[],"methods":[]}},"-1":{"name":"unit","type":{"events":[],"methods":[]}},"-2":{"name":"system","type":{"events":[],"methods":[]}},"-3":{"name":"library","type":{"events":[],"methods":[]}}},"handlers":[{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"1"},"key":"0"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"2"},"key":"1"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"3"},"key":"2"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"4"},"key":"3"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"5"},"key":"4"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"6"},"key":"5"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"7"},"key":"6"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"8"},"key":"7"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"9"},"key":"8"},{"code":"--[[\n DamageReport v1.5\n\n Created By Dorian Gray\n\n Discord: Dorian Gray#2623\n InGame: DorianGray\n GitHub: https://github.com/DorianTheGrey/DU-DamageReport\n\n GNU Public License 3.0. Use whatever you want, be so kind to leave credit.\n\n Thanks to Jericho, Dmentia and Archaegeo for learning from their fine scripts.\n]]\n\n-----------------------------------------------\n-- CONFIG\n-----------------------------------------------\n\nUseMyElementNames = false --export: If you active this, the display will not show the element type of damaged/broken elements but the name you gave them (truncated to 25 characters)\nUpdateInterval = 1 --export: Interval in seconds between updates of the calculations and (if anything changed) redrawing to the screen(s). You need to restart the script after changing this value.\nSimulationMode = false --export Randomize simluated damage on elements to check out the functionality of this script. And, no, your elements won't be harmed in the process :) You need to restart the script after changing this value.\nYourShipsName = \"Enter here\" --export Enter your ship name here if you want it displayed instead of the ship's ID.\n\nDebugMode = false -- Activate if you want some console messages\nVersionNumber = 1.5 -- Version number\n\ncore = nil \nscreens = {}\n\nshipID = 0\nforceRedraw = false\nSimulationActive=false\n\nclickAreas = {}\nDamagedSortingMode = 1 -- Define default sorting mode for damaged elements. 1 to sort by damage amount, 2 to sort by element id, 3 to sort by damage percent, \nBrokenSortingMode = 1 -- Define default sorting mode for broken elements. 1 to sort by damage amount, 2 to sort by element id\n\nHUDMode = false\nCurrentDamagedPage = 1\nCurrentBrokenPage = 1\n\ntotalShipHP = 0\ntotalShipMaxHP = 0\ntotalShipIntegrity = 100\nelementsId = {}\ndamagedElements = {}\nbrokenElements = {}\nElementCounter = 0\nhealthyElements = 0\n\nOkayCenterMessage = \"All systems nominal.\"\n\n-----------------------------------------------\n-- FUNCTIONS\n-----------------------------------------------\n\n\nfunction GenerateCommaValue(amount)\n local formatted = amount\n while true do \n formatted, k = string.gsub(formatted, \"^(-?%d+)(%d%d%d)\", '%1,%2')\n if (k==0) then break end\n end\n return formatted\nend\n\nfunction PrintDebug(output, highlight) \n highlight = highlight or false\n if DebugMode then\n if highlight then system.print(\"------------------------------------------------------------------------\") end\n system.print(output)\n if highlight then system.print(\"------------------------------------------------------------------------\") end\n end\nend\n\nfunction PrintError(output) \n system.print(output)\nend\n\nfunction DrawCenteredText(output)\n for i=1,#screens,1 do\n screens[i].setCenteredText(output)\n end\nend\n\nfunction DrawSVG(output)\n for i=1,#screens,1 do\n screens[i].setSVG(output)\n end\nend\n\nfunction ClearConsole()\n for i=1,10,1 do\n PrintDebug()\n end\nend\n\nfunction SwitchScreens(state)\n state = state or true\n if #screens > 0 then\n for i=1,#screens,1 do\n if state then\n screens[i].clear()\n screens[i].activate()\n else\n screens[i].deactivate()\n screens[i].clear()\n end\n end\n end\nend\n\nfunction InitiateSlots()\n for slot_name, slot in pairs(unit) do\n if\n type(slot) == \"table\"\n and type(slot.export) == \"table\"\n and slot.getElementClass\n then\n if slot.getElementClass():lower():find(\"coreunit\") then\n core = slot\n end\n if slot.getElementClass():lower():find(\"screenunit\") then\n screens[#screens + 1] = slot\n end\n end\n end\nend\n\nfunction AddClickArea(newEntry)\n table.insert(clickAreas, newEntry)\nend\n\nfunction RemoveFromClickAreas(candidate)\n for k, v in pairs(clickAreas) do\n if v.id==candidate then\n clickAreas[k]=nil\n break\n end\n end\nend\n\nfunction UpdateClickArea(candidate, newEntry)\n for k, v in pairs(clickAreas) do\n if v.id==candidate then\n clickAreas[k]=newEntry\n break\n end\n end\nend\n\nfunction DisableClickArea(candidate)\n for k, v in pairs(clickAreas) do\n if v.id==candidate then\n UpdateClickArea(candidate, { id = candidate, x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n break\n end\n end\nend\n\nfunction InitiateClickAreas()\n clickAreas = {}\n AddClickArea( { id = \"DamagedDamage\", x1 = 725, x2 = 870, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"DamagedHealth\", x1 = 520, x2 = 655, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"DamagedID\", x1 = 90, x2 = 150, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"BrokenDamage\", x1 = 1675, x2 = 1835, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"BrokenID\", x1 = 1050, x2 = 1110, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"ToggleSimulation\", x1 = 65, x2 = 660, y1 = 100, y2 = 145 } )\n AddClickArea( { id = \"ToggleElementLabel\", x1 = 225, x2 = 460, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"ToggleElementLabel2\", x1 = 1185, x2 = 1440, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"ToggleHudMode\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n AddClickArea( { id = \"DamagedPageDown\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n AddClickArea( { id = \"DamagedPageUp\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n AddClickArea( { id = \"BrokenPageDown\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n AddClickArea( { id = \"BrokenPageUp\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\nend\n\nfunction FlushClickAreas()\n clickAreas = {}\nend\n\nfunction CheckClick(x, y)\n PrintDebug(\"Clicked at \"..x..\" / \"..y)\n local HitTarget=\"\"\n for k, v in pairs(clickAreas) do\n if v and x>=v.x1 and x<=v.x2 and y>=v.y1 and y<=v.y2 then\n HitTarget=v.id\n break\n end\n end\n if HitTarget==\"DamagedDamage\" then\n DamagedSortingMode=1\n CurrentDamagedPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"DamagedHealth\" then\n DamagedSortingMode=3\n CurrentDamagedPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"DamagedID\" then\n DamagedSortingMode=2\n CurrentDamagedPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"BrokenDamage\" then\n BrokenSortingMode=1\n CurrentBrokenPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"BrokenID\" then\n BrokenSortingMode=2\n CurrentBrokenPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"DamagedPageDown\" then\n CurrentDamagedPage = CurrentDamagedPage + 1\n if CurrentDamagedPage > math.ceil(#damagedElements/12) then CurrentDamagedPage = math.ceil(#damagedElements/12) end\n DrawScreens()\n elseif HitTarget==\"DamagedPageUp\" then\n CurrentDamagedPage = CurrentDamagedPage - 1\n if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end\n DrawScreens()\n elseif HitTarget==\"BrokenPageDown\" then\n CurrentBrokenPage = CurrentBrokenPage + 1\n if CurrentBrokenPage > math.ceil(#brokenElements/12) then CurrentBrokenPage = math.ceil(#brokenElements/12) end\n DrawScreens()\n elseif HitTarget==\"BrokenPageUp\" then\n CurrentBrokenPage = CurrentBrokenPage - 1\n if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end\n DrawScreens()\n elseif HitTarget==\"ToggleSimulation\" then\n CurrentDamagedPage=1\n CurrentBrokenPage=1\n if SimulationMode == true then\n SimulationMode = false\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n DrawScreens()\n else\n SimulationMode = true\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n DrawScreens()\n end\n elseif HitTarget==\"ToggleElementLabel\" or HitTarget==\"ToggleElementLabel2\" then\n if UseMyElementNames == true then\n UseMyElementNames = false\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n DrawScreens()\n else\n UseMyElementNames = true\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n DrawScreens()\n end\n end\nend\n\nfunction SortTables()\n -- Sort damaged elements descending by percent damaged according to setting\n if DamagedSortingMode==1 then table.sort(damagedElements, function(a,b) return a.missinghp > b.missinghp end)\n elseif DamagedSortingMode==2 then table.sort(damagedElements, function(a,b) return a.id < b.id end)\n else table.sort(damagedElements, function(a,b) return a.percent < b.percent end)\n end\n\n -- Sort broken elements descending according to setting\n if BrokenSortingMode==1 then table.sort(brokenElements, function(a,b) return a.maxhp > b.maxhp end)\n else table.sort(brokenElements, function(a,b) return a.id < b.id end)\n end\nend\n\nfunction GenerateDamageData()\n if SimulationActive==true then\n return\n end\n\n local formerTotalShipHP = totalShipHP\n totalShipHP = 0\n totalShipMaxHP = 0\n totalShipIntegrity = 100\n elementsId = {}\n damagedElements = {}\n brokenElements = {}\n ElementCounter = 0\n healthyElements = 0\n\n elementsIdList = core.getElementIdList()\n\n for _,id in pairs(elementsIdList) do\n ElementCounter = ElementCounter + 1\n idHP = core.getElementHitPointsById(id) or 0\n idMaxHP = core.getElementMaxHitPointsById(id) or 0\n\n if SimulationMode then\n SimulationActive=true\n local dice =math.random(0,10)\n if dice < 2 then idHP = 0\n elseif dice >=2 and dice < 5 then idHP = idMaxHP\n else \n idHP = math.random(1, math.ceil(idMaxHP))\n end\n end\n\n totalShipHP = totalShipHP+idHP\n totalShipMaxHP = totalShipMaxHP+idMaxHP\n\n -- Is element damaged?\n if idMaxHP > idHP then\n idPos = core.getElementPositionById(id)\n idName = core.getElementNameById(id)\n idType = core.getElementTypeById(id)\n if idHP>0 then\n table.insert(damagedElements,\n {\n id = id,\n name = idName,\n type = idType,\n counter = ElementCounter,\n hp = idHP,\n maxhp = idMaxHP,\n missinghp = idMaxHP-idHP,\n percent = math.ceil(100/idMaxHP*idHP),\n pos =idPos\n }\n )\n -- if DebugMode then PrintDebug(\"Damaged: \"..idName..\" --- Type: \"..idType..\"\") end\n -- Is element broken?\n else\n table.insert(brokenElements,\n {\n id = id,\n name = idName,\n type = idType,\n counter = ElementCounter,\n hp = idHP,\n maxhp = idMaxHP,\n missinghp = idMaxHP-idHP,\n percent = 0,\n pos =idPos\n }\n )\n -- if DebugMode then PrintDebug(\"Broken: \"..idName..\" --- Type: \"..idType..\"\") end\n end\n else\n healthyElements = healthyElements + 1\n end\n end\n\n -- Sort tables by current settings \n SortTables()\n\n -- Update clickAreas\n\n\n -- Determine total ship integrity\n totalShipIntegrity = string.format(\"%2.0f\", 100/totalShipMaxHP*totalShipHP)\n\n -- Has anything changes since last check? If yes, force redrawing the screens\n if formerTotalShipHP ~= totalShipHP then\n forceRedraw=true\n formerTotalShipHP = totalShipHP\n else forceRedraw=false\n end \nend\n\nfunction GetAllSystemsNominalBackground()\n local output=\"\"\n output = output..\n [[\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ]]\n return output\nend\n\nfunction DrawScreens()\n if #screens > 0 then\n\n local healthyColor = \"#00aa00\"\n local brokenColor = \"#aa0000\"\n local damagedColor = \"#aaaa00\"\n local integrityColor = \"#aaaaaa\"\n local healthyTextColor = \"white\"\n local brokenTextColor = \"#ff4444\"\n local damagedTextColor = \"#ffff44\"\n local integrityTextColor = \"white\"\n\n if #damagedElements ==0 then\n damagedColor = \"#aaaaaa\"\n damagedTextColor = \"white\"\n end\n if #brokenElements == 0 then \n brokenColor = \"#aaaaaa\"\n brokenTextColor = \"white\"\n end\n \n -- Draw Header\n screenOutput = [[\n ]]\n \n -- Draw main background\n screenOutput = screenOutput..\n [[\n \n \n \n \n \n \n \n \n \n \n \n ]]\n\n -- Draw Title and summary\n if SimulationActive==true then\n screenOutput = screenOutput..[[Simulated Report]]\n else\n screenOutput = screenOutput..[[Damage Report]]\n end\n if YourShipsName==nil or YourShipsName==\"\" or YourShipsName==\"Enter here\" then screenOutput = screenOutput.. [[SHIP ID ]]..shipID..[[]]\n else screenOutput = screenOutput.. [[]]..YourShipsName..[[]]\n end\n screenOutput = screenOutput.. \n [[\n Healthy\n ]]..healthyElements..[[\n\n Damaged\n ]]..#damagedElements..[[\n\n Broken\n ]]..#brokenElements..[[\n\n Integrity\n ]]..totalShipIntegrity..[[%]]\n\n -- Draw damage elements\n\n if #damagedElements > 0 then\n local damagedElementsToDraw = #damagedElements\n if damagedElementsToDraw>12 then damagedElementsToDraw=12 end\n if CurrentDamagedPage==math.ceil(#damagedElements/12) then damagedElementsToDraw = #damagedElements%12 end\n screenOutput = screenOutput..\n [[]]\n screenOutput = screenOutput .. [[]]\n if (DamagedSortingMode==2) then \n screenOutput = screenOutput ..[[ID]]\n else\n screenOutput = screenOutput ..[[ID]]\n end\n if UseMyElementNames==true then screenOutput = screenOutput ..[[Element Name]]\n else screenOutput = screenOutput ..[[Element Type]]\n end\n \n if (DamagedSortingMode==3) then \n screenOutput = screenOutput ..[[Health]]\n else\n screenOutput = screenOutput ..[[Health]]\n end\n if (DamagedSortingMode==1) then \n screenOutput = screenOutput ..[[Damage]]\n else\n screenOutput = screenOutput ..[[Damage]]\n end\n\n local i=0\n for j=1+(CurrentDamagedPage-1)*12,damagedElementsToDraw+(CurrentDamagedPage-1)*12,1 do\n i = i + 1\n local DP = damagedElements[j]\n screenOutput = screenOutput ..\n [[]]..string.format(\"%03.0f\",DP.id)..[[]]\n if UseMyElementNames==true then\n screenOutput = screenOutput .. [[]]..string.format(\"%.25s\", DP.name)..[[]]\n else\n screenOutput = screenOutput .. [[]]..string.format(\"%.25s\", DP.type)..[[]]\n end\n screenOutput = screenOutput ..\n [[]]..DP.percent..[[%]]..\n [[]]..GenerateCommaValue(string.format(\"%.0f\", DP.missinghp))..[[]]..\n [[]]\n end\n screenOutput = screenOutput ..\n [[\n \n ]]\n\n if #damagedElements>12 then\n screenOutput = screenOutput ..\n [[Page ]]..CurrentDamagedPage..\" of \"..math.ceil(#damagedElements/12)..[[]]\n\n if CurrentDamagedPage < math.ceil(#damagedElements/12) then\n screenOutput = screenOutput ..\n [[\n \n \n ]]\n UpdateClickArea( \"DamagedPageDown\", { id = \"DamagedPageDown\", x1 = 70, x2 = 270, y1 = 350+11+(damagedElementsToDraw+1)*50, y2 = 350+11+50+(damagedElementsToDraw+1)*50 } )\n else\n DisableClickArea( \"DamagedPageDown\" )\n end\n \n if CurrentDamagedPage > 1 then\n screenOutput = screenOutput ..\n [[\n \n \n ]]\n UpdateClickArea( \"DamagedPageUp\", { id = \"DamagedPageUp\", x1 = 280, x2 = 480, y1 = 350+11+(damagedElementsToDraw+1)*50, y2 = 350+11+50+(damagedElementsToDraw+1)*50 } )\n else\n DisableClickArea( \"DamagedPageUp\" )\n end\n end\n\n\n\n\n end\n\n -- Draw broken elements\n if #brokenElements > 0 then\n local brokenElementsToDraw = #brokenElements\n if brokenElementsToDraw>12 then brokenElementsToDraw=12 end\n if CurrentBrokenPage==math.ceil(#brokenElements/12) then brokenElementsToDraw = #brokenElements%12 end\n screenOutput = screenOutput..\n [[]]\n screenOutput = screenOutput .. [[]]\n if (BrokenSortingMode==2) then \n screenOutput = screenOutput ..[[ID]]\n else\n screenOutput = screenOutput ..[[ID]]\n end\n if UseMyElementNames==true then screenOutput = screenOutput .. [[Element Name]]\n else screenOutput = screenOutput .. [[Element Type]]\n end\n if (BrokenSortingMode==1) then \n screenOutput = screenOutput ..[[Damage]]\n else\n screenOutput = screenOutput ..[[Damage]]\n end\n\n local i=0\n for j=1+(CurrentBrokenPage-1)*12,brokenElementsToDraw+(CurrentBrokenPage-1)*12,1 do\n i = i + 1\n local DP = brokenElements[j]\n screenOutput = screenOutput ..\n [[]]..string.format(\"%03.0f\",DP.id)..[[]]\n if UseMyElementNames==true then\n screenOutput = screenOutput .. [[]]..string.format(\"%.25s\", DP.name)..[[]]\n else\n screenOutput = screenOutput .. [[]]..string.format(\"%.25s\", DP.type)..[[]]\n end\n screenOutput = screenOutput ..\n [[]]..GenerateCommaValue(string.format(\"%.0f\", DP.missinghp))..[[]]..\n [[]]\n end\n\n screenOutput = screenOutput.. \n [[\n \n ]]\n\n\n if #brokenElements>12 then\n screenOutput = screenOutput ..\n [[Page ]]..CurrentBrokenPage..\" of \"..math.ceil(#brokenElements/12)..[[]]\n\n if CurrentBrokenPage > 1 then\n screenOutput = screenOutput ..\n [[\n \n \n ]]\n UpdateClickArea( \"BrokenPageUp\", { id = \"BrokenPageUp\", x1 = 1442, x2 = 1642, y1 = 350+11+(brokenElementsToDraw+1)*50, y2 = 350+11+50+(brokenElementsToDraw+1)*50 } )\n else\n DisableClickArea( \"BrokenPageUp\" )\n end\n \n if CurrentBrokenPage < math.ceil(#brokenElements/12) then\n screenOutput = screenOutput ..\n [[\n \n \n ]]\n UpdateClickArea( \"BrokenPageDown\", { id = \"BrokenPageDown\", x1 = 1652, x2 = 1852, y1 = 350+11+(brokenElementsToDraw+1)*50, y2 = 350+11+50+(brokenElementsToDraw+1)*50 } )\n else\n DisableClickArea( \"BrokenPageDown\" )\n end\n end\n\n\n\n end\n\n -- Draw damage summary\n if #damagedElements>0 or #brokenElements > 0 then\n screenOutput = screenOutput..\n [[]]..GenerateCommaValue(string.format(\"%.0f\", totalShipMaxHP-totalShipHP))..[[ HP damage in total]]\n else\n screenOutput = screenOutput..\n [[]]..\n GetAllSystemsNominalBackground()..\n [[]]..\n [[]]..OkayCenterMessage..[[]]\n end\n\n -- Draw HUD Mode button\n screenOutput = screenOutput..[[]]\n\n DrawSVG(screenOutput)\n\n forceRedraw=false\n end\nend\n\n-----------------------------------------------\n-- Execute\n-----------------------------------------------\n\nunit.hide()\nClearConsole()\nPrintDebug(\"SCRIPT STARTED\", true)\n\nInitiateSlots()\nSwitchScreens(true)\nInitiateClickAreas()\n\nif core == nil then\n DrawCenteredText(\"ERROR: No core connected.\")\n PrintError(\"ERROR: No core connected.\")\n goto exit\nelse\n shipID = core.getConstructId()\nend\n\nGenerateDamageData()\nif forceRedraw then\n DrawScreens()\nend\n\nunit.setTimer('UpdateData', UpdateInterval)\n\n::exit::","filter":{"args":[],"signature":"start()","slotKey":"-1"},"key":"9"},{"code":"if #screens > 0 then\n for i=1,#screens,1 do\n screens[i].deactivate()\n screens[i].clear()\n end\nend","filter":{"args":[],"signature":"stop()","slotKey":"-1"},"key":"10"},{"code":"GenerateDamageData()\nif forceRedraw then\n DrawScreens()\nend","filter":{"args":[{"value":"UpdateData"}],"signature":"tick(timerId)","slotKey":"-1"},"key":"11"}],"methods":[],"events":[]}
\ No newline at end of file
diff --git a/versions/DamageReport_1_51.json b/versions/DamageReport_1_51.json
deleted file mode 100644
index 55bfa84..0000000
--- a/versions/DamageReport_1_51.json
+++ /dev/null
@@ -1 +0,0 @@
-{"slots":{"0":{"name":"core","type":{"events":[],"methods":[]}},"1":{"name":"slot2","type":{"events":[],"methods":[]}},"2":{"name":"slot3","type":{"events":[],"methods":[]}},"3":{"name":"slot4","type":{"events":[],"methods":[]}},"4":{"name":"slot5","type":{"events":[],"methods":[]}},"5":{"name":"slot6","type":{"events":[],"methods":[]}},"6":{"name":"slot7","type":{"events":[],"methods":[]}},"7":{"name":"slot8","type":{"events":[],"methods":[]}},"8":{"name":"slot9","type":{"events":[],"methods":[]}},"9":{"name":"slot10","type":{"events":[],"methods":[]}},"-1":{"name":"unit","type":{"events":[],"methods":[]}},"-2":{"name":"system","type":{"events":[],"methods":[]}},"-3":{"name":"library","type":{"events":[],"methods":[]}}},"handlers":[{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"1"},"key":"0"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"2"},"key":"1"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"3"},"key":"2"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"4"},"key":"3"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"5"},"key":"4"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"6"},"key":"5"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"7"},"key":"6"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"8"},"key":"7"},{"code":"clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"9"},"key":"8"},{"code":"--[[\n DamageReport v1.51\n\n Created By Dorian Gray\n\n Discord: Dorian Gray#2623\n InGame: DorianGray\n GitHub: https://github.com/DorianTheGrey/DU-DamageReport\n\n GNU Public License 3.0. Use whatever you want, be so kind to leave credit.\n\n Thanks to Jericho, Dmentia and Archaegeo for learning from their fine scripts.\n]]\n\n-----------------------------------------------\n-- CONFIG\n-----------------------------------------------\n\nUseMyElementNames = false --export: If you active this, the display will not show the element type of damaged/broken elements but the name you gave them (truncated to 25 characters)\nUpdateInterval = 1 --export: Interval in seconds between updates of the calculations and (if anything changed) redrawing to the screen(s). You need to restart the script after changing this value.\nSimulationMode = false --export Randomize simluated damage on elements to check out the functionality of this script. And, no, your elements won't be harmed in the process :) You need to restart the script after changing this value.\nYourShipsName = \"Enter here\" --export Enter your ship name here if you want it displayed instead of the ship's ID. YOU NEED TO LEAVE THE QUOTATION MARKS.\n\nDebugMode = false -- Activate if you want some console messages\nVersionNumber = 1.51 -- Version number\n\ncore = nil \nscreens = {}\n\nshipID = 0\nforceRedraw = false\nSimulationActive=false\n\nclickAreas = {}\nDamagedSortingMode = 1 -- Define default sorting mode for damaged elements. 1 to sort by damage amount, 2 to sort by element id, 3 to sort by damage percent, \nBrokenSortingMode = 1 -- Define default sorting mode for broken elements. 1 to sort by damage amount, 2 to sort by element id\n\nHUDMode = false\nCurrentDamagedPage = 1\nCurrentBrokenPage = 1\n\ntotalShipHP = 0\ntotalShipMaxHP = 0\ntotalShipIntegrity = 100\nelementsId = {}\ndamagedElements = {}\nbrokenElements = {}\nElementCounter = 0\nhealthyElements = 0\n\nOkayCenterMessage = \"All systems nominal.\"\n\n-----------------------------------------------\n-- FUNCTIONS\n-----------------------------------------------\n\n\nfunction GenerateCommaValue(amount)\n local formatted = amount\n while true do \n formatted, k = string.gsub(formatted, \"^(-?%d+)(%d%d%d)\", '%1,%2')\n if (k==0) then break end\n end\n return formatted\nend\n\nfunction PrintDebug(output, highlight) \n highlight = highlight or false\n if DebugMode then\n if highlight then system.print(\"------------------------------------------------------------------------\") end\n system.print(output)\n if highlight then system.print(\"------------------------------------------------------------------------\") end\n end\nend\n\nfunction PrintError(output) \n system.print(output)\nend\n\nfunction DrawCenteredText(output)\n for i=1,#screens,1 do\n screens[i].setCenteredText(output)\n end\nend\n\nfunction DrawSVG(output)\n for i=1,#screens,1 do\n screens[i].setSVG(output)\n end\nend\n\nfunction ClearConsole()\n for i=1,10,1 do\n PrintDebug()\n end\nend\n\nfunction SwitchScreens(state)\n state = state or true\n if #screens > 0 then\n for i=1,#screens,1 do\n if state then\n screens[i].clear()\n screens[i].activate()\n else\n screens[i].deactivate()\n screens[i].clear()\n end\n end\n end\nend\n\nfunction InitiateSlots()\n for slot_name, slot in pairs(unit) do\n if\n type(slot) == \"table\"\n and type(slot.export) == \"table\"\n and slot.getElementClass\n then\n if slot.getElementClass():lower():find(\"coreunit\") then\n core = slot\n end\n if slot.getElementClass():lower():find(\"screenunit\") then\n screens[#screens + 1] = slot\n end\n end\n end\nend\n\nfunction AddClickArea(newEntry)\n table.insert(clickAreas, newEntry)\nend\n\nfunction RemoveFromClickAreas(candidate)\n for k, v in pairs(clickAreas) do\n if v.id==candidate then\n clickAreas[k]=nil\n break\n end\n end\nend\n\nfunction UpdateClickArea(candidate, newEntry)\n for k, v in pairs(clickAreas) do\n if v.id==candidate then\n clickAreas[k]=newEntry\n break\n end\n end\nend\n\nfunction DisableClickArea(candidate)\n for k, v in pairs(clickAreas) do\n if v.id==candidate then\n UpdateClickArea(candidate, { id = candidate, x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n break\n end\n end\nend\n\nfunction InitiateClickAreas()\n clickAreas = {}\n AddClickArea( { id = \"DamagedDamage\", x1 = 725, x2 = 870, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"DamagedHealth\", x1 = 520, x2 = 655, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"DamagedID\", x1 = 90, x2 = 150, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"BrokenDamage\", x1 = 1675, x2 = 1835, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"BrokenID\", x1 = 1050, x2 = 1110, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"ToggleSimulation\", x1 = 65, x2 = 660, y1 = 100, y2 = 145 } )\n AddClickArea( { id = \"ToggleElementLabel\", x1 = 225, x2 = 460, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"ToggleElementLabel2\", x1 = 1185, x2 = 1440, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"ToggleHudMode\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n AddClickArea( { id = \"DamagedPageDown\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n AddClickArea( { id = \"DamagedPageUp\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n AddClickArea( { id = \"BrokenPageDown\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n AddClickArea( { id = \"BrokenPageUp\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\nend\n\nfunction FlushClickAreas()\n clickAreas = {}\nend\n\nfunction CheckClick(x, y)\n PrintDebug(\"Clicked at \"..x..\" / \"..y)\n local HitTarget=\"\"\n for k, v in pairs(clickAreas) do\n if v and x>=v.x1 and x<=v.x2 and y>=v.y1 and y<=v.y2 then\n HitTarget=v.id\n break\n end\n end\n if HitTarget==\"DamagedDamage\" then\n DamagedSortingMode=1\n CurrentDamagedPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"DamagedHealth\" then\n DamagedSortingMode=3\n CurrentDamagedPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"DamagedID\" then\n DamagedSortingMode=2\n CurrentDamagedPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"BrokenDamage\" then\n BrokenSortingMode=1\n CurrentBrokenPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"BrokenID\" then\n BrokenSortingMode=2\n CurrentBrokenPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"DamagedPageDown\" then\n CurrentDamagedPage = CurrentDamagedPage + 1\n if CurrentDamagedPage > math.ceil(#damagedElements/12) then CurrentDamagedPage = math.ceil(#damagedElements/12) end\n DrawScreens()\n elseif HitTarget==\"DamagedPageUp\" then\n CurrentDamagedPage = CurrentDamagedPage - 1\n if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end\n DrawScreens()\n elseif HitTarget==\"BrokenPageDown\" then\n CurrentBrokenPage = CurrentBrokenPage + 1\n if CurrentBrokenPage > math.ceil(#brokenElements/12) then CurrentBrokenPage = math.ceil(#brokenElements/12) end\n DrawScreens()\n elseif HitTarget==\"BrokenPageUp\" then\n CurrentBrokenPage = CurrentBrokenPage - 1\n if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end\n DrawScreens()\n elseif HitTarget==\"ToggleSimulation\" then\n CurrentDamagedPage=1\n CurrentBrokenPage=1\n if SimulationMode == true then\n SimulationMode = false\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n DrawScreens()\n else\n SimulationMode = true\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n DrawScreens()\n end\n elseif HitTarget==\"ToggleElementLabel\" or HitTarget==\"ToggleElementLabel2\" then\n if UseMyElementNames == true then\n UseMyElementNames = false\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n DrawScreens()\n else\n UseMyElementNames = true\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n DrawScreens()\n end\n end\nend\n\nfunction SortTables()\n -- Sort damaged elements descending by percent damaged according to setting\n if DamagedSortingMode==1 then table.sort(damagedElements, function(a,b) return a.missinghp > b.missinghp end)\n elseif DamagedSortingMode==2 then table.sort(damagedElements, function(a,b) return a.id < b.id end)\n else table.sort(damagedElements, function(a,b) return a.percent < b.percent end)\n end\n\n -- Sort broken elements descending according to setting\n if BrokenSortingMode==1 then table.sort(brokenElements, function(a,b) return a.maxhp > b.maxhp end)\n else table.sort(brokenElements, function(a,b) return a.id < b.id end)\n end\nend\n\nfunction GenerateDamageData()\n if SimulationActive==true then\n return\n end\n\n local formerTotalShipHP = totalShipHP\n totalShipHP = 0\n totalShipMaxHP = 0\n totalShipIntegrity = 100\n elementsId = {}\n damagedElements = {}\n brokenElements = {}\n ElementCounter = 0\n healthyElements = 0\n\n elementsIdList = core.getElementIdList()\n\n for _,id in pairs(elementsIdList) do\n ElementCounter = ElementCounter + 1\n idHP = core.getElementHitPointsById(id) or 0\n idMaxHP = core.getElementMaxHitPointsById(id) or 0\n\n if SimulationMode then\n SimulationActive=true\n local dice =math.random(0,10)\n if dice < 2 then idHP = 0\n elseif dice >=2 and dice < 5 then idHP = idMaxHP\n else \n idHP = math.random(1, math.ceil(idMaxHP))\n end\n end\n\n totalShipHP = totalShipHP+idHP\n totalShipMaxHP = totalShipMaxHP+idMaxHP\n\n -- Is element damaged?\n if idMaxHP > idHP then\n idPos = core.getElementPositionById(id)\n idName = core.getElementNameById(id)\n idType = core.getElementTypeById(id)\n if idHP>0 then\n table.insert(damagedElements,\n {\n id = id,\n name = idName,\n type = idType,\n counter = ElementCounter,\n hp = idHP,\n maxhp = idMaxHP,\n missinghp = idMaxHP-idHP,\n percent = math.ceil(100/idMaxHP*idHP),\n pos =idPos\n }\n )\n -- if DebugMode then PrintDebug(\"Damaged: \"..idName..\" --- Type: \"..idType..\"\") end\n -- Is element broken?\n else\n table.insert(brokenElements,\n {\n id = id,\n name = idName,\n type = idType,\n counter = ElementCounter,\n hp = idHP,\n maxhp = idMaxHP,\n missinghp = idMaxHP-idHP,\n percent = 0,\n pos =idPos\n }\n )\n -- if DebugMode then PrintDebug(\"Broken: \"..idName..\" --- Type: \"..idType..\"\") end\n end\n else\n healthyElements = healthyElements + 1\n end\n end\n\n -- Sort tables by current settings \n SortTables()\n\n -- Update clickAreas\n\n\n -- Determine total ship integrity\n totalShipIntegrity = string.format(\"%2.0f\", 100/totalShipMaxHP*totalShipHP)\n\n -- Has anything changes since last check? If yes, force redrawing the screens\n if formerTotalShipHP ~= totalShipHP then\n forceRedraw=true\n formerTotalShipHP = totalShipHP\n else forceRedraw=false\n end \nend\n\nfunction GetAllSystemsNominalBackground()\n local output=\"\"\n output = output..\n [[\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ]]\n return output\nend\n\nfunction DrawScreens()\n if #screens > 0 then\n\n local healthyColor = \"#00aa00\"\n local brokenColor = \"#aa0000\"\n local damagedColor = \"#aaaa00\"\n local integrityColor = \"#aaaaaa\"\n local healthyTextColor = \"white\"\n local brokenTextColor = \"#ff4444\"\n local damagedTextColor = \"#ffff44\"\n local integrityTextColor = \"white\"\n\n if #damagedElements ==0 then\n damagedColor = \"#aaaaaa\"\n damagedTextColor = \"white\"\n end\n if #brokenElements == 0 then \n brokenColor = \"#aaaaaa\"\n brokenTextColor = \"white\"\n end\n \n -- Draw Header\n screenOutput = [[\n ]]\n \n -- Draw main background\n screenOutput = screenOutput..\n [[\n \n \n \n \n \n \n \n \n \n \n \n ]]\n\n -- Draw Title and summary\n if SimulationActive==true then\n screenOutput = screenOutput..[[Simulated Report]]\n else\n screenOutput = screenOutput..[[Damage Report]]\n end\n if YourShipsName==nil or YourShipsName==\"\" or YourShipsName==\"Enter here\" then screenOutput = screenOutput.. [[SHIP ID ]]..shipID..[[]]\n else screenOutput = screenOutput.. [[]]..YourShipsName..[[]]\n end\n screenOutput = screenOutput.. \n [[\n Healthy\n ]]..healthyElements..[[\n\n Damaged\n ]]..#damagedElements..[[\n\n Broken\n ]]..#brokenElements..[[\n\n Integrity\n ]]..totalShipIntegrity..[[%]]\n\n -- Draw damage elements\n\n if #damagedElements > 0 then\n local damagedElementsToDraw = #damagedElements\n if damagedElementsToDraw>12 then damagedElementsToDraw=12 end\n if CurrentDamagedPage==math.ceil(#damagedElements/12) then damagedElementsToDraw = #damagedElements%12 end\n screenOutput = screenOutput..\n [[]]\n screenOutput = screenOutput .. [[]]\n if (DamagedSortingMode==2) then \n screenOutput = screenOutput ..[[ID]]\n else\n screenOutput = screenOutput ..[[ID]]\n end\n if UseMyElementNames==true then screenOutput = screenOutput ..[[Element Name]]\n else screenOutput = screenOutput ..[[Element Type]]\n end\n \n if (DamagedSortingMode==3) then \n screenOutput = screenOutput ..[[Health]]\n else\n screenOutput = screenOutput ..[[Health]]\n end\n if (DamagedSortingMode==1) then \n screenOutput = screenOutput ..[[Damage]]\n else\n screenOutput = screenOutput ..[[Damage]]\n end\n\n local i=0\n for j=1+(CurrentDamagedPage-1)*12,damagedElementsToDraw+(CurrentDamagedPage-1)*12,1 do\n i = i + 1\n local DP = damagedElements[j]\n screenOutput = screenOutput ..\n [[]]..string.format(\"%03.0f\",DP.id)..[[]]\n if UseMyElementNames==true then\n screenOutput = screenOutput .. [[]]..string.format(\"%.25s\", DP.name)..[[]]\n else\n screenOutput = screenOutput .. [[]]..string.format(\"%.25s\", DP.type)..[[]]\n end\n screenOutput = screenOutput ..\n [[]]..DP.percent..[[%]]..\n [[]]..GenerateCommaValue(string.format(\"%.0f\", DP.missinghp))..[[]]..\n [[]]\n end\n screenOutput = screenOutput ..\n [[\n \n ]]\n\n if #damagedElements>12 then\n screenOutput = screenOutput ..\n [[Page ]]..CurrentDamagedPage..\" of \"..math.ceil(#damagedElements/12)..[[]]\n\n if CurrentDamagedPage < math.ceil(#damagedElements/12) then\n screenOutput = screenOutput ..\n [[\n \n \n ]]\n UpdateClickArea( \"DamagedPageDown\", { id = \"DamagedPageDown\", x1 = 70, x2 = 270, y1 = 350+11+(damagedElementsToDraw+1)*50, y2 = 350+11+50+(damagedElementsToDraw+1)*50 } )\n else\n DisableClickArea( \"DamagedPageDown\" )\n end\n \n if CurrentDamagedPage > 1 then\n screenOutput = screenOutput ..\n [[\n \n \n ]]\n UpdateClickArea( \"DamagedPageUp\", { id = \"DamagedPageUp\", x1 = 280, x2 = 480, y1 = 350+11+(damagedElementsToDraw+1)*50, y2 = 350+11+50+(damagedElementsToDraw+1)*50 } )\n else\n DisableClickArea( \"DamagedPageUp\" )\n end\n end\n\n\n\n\n end\n\n -- Draw broken elements\n if #brokenElements > 0 then\n local brokenElementsToDraw = #brokenElements\n if brokenElementsToDraw>12 then brokenElementsToDraw=12 end\n if CurrentBrokenPage==math.ceil(#brokenElements/12) then brokenElementsToDraw = #brokenElements%12 end\n screenOutput = screenOutput..\n [[]]\n screenOutput = screenOutput .. [[]]\n if (BrokenSortingMode==2) then \n screenOutput = screenOutput ..[[ID]]\n else\n screenOutput = screenOutput ..[[ID]]\n end\n if UseMyElementNames==true then screenOutput = screenOutput .. [[Element Name]]\n else screenOutput = screenOutput .. [[Element Type]]\n end\n if (BrokenSortingMode==1) then \n screenOutput = screenOutput ..[[Damage]]\n else\n screenOutput = screenOutput ..[[Damage]]\n end\n\n local i=0\n for j=1+(CurrentBrokenPage-1)*12,brokenElementsToDraw+(CurrentBrokenPage-1)*12,1 do\n i = i + 1\n local DP = brokenElements[j]\n screenOutput = screenOutput ..\n [[]]..string.format(\"%03.0f\",DP.id)..[[]]\n if UseMyElementNames==true then\n screenOutput = screenOutput .. [[]]..string.format(\"%.25s\", DP.name)..[[]]\n else\n screenOutput = screenOutput .. [[]]..string.format(\"%.25s\", DP.type)..[[]]\n end\n screenOutput = screenOutput ..\n [[]]..GenerateCommaValue(string.format(\"%.0f\", DP.missinghp))..[[]]..\n [[]]\n end\n\n screenOutput = screenOutput.. \n [[\n \n ]]\n\n\n if #brokenElements>12 then\n screenOutput = screenOutput ..\n [[Page ]]..CurrentBrokenPage..\" of \"..math.ceil(#brokenElements/12)..[[]]\n\n if CurrentBrokenPage > 1 then\n screenOutput = screenOutput ..\n [[\n \n \n ]]\n UpdateClickArea( \"BrokenPageUp\", { id = \"BrokenPageUp\", x1 = 1442, x2 = 1642, y1 = 350+11+(brokenElementsToDraw+1)*50, y2 = 350+11+50+(brokenElementsToDraw+1)*50 } )\n else\n DisableClickArea( \"BrokenPageUp\" )\n end\n \n if CurrentBrokenPage < math.ceil(#brokenElements/12) then\n screenOutput = screenOutput ..\n [[\n \n \n ]]\n UpdateClickArea( \"BrokenPageDown\", { id = \"BrokenPageDown\", x1 = 1652, x2 = 1852, y1 = 350+11+(brokenElementsToDraw+1)*50, y2 = 350+11+50+(brokenElementsToDraw+1)*50 } )\n else\n DisableClickArea( \"BrokenPageDown\" )\n end\n end\n\n\n\n end\n\n -- Draw damage summary\n if #damagedElements>0 or #brokenElements > 0 then\n screenOutput = screenOutput..\n [[]]..GenerateCommaValue(string.format(\"%.0f\", totalShipMaxHP-totalShipHP))..[[ HP damage in total]]\n else\n screenOutput = screenOutput..\n [[]]..\n GetAllSystemsNominalBackground()..\n [[]]..\n [[]]..OkayCenterMessage..[[]]\n end\n\n -- Draw HUD Mode button\n screenOutput = screenOutput..[[]]\n\n DrawSVG(screenOutput)\n\n forceRedraw=false\n end\nend\n\n-----------------------------------------------\n-- Execute\n-----------------------------------------------\n\nunit.hide()\nClearConsole()\nPrintDebug(\"SCRIPT STARTED\", true)\n\nInitiateSlots()\nSwitchScreens(true)\nInitiateClickAreas()\n\nif core == nil then\n DrawCenteredText(\"ERROR: No core connected.\")\n PrintError(\"ERROR: No core connected.\")\n goto exit\nelse\n shipID = core.getConstructId()\nend\n\nGenerateDamageData()\nif forceRedraw then\n DrawScreens()\nend\n\nunit.setTimer('UpdateData', UpdateInterval)\n\n::exit::","filter":{"args":[],"signature":"start()","slotKey":"-1"},"key":"9"},{"code":"if #screens > 0 then\n for i=1,#screens,1 do\n screens[i].deactivate()\n screens[i].clear()\n end\nend","filter":{"args":[],"signature":"stop()","slotKey":"-1"},"key":"10"},{"code":"GenerateDamageData()\nif forceRedraw then\n DrawScreens()\nend","filter":{"args":[{"value":"UpdateData"}],"signature":"tick(timerId)","slotKey":"-1"},"key":"11"}],"methods":[],"events":[]}
\ No newline at end of file
diff --git a/versions/DamageReport_1_52.json b/versions/DamageReport_1_52.json
deleted file mode 100644
index 621a86e..0000000
--- a/versions/DamageReport_1_52.json
+++ /dev/null
@@ -1,274 +0,0 @@
-{
- "slots": {
- "0": {
- "name": "slot1",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "1": {
- "name": "slot2",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "2": {
- "name": "slot3",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "3": {
- "name": "slot4",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "4": {
- "name": "slot5",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "5": {
- "name": "slot6",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "6": {
- "name": "slot7",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "7": {
- "name": "slot8",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "8": {
- "name": "slot9",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "9": {
- "name": "slot10",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-1": {
- "name": "unit",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-2": {
- "name": "system",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-3": {
- "name": "library",
- "type": {
- "events": [],
- "methods": []
- }
- }
- },
- "handlers": [
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "1"
- },
- "key": "0"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "2"
- },
- "key": "1"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "3"
- },
- "key": "2"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "4"
- },
- "key": "3"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "5"
- },
- "key": "4"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "6"
- },
- "key": "5"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "7"
- },
- "key": "6"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "8"
- },
- "key": "7"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "9"
- },
- "key": "8"
- },
- {
- "code": "--[[\n DamageReport v1.52\n\n Created By Dorian Gray\n\n Discord: Dorian Gray#2623\n InGame: DorianGray\n GitHub: https://github.com/DorianTheGrey/DU-DamageReport\n\n GNU Public License 3.0. Use whatever you want, be so kind to leave credit.\n\n Thanks to Jericho, Dmentia and Archaegeo for learning from their fine scripts.\n]]\n\n-----------------------------------------------\n-- CONFIG\n-----------------------------------------------\n\nUseMyElementNames = false --export: If you active this, the display will not show the element type of damaged/broken elements but the name you gave them (truncated to 25 characters)\nUpdateInterval = 1 --export: Interval in seconds between updates of the calculations and (if anything changed) redrawing to the screen(s). You need to restart the script after changing this value.\nSimulationMode = false --export Randomize simluated damage on elements to check out the functionality of this script. And, no, your elements won't be harmed in the process :) You need to restart the script after changing this value.\nYourShipsName = \"Enter here\" --export Enter your ship name here if you want it displayed instead of the ship's ID. YOU NEED TO LEAVE THE QUOTATION MARKS.\n\nDebugMode = false -- Activate if you want some console messages\nVersionNumber = 1.52 -- Version number\n\ncore = nil \nscreens = {}\n\nshipID = 0\nforceRedraw = false\nSimulationActive=false\n\nclickAreas = {}\nDamagedSortingMode = 1 -- Define default sorting mode for damaged elements. 1 to sort by damage amount, 2 to sort by element id, 3 to sort by damage percent, \nBrokenSortingMode = 1 -- Define default sorting mode for broken elements. 1 to sort by damage amount, 2 to sort by element id\n\nHUDMode = false\nCurrentDamagedPage = 1\nCurrentBrokenPage = 1\n\ntotalShipHP = 0\ntotalShipMaxHP = 0\ntotalShipIntegrity = 100\nelementsId = {}\ndamagedElements = {}\nbrokenElements = {}\nElementCounter = 0\nhealthyElements = 0\n\nOkayCenterMessage = \"All systems nominal.\"\n\n-----------------------------------------------\n-- FUNCTIONS\n-----------------------------------------------\n\n\nfunction GenerateCommaValue(amount)\n local formatted = amount\n while true do \n formatted, k = string.gsub(formatted, \"^(-?%d+)(%d%d%d)\", '%1,%2')\n if (k==0) then break end\n end\n return formatted\nend\n\nfunction PrintDebug(output, highlight) \n highlight = highlight or false\n if DebugMode then\n if highlight then system.print(\"------------------------------------------------------------------------\") end\n system.print(output)\n if highlight then system.print(\"------------------------------------------------------------------------\") end\n end\nend\n\nfunction PrintError(output) \n system.print(output)\nend\n\nfunction DrawCenteredText(output)\n for i=1,#screens,1 do\n screens[i].setCenteredText(output)\n end\nend\n\nfunction DrawSVG(output)\n for i=1,#screens,1 do\n screens[i].setSVG(output)\n end\nend\n\nfunction ClearConsole()\n for i=1,10,1 do\n PrintDebug()\n end\nend\n\nfunction SwitchScreens(state)\n state = state or true\n if #screens > 0 then\n for i=1,#screens,1 do\n if state then\n screens[i].clear()\n screens[i].activate()\n else\n screens[i].deactivate()\n screens[i].clear()\n end\n end\n end\nend\n\nfunction InitiateSlots()\n for slot_name, slot in pairs(unit) do\n if\n type(slot) == \"table\"\n and type(slot.export) == \"table\"\n and slot.getElementClass\n then\n if slot.getElementClass():lower():find(\"coreunit\") then\n core = slot\n end\n if slot.getElementClass():lower():find(\"screenunit\") then\n screens[#screens + 1] = slot\n end\n end\n end\nend\n\nfunction AddClickArea(newEntry)\n table.insert(clickAreas, newEntry)\nend\n\nfunction RemoveFromClickAreas(candidate)\n for k, v in pairs(clickAreas) do\n if v.id==candidate then\n clickAreas[k]=nil\n break\n end\n end\nend\n\nfunction UpdateClickArea(candidate, newEntry)\n for k, v in pairs(clickAreas) do\n if v.id==candidate then\n clickAreas[k]=newEntry\n break\n end\n end\nend\n\nfunction DisableClickArea(candidate)\n for k, v in pairs(clickAreas) do\n if v.id==candidate then\n UpdateClickArea(candidate, { id = candidate, x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n break\n end\n end\nend\n\nfunction InitiateClickAreas()\n clickAreas = {}\n AddClickArea( { id = \"DamagedDamage\", x1 = 725, x2 = 870, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"DamagedHealth\", x1 = 520, x2 = 655, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"DamagedID\", x1 = 90, x2 = 150, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"BrokenDamage\", x1 = 1675, x2 = 1835, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"BrokenID\", x1 = 1050, x2 = 1110, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"ToggleSimulation\", x1 = 65, x2 = 660, y1 = 100, y2 = 145 } )\n AddClickArea( { id = \"ToggleElementLabel\", x1 = 225, x2 = 460, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"ToggleElementLabel2\", x1 = 1185, x2 = 1440, y1 = 380, y2 = 415 } )\n AddClickArea( { id = \"ToggleHudMode\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n AddClickArea( { id = \"DamagedPageDown\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n AddClickArea( { id = \"DamagedPageUp\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n AddClickArea( { id = \"BrokenPageDown\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\n AddClickArea( { id = \"BrokenPageUp\", x1 = -1, x2 = -1, y1 = -1, y2 = -1 } )\nend\n\nfunction FlushClickAreas()\n clickAreas = {}\nend\n\nfunction CheckClick(x, y)\n PrintDebug(\"Clicked at \"..x..\" / \"..y)\n local HitTarget=\"\"\n for k, v in pairs(clickAreas) do\n if v and x>=v.x1 and x<=v.x2 and y>=v.y1 and y<=v.y2 then\n HitTarget=v.id\n break\n end\n end\n if HitTarget==\"DamagedDamage\" then\n DamagedSortingMode=1\n CurrentDamagedPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"DamagedHealth\" then\n DamagedSortingMode=3\n CurrentDamagedPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"DamagedID\" then\n DamagedSortingMode=2\n CurrentDamagedPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"BrokenDamage\" then\n BrokenSortingMode=1\n CurrentBrokenPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"BrokenID\" then\n BrokenSortingMode=2\n CurrentBrokenPage=1\n SortTables()\n DrawScreens()\n elseif HitTarget==\"DamagedPageDown\" then\n CurrentDamagedPage = CurrentDamagedPage + 1\n if CurrentDamagedPage > math.ceil(#damagedElements/12) then CurrentDamagedPage = math.ceil(#damagedElements/12) end\n DrawScreens()\n elseif HitTarget==\"DamagedPageUp\" then\n CurrentDamagedPage = CurrentDamagedPage - 1\n if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end\n DrawScreens()\n elseif HitTarget==\"BrokenPageDown\" then\n CurrentBrokenPage = CurrentBrokenPage + 1\n if CurrentBrokenPage > math.ceil(#brokenElements/12) then CurrentBrokenPage = math.ceil(#brokenElements/12) end\n DrawScreens()\n elseif HitTarget==\"BrokenPageUp\" then\n CurrentBrokenPage = CurrentBrokenPage - 1\n if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end\n DrawScreens()\n elseif HitTarget==\"ToggleSimulation\" then\n CurrentDamagedPage=1\n CurrentBrokenPage=1\n if SimulationMode == true then\n SimulationMode = false\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n DrawScreens()\n else\n SimulationMode = true\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n DrawScreens()\n end\n elseif HitTarget==\"ToggleElementLabel\" or HitTarget==\"ToggleElementLabel2\" then\n if UseMyElementNames == true then\n UseMyElementNames = false\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n DrawScreens()\n else\n UseMyElementNames = true\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n DrawScreens()\n end\n end\nend\n\nfunction SortTables()\n -- Sort damaged elements descending by percent damaged according to setting\n if DamagedSortingMode==1 then table.sort(damagedElements, function(a,b) return a.missinghp > b.missinghp end)\n elseif DamagedSortingMode==2 then table.sort(damagedElements, function(a,b) return a.id < b.id end)\n else table.sort(damagedElements, function(a,b) return a.percent < b.percent end)\n end\n\n -- Sort broken elements descending according to setting\n if BrokenSortingMode==1 then table.sort(brokenElements, function(a,b) return a.maxhp > b.maxhp end)\n else table.sort(brokenElements, function(a,b) return a.id < b.id end)\n end\nend\n\nfunction GenerateDamageData()\n if SimulationActive==true then\n return\n end\n\n local formerTotalShipHP = totalShipHP\n totalShipHP = 0\n totalShipMaxHP = 0\n totalShipIntegrity = 100\n elementsId = {}\n damagedElements = {}\n brokenElements = {}\n ElementCounter = 0\n healthyElements = 0\n\n elementsIdList = core.getElementIdList()\n\n for _,id in pairs(elementsIdList) do\n ElementCounter = ElementCounter + 1\n idHP = core.getElementHitPointsById(id) or 0\n idMaxHP = core.getElementMaxHitPointsById(id) or 0\n\n if SimulationMode then\n SimulationActive=true\n local dice =math.random(0,10)\n if dice < 2 then idHP = 0\n elseif dice >=2 and dice < 5 then idHP = idMaxHP\n else \n idHP = math.random(1, math.ceil(idMaxHP))\n end\n end\n\n totalShipHP = totalShipHP+idHP\n totalShipMaxHP = totalShipMaxHP+idMaxHP\n\n -- Is element damaged?\n if idMaxHP > idHP then\n idPos = core.getElementPositionById(id)\n idName = core.getElementNameById(id)\n idType = core.getElementTypeById(id)\n if idHP>0 then\n table.insert(damagedElements,\n {\n id = id,\n name = idName,\n type = idType,\n counter = ElementCounter,\n hp = idHP,\n maxhp = idMaxHP,\n missinghp = idMaxHP-idHP,\n percent = math.ceil(100/idMaxHP*idHP),\n pos =idPos\n }\n )\n -- if DebugMode then PrintDebug(\"Damaged: \"..idName..\" --- Type: \"..idType..\"\") end\n -- Is element broken?\n else\n table.insert(brokenElements,\n {\n id = id,\n name = idName,\n type = idType,\n counter = ElementCounter,\n hp = idHP,\n maxhp = idMaxHP,\n missinghp = idMaxHP-idHP,\n percent = 0,\n pos =idPos\n }\n )\n -- if DebugMode then PrintDebug(\"Broken: \"..idName..\" --- Type: \"..idType..\"\") end\n end\n else\n healthyElements = healthyElements + 1\n end\n end\n\n -- Sort tables by current settings \n SortTables()\n\n -- Update clickAreas\n\n\n -- Determine total ship integrity\n totalShipIntegrity = string.format(\"%2.0f\", 100/totalShipMaxHP*totalShipHP)\n\n -- Has anything changes since last check? If yes, force redrawing the screens\n if formerTotalShipHP ~= totalShipHP then\n forceRedraw=true\n formerTotalShipHP = totalShipHP\n else forceRedraw=false\n end \nend\n\nfunction GetAllSystemsNominalBackground()\n local output=\"\"\n output = output..\n [[\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ]]\n return output\nend\n\nfunction DrawScreens()\n if #screens > 0 then\n\n local healthyColor = \"#00aa00\"\n local brokenColor = \"#aa0000\"\n local damagedColor = \"#aaaa00\"\n local integrityColor = \"#aaaaaa\"\n local healthyTextColor = \"white\"\n local brokenTextColor = \"#ff4444\"\n local damagedTextColor = \"#ffff44\"\n local integrityTextColor = \"white\"\n\n if #damagedElements ==0 then\n damagedColor = \"#aaaaaa\"\n damagedTextColor = \"white\"\n end\n if #brokenElements == 0 then \n brokenColor = \"#aaaaaa\"\n brokenTextColor = \"white\"\n end\n \n -- Draw Header\n screenOutput = [[\n ]]\n \n -- Draw main background\n screenOutput = screenOutput..\n [[\n \n \n \n \n \n \n \n \n \n \n \n ]]\n\n -- Draw Title and summary\n if SimulationActive==true then\n screenOutput = screenOutput..[[Simulated Report]]\n else\n screenOutput = screenOutput..[[Damage Report]]\n end\n if YourShipsName==nil or YourShipsName==\"\" or YourShipsName==\"Enter here\" then screenOutput = screenOutput.. [[SHIP ID ]]..shipID..[[]]\n else screenOutput = screenOutput.. [[]]..YourShipsName..[[]]\n end\n screenOutput = screenOutput.. \n [[\n Healthy\n ]]..healthyElements..[[\n\n Damaged\n ]]..#damagedElements..[[\n\n Broken\n ]]..#brokenElements..[[\n\n Integrity\n ]]..totalShipIntegrity..[[%]]\n\n -- Draw damage elements\n\n if #damagedElements > 0 then\n local damagedElementsToDraw = #damagedElements\n if damagedElementsToDraw>12 then damagedElementsToDraw=12 end\n if CurrentDamagedPage==math.ceil(#damagedElements/12) then damagedElementsToDraw = #damagedElements%12 end\n screenOutput = screenOutput..\n [[]]\n screenOutput = screenOutput .. [[]]\n if (DamagedSortingMode==2) then \n screenOutput = screenOutput ..[[ID]]\n else\n screenOutput = screenOutput ..[[ID]]\n end\n if UseMyElementNames==true then screenOutput = screenOutput ..[[Element Name]]\n else screenOutput = screenOutput ..[[Element Type]]\n end\n \n if (DamagedSortingMode==3) then \n screenOutput = screenOutput ..[[Health]]\n else\n screenOutput = screenOutput ..[[Health]]\n end\n if (DamagedSortingMode==1) then \n screenOutput = screenOutput ..[[Damage]]\n else\n screenOutput = screenOutput ..[[Damage]]\n end\n\n local i=0\n for j=1+(CurrentDamagedPage-1)*12,damagedElementsToDraw+(CurrentDamagedPage-1)*12,1 do\n i = i + 1\n local DP = damagedElements[j]\n screenOutput = screenOutput ..\n [[]]..string.format(\"%03.0f\",DP.id)..[[]]\n if UseMyElementNames==true then\n screenOutput = screenOutput .. [[]]..string.format(\"%.25s\", DP.name)..[[]]\n else\n screenOutput = screenOutput .. [[]]..string.format(\"%.25s\", DP.type)..[[]]\n end\n screenOutput = screenOutput ..\n [[]]..DP.percent..[[%]]..\n [[]]..GenerateCommaValue(string.format(\"%.0f\", DP.missinghp))..[[]]..\n [[]]\n end\n screenOutput = screenOutput ..\n [[\n \n ]]\n\n if #damagedElements>12 then\n screenOutput = screenOutput ..\n [[Page ]]..CurrentDamagedPage..\" of \"..math.ceil(#damagedElements/12)..[[]]\n\n if CurrentDamagedPage < math.ceil(#damagedElements/12) then\n screenOutput = screenOutput ..\n [[\n \n \n ]]\n UpdateClickArea( \"DamagedPageDown\", { id = \"DamagedPageDown\", x1 = 70, x2 = 270, y1 = 350+11+(damagedElementsToDraw+1)*50, y2 = 350+11+50+(damagedElementsToDraw+1)*50 } )\n else\n DisableClickArea( \"DamagedPageDown\" )\n end\n \n if CurrentDamagedPage > 1 then\n screenOutput = screenOutput ..\n [[\n \n \n ]]\n UpdateClickArea( \"DamagedPageUp\", { id = \"DamagedPageUp\", x1 = 280, x2 = 480, y1 = 350+11+(damagedElementsToDraw+1)*50, y2 = 350+11+50+(damagedElementsToDraw+1)*50 } )\n else\n DisableClickArea( \"DamagedPageUp\" )\n end\n end\n\n\n\n\n end\n\n -- Draw broken elements\n if #brokenElements > 0 then\n local brokenElementsToDraw = #brokenElements\n if brokenElementsToDraw>12 then brokenElementsToDraw=12 end\n if CurrentBrokenPage==math.ceil(#brokenElements/12) then brokenElementsToDraw = #brokenElements%12 end\n screenOutput = screenOutput..\n [[]]\n screenOutput = screenOutput .. [[]]\n if (BrokenSortingMode==2) then \n screenOutput = screenOutput ..[[ID]]\n else\n screenOutput = screenOutput ..[[ID]]\n end\n if UseMyElementNames==true then screenOutput = screenOutput .. [[Element Name]]\n else screenOutput = screenOutput .. [[Element Type]]\n end\n if (BrokenSortingMode==1) then \n screenOutput = screenOutput ..[[Damage]]\n else\n screenOutput = screenOutput ..[[Damage]]\n end\n\n local i=0\n for j=1+(CurrentBrokenPage-1)*12,brokenElementsToDraw+(CurrentBrokenPage-1)*12,1 do\n i = i + 1\n local DP = brokenElements[j]\n screenOutput = screenOutput ..\n [[]]..string.format(\"%03.0f\",DP.id)..[[]]\n if UseMyElementNames==true then\n screenOutput = screenOutput .. [[]]..string.format(\"%.25s\", DP.name)..[[]]\n else\n screenOutput = screenOutput .. [[]]..string.format(\"%.25s\", DP.type)..[[]]\n end\n screenOutput = screenOutput ..\n [[]]..GenerateCommaValue(string.format(\"%.0f\", DP.missinghp))..[[]]..\n [[]]\n end\n\n screenOutput = screenOutput.. \n [[\n \n ]]\n\n\n if #brokenElements>12 then\n screenOutput = screenOutput ..\n [[Page ]]..CurrentBrokenPage..\" of \"..math.ceil(#brokenElements/12)..[[]]\n\n if CurrentBrokenPage > 1 then\n screenOutput = screenOutput ..\n [[\n \n \n ]]\n UpdateClickArea( \"BrokenPageUp\", { id = \"BrokenPageUp\", x1 = 1442, x2 = 1642, y1 = 350+11+(brokenElementsToDraw+1)*50, y2 = 350+11+50+(brokenElementsToDraw+1)*50 } )\n else\n DisableClickArea( \"BrokenPageUp\" )\n end\n \n if CurrentBrokenPage < math.ceil(#brokenElements/12) then\n screenOutput = screenOutput ..\n [[\n \n \n ]]\n UpdateClickArea( \"BrokenPageDown\", { id = \"BrokenPageDown\", x1 = 1652, x2 = 1852, y1 = 350+11+(brokenElementsToDraw+1)*50, y2 = 350+11+50+(brokenElementsToDraw+1)*50 } )\n else\n DisableClickArea( \"BrokenPageDown\" )\n end\n end\n\n\n\n end\n\n -- Draw damage summary\n if #damagedElements>0 or #brokenElements > 0 then\n screenOutput = screenOutput..\n [[]]..GenerateCommaValue(string.format(\"%.0f\", totalShipMaxHP-totalShipHP))..[[ HP damage in total]]\n else\n screenOutput = screenOutput ..\n [[]] ..\n GetAllSystemsNominalBackground() ..\n [[]] ..\n [[]]..OkayCenterMessage..[[]] ..\n [[Ship stands ]]..GenerateCommaValue(string.format(\"%.0f\", totalShipMaxHP))..[[ HP strong.]]\n end\n\n -- Draw HUD Mode button\n screenOutput = screenOutput..[[]]\n\n DrawSVG(screenOutput)\n\n forceRedraw=false\n end\nend\n\n-----------------------------------------------\n-- Execute\n-----------------------------------------------\n\nunit.hide()\nClearConsole()\nPrintDebug(\"SCRIPT STARTED\", true)\n\nInitiateSlots()\nSwitchScreens(true)\nInitiateClickAreas()\n\nif core == nil then\n DrawCenteredText(\"ERROR: No core connected.\")\n PrintError(\"ERROR: No core connected.\")\n goto exit\nelse\n shipID = core.getConstructId()\nend\n\nGenerateDamageData()\nif forceRedraw then\n DrawScreens()\nend\n\nunit.setTimer('UpdateData', UpdateInterval)\n\n::exit::",
- "filter": {
- "args": [],
- "signature": "start()",
- "slotKey": "-1"
- },
- "key": "9"
- },
- {
- "code": "if #screens > 0 then\n for i=1,#screens,1 do\n screens[i].deactivate()\n screens[i].clear()\n end\nend",
- "filter": {
- "args": [],
- "signature": "stop()",
- "slotKey": "-1"
- },
- "key": "10"
- },
- {
- "code": "GenerateDamageData()\nif forceRedraw then\n DrawScreens()\nend",
- "filter": {
- "args": [
- {
- "value": "UpdateData"
- }
- ],
- "signature": "tick(timerId)",
- "slotKey": "-1"
- },
- "key": "11"
- }
- ],
- "methods": [],
- "events": []
-}
\ No newline at end of file
diff --git a/versions/DamageReport_2_1.json b/versions/DamageReport_2_1.json
deleted file mode 100644
index dd6f61c..0000000
--- a/versions/DamageReport_2_1.json
+++ /dev/null
@@ -1,339 +0,0 @@
-{
- "slots": {
- "0": {
- "name": "core",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "1": {
- "name": "slot2",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "2": {
- "name": "slot3",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "3": {
- "name": "slot4",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "4": {
- "name": "slot5",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "5": {
- "name": "slot6",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "6": {
- "name": "slot7",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "7": {
- "name": "slot8",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "8": {
- "name": "slot9",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "9": {
- "name": "slot10",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-1": {
- "name": "unit",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-2": {
- "name": "system",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-3": {
- "name": "library",
- "type": {
- "events": [],
- "methods": []
- }
- }
- },
- "handlers": [
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "1"
- },
- "key": "0"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "2"
- },
- "key": "1"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "3"
- },
- "key": "2"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "4"
- },
- "key": "3"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "5"
- },
- "key": "4"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "6"
- },
- "key": "5"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "7"
- },
- "key": "6"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "8"
- },
- "key": "7"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "9"
- },
- "key": "8"
- },
- {
- "code": "--[[\n DamageReport v2.1\n\n Created By Dorian Gray\n\n Discord: Dorian Gray#2623\n InGame: DorianGray\n GitHub: https://github.com/DorianTheGrey/DU-DamageReport\n\n GNU Public License 3.0. Use whatever you want, be so kind to leave credit.\n\n Thanks to Jericho, Dmentia and Archaegeo for learning from their fine scripts.\n]] -----------------------------------------------\n-- CONFIG\n-----------------------------------------------\nUseMyElementNames = true -- export: If you active this, the display will not show the element type of damaged/broken elements but the name you gave them (truncated to 25 characters)\nAllowElementHighlighting = true -- export: Are you allowing damaged/broken elements to be highlighted in 3D space when selected in the HUD?\nUpdateInterval = 1 -- export: Interval in seconds between updates of the calculations and (if anything changed) redrawing to the screen(s). You need to restart the script after changing this value.\nHighlightBlinkingInterval = 0.5 -- export: If an element is marked, how fast do you want the arrows to blink?\nSimulationMode = false -- export Randomize simluated damage on elements to check out the functionality of this script. And, no, your elements won't be harmed in the process :) You need to restart the script after changing this value.\nYourShipsName = \"Enter here\" -- export Enter your ship name here if you want it displayed instead of the ship's ID. YOU NEED TO LEAVE THE QUOTATION MARKS.\n\nDebugMode = false -- Activate if you want some console messages\nVersionNumber = 2.1 -- Version number\n\ncore = nil\nscreens = {}\n\nshipID = 0\nforceRedraw = false\nSimulationActive = false\n\nclickAreas = {}\nDamagedSortingMode = 1 -- Define default sorting mode for damaged elements. 1 to sort by damage amount, 2 to sort by element id, 3 to sort by damage percent, \nBrokenSortingMode = 1 -- Define default sorting mode for broken elements. 1 to sort by damage amount, 2 to sort by element id\n\nHUDMode = false -- Is Hud active?\nhudSelectedIndex = 0 -- Which element is selected?\nhudSelectedType = 0 -- Is selected element damaged (1) or broken (2)\nhudArrowSticker = {}\nhighlightOn = false\nhighlightX = 0\nhighlightY = 0\nhighlightZ = 0\n\nCurrentDamagedPage = 1\nCurrentBrokenPage = 1\n\ncoreWorldOffset = 0\ntotalShipHP = 0\ntotalShipMaxHP = 0\ntotalShipIntegrity = 100\nelementsId = {}\ndamagedElements = {}\nbrokenElements = {}\nElementCounter = 0\nhealthyElements = 0\n\nOkayCenterMessage = \"All systems nominal.\"\n\n-----------------------------------------------\n-- FUNCTIONS\n-----------------------------------------------\n\nfunction GenerateCommaValue(amount)\n local formatted = amount\n while true do\n formatted, k = string.gsub(formatted, \"^(-?%d+)(%d%d%d)\", '%1,%2')\n if (k == 0) then break end\n end\n return formatted\nend\n\nfunction PrintDebug(output, highlight)\n highlight = highlight or false\n if DebugMode then\n if highlight then\n system.print(\n \"------------------------------------------------------------------------\")\n end\n system.print(output)\n if highlight then\n system.print(\n \"------------------------------------------------------------------------\")\n end\n end\nend\n\nfunction PrintError(output) system.print(output) end\n\nfunction DrawCenteredText(output)\n for i = 1, #screens, 1 do screens[i].setCenteredText(output) end\nend\n\nfunction DrawSVG(output) for i = 1, #screens, 1 do screens[i].setSVG(output) end end\n\nfunction ClearConsole() for i = 1, 10, 1 do PrintDebug() end end\n\nfunction SwitchScreens(state)\n state = state or true\n if #screens > 0 then\n for i = 1, #screens, 1 do\n if state then\n screens[i].clear()\n screens[i].activate()\n else\n screens[i].deactivate()\n screens[i].clear()\n end\n end\n end\nend\n\nfunction InitiateSlots()\n for slot_name, slot in pairs(unit) do\n if type(slot) == \"table\" and type(slot.export) == \"table\" and\n slot.getElementClass then\n if slot.getElementClass():lower():find(\"coreunit\") then\n core = slot\n local coreHP = core.getMaxHitPoints()\n if coreHP > 10000 then\n coreWorldOffset = 128\n elseif coreHP > 1000 then\n coreWorldOffset = 64\n elseif coreHP > 150 then\n coreWorldOffset = 32\n else\n coreWorldOffset = 16\n end\n end\n if slot.getElementClass():lower():find(\"screenunit\") then\n screens[#screens + 1] = slot\n end\n end\n end\nend\n\nfunction AddClickArea(newEntry) table.insert(clickAreas, newEntry) end\n\nfunction RemoveFromClickAreas(candidate)\n for k, v in pairs(clickAreas) do\n if v.id == candidate then\n clickAreas[k] = nil\n break\n end\n end\nend\n\nfunction UpdateClickArea(candidate, newEntry)\n for k, v in pairs(clickAreas) do\n if v.id == candidate then\n clickAreas[k] = newEntry\n break\n end\n end\nend\n\nfunction DisableClickArea(candidate)\n for k, v in pairs(clickAreas) do\n if v.id == candidate then\n UpdateClickArea(candidate, {\n id = candidate,\n x1 = -1,\n x2 = -1,\n y1 = -1,\n y2 = -1\n })\n break\n end\n end\nend\n\nfunction InitiateClickAreas()\n clickAreas = {}\n AddClickArea({id = \"DamagedDamage\", x1 = 725, x2 = 870, y1 = 380, y2 = 415})\n AddClickArea({id = \"DamagedHealth\", x1 = 520, x2 = 655, y1 = 380, y2 = 415})\n AddClickArea({id = \"DamagedID\", x1 = 90, x2 = 150, y1 = 380, y2 = 415})\n AddClickArea({id = \"BrokenDamage\", x1 = 1675, x2 = 1835, y1 = 380, y2 = 415})\n AddClickArea({id = \"BrokenID\", x1 = 1050, x2 = 1110, y1 = 380, y2 = 415})\n AddClickArea({\n id = \"ToggleSimulation\",\n x1 = 65,\n x2 = 660,\n y1 = 100,\n y2 = 145\n })\n AddClickArea({\n id = \"ToggleElementLabel\",\n x1 = 225,\n x2 = 460,\n y1 = 380,\n y2 = 415\n })\n AddClickArea({\n id = \"ToggleElementLabel2\",\n x1 = 1185,\n x2 = 1440,\n y1 = 380,\n y2 = 415\n })\n AddClickArea({\n id = \"ToggleHudMode\",\n x1 = 1397,\n x2 = 1840,\n y1 = 133,\n y2 = 220\n })\n AddClickArea({id = \"DamagedPageDown\", x1 = -1, x2 = -1, y1 = -1, y2 = -1})\n AddClickArea({id = \"DamagedPageUp\", x1 = -1, x2 = -1, y1 = -1, y2 = -1})\n AddClickArea({id = \"BrokenPageDown\", x1 = -1, x2 = -1, y1 = -1, y2 = -1})\n AddClickArea({id = \"BrokenPageUp\", x1 = -1, x2 = -1, y1 = -1, y2 = -1})\nend\n\nfunction FlushClickAreas() clickAreas = {} end\n\nfunction CheckClick(x, y, HitTarget)\n HitTarget = HitTarget or \"\"\n if HitTarget == \"\" then\n for k, v in pairs(clickAreas) do\n if v and x >= v.x1 and x <= v.x2 and y >= v.y1 and y <= v.y2 then\n HitTarget = v.id\n break\n end\n end\n end\n if HitTarget == \"DamagedDamage\" then\n DamagedSortingMode = 1\n CurrentDamagedPage = 1\n SortTables()\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"DamagedHealth\" then\n DamagedSortingMode = 3\n CurrentDamagedPage = 1\n SortTables()\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"DamagedID\" then\n DamagedSortingMode = 2\n CurrentDamagedPage = 1\n SortTables()\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"BrokenDamage\" then\n BrokenSortingMode = 1\n CurrentBrokenPage = 1\n SortTables()\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"BrokenID\" then\n BrokenSortingMode = 2\n CurrentBrokenPage = 1\n SortTables()\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"DamagedPageDown\" then\n CurrentDamagedPage = CurrentDamagedPage + 1\n if CurrentDamagedPage > math.ceil(#damagedElements / 12) then\n CurrentDamagedPage = math.ceil(#damagedElements / 12)\n end\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"DamagedPageUp\" then\n CurrentDamagedPage = CurrentDamagedPage - 1\n if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"BrokenPageDown\" then\n CurrentBrokenPage = CurrentBrokenPage + 1\n if CurrentBrokenPage > math.ceil(#brokenElements / 12) then\n CurrentBrokenPage = math.ceil(#brokenElements / 12)\n end\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"BrokenPageUp\" then\n CurrentBrokenPage = CurrentBrokenPage - 1\n if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"ToggleHudMode\" then\n if HUDMode == true then\n HUDMode = false\n forceRedraw = true\n HudDeselectElement()\n DrawScreens()\n else\n HUDMode = true\n forceRedraw = true\n HudDeselectElement()\n DrawScreens()\n end\n elseif HitTarget == \"ToggleSimulation\" then\n CurrentDamagedPage = 1\n CurrentBrokenPage = 1\n if SimulationMode == true then\n SimulationMode = false\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n HudDeselectElement()\n DrawScreens()\n else\n SimulationMode = true\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n HudDeselectElement()\n DrawScreens()\n end\n elseif HitTarget == \"ToggleElementLabel\" or HitTarget ==\n \"ToggleElementLabel2\" then\n if UseMyElementNames == true then\n UseMyElementNames = false\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n HudDeselectElement()\n DrawScreens()\n else\n UseMyElementNames = true\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n HudDeselectElement()\n DrawScreens()\n end\n end\nend\n\nfunction ToggleHUD()\n HideHighlight()\n CheckClick(nil, nil, \"ToggleHudMode\")\nend\n\nfunction HudDeselectElement()\n if HUDMode == true then\n hudSelectedType = 0\n hudSelectedIndex = 0\n HideHighlight()\n DrawScreens()\n end\nend\n\nfunction ChangeHudSelectedElement(step)\n if HUDMode == true and (#damagedElements or #brokenElements) then\n local damagedElementsHUD = 12\n if #damagedElements < 12 then\n damagedElementsHUD = #damagedElements\n end\n local brokenElementsHUD = 12\n if #brokenElements < 12 then brokenElementsHUD = #brokenElements end\n if step == 1 then\n if hudSelectedIndex == 0 then\n if damagedElementsHUD > 0 then\n hudSelectedType = 1\n hudSelectedIndex = 1\n elseif brokenElementsHUD > 0 then\n hudSelectedType = 2\n hudSelectedIndex = 1\n end\n elseif hudSelectedType == 1 then\n if damagedElementsHUD > hudSelectedIndex then\n hudSelectedIndex = hudSelectedIndex + 1\n elseif brokenElementsHUD > 0 then\n hudSelectedType = 2\n hudSelectedIndex = 1\n elseif damagedElementsHUD > 0 then\n hudSelectedIndex = 1\n end\n elseif hudSelectedType == 2 then\n if brokenElementsHUD > hudSelectedIndex then\n hudSelectedIndex = hudSelectedIndex + 1\n elseif damagedElementsHUD > 0 then\n hudSelectedType = 1\n hudSelectedIndex = 1\n elseif brokenElementsHUD > 0 then\n hudSelectedIndex = 1\n end\n end\n elseif step == -1 then\n if hudSelectedIndex == 0 then\n if brokenElementsHUD > 0 then\n hudSelectedType = 2\n hudSelectedIndex = 1\n elseif damagedElementsHUD > 0 then\n hudSelectedType = 1\n hudSelectedIndex = 1\n end\n elseif hudSelectedType == 1 then\n if hudSelectedIndex > 1 then\n hudSelectedIndex = hudSelectedIndex - 1\n elseif brokenElementsHUD > 0 then\n hudSelectedType = 2\n hudSelectedIndex = brokenElementsHUD\n elseif damagedElementsHUD > 0 then\n hudSelectedIndex = damagedElementsHUD\n end\n elseif hudSelectedType == 2 then\n if hudSelectedIndex > 1 then\n hudSelectedIndex = hudSelectedIndex - 1\n elseif damagedElementsHUD > 0 then\n hudSelectedType = 1\n hudSelectedIndex = damagedElementsHUD\n elseif brokenElementsHUD > 0 then\n hudSelectedIndex = brokenElementsHUD\n end\n end\n end\n HighlightElement()\n DrawScreens()\n -- PrintDebug(\"-> Type: \"..hudSelectedType.. \" Index: \"..hudSelectedIndex)\n end\nend\n\nfunction HideHighlight()\n if #hudArrowSticker > 0 then\n for i in pairs(hudArrowSticker) do\n core.deleteSticker(hudArrowSticker[i])\n end\n hudArrowSticker = {}\n end\nend\n\nfunction ShowHighlight()\n if highlightOn == true then\n table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX + 2,\n highlightY,\n highlightZ, \"north\"))\n table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,\n highlightY - 2,\n highlightZ, \"east\"))\n table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX - 2,\n highlightY,\n highlightZ, \"south\"))\n table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,\n highlightY + 2,\n highlightZ, \"west\"))\n table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,\n highlightY,\n highlightZ - 2,\n \"up\"))\n table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,\n highlightY,\n highlightZ + 2,\n \"down\"))\n end\nend\n\nfunction ToggleHighlight()\n if highlightOn == true then\n highlightOn = false\n HideHighlight()\n else\n highlightOn = true\n ShowHighlight()\n end\nend\n\nfunction HighlightElement(elementID)\n elementID = elementID or 0\n local targetElement = {}\n\n if elementID == 0 then\n if hudSelectedType == 1 then\n elementID = damagedElements[(CurrentDamagedPage - 1) * 12 +\n hudSelectedIndex].id\n elseif hudSelectedType == 2 then\n elementID = brokenElements[(CurrentBrokenPage - 1) * 12 +\n hudSelectedIndex].id\n end\n\n if elementID ~= 0 then\n local bFound = false\n for k, v in pairs(damagedElements) do\n if v.id == elementID then\n targetElement = v\n bFound = true\n break\n end\n end\n if bFound == false then\n for k, v in pairs(brokenElements) do\n if v.id == elementID then\n targetElement = v\n bFound = true\n break\n end\n end\n end\n\n if bFound == true and AllowElementHighlighting == true then\n HideHighlight()\n elementPosition = vec3(targetElement.pos)\n highlightX = elementPosition.x - coreWorldOffset\n highlightY = elementPosition.y - coreWorldOffset\n highlightZ = elementPosition.z - coreWorldOffset\n highlightOn = true\n ShowHighlight()\n end\n end\n end\nend\n\nfunction SortTables()\n -- Sort damaged elements descending by percent damaged according to setting\n if DamagedSortingMode == 1 then\n table.sort(damagedElements,\n function(a, b) return a.missinghp > b.missinghp end)\n elseif DamagedSortingMode == 2 then\n table.sort(damagedElements, function(a, b) return a.id < b.id end)\n else\n table.sort(damagedElements,\n function(a, b) return a.percent < b.percent end)\n end\n\n -- Sort broken elements descending according to setting\n if BrokenSortingMode == 1 then\n table.sort(brokenElements, function(a, b)\n return a.maxhp > b.maxhp\n end)\n else\n table.sort(brokenElements, function(a, b) return a.id < b.id end)\n end\nend\n\nfunction GenerateDamageData()\n if SimulationActive == true then return end\n\n local formerTotalShipHP = totalShipHP\n totalShipHP = 0\n totalShipMaxHP = 0\n totalShipIntegrity = 100\n elementsId = {}\n damagedElements = {}\n brokenElements = {}\n ElementCounter = 0\n healthyElements = 0\n\n elementsIdList = core.getElementIdList()\n\n for _, id in pairs(elementsIdList) do\n ElementCounter = ElementCounter + 1\n idHP = core.getElementHitPointsById(id) or 0\n idMaxHP = core.getElementMaxHitPointsById(id) or 0\n\n if SimulationMode then\n SimulationActive = true\n local dice = math.random(0, 10)\n if dice < 2 then\n idHP = 0\n elseif dice >= 2 and dice < 5 then\n idHP = idMaxHP\n else\n idHP = math.random(1, math.ceil(idMaxHP))\n end\n end\n\n totalShipHP = totalShipHP + idHP\n totalShipMaxHP = totalShipMaxHP + idMaxHP\n\n idName = core.getElementNameById(id)\n\n -- Is element damaged?\n if idMaxHP > idHP then\n idPos = core.getElementPositionById(id)\n idType = core.getElementTypeById(id)\n if idHP > 0 then\n table.insert(damagedElements, {\n id = id,\n name = idName,\n type = idType,\n counter = ElementCounter,\n hp = idHP,\n maxhp = idMaxHP,\n missinghp = idMaxHP - idHP,\n percent = math.ceil(100 / idMaxHP * idHP),\n pos = idPos\n })\n -- if DebugMode then PrintDebug(\"Damaged: \"..idName..\" --- Type: \"..idType..\"\") end\n -- Is element broken?\n else\n table.insert(brokenElements, {\n id = id,\n name = idName,\n type = idType,\n counter = ElementCounter,\n hp = idHP,\n maxhp = idMaxHP,\n missinghp = idMaxHP - idHP,\n percent = 0,\n pos = idPos\n })\n -- if DebugMode then PrintDebug(\"Broken: \"..idName..\" --- Type: \"..idType..\"\") end\n end\n else\n healthyElements = healthyElements + 1\n end\n end\n\n -- Sort tables by current settings \n SortTables()\n\n -- Update clickAreas\n\n -- Determine total ship integrity\n totalShipIntegrity = string.format(\"%2.0f\",\n 100 / totalShipMaxHP * totalShipHP)\n\n -- Has anything changes since last check? If yes, force redrawing the screens\n if formerTotalShipHP ~= totalShipHP then\n forceRedraw = true\n formerTotalShipHP = totalShipHP\n else\n forceRedraw = false\n end\nend\n\nfunction GetAllSystemsNominalBackground()\n local output = \"\"\n output = output .. [[\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ]]\n return output\nend\n\nfunction GetDRLogo()\n output =\n [[]]\n return output\nend\n\nfunction GenerateHUDOutput()\n\n local hudWidth = 300\n local hudHeight = 125\n if #damagedElements > 0 or #brokenElements > 0 then hudHeight = 780 end\n local screenHeight = 1080\n\n local healthyColor = \"#00aa00\"\n local brokenColor = \"#aa0000\"\n local damagedColor = \"#aaaa00\"\n local integrityColor = \"#aaaaaa\"\n local healthyTextColor = \"white\"\n local brokenTextColor = \"#ff4444\"\n local damagedTextColor = \"#ffff44\"\n local integrityTextColor = \"white\"\n\n if #damagedElements == 0 then\n damagedColor = \"#aaaaaa\"\n damagedTextColor = \"white\"\n end\n if #brokenElements == 0 then\n brokenColor = \"#aaaaaa\"\n brokenTextColor = \"white\"\n end\n\n local hudOutput = \"\"\n\n -- Draw Header\n hudOutput = hudOutput .. [[\n ]]\n\n hudOutput = hudOutput .. [[]] ..\n [[]] .. GetDRLogo() .. [[]]\n\n hudOutput = hudOutput .. [[\n \n ]] .. healthyElements ..\n [[\n \n ]] .. #damagedElements ..\n [[\n \n ]] .. #brokenElements ..\n [[]]\n if #damagedElements > 0 or #brokenElements > 0 then\n hudOutput = hudOutput ..\n [[ ]] ..\n [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", totalShipMaxHP - totalShipHP)) ..\n [[ HP damage in total]]\n else\n hudOutput = hudOutput .. [[]] ..\n OkayCenterMessage .. [[]] ..\n [[Ship stands ]] ..\n GenerateCommaValue(string.format(\"%.0f\", totalShipMaxHP)) ..\n [[ HP strong.]]\n\n end\n hudOutput = hudOutput .. [[]]\n\n hudRowDistance = 25\n if #damagedElements > 0 then\n local damagedElementsToDraw = #damagedElements\n if damagedElementsToDraw > 12 then damagedElementsToDraw = 12 end\n if CurrentDamagedPage == math.ceil(#damagedElements / 12) then\n damagedElementsToDraw = #damagedElements % 12\n end\n local i = 0\n hudOutput = hudOutput .. [[]] ..\n [[]]\n\n for j = 1 + (CurrentDamagedPage - 1) * 12, damagedElementsToDraw +\n (CurrentDamagedPage - 1) * 12, 1 do\n i = i + 1\n local DP = damagedElements[j]\n if (hudSelectedType == 1 and hudSelectedIndex == i) then\n hudOutput = hudOutput .. [[]]\n if UseMyElementNames == true then\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.name) ..\n [[]]\n else\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.type) ..\n [[]]\n end\n if (DamagedSortingMode == 3) then\n hudOutput = hudOutput .. [[]] .. DP.percent ..\n [[%]]\n else\n hudOutput = hudOutput .. [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", DP.missinghp)) ..\n [[]]\n end\n else\n if UseMyElementNames == true then\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.name) ..\n [[]]\n else\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.type) ..\n [[]]\n end\n if (DamagedSortingMode == 3) then\n hudOutput = hudOutput .. [[]] .. DP.percent ..\n [[%]]\n else\n hudOutput = hudOutput .. [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", DP.missinghp)) ..\n [[]]\n end\n hudOutput = hudOutput .. [[]]\n end\n end\n hudOutput = hudOutput .. [[]]\n end\n\n if #brokenElements > 0 then\n local brokenElementsToDraw = #brokenElements\n if brokenElementsToDraw > 12 then brokenElementsToDraw = 12 end\n if CurrentbrokenPage == math.ceil(#brokenElements / 12) then\n brokenElementsToDraw = #brokenElements % 12\n end\n local i = 0\n hudOutput = hudOutput .. [[]] ..\n [[]]\n\n for j = 1 + (CurrentBrokenPage - 1) * 12, brokenElementsToDraw +\n (CurrentBrokenPage - 1) * 12, 1 do\n i = i + 1\n local DP = brokenElements[j]\n if (hudSelectedType == 2 and hudSelectedIndex == i) then\n hudOutput = hudOutput .. [[]]\n if UseMyElementNames == true then\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.name) ..\n [[]]\n else\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.type) ..\n [[]]\n end\n if (brokenSortingMode == 3) then\n hudOutput = hudOutput .. [[]] .. DP.percent ..\n [[%]]\n else\n hudOutput = hudOutput .. [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", DP.missinghp)) ..\n [[]]\n end\n else\n if UseMyElementNames == true then\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.name) ..\n [[]]\n else\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.type) ..\n [[]]\n end\n if (brokenSortingMode == 3) then\n hudOutput = hudOutput .. [[]] .. DP.percent ..\n [[%]]\n else\n hudOutput = hudOutput .. [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", DP.missinghp)) ..\n [[]]\n end\n hudOutput = hudOutput .. [[]]\n end\n end\n hudOutput = hudOutput .. [[]]\n end\n\n if #damagedElements or #brokenElements then\n hudOutput = hudOutput .. [[]] ..\n [[Use up/down arrows to select element to find.]] ..\n [[Use right arrow to deselect.]] ..\n [[Use left arrow to exit HUD mode.]] ..\n [[]]\n end\n\n hudOutput = hudOutput .. [[]]\n\n return hudOutput\nend\n\nfunction DrawScreens()\n if #screens > 0 then\n\n local healthyColor = \"#00aa00\"\n local brokenColor = \"#aa0000\"\n local damagedColor = \"#aaaa00\"\n local integrityColor = \"#aaaaaa\"\n local healthyTextColor = \"white\"\n local brokenTextColor = \"#ff4444\"\n local damagedTextColor = \"#ffff44\"\n local integrityTextColor = \"white\"\n\n if #damagedElements == 0 then\n damagedColor = \"#aaaaaa\"\n damagedTextColor = \"white\"\n end\n if #brokenElements == 0 then\n brokenColor = \"#aaaaaa\"\n brokenTextColor = \"white\"\n end\n\n local screenOutput = \"\"\n\n -- Draw Header\n screenOutput = screenOutput ..\n [[\n ]]\n\n -- Draw main background\n screenOutput = screenOutput ..\n [[\n \n \n \n \n \n \n \n \n \n \n \n ]]\n\n -- Draw Title and summary\n if SimulationActive == true then\n screenOutput = screenOutput ..\n [[Simulated Report]]\n else\n screenOutput = screenOutput ..\n [[Damage Report]]\n end\n if YourShipsName == nil or YourShipsName == \"\" or YourShipsName ==\n \"Enter here\" then\n screenOutput = screenOutput ..\n [[SHIP ID ]] ..\n shipID .. [[]]\n else\n screenOutput = screenOutput ..\n [[]] ..\n YourShipsName .. [[]]\n end\n screenOutput = screenOutput .. [[\n Healthy\n ]] .. healthyElements ..\n [[\n\n Damaged\n ]] .. #damagedElements ..\n [[\n\n Broken\n ]] .. #brokenElements ..\n [[\n\n Integrity\n ]] .. totalShipIntegrity ..\n [[%]]\n\n -- Draw damage elements\n\n if #damagedElements > 0 then\n local damagedElementsToDraw = #damagedElements\n if damagedElementsToDraw > 12 then\n damagedElementsToDraw = 12\n end\n if CurrentDamagedPage == math.ceil(#damagedElements / 12) then\n damagedElementsToDraw = #damagedElements % 12\n end\n screenOutput = screenOutput ..\n [[]]\n screenOutput = screenOutput ..\n [[]]\n if (DamagedSortingMode == 2) then\n screenOutput = screenOutput ..\n [[ID]]\n else\n screenOutput = screenOutput ..\n [[ID]]\n end\n if UseMyElementNames == true then\n screenOutput = screenOutput ..\n [[Element Name]]\n else\n screenOutput = screenOutput ..\n [[Element Type]]\n end\n\n if (DamagedSortingMode == 3) then\n screenOutput = screenOutput ..\n [[Health]]\n else\n screenOutput = screenOutput ..\n [[Health]]\n end\n if (DamagedSortingMode == 1) then\n screenOutput = screenOutput ..\n [[Damage]]\n else\n screenOutput = screenOutput ..\n [[Damage]]\n end\n\n local i = 0\n for j = 1 + (CurrentDamagedPage - 1) * 12, damagedElementsToDraw +\n (CurrentDamagedPage - 1) * 12, 1 do\n i = i + 1\n local DP = damagedElements[j]\n screenOutput = screenOutput .. [[]] ..\n string.format(\"%03.0f\", DP.id) .. [[]]\n if UseMyElementNames == true then\n screenOutput = screenOutput .. [[]] ..\n string.format(\"%.25s\", DP.name) ..\n [[]]\n else\n screenOutput = screenOutput .. [[]] ..\n string.format(\"%.25s\", DP.type) ..\n [[]]\n end\n screenOutput = screenOutput .. [[]] ..\n DP.percent .. [[%]] ..\n [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", DP.missinghp)) ..\n [[]] ..\n [[]]\n end\n screenOutput = screenOutput ..\n [[\n \n ]]\n\n if #damagedElements > 12 then\n screenOutput = screenOutput ..\n [[Page ]] ..\n CurrentDamagedPage .. \" of \" ..\n math.ceil(#damagedElements / 12) ..\n [[]]\n\n if CurrentDamagedPage < math.ceil(#damagedElements / 12) then\n screenOutput = screenOutput .. [[\n \n \n ]]\n UpdateClickArea(\"DamagedPageDown\", {\n id = \"DamagedPageDown\",\n x1 = 70,\n x2 = 270,\n y1 = 350 + 11 + (damagedElementsToDraw + 1) * 50,\n y2 = 350 + 11 + 50 + (damagedElementsToDraw + 1) * 50\n })\n else\n DisableClickArea(\"DamagedPageDown\")\n end\n\n if CurrentDamagedPage > 1 then\n screenOutput = screenOutput .. [[\n \n \n ]]\n UpdateClickArea(\"DamagedPageUp\", {\n id = \"DamagedPageUp\",\n x1 = 280,\n x2 = 480,\n y1 = 350 + 11 + (damagedElementsToDraw + 1) * 50,\n y2 = 350 + 11 + 50 + (damagedElementsToDraw + 1) * 50\n })\n else\n DisableClickArea(\"DamagedPageUp\")\n end\n end\n end\n\n -- Draw broken elements\n if #brokenElements > 0 then\n local brokenElementsToDraw = #brokenElements\n if brokenElementsToDraw > 12 then\n brokenElementsToDraw = 12\n end\n if CurrentBrokenPage == math.ceil(#brokenElements / 12) then\n brokenElementsToDraw = #brokenElements % 12\n end\n screenOutput = screenOutput ..\n [[]]\n screenOutput = screenOutput ..\n [[]]\n if (BrokenSortingMode == 2) then\n screenOutput = screenOutput ..\n [[ID]]\n else\n screenOutput = screenOutput ..\n [[ID]]\n end\n if UseMyElementNames == true then\n screenOutput = screenOutput ..\n [[Element Name]]\n else\n screenOutput = screenOutput ..\n [[Element Type]]\n end\n if (BrokenSortingMode == 1) then\n screenOutput = screenOutput ..\n [[Damage]]\n else\n screenOutput = screenOutput ..\n [[Damage]]\n end\n\n local i = 0\n for j = 1 + (CurrentBrokenPage - 1) * 12, brokenElementsToDraw +\n (CurrentBrokenPage - 1) * 12, 1 do\n i = i + 1\n local DP = brokenElements[j]\n screenOutput = screenOutput .. [[]] ..\n string.format(\"%03.0f\", DP.id) .. [[]]\n if UseMyElementNames == true then\n screenOutput = screenOutput .. [[]] ..\n string.format(\"%.25s\", DP.name) ..\n [[]]\n else\n screenOutput = screenOutput .. [[]] ..\n string.format(\"%.25s\", DP.type) ..\n [[]]\n end\n screenOutput = screenOutput .. [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", DP.missinghp)) ..\n [[]] ..\n [[]]\n end\n\n screenOutput = screenOutput ..\n [[\n \n ]]\n\n if #brokenElements > 12 then\n screenOutput = screenOutput ..\n [[Page ]] ..\n CurrentBrokenPage .. \" of \" ..\n math.ceil(#brokenElements / 12) ..\n [[]]\n\n if CurrentBrokenPage > 1 then\n screenOutput = screenOutput .. [[\n \n \n ]]\n UpdateClickArea(\"BrokenPageUp\", {\n id = \"BrokenPageUp\",\n x1 = 1442,\n x2 = 1642,\n y1 = 350 + 11 + (brokenElementsToDraw + 1) * 50,\n y2 = 350 + 11 + 50 + (brokenElementsToDraw + 1) * 50\n })\n else\n DisableClickArea(\"BrokenPageUp\")\n end\n\n if CurrentBrokenPage < math.ceil(#brokenElements / 12) then\n screenOutput = screenOutput .. [[\n \n \n ]]\n UpdateClickArea(\"BrokenPageDown\", {\n id = \"BrokenPageDown\",\n x1 = 1652,\n x2 = 1852,\n y1 = 350 + 11 + (brokenElementsToDraw + 1) * 50,\n y2 = 350 + 11 + 50 + (brokenElementsToDraw + 1) * 50\n })\n else\n DisableClickArea(\"BrokenPageDown\")\n end\n end\n\n end\n\n -- Draw damage summary\n if #damagedElements > 0 or #brokenElements > 0 then\n screenOutput = screenOutput ..\n [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\",\n totalShipMaxHP - totalShipHP)) ..\n [[ HP damage in total]]\n else\n screenOutput = screenOutput .. [[]] ..\n GetAllSystemsNominalBackground() .. [[]] ..\n [[]] ..\n OkayCenterMessage .. [[]] ..\n [[Ship stands ]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", totalShipMaxHP)) ..\n [[ HP strong.]]\n end\n\n -- Draw HUD Mode button\n if HUDMode == true then\n screenOutput = screenOutput ..\n [[]] ..\n [[HUD Mode activated]]\n\n else\n screenOutput = screenOutput ..\n [[]] ..\n [[Activate HUD Mode]]\n end\n\n screenOutput = screenOutput .. [[]]\n\n if HUDMode == true then\n system.setScreen(GenerateHUDOutput())\n system.showScreen(1)\n else\n system.showScreen(0)\n end\n\n DrawSVG(screenOutput)\n\n forceRedraw = false\n end\nend\n\n-----------------------------------------------\n-- Execute\n-----------------------------------------------\n\nunit.hide()\nClearConsole()\nPrintDebug(\"SCRIPT STARTED\", true)\n\nInitiateSlots()\nSwitchScreens(true)\nInitiateClickAreas()\n\nif core == nil then\n DrawCenteredText(\"ERROR: No core connected.\")\n PrintError(\"ERROR: No core connected.\")\n goto exit\nelse\n shipID = core.getConstructId()\nend\n\nGenerateDamageData()\nif forceRedraw then DrawScreens() end\n\nunit.setTimer('UpdateData', UpdateInterval)\nunit.setTimer('UpdateHighlight', HighlightBlinkingInterval)\n\n::exit::\n",
- "filter": {
- "args": [],
- "signature": "start()",
- "slotKey": "-1"
- },
- "key": "9"
- },
- {
- "code": "if #screens > 0 then\n for i=1,#screens,1 do\n screens[i].deactivate()\n screens[i].clear()\n end\nend",
- "filter": {
- "args": [],
- "signature": "stop()",
- "slotKey": "-1"
- },
- "key": "10"
- },
- {
- "code": "GenerateDamageData()\nif forceRedraw then\n DrawScreens()\nend",
- "filter": {
- "args": [
- {
- "value": "UpdateData"
- }
- ],
- "signature": "tick(timerId)",
- "slotKey": "-1"
- },
- "key": "11"
- },
- {
- "code": "ToggleHighlight()",
- "filter": {
- "args": [
- {
- "value": "UpdateHighlight"
- }
- ],
- "signature": "tick(timerId)",
- "slotKey": "-1"
- },
- "key": "12"
- },
- {
- "code": "HudDeselectElement()",
- "filter": {
- "args": [
- {
- "value": "straferight"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "13"
- },
- {
- "code": "ToggleHUD()",
- "filter": {
- "args": [
- {
- "value": "strafeleft"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "14"
- },
- {
- "code": "ChangeHudSelectedElement(1)",
- "filter": {
- "args": [
- {
- "value": "down"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "15"
- },
- {
- "code": "ChangeHudSelectedElement(-1)",
- "filter": {
- "args": [
- {
- "value": "up"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "16"
- }
- ],
- "methods": [],
- "events": []
-}
\ No newline at end of file
diff --git a/versions/DamageReport_2_2.json b/versions/DamageReport_2_2.json
deleted file mode 100644
index 9e2661e..0000000
--- a/versions/DamageReport_2_2.json
+++ /dev/null
@@ -1,339 +0,0 @@
-{
- "slots": {
- "0": {
- "name": "core",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "1": {
- "name": "slot2",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "2": {
- "name": "slot3",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "3": {
- "name": "slot4",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "4": {
- "name": "slot5",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "5": {
- "name": "slot6",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "6": {
- "name": "slot7",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "7": {
- "name": "slot8",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "8": {
- "name": "slot9",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "9": {
- "name": "slot10",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-1": {
- "name": "unit",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-2": {
- "name": "system",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-3": {
- "name": "library",
- "type": {
- "events": [],
- "methods": []
- }
- }
- },
- "handlers": [
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "1"
- },
- "key": "0"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "2"
- },
- "key": "1"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "3"
- },
- "key": "2"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "4"
- },
- "key": "3"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "5"
- },
- "key": "4"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "6"
- },
- "key": "5"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "7"
- },
- "key": "6"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "8"
- },
- "key": "7"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "9"
- },
- "key": "8"
- },
- {
- "code": "--[[\n DamageReport v2.2\n\n Created By Dorian Gray\n\n Discord: Dorian Gray#2623\n InGame: DorianGray\n GitHub: https://github.com/DorianTheGrey/DU-DamageReport\n\n GNU Public License 3.0. Use whatever you want, be so kind to leave credit.\n\n Thanks to Jericho, Dmentia and Archaegeo for learning from their fine scripts.\n]] -----------------------------------------------\n-- CONFIG\n-----------------------------------------------\nUseMyElementNames = true -- export: If you active this, the display will not show the element type of damaged/broken elements but the name you gave them (truncated to 25 characters)\nAllowElementHighlighting = true -- export: Are you allowing damaged/broken elements to be highlighted in 3D space when selected in the HUD?\nUpdateInterval = 1 -- export: Interval in seconds between updates of the calculations and (if anything changed) redrawing to the screen(s). You need to restart the script after changing this value.\nHighlightBlinkingInterval = 0.5 -- export: If an element is marked, how fast do you want the arrows to blink?\nSimulationMode = false -- export Randomize simluated damage on elements to check out the functionality of this script. And, no, your elements won't be harmed in the process :) You need to restart the script after changing this value.\nYourShipsName = \"Enter here\" -- export Enter your ship name here if you want it displayed instead of the ship's ID. YOU NEED TO LEAVE THE QUOTATION MARKS.\n\nDebugMode = false -- Activate if you want some console messages\nVersionNumber = 2.2 -- Version number\n\ncore = nil\nscreens = {}\n\nshipID = 0\nforceRedraw = false\nSimulationActive = false\n\nclickAreas = {}\nDamagedSortingMode = 1 -- Define default sorting mode for damaged elements. 1 to sort by damage amount, 2 to sort by element id, 3 to sort by damage percent, \nBrokenSortingMode = 1 -- Define default sorting mode for broken elements. 1 to sort by damage amount, 2 to sort by element id\n\nHUDMode = false -- Is Hud active?\nhudSelectedIndex = 0 -- Which element is selected?\nhudSelectedType = 0 -- Is selected element damaged (1) or broken (2)\nhudArrowSticker = {}\nhighlightOn = false\nhighlightID = 0\nhighlightX = 0\nhighlightY = 0\nhighlightZ = 0\n\nCurrentDamagedPage = 1\nCurrentBrokenPage = 1\n\ncoreWorldOffset = 0\ntotalShipHP = 0\ntotalShipMaxHP = 0\ntotalShipIntegrity = 100\nelementsId = {}\ndamagedElements = {}\nbrokenElements = {}\nElementCounter = 0\nhealthyElements = 0\n\nOkayCenterMessage = \"All systems nominal.\"\n\n-----------------------------------------------\n-- FUNCTIONS\n-----------------------------------------------\n\nfunction GenerateCommaValue(amount)\n local formatted = amount\n while true do\n formatted, k = string.gsub(formatted, \"^(-?%d+)(%d%d%d)\", '%1,%2')\n if (k == 0) then break end\n end\n return formatted\nend\n\nfunction PrintDebug(output, highlight)\n highlight = highlight or false\n if DebugMode then\n if highlight then\n system.print(\n \"------------------------------------------------------------------------\")\n end\n system.print(output)\n if highlight then\n system.print(\n \"------------------------------------------------------------------------\")\n end\n end\nend\n\nfunction PrintError(output) system.print(output) end\n\nfunction DrawCenteredText(output)\n for i = 1, #screens, 1 do screens[i].setCenteredText(output) end\nend\n\nfunction DrawSVG(output) for i = 1, #screens, 1 do screens[i].setSVG(output) end end\n\nfunction ClearConsole() for i = 1, 10, 1 do PrintDebug() end end\n\nfunction SwitchScreens(state)\n state = state or true\n if #screens > 0 then\n for i = 1, #screens, 1 do\n if state==true then\n screens[i].clear()\n screens[i].activate()\n else\n screens[i].deactivate()\n screens[i].clear()\n end\n end\n end\nend\n\nfunction InitiateSlots()\n for slot_name, slot in pairs(unit) do\n if type(slot) == \"table\" and type(slot.export) == \"table\" and\n slot.getElementClass then\n if slot.getElementClass():lower():find(\"coreunit\") then\n core = slot\n local coreHP = core.getMaxHitPoints()\n if coreHP > 10000 then\n coreWorldOffset = 128\n elseif coreHP > 1000 then\n coreWorldOffset = 64\n elseif coreHP > 150 then\n coreWorldOffset = 32\n else\n coreWorldOffset = 16\n end\n end\n if slot.getElementClass():lower():find(\"screenunit\") then\n screens[#screens + 1] = slot\n end\n end\n end\nend\n\nfunction AddClickArea(newEntry) table.insert(clickAreas, newEntry) end\n\nfunction RemoveFromClickAreas(candidate)\n for k, v in pairs(clickAreas) do\n if v.id == candidate then\n clickAreas[k] = nil\n break\n end\n end\nend\n\nfunction UpdateClickArea(candidate, newEntry)\n for k, v in pairs(clickAreas) do\n if v.id == candidate then\n clickAreas[k] = newEntry\n break\n end\n end\nend\n\nfunction DisableClickArea(candidate)\n for k, v in pairs(clickAreas) do\n if v.id == candidate then\n UpdateClickArea(candidate, {\n id = candidate,\n x1 = -1,\n x2 = -1,\n y1 = -1,\n y2 = -1\n })\n break\n end\n end\nend\n\nfunction InitiateClickAreas()\n clickAreas = {}\n AddClickArea({id = \"DamagedDamage\", x1 = 725, x2 = 870, y1 = 380, y2 = 415})\n AddClickArea({id = \"DamagedHealth\", x1 = 520, x2 = 655, y1 = 380, y2 = 415})\n AddClickArea({id = \"DamagedID\", x1 = 90, x2 = 150, y1 = 380, y2 = 415})\n AddClickArea({id = \"BrokenDamage\", x1 = 1675, x2 = 1835, y1 = 380, y2 = 415})\n AddClickArea({id = \"BrokenID\", x1 = 1050, x2 = 1110, y1 = 380, y2 = 415})\n AddClickArea({\n id = \"ToggleSimulation\",\n x1 = 65,\n x2 = 660,\n y1 = 100,\n y2 = 145\n })\n AddClickArea({\n id = \"ToggleElementLabel\",\n x1 = 225,\n x2 = 460,\n y1 = 380,\n y2 = 415\n })\n AddClickArea({\n id = \"ToggleElementLabel2\",\n x1 = 1185,\n x2 = 1440,\n y1 = 380,\n y2 = 415\n })\n AddClickArea({\n id = \"ToggleHudMode\",\n x1 = 1397,\n x2 = 1840,\n y1 = 133,\n y2 = 220\n })\n AddClickArea({id = \"DamagedPageDown\", x1 = -1, x2 = -1, y1 = -1, y2 = -1})\n AddClickArea({id = \"DamagedPageUp\", x1 = -1, x2 = -1, y1 = -1, y2 = -1})\n AddClickArea({id = \"BrokenPageDown\", x1 = -1, x2 = -1, y1 = -1, y2 = -1})\n AddClickArea({id = \"BrokenPageUp\", x1 = -1, x2 = -1, y1 = -1, y2 = -1})\nend\n\nfunction FlushClickAreas() clickAreas = {} end\n\nfunction CheckClick(x, y, HitTarget)\n HitTarget = HitTarget or \"\"\n if HitTarget == \"\" then\n for k, v in pairs(clickAreas) do\n if v and x >= v.x1 and x <= v.x2 and y >= v.y1 and y <= v.y2 then\n HitTarget = v.id\n break\n end\n end\n end\n if HitTarget == \"DamagedDamage\" then\n DamagedSortingMode = 1\n CurrentDamagedPage = 1\n SortTables()\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"DamagedHealth\" then\n DamagedSortingMode = 3\n CurrentDamagedPage = 1\n SortTables()\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"DamagedID\" then\n DamagedSortingMode = 2\n CurrentDamagedPage = 1\n SortTables()\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"BrokenDamage\" then\n BrokenSortingMode = 1\n CurrentBrokenPage = 1\n SortTables()\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"BrokenID\" then\n BrokenSortingMode = 2\n CurrentBrokenPage = 1\n SortTables()\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"DamagedPageDown\" then\n CurrentDamagedPage = CurrentDamagedPage + 1\n if CurrentDamagedPage > math.ceil(#damagedElements / 12) then\n CurrentDamagedPage = math.ceil(#damagedElements / 12)\n end\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"DamagedPageUp\" then\n CurrentDamagedPage = CurrentDamagedPage - 1\n if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"BrokenPageDown\" then\n CurrentBrokenPage = CurrentBrokenPage + 1\n if CurrentBrokenPage > math.ceil(#brokenElements / 12) then\n CurrentBrokenPage = math.ceil(#brokenElements / 12)\n end\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"BrokenPageUp\" then\n CurrentBrokenPage = CurrentBrokenPage - 1\n if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"ToggleHudMode\" then\n if HUDMode == true then\n HUDMode = false\n forceRedraw = true\n HudDeselectElement()\n DrawScreens()\n else\n HUDMode = true\n forceRedraw = true\n HudDeselectElement()\n DrawScreens()\n end\n elseif HitTarget == \"ToggleSimulation\" then\n CurrentDamagedPage = 1\n CurrentBrokenPage = 1\n if SimulationMode == true then\n SimulationMode = false\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n HudDeselectElement()\n DrawScreens()\n else\n SimulationMode = true\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n HudDeselectElement()\n DrawScreens()\n end\n elseif HitTarget == \"ToggleElementLabel\" or HitTarget ==\n \"ToggleElementLabel2\" then\n if UseMyElementNames == true then\n UseMyElementNames = false\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n HudDeselectElement()\n DrawScreens()\n else\n UseMyElementNames = true\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n HudDeselectElement()\n DrawScreens()\n end\n end\nend\n\nfunction ToggleHUD()\n HideHighlight()\n CheckClick(nil, nil, \"ToggleHudMode\")\nend\n\nfunction HudDeselectElement()\n if HUDMode == true then\n hudSelectedType = 0\n hudSelectedIndex = 0\n HideHighlight()\n DrawScreens()\n end\nend\n\nfunction ChangeHudSelectedElement(step)\n if HUDMode == true and (#damagedElements or #brokenElements) then\n local damagedElementsHUD = 12\n if #damagedElements < 12 then\n damagedElementsHUD = #damagedElements\n end\n local brokenElementsHUD = 12\n if #brokenElements < 12 then brokenElementsHUD = #brokenElements end\n if step == 1 then\n if hudSelectedIndex == 0 then\n if damagedElementsHUD > 0 then\n hudSelectedType = 1\n hudSelectedIndex = 1\n elseif brokenElementsHUD > 0 then\n hudSelectedType = 2\n hudSelectedIndex = 1\n end\n elseif hudSelectedType == 1 then\n if damagedElementsHUD > hudSelectedIndex then\n hudSelectedIndex = hudSelectedIndex + 1\n elseif brokenElementsHUD > 0 then\n hudSelectedType = 2\n hudSelectedIndex = 1\n elseif damagedElementsHUD > 0 then\n hudSelectedIndex = 1\n end\n elseif hudSelectedType == 2 then\n if brokenElementsHUD > hudSelectedIndex then\n hudSelectedIndex = hudSelectedIndex + 1\n elseif damagedElementsHUD > 0 then\n hudSelectedType = 1\n hudSelectedIndex = 1\n elseif brokenElementsHUD > 0 then\n hudSelectedIndex = 1\n end\n end\n elseif step == -1 then\n if hudSelectedIndex == 0 then\n if brokenElementsHUD > 0 then\n hudSelectedType = 2\n hudSelectedIndex = 1\n elseif damagedElementsHUD > 0 then\n hudSelectedType = 1\n hudSelectedIndex = 1\n end\n elseif hudSelectedType == 1 then\n if hudSelectedIndex > 1 then\n hudSelectedIndex = hudSelectedIndex - 1\n elseif brokenElementsHUD > 0 then\n hudSelectedType = 2\n hudSelectedIndex = brokenElementsHUD\n elseif damagedElementsHUD > 0 then\n hudSelectedIndex = damagedElementsHUD\n end\n elseif hudSelectedType == 2 then\n if hudSelectedIndex > 1 then\n hudSelectedIndex = hudSelectedIndex - 1\n elseif damagedElementsHUD > 0 then\n hudSelectedType = 1\n hudSelectedIndex = damagedElementsHUD\n elseif brokenElementsHUD > 0 then\n hudSelectedIndex = brokenElementsHUD\n end\n end\n end\n HighlightElement()\n DrawScreens()\n -- PrintDebug(\"-> Type: \"..hudSelectedType.. \" Index: \"..hudSelectedIndex)\n end\nend\n\nfunction HideHighlight()\n if #hudArrowSticker > 0 then\n for i in pairs(hudArrowSticker) do\n core.deleteSticker(hudArrowSticker[i])\n end\n hudArrowSticker = {}\n end\nend\n\nfunction ShowHighlight()\n if highlightOn == true and highlightID > 0 then\n table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX + 2,\n highlightY,\n highlightZ, \"north\"))\n table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,\n highlightY - 2,\n highlightZ, \"east\"))\n table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX - 2,\n highlightY,\n highlightZ, \"south\"))\n table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,\n highlightY + 2,\n highlightZ, \"west\"))\n table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,\n highlightY,\n highlightZ - 2,\n \"up\"))\n table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,\n highlightY,\n highlightZ + 2,\n \"down\"))\n end\nend\n\nfunction ToggleHighlight()\n if highlightOn == true then\n highlightOn = false\n HideHighlight()\n else\n highlightOn = true\n ShowHighlight()\n end\nend\n\nfunction HighlightElement(elementID)\n elementID = elementID or 0\n local targetElement = {}\n\n if elementID == 0 then\n if hudSelectedType == 1 then\n elementID = damagedElements[(CurrentDamagedPage - 1) * 12 +\n hudSelectedIndex].id\n elseif hudSelectedType == 2 then\n elementID = brokenElements[(CurrentBrokenPage - 1) * 12 +\n hudSelectedIndex].id\n end\n\n if elementID ~= 0 then\n local bFound = false\n for k, v in pairs(damagedElements) do\n if v.id == elementID then\n targetElement = v\n bFound = true\n break\n end\n end\n if bFound == false then\n for k, v in pairs(brokenElements) do\n if v.id == elementID then\n targetElement = v\n bFound = true\n break\n end\n end\n end\n\n if bFound == true and AllowElementHighlighting == true then\n HideHighlight()\n elementPosition = vec3(targetElement.pos)\n highlightX = elementPosition.x - coreWorldOffset\n highlightY = elementPosition.y - coreWorldOffset\n highlightZ = elementPosition.z - coreWorldOffset\n highlightID = targetElement.id\n highlightOn = true\n ShowHighlight()\n end\n end\n end\nend\n\nfunction SortTables()\n -- Sort damaged elements descending by percent damaged according to setting\n if DamagedSortingMode == 1 then\n table.sort(damagedElements,\n function(a, b) return a.missinghp > b.missinghp end)\n elseif DamagedSortingMode == 2 then\n table.sort(damagedElements, function(a, b) return a.id < b.id end)\n else\n table.sort(damagedElements,\n function(a, b) return a.percent < b.percent end)\n end\n\n -- Sort broken elements descending according to setting\n if BrokenSortingMode == 1 then\n table.sort(brokenElements, function(a, b)\n return a.maxhp > b.maxhp\n end)\n else\n table.sort(brokenElements, function(a, b) return a.id < b.id end)\n end\nend\n\nfunction GenerateDamageData()\n if SimulationActive == true then return end\n\n local formerTotalShipHP = totalShipHP\n totalShipHP = 0\n totalShipMaxHP = 0\n totalShipIntegrity = 100\n elementsId = {}\n damagedElements = {}\n brokenElements = {}\n ElementCounter = 0\n healthyElements = 0\n\n elementsIdList = core.getElementIdList()\n\n for _, id in pairs(elementsIdList) do\n ElementCounter = ElementCounter + 1\n idHP = core.getElementHitPointsById(id) or 0\n idMaxHP = core.getElementMaxHitPointsById(id) or 0\n\n if SimulationMode then\n SimulationActive = true\n local dice = math.random(0, 10)\n if dice < 2 then\n idHP = 0\n elseif dice >= 2 and dice < 5 then\n idHP = idMaxHP\n else\n idHP = math.random(1, math.ceil(idMaxHP))\n end\n end\n\n totalShipHP = totalShipHP + idHP\n totalShipMaxHP = totalShipMaxHP + idMaxHP\n\n idName = core.getElementNameById(id)\n\n -- Is element damaged?\n if idMaxHP > idHP then\n idPos = core.getElementPositionById(id)\n idType = core.getElementTypeById(id)\n if idHP > 0 then\n table.insert(damagedElements, {\n id = id,\n name = idName,\n type = idType,\n counter = ElementCounter,\n hp = idHP,\n maxhp = idMaxHP,\n missinghp = idMaxHP - idHP,\n percent = math.ceil(100 / idMaxHP * idHP),\n pos = idPos\n })\n -- if DebugMode then PrintDebug(\"Damaged: \"..idName..\" --- Type: \"..idType..\"\") end\n -- Is element broken?\n else\n table.insert(brokenElements, {\n id = id,\n name = idName,\n type = idType,\n counter = ElementCounter,\n hp = idHP,\n maxhp = idMaxHP,\n missinghp = idMaxHP - idHP,\n percent = 0,\n pos = idPos\n })\n -- if DebugMode then PrintDebug(\"Broken: \"..idName..\" --- Type: \"..idType..\"\") end\n end\n else\n healthyElements = healthyElements + 1\n if id == highlightID then\n highlightID = 0\n end\n end\n end\n\n -- Sort tables by current settings \n SortTables()\n\n -- Update clickAreas\n\n -- Determine total ship integrity\n totalShipIntegrity = string.format(\"%2.0f\",\n 100 / totalShipMaxHP * totalShipHP)\n\n -- Has anything changes since last check? If yes, force redrawing the screens\n if formerTotalShipHP ~= totalShipHP then\n forceRedraw = true\n formerTotalShipHP = totalShipHP\n else\n forceRedraw = false\n end\nend\n\nfunction GetAllSystemsNominalBackground()\n local output = \"\"\n output = output .. [[\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ]]\n return output\nend\n\nfunction GetDRLogo()\n output =\n [[]]\n return output\nend\n\nfunction GenerateHUDOutput()\n\n local hudWidth = 300\n local hudHeight = 125\n if #damagedElements > 0 or #brokenElements > 0 then hudHeight = 780 end\n local screenHeight = 1080\n\n local healthyColor = \"#00aa00\"\n local brokenColor = \"#aa0000\"\n local damagedColor = \"#aaaa00\"\n local integrityColor = \"#aaaaaa\"\n local healthyTextColor = \"white\"\n local brokenTextColor = \"#ff4444\"\n local damagedTextColor = \"#ffff44\"\n local integrityTextColor = \"white\"\n\n if #damagedElements == 0 then\n damagedColor = \"#aaaaaa\"\n damagedTextColor = \"white\"\n end\n if #brokenElements == 0 then\n brokenColor = \"#aaaaaa\"\n brokenTextColor = \"white\"\n end\n\n local hudOutput = \"\"\n\n -- Draw Header\n hudOutput = hudOutput .. [[\n ]]\n\n hudOutput = hudOutput .. [[]] ..\n [[]] .. GetDRLogo() .. [[]]\n\n hudOutput = hudOutput .. [[\n \n ]] .. healthyElements ..\n [[\n \n ]] .. #damagedElements ..\n [[\n \n ]] .. #brokenElements ..\n [[]]\n if #damagedElements > 0 or #brokenElements > 0 then\n hudOutput = hudOutput ..\n [[ ]] ..\n [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", totalShipMaxHP - totalShipHP)) ..\n [[ HP damage in total]]\n else\n hudOutput = hudOutput .. [[]] ..\n OkayCenterMessage .. [[]] ..\n [[Ship stands ]] ..\n GenerateCommaValue(string.format(\"%.0f\", totalShipMaxHP)) ..\n [[ HP strong.]]\n\n end\n hudOutput = hudOutput .. [[]]\n\n hudRowDistance = 25\n if #damagedElements > 0 then\n local damagedElementsToDraw = #damagedElements\n if damagedElementsToDraw > 12 then damagedElementsToDraw = 12 end\n if CurrentDamagedPage == math.ceil(#damagedElements / 12) then\n damagedElementsToDraw = #damagedElements % 12\n end\n local i = 0\n hudOutput = hudOutput .. [[]] ..\n [[]]\n\n for j = 1 + (CurrentDamagedPage - 1) * 12, damagedElementsToDraw +\n (CurrentDamagedPage - 1) * 12, 1 do\n i = i + 1\n local DP = damagedElements[j]\n if (hudSelectedType == 1 and hudSelectedIndex == i) then\n hudOutput = hudOutput .. [[]]\n if UseMyElementNames == true then\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.name) ..\n [[]]\n else\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.type) ..\n [[]]\n end\n if (DamagedSortingMode == 3) then\n hudOutput = hudOutput .. [[]] .. DP.percent ..\n [[%]]\n else\n hudOutput = hudOutput .. [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", DP.missinghp)) ..\n [[]]\n end\n else\n if UseMyElementNames == true then\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.name) ..\n [[]]\n else\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.type) ..\n [[]]\n end\n if (DamagedSortingMode == 3) then\n hudOutput = hudOutput .. [[]] .. DP.percent ..\n [[%]]\n else\n hudOutput = hudOutput .. [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", DP.missinghp)) ..\n [[]]\n end\n hudOutput = hudOutput .. [[]]\n end\n end\n hudOutput = hudOutput .. [[]]\n end\n\n if #brokenElements > 0 then\n local brokenElementsToDraw = #brokenElements\n if brokenElementsToDraw > 12 then brokenElementsToDraw = 12 end\n if CurrentbrokenPage == math.ceil(#brokenElements / 12) then\n brokenElementsToDraw = #brokenElements % 12\n end\n local i = 0\n hudOutput = hudOutput .. [[]] ..\n [[]]\n\n for j = 1 + (CurrentBrokenPage - 1) * 12, brokenElementsToDraw +\n (CurrentBrokenPage - 1) * 12, 1 do\n i = i + 1\n local DP = brokenElements[j]\n if (hudSelectedType == 2 and hudSelectedIndex == i) then\n hudOutput = hudOutput .. [[]]\n if UseMyElementNames == true then\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.name) ..\n [[]]\n else\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.type) ..\n [[]]\n end\n if (brokenSortingMode == 3) then\n hudOutput = hudOutput .. [[]] .. DP.percent ..\n [[%]]\n else\n hudOutput = hudOutput .. [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", DP.missinghp)) ..\n [[]]\n end\n else\n if UseMyElementNames == true then\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.name) ..\n [[]]\n else\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.type) ..\n [[]]\n end\n if (brokenSortingMode == 3) then\n hudOutput = hudOutput .. [[]] .. DP.percent ..\n [[%]]\n else\n hudOutput = hudOutput .. [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", DP.missinghp)) ..\n [[]]\n end\n hudOutput = hudOutput .. [[]]\n end\n end\n hudOutput = hudOutput .. [[]]\n end\n\n if #damagedElements or #brokenElements then\n hudOutput = hudOutput .. [[]] ..\n [[Use up/down arrows to select element to find.]] ..\n [[Use right arrow to deselect.]] ..\n [[Use left arrow to exit HUD mode.]] ..\n [[]]\n end\n\n hudOutput = hudOutput .. [[]]\n\n return hudOutput\nend\n\nfunction DrawScreens()\n if #screens > 0 then\n\n local healthyColor = \"#00aa00\"\n local brokenColor = \"#aa0000\"\n local damagedColor = \"#aaaa00\"\n local integrityColor = \"#aaaaaa\"\n local healthyTextColor = \"white\"\n local brokenTextColor = \"#ff4444\"\n local damagedTextColor = \"#ffff44\"\n local integrityTextColor = \"white\"\n\n if #damagedElements == 0 then\n damagedColor = \"#aaaaaa\"\n damagedTextColor = \"white\"\n end\n if #brokenElements == 0 then\n brokenColor = \"#aaaaaa\"\n brokenTextColor = \"white\"\n end\n\n local screenOutput = \"\"\n\n -- Draw Header\n screenOutput = screenOutput ..\n [[\n ]]\n\n -- Draw main background\n screenOutput = screenOutput ..\n [[\n \n \n \n \n \n \n \n \n \n \n \n ]]\n\n -- Draw Title and summary\n if SimulationActive == true then\n screenOutput = screenOutput ..\n [[Simulated Report]]\n else\n screenOutput = screenOutput ..\n [[Damage Report]]\n end\n if YourShipsName == nil or YourShipsName == \"\" or YourShipsName ==\n \"Enter here\" then\n screenOutput = screenOutput ..\n [[SHIP ID ]] ..\n shipID .. [[]]\n else\n screenOutput = screenOutput ..\n [[]] ..\n YourShipsName .. [[]]\n end\n screenOutput = screenOutput .. [[\n Healthy\n ]] .. healthyElements ..\n [[\n\n Damaged\n ]] .. #damagedElements ..\n [[\n\n Broken\n ]] .. #brokenElements ..\n [[\n\n Integrity\n ]] .. totalShipIntegrity ..\n [[%]]\n\n -- Draw damage elements\n\n if #damagedElements > 0 then\n local damagedElementsToDraw = #damagedElements\n if damagedElementsToDraw > 12 then\n damagedElementsToDraw = 12\n end\n if CurrentDamagedPage == math.ceil(#damagedElements / 12) then\n damagedElementsToDraw = #damagedElements % 12\n end\n screenOutput = screenOutput ..\n [[]]\n screenOutput = screenOutput ..\n [[]]\n if (DamagedSortingMode == 2) then\n screenOutput = screenOutput ..\n [[ID]]\n else\n screenOutput = screenOutput ..\n [[ID]]\n end\n if UseMyElementNames == true then\n screenOutput = screenOutput ..\n [[Element Name]]\n else\n screenOutput = screenOutput ..\n [[Element Type]]\n end\n\n if (DamagedSortingMode == 3) then\n screenOutput = screenOutput ..\n [[Health]]\n else\n screenOutput = screenOutput ..\n [[Health]]\n end\n if (DamagedSortingMode == 1) then\n screenOutput = screenOutput ..\n [[Damage]]\n else\n screenOutput = screenOutput ..\n [[Damage]]\n end\n\n local i = 0\n for j = 1 + (CurrentDamagedPage - 1) * 12, damagedElementsToDraw +\n (CurrentDamagedPage - 1) * 12, 1 do\n i = i + 1\n local DP = damagedElements[j]\n screenOutput = screenOutput .. [[]] ..\n string.format(\"%03.0f\", DP.id) .. [[]]\n if UseMyElementNames == true then\n screenOutput = screenOutput .. [[]] ..\n string.format(\"%.25s\", DP.name) ..\n [[]]\n else\n screenOutput = screenOutput .. [[]] ..\n string.format(\"%.25s\", DP.type) ..\n [[]]\n end\n screenOutput = screenOutput .. [[]] ..\n DP.percent .. [[%]] ..\n [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", DP.missinghp)) ..\n [[]] ..\n [[]]\n end\n screenOutput = screenOutput ..\n [[\n \n ]]\n\n if #damagedElements > 12 then\n screenOutput = screenOutput ..\n [[Page ]] ..\n CurrentDamagedPage .. \" of \" ..\n math.ceil(#damagedElements / 12) ..\n [[]]\n\n if CurrentDamagedPage < math.ceil(#damagedElements / 12) then\n screenOutput = screenOutput .. [[\n \n \n ]]\n UpdateClickArea(\"DamagedPageDown\", {\n id = \"DamagedPageDown\",\n x1 = 70,\n x2 = 270,\n y1 = 350 + 11 + (damagedElementsToDraw + 1) * 50,\n y2 = 350 + 11 + 50 + (damagedElementsToDraw + 1) * 50\n })\n else\n DisableClickArea(\"DamagedPageDown\")\n end\n\n if CurrentDamagedPage > 1 then\n screenOutput = screenOutput .. [[\n \n \n ]]\n UpdateClickArea(\"DamagedPageUp\", {\n id = \"DamagedPageUp\",\n x1 = 280,\n x2 = 480,\n y1 = 350 + 11 + (damagedElementsToDraw + 1) * 50,\n y2 = 350 + 11 + 50 + (damagedElementsToDraw + 1) * 50\n })\n else\n DisableClickArea(\"DamagedPageUp\")\n end\n end\n end\n\n -- Draw broken elements\n if #brokenElements > 0 then\n local brokenElementsToDraw = #brokenElements\n if brokenElementsToDraw > 12 then\n brokenElementsToDraw = 12\n end\n if CurrentBrokenPage == math.ceil(#brokenElements / 12) then\n brokenElementsToDraw = #brokenElements % 12\n end\n screenOutput = screenOutput ..\n [[]]\n screenOutput = screenOutput ..\n [[]]\n if (BrokenSortingMode == 2) then\n screenOutput = screenOutput ..\n [[ID]]\n else\n screenOutput = screenOutput ..\n [[ID]]\n end\n if UseMyElementNames == true then\n screenOutput = screenOutput ..\n [[Element Name]]\n else\n screenOutput = screenOutput ..\n [[Element Type]]\n end\n if (BrokenSortingMode == 1) then\n screenOutput = screenOutput ..\n [[Damage]]\n else\n screenOutput = screenOutput ..\n [[Damage]]\n end\n\n local i = 0\n for j = 1 + (CurrentBrokenPage - 1) * 12, brokenElementsToDraw +\n (CurrentBrokenPage - 1) * 12, 1 do\n i = i + 1\n local DP = brokenElements[j]\n screenOutput = screenOutput .. [[]] ..\n string.format(\"%03.0f\", DP.id) .. [[]]\n if UseMyElementNames == true then\n screenOutput = screenOutput .. [[]] ..\n string.format(\"%.25s\", DP.name) ..\n [[]]\n else\n screenOutput = screenOutput .. [[]] ..\n string.format(\"%.25s\", DP.type) ..\n [[]]\n end\n screenOutput = screenOutput .. [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", DP.missinghp)) ..\n [[]] ..\n [[]]\n end\n\n screenOutput = screenOutput ..\n [[\n \n ]]\n\n if #brokenElements > 12 then\n screenOutput = screenOutput ..\n [[Page ]] ..\n CurrentBrokenPage .. \" of \" ..\n math.ceil(#brokenElements / 12) ..\n [[]]\n\n if CurrentBrokenPage > 1 then\n screenOutput = screenOutput .. [[\n \n \n ]]\n UpdateClickArea(\"BrokenPageUp\", {\n id = \"BrokenPageUp\",\n x1 = 1442,\n x2 = 1642,\n y1 = 350 + 11 + (brokenElementsToDraw + 1) * 50,\n y2 = 350 + 11 + 50 + (brokenElementsToDraw + 1) * 50\n })\n else\n DisableClickArea(\"BrokenPageUp\")\n end\n\n if CurrentBrokenPage < math.ceil(#brokenElements / 12) then\n screenOutput = screenOutput .. [[\n \n \n ]]\n UpdateClickArea(\"BrokenPageDown\", {\n id = \"BrokenPageDown\",\n x1 = 1652,\n x2 = 1852,\n y1 = 350 + 11 + (brokenElementsToDraw + 1) * 50,\n y2 = 350 + 11 + 50 + (brokenElementsToDraw + 1) * 50\n })\n else\n DisableClickArea(\"BrokenPageDown\")\n end\n end\n\n end\n\n -- Draw damage summary\n if #damagedElements > 0 or #brokenElements > 0 then\n screenOutput = screenOutput ..\n [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\",\n totalShipMaxHP - totalShipHP)) ..\n [[ HP damage in total]]\n else\n screenOutput = screenOutput .. [[]] ..\n GetAllSystemsNominalBackground() .. [[]] ..\n [[]] ..\n OkayCenterMessage .. [[]] ..\n [[Ship stands ]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", totalShipMaxHP)) ..\n [[ HP strong.]]\n end\n\n -- Draw HUD Mode button\n if HUDMode == true then\n screenOutput = screenOutput ..\n [[]] ..\n [[HUD Mode activated]]\n\n else\n screenOutput = screenOutput ..\n [[]] ..\n [[Activate HUD Mode]]\n end\n\n screenOutput = screenOutput .. [[]]\n\n if HUDMode == true then\n system.setScreen(GenerateHUDOutput())\n system.showScreen(1)\n else\n system.showScreen(0)\n end\n\n DrawSVG(screenOutput)\n\n forceRedraw = false\n end\nend\n\n-----------------------------------------------\n-- Execute\n-----------------------------------------------\n\nunit.hide()\nClearConsole()\nPrintDebug(\"SCRIPT STARTED\", true)\n\nInitiateSlots()\nSwitchScreens(true)\nInitiateClickAreas()\n\nif core == nil then\n DrawCenteredText(\"ERROR: No core connected.\")\n PrintError(\"ERROR: No core connected.\")\n goto exit\nelse\n shipID = core.getConstructId()\nend\n\nGenerateDamageData()\nif forceRedraw then DrawScreens() end\n\nunit.setTimer('UpdateData', UpdateInterval)\nunit.setTimer('UpdateHighlight', HighlightBlinkingInterval)\n\n::exit::\n",
- "filter": {
- "args": [],
- "signature": "start()",
- "slotKey": "-1"
- },
- "key": "9"
- },
- {
- "code": "HideHighlight()\nSwitchScreens(false)\n",
- "filter": {
- "args": [],
- "signature": "stop()",
- "slotKey": "-1"
- },
- "key": "10"
- },
- {
- "code": "GenerateDamageData()\nif forceRedraw then\n DrawScreens()\nend",
- "filter": {
- "args": [
- {
- "value": "UpdateData"
- }
- ],
- "signature": "tick(timerId)",
- "slotKey": "-1"
- },
- "key": "11"
- },
- {
- "code": "ToggleHighlight()",
- "filter": {
- "args": [
- {
- "value": "UpdateHighlight"
- }
- ],
- "signature": "tick(timerId)",
- "slotKey": "-1"
- },
- "key": "12"
- },
- {
- "code": "HudDeselectElement()",
- "filter": {
- "args": [
- {
- "value": "straferight"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "13"
- },
- {
- "code": "ToggleHUD()",
- "filter": {
- "args": [
- {
- "value": "strafeleft"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "14"
- },
- {
- "code": "ChangeHudSelectedElement(1)",
- "filter": {
- "args": [
- {
- "value": "down"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "15"
- },
- {
- "code": "ChangeHudSelectedElement(-1)",
- "filter": {
- "args": [
- {
- "value": "up"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "16"
- }
- ],
- "methods": [],
- "events": []
-}
\ No newline at end of file
diff --git a/versions/DamageReport_2_3.json b/versions/DamageReport_2_3.json
deleted file mode 100644
index 24209b4..0000000
--- a/versions/DamageReport_2_3.json
+++ /dev/null
@@ -1,339 +0,0 @@
-{
- "slots": {
- "0": {
- "name": "core",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "1": {
- "name": "slot2",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "2": {
- "name": "slot3",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "3": {
- "name": "slot4",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "4": {
- "name": "slot5",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "5": {
- "name": "slot6",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "6": {
- "name": "slot7",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "7": {
- "name": "slot8",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "8": {
- "name": "slot9",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "9": {
- "name": "slot10",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-1": {
- "name": "unit",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-2": {
- "name": "system",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-3": {
- "name": "library",
- "type": {
- "events": [],
- "methods": []
- }
- }
- },
- "handlers": [
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "1"
- },
- "key": "0"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "2"
- },
- "key": "1"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "3"
- },
- "key": "2"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "4"
- },
- "key": "3"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "5"
- },
- "key": "4"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "6"
- },
- "key": "5"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "7"
- },
- "key": "6"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "8"
- },
- "key": "7"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "9"
- },
- "key": "8"
- },
- {
- "code": "--[[\n DamageReport v2.3\n\n Created By Dorian Gray\n\n Discord: Dorian Gray#2623\n InGame: DorianGray\n GitHub: https://github.com/DorianTheGrey/DU-DamageReport\n\n GNU Public License 3.0. Use whatever you want, be so kind to leave credit.\n\n Thanks to Jericho, Dmentia and Archaegeo for learning from their fine scripts.\n]] \n-----------------------------------------------\n-- CONFIG\n-----------------------------------------------\nUseMyElementNames = true -- export: If you active this, the display will not show the element type of damaged/broken elements but the name you gave them (truncated to 25 characters)\nAllowElementHighlighting = true -- export: Are you allowing damaged/broken elements to be highlighted in 3D space when selected in the HUD?\nUpdateInterval = 1 -- export: Interval in seconds between updates of the calculations and (if anything changed) redrawing to the screen(s). You need to restart the script after changing this value.\nHighlightBlinkingInterval = 0.5 -- export: If an element is marked, how fast do you want the arrows to blink?\nSimulationMode = false -- export Randomize simluated damage on elements to check out the functionality of this script. And, no, your elements won't be harmed in the process :) You need to restart the script after changing this value.\nYourShipsName = \"Enter here\" -- export Enter your ship name here if you want it displayed instead of the ship's ID. YOU NEED TO LEAVE THE QUOTATION MARKS.\n\nDebugMode = false -- Activate if you want some console messages\nVersionNumber = 2.3 -- Version number\n\ncore = nil\nscreens = {}\n\nshipID = 0\nforceRedraw = false\nSimulationActive = false\n\nclickAreas = {}\nDamagedSortingMode = 1 -- Define default sorting mode for damaged elements. 1 to sort by damage amount, 2 to sort by element id, 3 to sort by damage percent, \nBrokenSortingMode = 1 -- Define default sorting mode for broken elements. 1 to sort by damage amount, 2 to sort by element id\n\nHUDMode = false -- Is Hud active?\nhudSelectedIndex = 0 -- Which element is selected?\nhudSelectedType = 0 -- Is selected element damaged (1) or broken (2)\nhudArrowSticker = {}\nhighlightOn = false\nhighlightID = 0\nhighlightX = 0\nhighlightY = 0\nhighlightZ = 0\n\nCurrentDamagedPage = 1\nCurrentBrokenPage = 1\n\ncoreWorldOffset = 0\ntotalShipHP = 0\ntotalShipMaxHP = 0\ntotalShipIntegrity = 100\nelementsId = {}\ndamagedElements = {}\nbrokenElements = {}\nElementCounter = 0\nhealthyElements = 0\n\nOkayCenterMessage = \"All systems nominal.\"\n\n-----------------------------------------------\n-- FUNCTIONS\n-----------------------------------------------\n\nfunction GenerateCommaValue(amount)\n local formatted = amount\n while true do\n formatted, k = string.gsub(formatted, \"^(-?%d+)(%d%d%d)\", '%1,%2')\n if (k == 0) then break end\n end\n return formatted\nend\n\nfunction PrintDebug(output, highlight)\n highlight = highlight or false\n if DebugMode then\n if highlight then\n system.print(\n \"------------------------------------------------------------------------\")\n end\n system.print(output)\n if highlight then\n system.print(\n \"------------------------------------------------------------------------\")\n end\n end\nend\n\nfunction PrintError(output) system.print(output) end\n\nfunction DrawCenteredText(output)\n for i = 1, #screens, 1 do screens[i].setCenteredText(output) end\nend\n\nfunction DrawSVG(output) for i = 1, #screens, 1 do screens[i].setSVG(output) end end\n\nfunction ClearConsole() for i = 1, 10, 1 do PrintDebug() end end\n\nfunction SwitchScreens(state)\n state = state or true\n if #screens > 0 then\n for i = 1, #screens, 1 do\n if state==true then\n screens[i].clear()\n screens[i].activate()\n else\n screens[i].deactivate()\n screens[i].clear()\n end\n end\n end\nend\n\nfunction InitiateSlots()\n for slot_name, slot in pairs(unit) do\n if type(slot) == \"table\" and type(slot.export) == \"table\" and\n slot.getElementClass then\n if slot.getElementClass():lower():find(\"coreunit\") then\n core = slot\n local coreHP = core.getMaxHitPoints()\n if coreHP > 10000 then\n coreWorldOffset = 128\n elseif coreHP > 1000 then\n coreWorldOffset = 64\n elseif coreHP > 150 then\n coreWorldOffset = 32\n else\n coreWorldOffset = 16\n end\n end\n if slot.getElementClass():lower():find(\"screenunit\") then\n screens[#screens + 1] = slot\n end\n end\n end\nend\n\nfunction AddClickArea(newEntry) table.insert(clickAreas, newEntry) end\n\nfunction RemoveFromClickAreas(candidate)\n for k, v in pairs(clickAreas) do\n if v.id == candidate then\n clickAreas[k] = nil\n break\n end\n end\nend\n\nfunction UpdateClickArea(candidate, newEntry)\n for k, v in pairs(clickAreas) do\n if v.id == candidate then\n clickAreas[k] = newEntry\n break\n end\n end\nend\n\nfunction DisableClickArea(candidate)\n for k, v in pairs(clickAreas) do\n if v.id == candidate then\n UpdateClickArea(candidate, {\n id = candidate,\n x1 = -1,\n x2 = -1,\n y1 = -1,\n y2 = -1\n })\n break\n end\n end\nend\n\nfunction InitiateClickAreas()\n clickAreas = {}\n AddClickArea({id = \"DamagedDamage\", x1 = 725, x2 = 870, y1 = 380, y2 = 415})\n AddClickArea({id = \"DamagedHealth\", x1 = 520, x2 = 655, y1 = 380, y2 = 415})\n AddClickArea({id = \"DamagedID\", x1 = 90, x2 = 150, y1 = 380, y2 = 415})\n AddClickArea({id = \"BrokenDamage\", x1 = 1675, x2 = 1835, y1 = 380, y2 = 415})\n AddClickArea({id = \"BrokenID\", x1 = 1050, x2 = 1110, y1 = 380, y2 = 415})\n AddClickArea({id = \"ToggleSimulation\", x1 = 65, x2 = 660, y1 = 100, y2 = 145})\n AddClickArea({id = \"ToggleSimulation2\", x1 = 1650, x2 = 1850, y1 = 75, y2 = 117})\n AddClickArea({id = \"ToggleElementLabel\", x1 = 225, x2 = 460, y1 = 380, y2 = 415})\n AddClickArea({id = \"ToggleElementLabel2\", x1 = 1185, x2 = 1440, y1 = 380, y2 = 415})\n AddClickArea({id = \"ToggleHudMode\", x1 = 1650, x2 = 1850, y1 = 125, y2 = 167})\n AddClickArea({id = \"DamagedPageDown\", x1 = -1, x2 = -1, y1 = -1, y2 = -1})\n AddClickArea({id = \"DamagedPageUp\", x1 = -1, x2 = -1, y1 = -1, y2 = -1})\n AddClickArea({id = \"BrokenPageDown\", x1 = -1, x2 = -1, y1 = -1, y2 = -1})\n AddClickArea({id = \"BrokenPageUp\", x1 = -1, x2 = -1, y1 = -1, y2 = -1})\nend\n\nfunction FlushClickAreas() clickAreas = {} end\n\nfunction CheckClick(x, y, HitTarget)\n HitTarget = HitTarget or \"\"\n if HitTarget == \"\" then\n for k, v in pairs(clickAreas) do\n if v and x >= v.x1 and x <= v.x2 and y >= v.y1 and y <= v.y2 then\n HitTarget = v.id\n break\n end\n end\n end\n if HitTarget == \"DamagedDamage\" then\n DamagedSortingMode = 1\n CurrentDamagedPage = 1\n SortTables()\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"DamagedHealth\" then\n DamagedSortingMode = 3\n CurrentDamagedPage = 1\n SortTables()\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"DamagedID\" then\n DamagedSortingMode = 2\n CurrentDamagedPage = 1\n SortTables()\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"BrokenDamage\" then\n BrokenSortingMode = 1\n CurrentBrokenPage = 1\n SortTables()\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"BrokenID\" then\n BrokenSortingMode = 2\n CurrentBrokenPage = 1\n SortTables()\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"DamagedPageDown\" then\n CurrentDamagedPage = CurrentDamagedPage + 1\n if CurrentDamagedPage > math.ceil(#damagedElements / 12) then\n CurrentDamagedPage = math.ceil(#damagedElements / 12)\n end\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"DamagedPageUp\" then\n CurrentDamagedPage = CurrentDamagedPage - 1\n if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"BrokenPageDown\" then\n CurrentBrokenPage = CurrentBrokenPage + 1\n if CurrentBrokenPage > math.ceil(#brokenElements / 12) then\n CurrentBrokenPage = math.ceil(#brokenElements / 12)\n end\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"BrokenPageUp\" then\n CurrentBrokenPage = CurrentBrokenPage - 1\n if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"ToggleHudMode\" then\n if HUDMode == true then\n HUDMode = false\n forceRedraw = true\n HudDeselectElement()\n DrawScreens()\n else\n HUDMode = true\n forceRedraw = true\n HudDeselectElement()\n DrawScreens()\n end\n elseif HitTarget == \"ToggleSimulation\" or HitTarget == \"ToggleSimulation2\" then\n CurrentDamagedPage = 1\n CurrentBrokenPage = 1\n if SimulationMode == true then\n SimulationMode = false\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n HudDeselectElement()\n DrawScreens()\n else\n SimulationMode = true\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n HudDeselectElement()\n DrawScreens()\n end\n elseif HitTarget == \"ToggleElementLabel\" or HitTarget ==\n \"ToggleElementLabel2\" then\n if UseMyElementNames == true then\n UseMyElementNames = false\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n HudDeselectElement()\n DrawScreens()\n else\n UseMyElementNames = true\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n HudDeselectElement()\n DrawScreens()\n end\n end\nend\n\nfunction ToggleHUD()\n HideHighlight()\n CheckClick(nil, nil, \"ToggleHudMode\")\nend\n\nfunction HudDeselectElement()\n if HUDMode == true then\n hudSelectedType = 0\n hudSelectedIndex = 0\n HideHighlight()\n DrawScreens()\n end\nend\n\nfunction ChangeHudSelectedElement(step)\n if HUDMode == true and (#damagedElements or #brokenElements) then\n local damagedElementsHUD = 12\n if #damagedElements < 12 then\n damagedElementsHUD = #damagedElements\n end\n local brokenElementsHUD = 12\n if #brokenElements < 12 then brokenElementsHUD = #brokenElements end\n if step == 1 then\n if hudSelectedIndex == 0 then\n if damagedElementsHUD > 0 then\n hudSelectedType = 1\n hudSelectedIndex = 1\n elseif brokenElementsHUD > 0 then\n hudSelectedType = 2\n hudSelectedIndex = 1\n end\n elseif hudSelectedType == 1 then\n if damagedElementsHUD > hudSelectedIndex then\n hudSelectedIndex = hudSelectedIndex + 1\n elseif brokenElementsHUD > 0 then\n hudSelectedType = 2\n hudSelectedIndex = 1\n elseif damagedElementsHUD > 0 then\n hudSelectedIndex = 1\n end\n elseif hudSelectedType == 2 then\n if brokenElementsHUD > hudSelectedIndex then\n hudSelectedIndex = hudSelectedIndex + 1\n elseif damagedElementsHUD > 0 then\n hudSelectedType = 1\n hudSelectedIndex = 1\n elseif brokenElementsHUD > 0 then\n hudSelectedIndex = 1\n end\n end\n elseif step == -1 then\n if hudSelectedIndex == 0 then\n if brokenElementsHUD > 0 then\n hudSelectedType = 2\n hudSelectedIndex = 1\n elseif damagedElementsHUD > 0 then\n hudSelectedType = 1\n hudSelectedIndex = 1\n end\n elseif hudSelectedType == 1 then\n if hudSelectedIndex > 1 then\n hudSelectedIndex = hudSelectedIndex - 1\n elseif brokenElementsHUD > 0 then\n hudSelectedType = 2\n hudSelectedIndex = brokenElementsHUD\n elseif damagedElementsHUD > 0 then\n hudSelectedIndex = damagedElementsHUD\n end\n elseif hudSelectedType == 2 then\n if hudSelectedIndex > 1 then\n hudSelectedIndex = hudSelectedIndex - 1\n elseif damagedElementsHUD > 0 then\n hudSelectedType = 1\n hudSelectedIndex = damagedElementsHUD\n elseif brokenElementsHUD > 0 then\n hudSelectedIndex = brokenElementsHUD\n end\n end\n end\n HighlightElement()\n DrawScreens()\n -- PrintDebug(\"-> Type: \"..hudSelectedType.. \" Index: \"..hudSelectedIndex)\n end\nend\n\nfunction HideHighlight()\n if #hudArrowSticker > 0 then\n for i in pairs(hudArrowSticker) do\n core.deleteSticker(hudArrowSticker[i])\n end\n hudArrowSticker = {}\n end\nend\n\nfunction ShowHighlight()\n if highlightOn == true and highlightID > 0 then\n table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX + 2,\n highlightY,\n highlightZ, \"north\"))\n table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,\n highlightY - 2,\n highlightZ, \"east\"))\n table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX - 2,\n highlightY,\n highlightZ, \"south\"))\n table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,\n highlightY + 2,\n highlightZ, \"west\"))\n table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,\n highlightY,\n highlightZ - 2,\n \"up\"))\n table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,\n highlightY,\n highlightZ + 2,\n \"down\"))\n end\nend\n\nfunction ToggleHighlight()\n if highlightOn == true then\n highlightOn = false\n HideHighlight()\n else\n highlightOn = true\n ShowHighlight()\n end\nend\n\nfunction HighlightElement(elementID)\n elementID = elementID or 0\n local targetElement = {}\n\n if elementID == 0 then\n if hudSelectedType == 1 then\n elementID = damagedElements[(CurrentDamagedPage - 1) * 12 +\n hudSelectedIndex].id\n elseif hudSelectedType == 2 then\n elementID = brokenElements[(CurrentBrokenPage - 1) * 12 +\n hudSelectedIndex].id\n end\n\n if elementID ~= 0 then\n local bFound = false\n for k, v in pairs(damagedElements) do\n if v.id == elementID then\n targetElement = v\n bFound = true\n break\n end\n end\n if bFound == false then\n for k, v in pairs(brokenElements) do\n if v.id == elementID then\n targetElement = v\n bFound = true\n break\n end\n end\n end\n\n if bFound == true and AllowElementHighlighting == true then\n HideHighlight()\n elementPosition = vec3(targetElement.pos)\n highlightX = elementPosition.x - coreWorldOffset\n highlightY = elementPosition.y - coreWorldOffset\n highlightZ = elementPosition.z - coreWorldOffset\n highlightID = targetElement.id\n highlightOn = true\n ShowHighlight()\n end\n end\n end\nend\n\nfunction SortTables()\n -- Sort damaged elements descending by percent damaged according to setting\n if DamagedSortingMode == 1 then\n table.sort(damagedElements,\n function(a, b) return a.missinghp > b.missinghp end)\n elseif DamagedSortingMode == 2 then\n table.sort(damagedElements, function(a, b) return a.id < b.id end)\n else\n table.sort(damagedElements,\n function(a, b) return a.percent < b.percent end)\n end\n\n -- Sort broken elements descending according to setting\n if BrokenSortingMode == 1 then\n table.sort(brokenElements, function(a, b)\n return a.maxhp > b.maxhp\n end)\n else\n table.sort(brokenElements, function(a, b) return a.id < b.id end)\n end\nend\n\nfunction GenerateDamageData()\n if SimulationActive == true then return end\n\n local formerTotalShipHP = totalShipHP\n totalShipHP = 0\n totalShipMaxHP = 0\n totalShipIntegrity = 100\n elementsId = {}\n damagedElements = {}\n brokenElements = {}\n ElementCounter = 0\n healthyElements = 0\n\n elementsIdList = core.getElementIdList()\n\n for _, id in pairs(elementsIdList) do\n ElementCounter = ElementCounter + 1\n idHP = core.getElementHitPointsById(id) or 0\n idMaxHP = core.getElementMaxHitPointsById(id) or 0\n\n if SimulationMode then\n SimulationActive = true\n local dice = math.random(0, 10)\n if dice < 2 then\n idHP = 0\n elseif dice >= 2 and dice < 5 then\n idHP = idMaxHP\n else\n idHP = math.random(1, math.ceil(idMaxHP))\n end\n end\n\n totalShipHP = totalShipHP + idHP\n totalShipMaxHP = totalShipMaxHP + idMaxHP\n\n idName = core.getElementNameById(id)\n idType = core.getElementTypeById(id)\n\n -- Is element damaged?\n if idMaxHP > idHP then\n idPos = core.getElementPositionById(id)\n if idHP > 0 then\n table.insert(damagedElements, {\n id = id,\n name = idName,\n type = idType,\n counter = ElementCounter,\n hp = idHP,\n maxhp = idMaxHP,\n missinghp = idMaxHP - idHP,\n percent = math.ceil(100 / idMaxHP * idHP),\n pos = idPos\n })\n -- if DebugMode then PrintDebug(\"Damaged: \"..idName..\" --- Type: \"..idType..\"\") end\n -- Is element broken?\n else\n table.insert(brokenElements, {\n id = id,\n name = idName,\n type = idType,\n counter = ElementCounter,\n hp = idHP,\n maxhp = idMaxHP,\n missinghp = idMaxHP - idHP,\n percent = 0,\n pos = idPos\n })\n -- if DebugMode then PrintDebug(\"Broken: \"..idName..\" --- Type: \"..idType..\"\") end\n end\n else\n healthyElements = healthyElements + 1\n if id == highlightID then\n highlightID = 0\n end\n end\n end\n\n -- Sort tables by current settings \n SortTables()\n\n -- Update clickAreas\n\n -- Determine total ship integrity\n totalShipIntegrity = string.format(\"%2.0f\",\n 100 / totalShipMaxHP * totalShipHP)\n\n -- Has anything changes since last check? If yes, force redrawing the screens\n if formerTotalShipHP ~= totalShipHP then\n forceRedraw = true\n formerTotalShipHP = totalShipHP\n else\n forceRedraw = false\n end\nend\n\nfunction GetAllSystemsNominalBackground()\n local output = \"\"\n output = output .. [[\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ]]\n return output\nend\n\nfunction GetDRLogo()\n output =\n [[]]\n return output\nend\n\nfunction GenerateHUDOutput()\n\n local hudWidth = 300\n local hudHeight = 125\n if #damagedElements > 0 or #brokenElements > 0 then hudHeight = 780 end\n local screenHeight = 1080\n\n local healthyColor = \"#00aa00\"\n local brokenColor = \"#aa0000\"\n local damagedColor = \"#aaaa00\"\n local integrityColor = \"#aaaaaa\"\n local healthyTextColor = \"white\"\n local brokenTextColor = \"#ff4444\"\n local damagedTextColor = \"#ffff44\"\n local integrityTextColor = \"white\"\n\n if #damagedElements == 0 then\n damagedColor = \"#aaaaaa\"\n damagedTextColor = \"white\"\n end\n if #brokenElements == 0 then\n brokenColor = \"#aaaaaa\"\n brokenTextColor = \"white\"\n end\n\n local hudOutput = \"\"\n\n -- Draw Header\n hudOutput = hudOutput .. [[\n ]]\n\n hudOutput = hudOutput .. [[]] ..\n [[]] .. GetDRLogo() .. [[]]\n\n hudOutput = hudOutput .. [[\n \n ]] .. healthyElements ..\n [[\n \n ]] .. #damagedElements ..\n [[\n \n ]] .. #brokenElements ..\n [[]]\n if #damagedElements > 0 or #brokenElements > 0 then\n hudOutput = hudOutput ..\n [[ ]] ..\n [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", totalShipMaxHP - totalShipHP)) ..\n [[ HP damage in total]]\n else\n hudOutput = hudOutput .. [[]] ..\n OkayCenterMessage .. [[]] ..\n [[Ship stands ]] ..\n GenerateCommaValue(string.format(\"%.0f\", totalShipMaxHP)) ..\n [[ HP strong.]]\n\n end\n hudOutput = hudOutput .. [[]]\n\n hudRowDistance = 25\n if #damagedElements > 0 then\n local damagedElementsToDraw = #damagedElements\n if damagedElementsToDraw > 12 then damagedElementsToDraw = 12 end\n if CurrentDamagedPage == math.ceil(#damagedElements / 12) then\n damagedElementsToDraw = #damagedElements % 12\n end\n local i = 0\n hudOutput = hudOutput .. [[]] ..\n [[]]\n\n for j = 1 + (CurrentDamagedPage - 1) * 12, damagedElementsToDraw +\n (CurrentDamagedPage - 1) * 12, 1 do\n i = i + 1\n local DP = damagedElements[j]\n if (hudSelectedType == 1 and hudSelectedIndex == i) then\n hudOutput = hudOutput .. [[]]\n if UseMyElementNames == true then\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.name) ..\n [[]]\n else\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.type) ..\n [[]]\n end\n if (DamagedSortingMode == 3) then\n hudOutput = hudOutput .. [[]] .. DP.percent ..\n [[%]]\n else\n hudOutput = hudOutput .. [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", DP.missinghp)) ..\n [[]]\n end\n else\n if UseMyElementNames == true then\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.name) ..\n [[]]\n else\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.type) ..\n [[]]\n end\n if (DamagedSortingMode == 3) then\n hudOutput = hudOutput .. [[]] .. DP.percent ..\n [[%]]\n else\n hudOutput = hudOutput .. [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", DP.missinghp)) ..\n [[]]\n end\n hudOutput = hudOutput .. [[]]\n end\n end\n hudOutput = hudOutput .. [[]]\n end\n\n if #brokenElements > 0 then\n local brokenElementsToDraw = #brokenElements\n if brokenElementsToDraw > 12 then brokenElementsToDraw = 12 end\n if CurrentbrokenPage == math.ceil(#brokenElements / 12) then\n brokenElementsToDraw = #brokenElements % 12\n end\n local i = 0\n hudOutput = hudOutput .. [[]] ..\n [[]]\n\n for j = 1 + (CurrentBrokenPage - 1) * 12, brokenElementsToDraw +\n (CurrentBrokenPage - 1) * 12, 1 do\n i = i + 1\n local DP = brokenElements[j]\n if (hudSelectedType == 2 and hudSelectedIndex == i) then\n hudOutput = hudOutput .. [[]]\n if UseMyElementNames == true then\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.name) ..\n [[]]\n else\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.type) ..\n [[]]\n end\n if (brokenSortingMode == 3) then\n hudOutput = hudOutput .. [[]] .. DP.percent ..\n [[%]]\n else\n hudOutput = hudOutput .. [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", DP.missinghp)) ..\n [[]]\n end\n else\n if UseMyElementNames == true then\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.name) ..\n [[]]\n else\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.type) ..\n [[]]\n end\n if (brokenSortingMode == 3) then\n hudOutput = hudOutput .. [[]] .. DP.percent ..\n [[%]]\n else\n hudOutput = hudOutput .. [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", DP.missinghp)) ..\n [[]]\n end\n hudOutput = hudOutput .. [[]]\n end\n end\n hudOutput = hudOutput .. [[]]\n end\n\n if #damagedElements or #brokenElements then\n hudOutput = hudOutput .. [[]] ..\n [[Use up/down arrows to select element to find.]] ..\n [[Use right arrow to deselect.]] ..\n [[Use left arrow to exit HUD mode.]] ..\n [[]]\n end\n\n hudOutput = hudOutput .. [[]]\n\n return hudOutput\nend\n\nfunction DrawScreens()\n if #screens > 0 then\n\n local healthyColor = \"#00aa00\"\n local brokenColor = \"#aa0000\"\n local damagedColor = \"#aaaa00\"\n local integrityColor = \"#aaaaaa\"\n local healthyTextColor = \"white\"\n local brokenTextColor = \"#ff4444\"\n local damagedTextColor = \"#ffff44\"\n local integrityTextColor = \"white\"\n\n if #damagedElements == 0 then\n damagedColor = \"#aaaaaa\"\n damagedTextColor = \"white\"\n end\n if #brokenElements == 0 then\n brokenColor = \"#aaaaaa\"\n brokenTextColor = \"white\"\n end\n\n local screenOutput = \"\"\n\n -- Draw Header\n screenOutput = screenOutput ..\n [[\n ]]\n\n -- Draw main background\n screenOutput = screenOutput ..\n [[\n \n \n \n \n \n \n \n \n \n \n \n ]]\n\n -- Draw Title and summary\n if SimulationActive == true then\n screenOutput = screenOutput ..\n [[Simulated Report]]\n else\n screenOutput = screenOutput ..\n [[Damage Report]]\n end\n if YourShipsName == nil or YourShipsName == \"\" or YourShipsName ==\n \"Enter here\" then\n screenOutput = screenOutput ..\n [[SHIP ID ]] ..\n shipID .. [[]]\n else\n screenOutput = screenOutput ..\n [[]] ..\n YourShipsName .. [[]]\n end\n screenOutput = screenOutput .. [[\n Healthy\n ]] .. healthyElements ..\n [[\n\n Damaged\n ]] .. #damagedElements ..\n [[\n\n Broken\n ]] .. #brokenElements ..\n [[\n\n Integrity\n ]] .. totalShipIntegrity ..\n [[%]]\n\n -- Draw damage elements\n\n if #damagedElements > 0 then\n local damagedElementsToDraw = #damagedElements\n if damagedElementsToDraw > 12 then\n damagedElementsToDraw = 12\n end\n if CurrentDamagedPage == math.ceil(#damagedElements / 12) then\n damagedElementsToDraw = #damagedElements % 12\n end\n screenOutput = screenOutput ..\n [[]]\n screenOutput = screenOutput ..\n [[]]\n if (DamagedSortingMode == 2) then\n screenOutput = screenOutput ..\n [[ID]]\n else\n screenOutput = screenOutput ..\n [[ID]]\n end\n if UseMyElementNames == true then\n screenOutput = screenOutput ..\n [[Element Name]]\n else\n screenOutput = screenOutput ..\n [[Element Type]]\n end\n\n if (DamagedSortingMode == 3) then\n screenOutput = screenOutput ..\n [[Health]]\n else\n screenOutput = screenOutput ..\n [[Health]]\n end\n if (DamagedSortingMode == 1) then\n screenOutput = screenOutput ..\n [[Damage]]\n else\n screenOutput = screenOutput ..\n [[Damage]]\n end\n\n local i = 0\n for j = 1 + (CurrentDamagedPage - 1) * 12, damagedElementsToDraw +\n (CurrentDamagedPage - 1) * 12, 1 do\n i = i + 1\n local DP = damagedElements[j]\n screenOutput = screenOutput .. [[]] ..\n string.format(\"%03.0f\", DP.id) .. [[]]\n if UseMyElementNames == true then\n screenOutput = screenOutput .. [[]] ..\n string.format(\"%.25s\", DP.name) ..\n [[]]\n else\n screenOutput = screenOutput .. [[]] ..\n string.format(\"%.25s\", DP.type) ..\n [[]]\n end\n screenOutput = screenOutput .. [[]] ..\n DP.percent .. [[%]] ..\n [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", DP.missinghp)) ..\n [[]] ..\n [[]]\n end\n screenOutput = screenOutput ..\n [[\n \n ]]\n\n if #damagedElements > 12 then\n screenOutput = screenOutput ..\n [[Page ]] ..\n CurrentDamagedPage .. \" of \" ..\n math.ceil(#damagedElements / 12) ..\n [[]]\n\n if CurrentDamagedPage < math.ceil(#damagedElements / 12) then\n screenOutput = screenOutput .. [[\n \n \n ]]\n UpdateClickArea(\"DamagedPageDown\", {\n id = \"DamagedPageDown\",\n x1 = 70,\n x2 = 270,\n y1 = 350 + 11 + (damagedElementsToDraw + 1) * 50,\n y2 = 350 + 11 + 50 + (damagedElementsToDraw + 1) * 50\n })\n else\n DisableClickArea(\"DamagedPageDown\")\n end\n\n if CurrentDamagedPage > 1 then\n screenOutput = screenOutput .. [[\n \n \n ]]\n UpdateClickArea(\"DamagedPageUp\", {\n id = \"DamagedPageUp\",\n x1 = 280,\n x2 = 480,\n y1 = 350 + 11 + (damagedElementsToDraw + 1) * 50,\n y2 = 350 + 11 + 50 + (damagedElementsToDraw + 1) * 50\n })\n else\n DisableClickArea(\"DamagedPageUp\")\n end\n end\n end\n\n -- Draw broken elements\n if #brokenElements > 0 then\n local brokenElementsToDraw = #brokenElements\n if brokenElementsToDraw > 12 then\n brokenElementsToDraw = 12\n end\n if CurrentBrokenPage == math.ceil(#brokenElements / 12) then\n brokenElementsToDraw = #brokenElements % 12\n end\n screenOutput = screenOutput ..\n [[]]\n screenOutput = screenOutput ..\n [[]]\n if (BrokenSortingMode == 2) then\n screenOutput = screenOutput ..\n [[ID]]\n else\n screenOutput = screenOutput ..\n [[ID]]\n end\n if UseMyElementNames == true then\n screenOutput = screenOutput ..\n [[Element Name]]\n else\n screenOutput = screenOutput ..\n [[Element Type]]\n end\n if (BrokenSortingMode == 1) then\n screenOutput = screenOutput ..\n [[Damage]]\n else\n screenOutput = screenOutput ..\n [[Damage]]\n end\n\n local i = 0\n for j = 1 + (CurrentBrokenPage - 1) * 12, brokenElementsToDraw +\n (CurrentBrokenPage - 1) * 12, 1 do\n i = i + 1\n local DP = brokenElements[j]\n screenOutput = screenOutput .. [[]] ..\n string.format(\"%03.0f\", DP.id) .. [[]]\n if UseMyElementNames == true then\n screenOutput = screenOutput .. [[]] ..\n string.format(\"%.25s\", DP.name) ..\n [[]]\n else\n screenOutput = screenOutput .. [[]] ..\n string.format(\"%.25s\", DP.type) ..\n [[]]\n end\n screenOutput = screenOutput .. [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", DP.missinghp)) ..\n [[]] ..\n [[]]\n end\n\n screenOutput = screenOutput ..\n [[\n \n ]]\n\n if #brokenElements > 12 then\n screenOutput = screenOutput ..\n [[Page ]] ..\n CurrentBrokenPage .. \" of \" ..\n math.ceil(#brokenElements / 12) ..\n [[]]\n\n if CurrentBrokenPage > 1 then\n screenOutput = screenOutput .. [[\n \n \n ]]\n UpdateClickArea(\"BrokenPageUp\", {\n id = \"BrokenPageUp\",\n x1 = 1442,\n x2 = 1642,\n y1 = 350 + 11 + (brokenElementsToDraw + 1) * 50,\n y2 = 350 + 11 + 50 + (brokenElementsToDraw + 1) * 50\n })\n else\n DisableClickArea(\"BrokenPageUp\")\n end\n\n if CurrentBrokenPage < math.ceil(#brokenElements / 12) then\n screenOutput = screenOutput .. [[\n \n \n ]]\n UpdateClickArea(\"BrokenPageDown\", {\n id = \"BrokenPageDown\",\n x1 = 1652,\n x2 = 1852,\n y1 = 350 + 11 + (brokenElementsToDraw + 1) * 50,\n y2 = 350 + 11 + 50 + (brokenElementsToDraw + 1) * 50\n })\n else\n DisableClickArea(\"BrokenPageDown\")\n end\n end\n\n end\n\n -- Draw damage summary\n if #damagedElements > 0 or #brokenElements > 0 then\n screenOutput = screenOutput ..\n [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\",\n totalShipMaxHP - totalShipHP)) ..\n [[ HP damage in total]]\n else\n screenOutput = screenOutput .. [[]] ..\n GetAllSystemsNominalBackground() .. [[]] ..\n [[]] ..\n OkayCenterMessage .. [[]] ..\n [[Ship stands ]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", totalShipMaxHP)) ..\n [[ HP strong.]]\n end\n\n -- Draw Sim Mode button\n if SimulationMode == true then\n screenOutput = screenOutput ..\n [[]] ..\n [[Sim Mode]]\n\n else\n screenOutput = screenOutput ..\n [[]] ..\n [[Sim Mode]]\n end\n\n -- Draw HUD Mode button\n if HUDMode == true then\n screenOutput = screenOutput ..\n [[]] ..\n [[HUD Mode]]\n\n else\n screenOutput = screenOutput ..\n [[]] ..\n [[HUD Mode]]\n end\n\n screenOutput = screenOutput .. [[]]\n\n if HUDMode == true then\n system.setScreen(GenerateHUDOutput())\n system.showScreen(1)\n else\n system.showScreen(0)\n end\n\n DrawSVG(screenOutput)\n\n forceRedraw = false\n end\nend\n\n-----------------------------------------------\n-- Execute\n-----------------------------------------------\n\nunit.hide()\nClearConsole()\nPrintDebug(\"SCRIPT STARTED\", true)\n\nInitiateSlots()\nSwitchScreens(true)\nInitiateClickAreas()\n\nif core == nil then\n DrawCenteredText(\"ERROR: No core connected.\")\n PrintError(\"ERROR: No core connected.\")\n goto exit\nelse\n shipID = core.getConstructId()\nend\n\nGenerateDamageData()\nif forceRedraw then DrawScreens() end\n\nunit.setTimer('UpdateData', UpdateInterval)\nunit.setTimer('UpdateHighlight', HighlightBlinkingInterval)\n\n::exit::\n",
- "filter": {
- "args": [],
- "signature": "start()",
- "slotKey": "-1"
- },
- "key": "9"
- },
- {
- "code": "HideHighlight()\nSwitchScreens(false)\n",
- "filter": {
- "args": [],
- "signature": "stop()",
- "slotKey": "-1"
- },
- "key": "10"
- },
- {
- "code": "GenerateDamageData()\nif forceRedraw then\n DrawScreens()\nend",
- "filter": {
- "args": [
- {
- "value": "UpdateData"
- }
- ],
- "signature": "tick(timerId)",
- "slotKey": "-1"
- },
- "key": "11"
- },
- {
- "code": "ToggleHighlight()",
- "filter": {
- "args": [
- {
- "value": "UpdateHighlight"
- }
- ],
- "signature": "tick(timerId)",
- "slotKey": "-1"
- },
- "key": "12"
- },
- {
- "code": "HudDeselectElement()",
- "filter": {
- "args": [
- {
- "value": "straferight"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "13"
- },
- {
- "code": "ToggleHUD()",
- "filter": {
- "args": [
- {
- "value": "strafeleft"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "14"
- },
- {
- "code": "ChangeHudSelectedElement(1)",
- "filter": {
- "args": [
- {
- "value": "down"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "15"
- },
- {
- "code": "ChangeHudSelectedElement(-1)",
- "filter": {
- "args": [
- {
- "value": "up"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "16"
- }
- ],
- "methods": [],
- "events": []
-}
\ No newline at end of file
diff --git a/versions/DamageReport_2_31.json b/versions/DamageReport_2_31.json
deleted file mode 100644
index abd5032..0000000
--- a/versions/DamageReport_2_31.json
+++ /dev/null
@@ -1,339 +0,0 @@
-{
- "slots": {
- "0": {
- "name": "core",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "1": {
- "name": "slot2",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "2": {
- "name": "slot3",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "3": {
- "name": "slot4",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "4": {
- "name": "slot5",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "5": {
- "name": "slot6",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "6": {
- "name": "slot7",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "7": {
- "name": "slot8",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "8": {
- "name": "slot9",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "9": {
- "name": "slot10",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-1": {
- "name": "unit",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-2": {
- "name": "system",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-3": {
- "name": "library",
- "type": {
- "events": [],
- "methods": []
- }
- }
- },
- "handlers": [
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "1"
- },
- "key": "0"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "2"
- },
- "key": "1"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "3"
- },
- "key": "2"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "4"
- },
- "key": "3"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "5"
- },
- "key": "4"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "6"
- },
- "key": "5"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "7"
- },
- "key": "6"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "8"
- },
- "key": "7"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "9"
- },
- "key": "8"
- },
- {
- "code": "--[[\n DamageReport v2.31\n Created By Dorian Gray\n\n Discord: Dorian Gray#2623\n InGame: DorianGray\n GitHub: https://github.com/DorianTheGrey/DU-DamageReport\n\n GNU Public License 3.0. Use whatever you want, be so kind to leave credit.\n\n Thanks to Jericho, Dmentia and Archaegeo for learning from their fine scripts.\n]] \n-----------------------------------------------\n-- CONFIG\n-----------------------------------------------\nUseMyElementNames = true --export: If you active this, the display will not show the element type of damaged/broken elements but the name you gave them (truncated to 25 characters)\nAllowElementHighlighting = true --export: Are you allowing damaged/broken elements to be highlighted in 3D space when selected in the HUD?\nUpdateInterval = 1 --export: Interval in seconds between updates of the calculations and (if anything changed) redrawing to the screen(s). You need to restart the script after changing this value.\nHighlightBlinkingInterval = 0.5 --export: If an element is marked, how fast do you want the arrows to blink?\nSimulationMode = false --export Randomize simluated damage on elements to check out the functionality of this script. And, no, your elements won't be harmed in the process :) You need to restart the script after changing this value.\nYourShipsName = \"Enter here\" --export Enter your ship name here if you want it displayed instead of the ship's ID. YOU NEED TO LEAVE THE QUOTATION MARKS.\n\nDebugMode = false -- Activate if you want some console messages\nVersionNumber = 2.31 -- Version number\n\ncore = nil\nscreens = {}\n\nshipID = 0\nforceRedraw = false\nSimulationActive = false\n\nclickAreas = {}\nDamagedSortingMode = 1 -- Define default sorting mode for damaged elements. 1 to sort by damage amount, 2 to sort by element id, 3 to sort by damage percent, \nBrokenSortingMode = 1 -- Define default sorting mode for broken elements. 1 to sort by damage amount, 2 to sort by element id\n\nHUDMode = false -- Is Hud active?\nhudSelectedIndex = 0 -- Which element is selected?\nhudSelectedType = 0 -- Is selected element damaged (1) or broken (2)\nhudArrowSticker = {}\nhighlightOn = false\nhighlightID = 0\nhighlightX = 0\nhighlightY = 0\nhighlightZ = 0\n\nCurrentDamagedPage = 1\nCurrentBrokenPage = 1\n\ncoreWorldOffset = 0\ntotalShipHP = 0\ntotalShipMaxHP = 0\ntotalShipIntegrity = 100\nelementsId = {}\ndamagedElements = {}\nbrokenElements = {}\nElementCounter = 0\nhealthyElements = 0\n\nOkayCenterMessage = \"All systems nominal.\"\n\n-----------------------------------------------\n-- FUNCTIONS\n-----------------------------------------------\n\nfunction GenerateCommaValue(amount)\n local formatted = amount\n while true do\n formatted, k = string.gsub(formatted, \"^(-?%d+)(%d%d%d)\", '%1,%2')\n if (k == 0) then break end\n end\n return formatted\nend\n\nfunction PrintDebug(output, highlight)\n highlight = highlight or false\n if DebugMode then\n if highlight then\n system.print(\n \"------------------------------------------------------------------------\")\n end\n system.print(output)\n if highlight then\n system.print(\n \"------------------------------------------------------------------------\")\n end\n end\nend\n\nfunction PrintError(output) system.print(output) end\n\nfunction DrawCenteredText(output)\n for i = 1, #screens, 1 do screens[i].setCenteredText(output) end\nend\n\nfunction DrawSVG(output) for i = 1, #screens, 1 do screens[i].setSVG(output) end end\n\nfunction ClearConsole() for i = 1, 10, 1 do PrintDebug() end end\n\nfunction SwitchScreens(state)\n state = state or true\n if #screens > 0 then\n for i = 1, #screens, 1 do\n if state==true then\n screens[i].clear()\n screens[i].activate()\n else\n screens[i].deactivate()\n screens[i].clear()\n end\n end\n end\nend\n\nfunction InitiateSlots()\n for slot_name, slot in pairs(unit) do\n if type(slot) == \"table\" and type(slot.export) == \"table\" and\n slot.getElementClass then\n if slot.getElementClass():lower():find(\"coreunit\") then\n core = slot\n local coreHP = core.getMaxHitPoints()\n if coreHP > 10000 then\n coreWorldOffset = 128\n elseif coreHP > 1000 then\n coreWorldOffset = 64\n elseif coreHP > 150 then\n coreWorldOffset = 32\n else\n coreWorldOffset = 16\n end\n end\n if slot.getElementClass():lower():find(\"screenunit\") then\n screens[#screens + 1] = slot\n end\n end\n end\nend\n\nfunction AddClickArea(newEntry) table.insert(clickAreas, newEntry) end\n\nfunction RemoveFromClickAreas(candidate)\n for k, v in pairs(clickAreas) do\n if v.id == candidate then\n clickAreas[k] = nil\n break\n end\n end\nend\n\nfunction UpdateClickArea(candidate, newEntry)\n for k, v in pairs(clickAreas) do\n if v.id == candidate then\n clickAreas[k] = newEntry\n break\n end\n end\nend\n\nfunction DisableClickArea(candidate)\n for k, v in pairs(clickAreas) do\n if v.id == candidate then\n UpdateClickArea(candidate, {\n id = candidate,\n x1 = -1,\n x2 = -1,\n y1 = -1,\n y2 = -1\n })\n break\n end\n end\nend\n\nfunction InitiateClickAreas()\n clickAreas = {}\n AddClickArea({id = \"DamagedDamage\", x1 = 725, x2 = 870, y1 = 380, y2 = 415})\n AddClickArea({id = \"DamagedHealth\", x1 = 520, x2 = 655, y1 = 380, y2 = 415})\n AddClickArea({id = \"DamagedID\", x1 = 90, x2 = 150, y1 = 380, y2 = 415})\n AddClickArea({id = \"BrokenDamage\", x1 = 1675, x2 = 1835, y1 = 380, y2 = 415})\n AddClickArea({id = \"BrokenID\", x1 = 1050, x2 = 1110, y1 = 380, y2 = 415})\n AddClickArea({id = \"ToggleSimulation\", x1 = 65, x2 = 660, y1 = 100, y2 = 145})\n AddClickArea({id = \"ToggleSimulation2\", x1 = 1650, x2 = 1850, y1 = 75, y2 = 117})\n AddClickArea({id = \"ToggleElementLabel\", x1 = 225, x2 = 460, y1 = 380, y2 = 415})\n AddClickArea({id = \"ToggleElementLabel2\", x1 = 1185, x2 = 1440, y1 = 380, y2 = 415})\n AddClickArea({id = \"ToggleHudMode\", x1 = 1650, x2 = 1850, y1 = 125, y2 = 167})\n AddClickArea({id = \"DamagedPageDown\", x1 = -1, x2 = -1, y1 = -1, y2 = -1})\n AddClickArea({id = \"DamagedPageUp\", x1 = -1, x2 = -1, y1 = -1, y2 = -1})\n AddClickArea({id = \"BrokenPageDown\", x1 = -1, x2 = -1, y1 = -1, y2 = -1})\n AddClickArea({id = \"BrokenPageUp\", x1 = -1, x2 = -1, y1 = -1, y2 = -1})\nend\n\nfunction FlushClickAreas() clickAreas = {} end\n\nfunction CheckClick(x, y, HitTarget)\n HitTarget = HitTarget or \"\"\n if HitTarget == \"\" then\n for k, v in pairs(clickAreas) do\n if v and x >= v.x1 and x <= v.x2 and y >= v.y1 and y <= v.y2 then\n HitTarget = v.id\n break\n end\n end\n end\n if HitTarget == \"DamagedDamage\" then\n DamagedSortingMode = 1\n CurrentDamagedPage = 1\n SortTables()\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"DamagedHealth\" then\n DamagedSortingMode = 3\n CurrentDamagedPage = 1\n SortTables()\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"DamagedID\" then\n DamagedSortingMode = 2\n CurrentDamagedPage = 1\n SortTables()\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"BrokenDamage\" then\n BrokenSortingMode = 1\n CurrentBrokenPage = 1\n SortTables()\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"BrokenID\" then\n BrokenSortingMode = 2\n CurrentBrokenPage = 1\n SortTables()\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"DamagedPageDown\" then\n CurrentDamagedPage = CurrentDamagedPage + 1\n if CurrentDamagedPage > math.ceil(#damagedElements / 12) then\n CurrentDamagedPage = math.ceil(#damagedElements / 12)\n end\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"DamagedPageUp\" then\n CurrentDamagedPage = CurrentDamagedPage - 1\n if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"BrokenPageDown\" then\n CurrentBrokenPage = CurrentBrokenPage + 1\n if CurrentBrokenPage > math.ceil(#brokenElements / 12) then\n CurrentBrokenPage = math.ceil(#brokenElements / 12)\n end\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"BrokenPageUp\" then\n CurrentBrokenPage = CurrentBrokenPage - 1\n if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"ToggleHudMode\" then\n if HUDMode == true then\n HUDMode = false\n forceRedraw = true\n HudDeselectElement()\n DrawScreens()\n else\n HUDMode = true\n forceRedraw = true\n HudDeselectElement()\n DrawScreens()\n end\n elseif HitTarget == \"ToggleSimulation\" or HitTarget == \"ToggleSimulation2\" then\n CurrentDamagedPage = 1\n CurrentBrokenPage = 1\n if SimulationMode == true then\n SimulationMode = false\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n HudDeselectElement()\n DrawScreens()\n else\n SimulationMode = true\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n HudDeselectElement()\n DrawScreens()\n end\n elseif HitTarget == \"ToggleElementLabel\" or HitTarget ==\n \"ToggleElementLabel2\" then\n if UseMyElementNames == true then\n UseMyElementNames = false\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n HudDeselectElement()\n DrawScreens()\n else\n UseMyElementNames = true\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n HudDeselectElement()\n DrawScreens()\n end\n end\nend\n\nfunction ToggleHUD()\n HideHighlight()\n CheckClick(nil, nil, \"ToggleHudMode\")\nend\n\nfunction HudDeselectElement()\n if HUDMode == true then\n hudSelectedType = 0\n hudSelectedIndex = 0\n HideHighlight()\n DrawScreens()\n end\nend\n\nfunction ChangeHudSelectedElement(step)\n if HUDMode == true and (#damagedElements or #brokenElements) then\n local damagedElementsHUD = 12\n if #damagedElements < 12 then\n damagedElementsHUD = #damagedElements\n end\n local brokenElementsHUD = 12\n if #brokenElements < 12 then brokenElementsHUD = #brokenElements end\n if step == 1 then\n if hudSelectedIndex == 0 then\n if damagedElementsHUD > 0 then\n hudSelectedType = 1\n hudSelectedIndex = 1\n elseif brokenElementsHUD > 0 then\n hudSelectedType = 2\n hudSelectedIndex = 1\n end\n elseif hudSelectedType == 1 then\n if damagedElementsHUD > hudSelectedIndex then\n hudSelectedIndex = hudSelectedIndex + 1\n elseif brokenElementsHUD > 0 then\n hudSelectedType = 2\n hudSelectedIndex = 1\n elseif damagedElementsHUD > 0 then\n hudSelectedIndex = 1\n end\n elseif hudSelectedType == 2 then\n if brokenElementsHUD > hudSelectedIndex then\n hudSelectedIndex = hudSelectedIndex + 1\n elseif damagedElementsHUD > 0 then\n hudSelectedType = 1\n hudSelectedIndex = 1\n elseif brokenElementsHUD > 0 then\n hudSelectedIndex = 1\n end\n end\n elseif step == -1 then\n if hudSelectedIndex == 0 then\n if brokenElementsHUD > 0 then\n hudSelectedType = 2\n hudSelectedIndex = 1\n elseif damagedElementsHUD > 0 then\n hudSelectedType = 1\n hudSelectedIndex = 1\n end\n elseif hudSelectedType == 1 then\n if hudSelectedIndex > 1 then\n hudSelectedIndex = hudSelectedIndex - 1\n elseif brokenElementsHUD > 0 then\n hudSelectedType = 2\n hudSelectedIndex = brokenElementsHUD\n elseif damagedElementsHUD > 0 then\n hudSelectedIndex = damagedElementsHUD\n end\n elseif hudSelectedType == 2 then\n if hudSelectedIndex > 1 then\n hudSelectedIndex = hudSelectedIndex - 1\n elseif damagedElementsHUD > 0 then\n hudSelectedType = 1\n hudSelectedIndex = damagedElementsHUD\n elseif brokenElementsHUD > 0 then\n hudSelectedIndex = brokenElementsHUD\n end\n end\n end\n HighlightElement()\n DrawScreens()\n -- PrintDebug(\"-> Type: \"..hudSelectedType.. \" Index: \"..hudSelectedIndex)\n end\nend\n\nfunction HideHighlight()\n if #hudArrowSticker > 0 then\n for i in pairs(hudArrowSticker) do\n core.deleteSticker(hudArrowSticker[i])\n end\n hudArrowSticker = {}\n end\nend\n\nfunction ShowHighlight()\n if highlightOn == true and highlightID > 0 then\n table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX + 2,\n highlightY,\n highlightZ, \"north\"))\n table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,\n highlightY - 2,\n highlightZ, \"east\"))\n table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX - 2,\n highlightY,\n highlightZ, \"south\"))\n table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,\n highlightY + 2,\n highlightZ, \"west\"))\n table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,\n highlightY,\n highlightZ - 2,\n \"up\"))\n table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,\n highlightY,\n highlightZ + 2,\n \"down\"))\n end\nend\n\nfunction ToggleHighlight()\n if highlightOn == true then\n highlightOn = false\n HideHighlight()\n else\n highlightOn = true\n ShowHighlight()\n end\nend\n\nfunction HighlightElement(elementID)\n elementID = elementID or 0\n local targetElement = {}\n\n if elementID == 0 then\n if hudSelectedType == 1 then\n elementID = damagedElements[(CurrentDamagedPage - 1) * 12 +\n hudSelectedIndex].id\n elseif hudSelectedType == 2 then\n elementID = brokenElements[(CurrentBrokenPage - 1) * 12 +\n hudSelectedIndex].id\n end\n\n if elementID ~= 0 then\n local bFound = false\n for k, v in pairs(damagedElements) do\n if v.id == elementID then\n targetElement = v\n bFound = true\n break\n end\n end\n if bFound == false then\n for k, v in pairs(brokenElements) do\n if v.id == elementID then\n targetElement = v\n bFound = true\n break\n end\n end\n end\n\n if bFound == true and AllowElementHighlighting == true then\n HideHighlight()\n elementPosition = vec3(targetElement.pos)\n highlightX = elementPosition.x - coreWorldOffset\n highlightY = elementPosition.y - coreWorldOffset\n highlightZ = elementPosition.z - coreWorldOffset\n highlightID = targetElement.id\n highlightOn = true\n ShowHighlight()\n end\n end\n end\nend\n\nfunction SortTables()\n -- Sort damaged elements descending by percent damaged according to setting\n if DamagedSortingMode == 1 then\n table.sort(damagedElements,\n function(a, b) return a.missinghp > b.missinghp end)\n elseif DamagedSortingMode == 2 then\n table.sort(damagedElements, function(a, b) return a.id < b.id end)\n else\n table.sort(damagedElements,\n function(a, b) return a.percent < b.percent end)\n end\n\n -- Sort broken elements descending according to setting\n if BrokenSortingMode == 1 then\n table.sort(brokenElements, function(a, b)\n return a.maxhp > b.maxhp\n end)\n else\n table.sort(brokenElements, function(a, b) return a.id < b.id end)\n end\nend\n\nfunction GenerateDamageData()\n if SimulationActive == true then return end\n\n local formerTotalShipHP = totalShipHP\n totalShipHP = 0\n totalShipMaxHP = 0\n totalShipIntegrity = 100\n elementsId = {}\n damagedElements = {}\n brokenElements = {}\n ElementCounter = 0\n healthyElements = 0\n\n elementsIdList = core.getElementIdList()\n\n for _, id in pairs(elementsIdList) do\n ElementCounter = ElementCounter + 1\n idHP = core.getElementHitPointsById(id) or 0\n idMaxHP = core.getElementMaxHitPointsById(id) or 0\n\n if SimulationMode then\n SimulationActive = true\n local dice = math.random(0, 10)\n if dice < 2 then\n idHP = 0\n elseif dice >= 2 and dice < 5 then\n idHP = idMaxHP\n else\n idHP = math.random(1, math.ceil(idMaxHP))\n end\n end\n\n totalShipHP = totalShipHP + idHP\n totalShipMaxHP = totalShipMaxHP + idMaxHP\n\n idName = core.getElementNameById(id)\n idType = core.getElementTypeById(id)\n\n -- Is element damaged?\n if idMaxHP > idHP then\n idPos = core.getElementPositionById(id)\n if idHP > 0 then\n table.insert(damagedElements, {\n id = id,\n name = idName,\n type = idType,\n counter = ElementCounter,\n hp = idHP,\n maxhp = idMaxHP,\n missinghp = idMaxHP - idHP,\n percent = math.ceil(100 / idMaxHP * idHP),\n pos = idPos\n })\n -- if DebugMode then PrintDebug(\"Damaged: \"..idName..\" --- Type: \"..idType..\"\") end\n -- Is element broken?\n else\n table.insert(brokenElements, {\n id = id,\n name = idName,\n type = idType,\n counter = ElementCounter,\n hp = idHP,\n maxhp = idMaxHP,\n missinghp = idMaxHP - idHP,\n percent = 0,\n pos = idPos\n })\n -- if DebugMode then PrintDebug(\"Broken: \"..idName..\" --- Type: \"..idType..\"\") end\n end\n else\n healthyElements = healthyElements + 1\n if id == highlightID then\n highlightID = 0\n end\n end\n end\n\n -- Sort tables by current settings \n SortTables()\n\n -- Update clickAreas\n\n -- Determine total ship integrity\n totalShipIntegrity = string.format(\"%2.0f\",\n 100 / totalShipMaxHP * totalShipHP)\n\n -- Has anything changes since last check? If yes, force redrawing the screens\n if formerTotalShipHP ~= totalShipHP then\n forceRedraw = true\n formerTotalShipHP = totalShipHP\n else\n forceRedraw = false\n end\nend\n\nfunction GetAllSystemsNominalBackground()\n local output = \"\"\n output = output .. [[\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ]]\n return output\nend\n\nfunction GetDRLogo()\n output =\n [[]]\n return output\nend\n\nfunction GenerateHUDOutput()\n\n local hudWidth = 300\n local hudHeight = 125\n if #damagedElements > 0 or #brokenElements > 0 then hudHeight = 780 end\n local screenHeight = 1080\n\n local healthyColor = \"#00aa00\"\n local brokenColor = \"#aa0000\"\n local damagedColor = \"#aaaa00\"\n local integrityColor = \"#aaaaaa\"\n local healthyTextColor = \"white\"\n local brokenTextColor = \"#ff4444\"\n local damagedTextColor = \"#ffff44\"\n local integrityTextColor = \"white\"\n\n if #damagedElements == 0 then\n damagedColor = \"#aaaaaa\"\n damagedTextColor = \"white\"\n end\n if #brokenElements == 0 then\n brokenColor = \"#aaaaaa\"\n brokenTextColor = \"white\"\n end\n\n local hudOutput = \"\"\n\n -- Draw Header\n hudOutput = hudOutput .. [[\n ]]\n\n hudOutput = hudOutput .. [[]] ..\n [[]] .. GetDRLogo() .. [[]]\n\n hudOutput = hudOutput .. [[\n \n ]] .. healthyElements ..\n [[\n \n ]] .. #damagedElements ..\n [[\n \n ]] .. #brokenElements ..\n [[]]\n if #damagedElements > 0 or #brokenElements > 0 then\n hudOutput = hudOutput ..\n [[ ]] ..\n [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", totalShipMaxHP - totalShipHP)) ..\n [[ HP damage in total]]\n else\n hudOutput = hudOutput .. [[]] ..\n OkayCenterMessage .. [[]] ..\n [[Ship stands ]] ..\n GenerateCommaValue(string.format(\"%.0f\", totalShipMaxHP)) ..\n [[ HP strong.]]\n\n end\n hudOutput = hudOutput .. [[]]\n\n hudRowDistance = 25\n if #damagedElements > 0 then\n local damagedElementsToDraw = #damagedElements\n if damagedElementsToDraw > 12 then damagedElementsToDraw = 12 end\n if CurrentDamagedPage == math.ceil(#damagedElements / 12) then\n damagedElementsToDraw = #damagedElements % 12\n end\n local i = 0\n hudOutput = hudOutput .. [[]] ..\n [[]]\n\n for j = 1 + (CurrentDamagedPage - 1) * 12, damagedElementsToDraw +\n (CurrentDamagedPage - 1) * 12, 1 do\n i = i + 1\n local DP = damagedElements[j]\n if (hudSelectedType == 1 and hudSelectedIndex == i) then\n hudOutput = hudOutput .. [[]]\n if UseMyElementNames == true then\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.name) ..\n [[]]\n else\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.type) ..\n [[]]\n end\n if (DamagedSortingMode == 3) then\n hudOutput = hudOutput .. [[]] .. DP.percent ..\n [[%]]\n else\n hudOutput = hudOutput .. [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", DP.missinghp)) ..\n [[]]\n end\n else\n if UseMyElementNames == true then\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.name) ..\n [[]]\n else\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.type) ..\n [[]]\n end\n if (DamagedSortingMode == 3) then\n hudOutput = hudOutput .. [[]] .. DP.percent ..\n [[%]]\n else\n hudOutput = hudOutput .. [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", DP.missinghp)) ..\n [[]]\n end\n hudOutput = hudOutput .. [[]]\n end\n end\n hudOutput = hudOutput .. [[]]\n end\n\n if #brokenElements > 0 then\n local brokenElementsToDraw = #brokenElements\n if brokenElementsToDraw > 12 then brokenElementsToDraw = 12 end\n if CurrentbrokenPage == math.ceil(#brokenElements / 12) then\n brokenElementsToDraw = #brokenElements % 12\n end\n local i = 0\n hudOutput = hudOutput .. [[]] ..\n [[]]\n\n for j = 1 + (CurrentBrokenPage - 1) * 12, brokenElementsToDraw +\n (CurrentBrokenPage - 1) * 12, 1 do\n i = i + 1\n local DP = brokenElements[j]\n if (hudSelectedType == 2 and hudSelectedIndex == i) then\n hudOutput = hudOutput .. [[]]\n if UseMyElementNames == true then\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.name) ..\n [[]]\n else\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.type) ..\n [[]]\n end\n if (brokenSortingMode == 3) then\n hudOutput = hudOutput .. [[]] .. DP.percent ..\n [[%]]\n else\n hudOutput = hudOutput .. [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", DP.missinghp)) ..\n [[]]\n end\n else\n if UseMyElementNames == true then\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.name) ..\n [[]]\n else\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.type) ..\n [[]]\n end\n if (brokenSortingMode == 3) then\n hudOutput = hudOutput .. [[]] .. DP.percent ..\n [[%]]\n else\n hudOutput = hudOutput .. [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", DP.missinghp)) ..\n [[]]\n end\n hudOutput = hudOutput .. [[]]\n end\n end\n hudOutput = hudOutput .. [[]]\n end\n\n if #damagedElements or #brokenElements then\n hudOutput = hudOutput .. [[]] ..\n [[Use up/down arrows to select element to find.]] ..\n [[Use right arrow to deselect.]] ..\n [[Use left arrow to exit HUD mode.]] ..\n [[]]\n end\n\n hudOutput = hudOutput .. [[]]\n\n return hudOutput\nend\n\nfunction DrawScreens()\n if #screens > 0 then\n\n local healthyColor = \"#00aa00\"\n local brokenColor = \"#aa0000\"\n local damagedColor = \"#aaaa00\"\n local integrityColor = \"#aaaaaa\"\n local healthyTextColor = \"white\"\n local brokenTextColor = \"#ff4444\"\n local damagedTextColor = \"#ffff44\"\n local integrityTextColor = \"white\"\n\n if #damagedElements == 0 then\n damagedColor = \"#aaaaaa\"\n damagedTextColor = \"white\"\n end\n if #brokenElements == 0 then\n brokenColor = \"#aaaaaa\"\n brokenTextColor = \"white\"\n end\n\n local screenOutput = \"\"\n\n -- Draw Header\n screenOutput = screenOutput ..\n [[\n ]]\n\n -- Draw main background\n screenOutput = screenOutput ..\n [[\n \n \n \n \n \n \n \n \n \n \n \n ]]\n\n -- Draw Title and summary\n if SimulationActive == true then\n screenOutput = screenOutput ..\n [[Simulated Report]]\n else\n screenOutput = screenOutput ..\n [[Damage Report]]\n end\n if YourShipsName == nil or YourShipsName == \"\" or YourShipsName ==\n \"Enter here\" then\n screenOutput = screenOutput ..\n [[SHIP ID ]] ..\n shipID .. [[]]\n else\n screenOutput = screenOutput ..\n [[]] ..\n YourShipsName .. [[]]\n end\n screenOutput = screenOutput .. [[\n Healthy\n ]] .. healthyElements ..\n [[\n\n Damaged\n ]] .. #damagedElements ..\n [[\n\n Broken\n ]] .. #brokenElements ..\n [[\n\n Integrity\n ]] .. totalShipIntegrity ..\n [[%]]\n\n -- Draw damage elements\n\n if #damagedElements > 0 then\n local damagedElementsToDraw = #damagedElements\n if damagedElementsToDraw > 12 then\n damagedElementsToDraw = 12\n end\n if CurrentDamagedPage == math.ceil(#damagedElements / 12) then\n damagedElementsToDraw = #damagedElements % 12\n end\n screenOutput = screenOutput ..\n [[]]\n screenOutput = screenOutput ..\n [[]]\n if (DamagedSortingMode == 2) then\n screenOutput = screenOutput ..\n [[ID]]\n else\n screenOutput = screenOutput ..\n [[ID]]\n end\n if UseMyElementNames == true then\n screenOutput = screenOutput ..\n [[Element Name]]\n else\n screenOutput = screenOutput ..\n [[Element Type]]\n end\n\n if (DamagedSortingMode == 3) then\n screenOutput = screenOutput ..\n [[Health]]\n else\n screenOutput = screenOutput ..\n [[Health]]\n end\n if (DamagedSortingMode == 1) then\n screenOutput = screenOutput ..\n [[Damage]]\n else\n screenOutput = screenOutput ..\n [[Damage]]\n end\n\n local i = 0\n for j = 1 + (CurrentDamagedPage - 1) * 12, damagedElementsToDraw +\n (CurrentDamagedPage - 1) * 12, 1 do\n i = i + 1\n local DP = damagedElements[j]\n screenOutput = screenOutput .. [[]] ..\n string.format(\"%03.0f\", DP.id) .. [[]]\n if UseMyElementNames == true then\n screenOutput = screenOutput .. [[]] ..\n string.format(\"%.25s\", DP.name) ..\n [[]]\n else\n screenOutput = screenOutput .. [[]] ..\n string.format(\"%.25s\", DP.type) ..\n [[]]\n end\n screenOutput = screenOutput .. [[]] ..\n DP.percent .. [[%]] ..\n [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", DP.missinghp)) ..\n [[]] ..\n [[]]\n end\n screenOutput = screenOutput ..\n [[\n \n ]]\n\n if #damagedElements > 12 then\n screenOutput = screenOutput ..\n [[Page ]] ..\n CurrentDamagedPage .. \" of \" ..\n math.ceil(#damagedElements / 12) ..\n [[]]\n\n if CurrentDamagedPage < math.ceil(#damagedElements / 12) then\n screenOutput = screenOutput .. [[\n \n \n ]]\n UpdateClickArea(\"DamagedPageDown\", {\n id = \"DamagedPageDown\",\n x1 = 70,\n x2 = 270,\n y1 = 350 + 11 + (damagedElementsToDraw + 1) * 50,\n y2 = 350 + 11 + 50 + (damagedElementsToDraw + 1) * 50\n })\n else\n DisableClickArea(\"DamagedPageDown\")\n end\n\n if CurrentDamagedPage > 1 then\n screenOutput = screenOutput .. [[\n \n \n ]]\n UpdateClickArea(\"DamagedPageUp\", {\n id = \"DamagedPageUp\",\n x1 = 280,\n x2 = 480,\n y1 = 350 + 11 + (damagedElementsToDraw + 1) * 50,\n y2 = 350 + 11 + 50 + (damagedElementsToDraw + 1) * 50\n })\n else\n DisableClickArea(\"DamagedPageUp\")\n end\n end\n end\n\n -- Draw broken elements\n if #brokenElements > 0 then\n local brokenElementsToDraw = #brokenElements\n if brokenElementsToDraw > 12 then\n brokenElementsToDraw = 12\n end\n if CurrentBrokenPage == math.ceil(#brokenElements / 12) then\n brokenElementsToDraw = #brokenElements % 12\n end\n screenOutput = screenOutput ..\n [[]]\n screenOutput = screenOutput ..\n [[]]\n if (BrokenSortingMode == 2) then\n screenOutput = screenOutput ..\n [[ID]]\n else\n screenOutput = screenOutput ..\n [[ID]]\n end\n if UseMyElementNames == true then\n screenOutput = screenOutput ..\n [[Element Name]]\n else\n screenOutput = screenOutput ..\n [[Element Type]]\n end\n if (BrokenSortingMode == 1) then\n screenOutput = screenOutput ..\n [[Damage]]\n else\n screenOutput = screenOutput ..\n [[Damage]]\n end\n\n local i = 0\n for j = 1 + (CurrentBrokenPage - 1) * 12, brokenElementsToDraw +\n (CurrentBrokenPage - 1) * 12, 1 do\n i = i + 1\n local DP = brokenElements[j]\n screenOutput = screenOutput .. [[]] ..\n string.format(\"%03.0f\", DP.id) .. [[]]\n if UseMyElementNames == true then\n screenOutput = screenOutput .. [[]] ..\n string.format(\"%.25s\", DP.name) ..\n [[]]\n else\n screenOutput = screenOutput .. [[]] ..\n string.format(\"%.25s\", DP.type) ..\n [[]]\n end\n screenOutput = screenOutput .. [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", DP.missinghp)) ..\n [[]] ..\n [[]]\n end\n\n screenOutput = screenOutput ..\n [[\n \n ]]\n\n if #brokenElements > 12 then\n screenOutput = screenOutput ..\n [[Page ]] ..\n CurrentBrokenPage .. \" of \" ..\n math.ceil(#brokenElements / 12) ..\n [[]]\n\n if CurrentBrokenPage > 1 then\n screenOutput = screenOutput .. [[\n \n \n ]]\n UpdateClickArea(\"BrokenPageUp\", {\n id = \"BrokenPageUp\",\n x1 = 1442,\n x2 = 1642,\n y1 = 350 + 11 + (brokenElementsToDraw + 1) * 50,\n y2 = 350 + 11 + 50 + (brokenElementsToDraw + 1) * 50\n })\n else\n DisableClickArea(\"BrokenPageUp\")\n end\n\n if CurrentBrokenPage < math.ceil(#brokenElements / 12) then\n screenOutput = screenOutput .. [[\n \n \n ]]\n UpdateClickArea(\"BrokenPageDown\", {\n id = \"BrokenPageDown\",\n x1 = 1652,\n x2 = 1852,\n y1 = 350 + 11 + (brokenElementsToDraw + 1) * 50,\n y2 = 350 + 11 + 50 + (brokenElementsToDraw + 1) * 50\n })\n else\n DisableClickArea(\"BrokenPageDown\")\n end\n end\n\n end\n\n -- Draw damage summary\n if #damagedElements > 0 or #brokenElements > 0 then\n screenOutput = screenOutput ..\n [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\",\n totalShipMaxHP - totalShipHP)) ..\n [[ HP damage in total]]\n else\n screenOutput = screenOutput .. [[]] ..\n GetAllSystemsNominalBackground() .. [[]] ..\n [[]] ..\n OkayCenterMessage .. [[]] ..\n [[Ship stands ]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", totalShipMaxHP)) ..\n [[ HP strong.]]\n end\n\n -- Draw Sim Mode button\n if SimulationMode == true then\n screenOutput = screenOutput ..\n [[]] ..\n [[Sim Mode]]\n\n else\n screenOutput = screenOutput ..\n [[]] ..\n [[Sim Mode]]\n end\n\n -- Draw HUD Mode button\n if HUDMode == true then\n screenOutput = screenOutput ..\n [[]] ..\n [[HUD Mode]]\n\n else\n screenOutput = screenOutput ..\n [[]] ..\n [[HUD Mode]]\n end\n\n screenOutput = screenOutput .. [[]]\n\n if HUDMode == true then\n system.setScreen(GenerateHUDOutput())\n system.showScreen(1)\n else\n system.showScreen(0)\n end\n\n DrawSVG(screenOutput)\n\n forceRedraw = false\n end\nend\n\n-----------------------------------------------\n-- Execute\n-----------------------------------------------\n\nunit.hide()\nClearConsole()\nPrintDebug(\"SCRIPT STARTED\", true)\n\nInitiateSlots()\nSwitchScreens(true)\nInitiateClickAreas()\n\nif core == nil then\n DrawCenteredText(\"ERROR: No core connected.\")\n PrintError(\"ERROR: No core connected.\")\n goto exit\nelse\n shipID = core.getConstructId()\nend\n\nGenerateDamageData()\nif forceRedraw then DrawScreens() end\n\nunit.setTimer('UpdateData', UpdateInterval)\nunit.setTimer('UpdateHighlight', HighlightBlinkingInterval)\n\n::exit::\n",
- "filter": {
- "args": [],
- "signature": "start()",
- "slotKey": "-1"
- },
- "key": "9"
- },
- {
- "code": "HideHighlight()\nSwitchScreens(false)\n",
- "filter": {
- "args": [],
- "signature": "stop()",
- "slotKey": "-1"
- },
- "key": "10"
- },
- {
- "code": "GenerateDamageData()\nif forceRedraw then\n DrawScreens()\nend",
- "filter": {
- "args": [
- {
- "value": "UpdateData"
- }
- ],
- "signature": "tick(timerId)",
- "slotKey": "-1"
- },
- "key": "11"
- },
- {
- "code": "ToggleHighlight()",
- "filter": {
- "args": [
- {
- "value": "UpdateHighlight"
- }
- ],
- "signature": "tick(timerId)",
- "slotKey": "-1"
- },
- "key": "12"
- },
- {
- "code": "HudDeselectElement()",
- "filter": {
- "args": [
- {
- "value": "straferight"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "13"
- },
- {
- "code": "ToggleHUD()",
- "filter": {
- "args": [
- {
- "value": "strafeleft"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "14"
- },
- {
- "code": "ChangeHudSelectedElement(1)",
- "filter": {
- "args": [
- {
- "value": "down"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "15"
- },
- {
- "code": "ChangeHudSelectedElement(-1)",
- "filter": {
- "args": [
- {
- "value": "up"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "16"
- }
- ],
- "methods": [],
- "events": []
-}
\ No newline at end of file
diff --git a/versions/DamageReport_2_32.json b/versions/DamageReport_2_32.json
deleted file mode 100644
index 90cd711..0000000
--- a/versions/DamageReport_2_32.json
+++ /dev/null
@@ -1,339 +0,0 @@
-{
- "slots": {
- "0": {
- "name": "core",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "1": {
- "name": "slot2",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "2": {
- "name": "slot3",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "3": {
- "name": "slot4",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "4": {
- "name": "slot5",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "5": {
- "name": "slot6",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "6": {
- "name": "slot7",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "7": {
- "name": "slot8",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "8": {
- "name": "slot9",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "9": {
- "name": "slot10",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-1": {
- "name": "unit",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-2": {
- "name": "system",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-3": {
- "name": "library",
- "type": {
- "events": [],
- "methods": []
- }
- }
- },
- "handlers": [
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "1"
- },
- "key": "0"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "2"
- },
- "key": "1"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "3"
- },
- "key": "2"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "4"
- },
- "key": "3"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "5"
- },
- "key": "4"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "6"
- },
- "key": "5"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "7"
- },
- "key": "6"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "8"
- },
- "key": "7"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "9"
- },
- "key": "8"
- },
- {
- "code": "--[[\n DamageReport v2.32\n Created By Dorian Gray\n\n Discord: Dorian Gray#2623\n InGame: DorianGray\n GitHub: https://github.com/DorianTheGrey/DU-DamageReport\n\n GNU Public License 3.0. Use whatever you want, be so kind to leave credit.\n\n Thanks to Jericho, Dmentia and Archaegeo for learning from their fine scripts.\n]] \n-----------------------------------------------\n-- CONFIG\n-----------------------------------------------\nUseMyElementNames = true --export: If you active this, the display will not show the element type of damaged/broken elements but the name you gave them (truncated to 25 characters)\nAllowElementHighlighting = true --export: Are you allowing damaged/broken elements to be highlighted in 3D space when selected in the HUD?\nUpdateInterval = 1 --export: Interval in seconds between updates of the calculations and (if anything changed) redrawing to the screen(s). You need to restart the script after changing this value.\nHighlightBlinkingInterval = 0.5 --export: If an element is marked, how fast do you want the arrows to blink?\nSimulationMode = false --export Randomize simluated damage on elements to check out the functionality of this script. And, no, your elements won't be harmed in the process :) You need to restart the script after changing this value.\nYourShipsName = \"Enter here\" --export Enter your ship name here if you want it displayed instead of the ship's ID. YOU NEED TO LEAVE THE QUOTATION MARKS.\n\nDebugMode = false -- Activate if you want some console messages\nVersionNumber = 2.32 -- Version number\n\ncore = nil\nscreens = {}\n\nshipID = 0\nforceRedraw = false\nSimulationActive = false\n\nclickAreas = {}\nDamagedSortingMode = 1 -- Define default sorting mode for damaged elements. 1 to sort by damage amount, 2 to sort by element id, 3 to sort by damage percent, \nBrokenSortingMode = 1 -- Define default sorting mode for broken elements. 1 to sort by damage amount, 2 to sort by element id\n\nHUDMode = false -- Is Hud active?\nhudSelectedIndex = 0 -- Which element is selected?\nhudSelectedType = 0 -- Is selected element damaged (1) or broken (2)\nhudArrowSticker = {}\nhighlightOn = false\nhighlightID = 0\nhighlightX = 0\nhighlightY = 0\nhighlightZ = 0\n\nCurrentDamagedPage = 1\nCurrentBrokenPage = 1\n\ncoreWorldOffset = 0\ntotalShipHP = 0\ntotalShipMaxHP = 0\ntotalShipIntegrity = 100\nelementsId = {}\ndamagedElements = {}\nbrokenElements = {}\nElementCounter = 0\nhealthyElements = 0\n\nOkayCenterMessage = \"All systems nominal.\"\n\n-----------------------------------------------\n-- FUNCTIONS\n-----------------------------------------------\n\nfunction GenerateCommaValue(amount)\n local formatted = amount\n while true do\n formatted, k = string.gsub(formatted, \"^(-?%d+)(%d%d%d)\", '%1,%2')\n if (k == 0) then break end\n end\n return formatted\nend\n\nfunction PrintDebug(output, highlight)\n highlight = highlight or false\n if DebugMode then\n if highlight then\n system.print(\n \"------------------------------------------------------------------------\")\n end\n system.print(output)\n if highlight then\n system.print(\n \"------------------------------------------------------------------------\")\n end\n end\nend\n\nfunction PrintError(output) system.print(output) end\n\nfunction DrawCenteredText(output)\n for i = 1, #screens, 1 do screens[i].setCenteredText(output) end\nend\n\nfunction DrawSVG(output) for i = 1, #screens, 1 do screens[i].setSVG(output) end end\n\nfunction ClearConsole() for i = 1, 10, 1 do PrintDebug() end end\n\nfunction SwitchScreens(state)\n state = state or true\n if #screens > 0 then\n for i = 1, #screens, 1 do\n if state==true then\n screens[i].clear()\n screens[i].activate()\n else\n screens[i].deactivate()\n screens[i].clear()\n end\n end\n end\nend\n\nfunction InitiateSlots()\n for slot_name, slot in pairs(unit) do\n if type(slot) == \"table\" and type(slot.export) == \"table\" and\n slot.getElementClass then\n if slot.getElementClass():lower():find(\"coreunit\") then\n core = slot\n local coreHP = core.getMaxHitPoints()\n if coreHP > 10000 then\n coreWorldOffset = 128\n elseif coreHP > 1000 then\n coreWorldOffset = 64\n elseif coreHP > 150 then\n coreWorldOffset = 32\n else\n coreWorldOffset = 16\n end\n end\n if slot.getElementClass():lower():find(\"screenunit\") then\n screens[#screens + 1] = slot\n end\n end\n end\nend\n\nfunction AddClickArea(newEntry) table.insert(clickAreas, newEntry) end\n\nfunction RemoveFromClickAreas(candidate)\n for k, v in pairs(clickAreas) do\n if v.id == candidate then\n clickAreas[k] = nil\n break\n end\n end\nend\n\nfunction UpdateClickArea(candidate, newEntry)\n for k, v in pairs(clickAreas) do\n if v.id == candidate then\n clickAreas[k] = newEntry\n break\n end\n end\nend\n\nfunction DisableClickArea(candidate)\n for k, v in pairs(clickAreas) do\n if v.id == candidate then\n UpdateClickArea(candidate, {\n id = candidate,\n x1 = -1,\n x2 = -1,\n y1 = -1,\n y2 = -1\n })\n break\n end\n end\nend\n\nfunction InitiateClickAreas()\n clickAreas = {}\n AddClickArea({id = \"DamagedDamage\", x1 = 725, x2 = 870, y1 = 380, y2 = 415})\n AddClickArea({id = \"DamagedHealth\", x1 = 520, x2 = 655, y1 = 380, y2 = 415})\n AddClickArea({id = \"DamagedID\", x1 = 90, x2 = 150, y1 = 380, y2 = 415})\n AddClickArea({id = \"BrokenDamage\", x1 = 1675, x2 = 1835, y1 = 380, y2 = 415})\n AddClickArea({id = \"BrokenID\", x1 = 1050, x2 = 1110, y1 = 380, y2 = 415})\n AddClickArea({id = \"ToggleSimulation\", x1 = 65, x2 = 660, y1 = 100, y2 = 145})\n AddClickArea({id = \"ToggleSimulation2\", x1 = 1650, x2 = 1850, y1 = 75, y2 = 117})\n AddClickArea({id = \"ToggleElementLabel\", x1 = 225, x2 = 460, y1 = 380, y2 = 415})\n AddClickArea({id = \"ToggleElementLabel2\", x1 = 1185, x2 = 1440, y1 = 380, y2 = 415})\n AddClickArea({id = \"ToggleHudMode\", x1 = 1650, x2 = 1850, y1 = 125, y2 = 167})\n AddClickArea({id = \"DamagedPageDown\", x1 = -1, x2 = -1, y1 = -1, y2 = -1})\n AddClickArea({id = \"DamagedPageUp\", x1 = -1, x2 = -1, y1 = -1, y2 = -1})\n AddClickArea({id = \"BrokenPageDown\", x1 = -1, x2 = -1, y1 = -1, y2 = -1})\n AddClickArea({id = \"BrokenPageUp\", x1 = -1, x2 = -1, y1 = -1, y2 = -1})\nend\n\nfunction FlushClickAreas() clickAreas = {} end\n\nfunction CheckClick(x, y, HitTarget)\n HitTarget = HitTarget or \"\"\n if HitTarget == \"\" then\n for k, v in pairs(clickAreas) do\n if v and x >= v.x1 and x <= v.x2 and y >= v.y1 and y <= v.y2 then\n HitTarget = v.id\n break\n end\n end\n end\n if HitTarget == \"DamagedDamage\" then\n DamagedSortingMode = 1\n CurrentDamagedPage = 1\n SortTables()\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"DamagedHealth\" then\n DamagedSortingMode = 3\n CurrentDamagedPage = 1\n SortTables()\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"DamagedID\" then\n DamagedSortingMode = 2\n CurrentDamagedPage = 1\n SortTables()\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"BrokenDamage\" then\n BrokenSortingMode = 1\n CurrentBrokenPage = 1\n SortTables()\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"BrokenID\" then\n BrokenSortingMode = 2\n CurrentBrokenPage = 1\n SortTables()\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"DamagedPageDown\" then\n CurrentDamagedPage = CurrentDamagedPage + 1\n if CurrentDamagedPage > math.ceil(#damagedElements / 12) then\n CurrentDamagedPage = math.ceil(#damagedElements / 12)\n end\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"DamagedPageUp\" then\n CurrentDamagedPage = CurrentDamagedPage - 1\n if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"BrokenPageDown\" then\n CurrentBrokenPage = CurrentBrokenPage + 1\n if CurrentBrokenPage > math.ceil(#brokenElements / 12) then\n CurrentBrokenPage = math.ceil(#brokenElements / 12)\n end\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"BrokenPageUp\" then\n CurrentBrokenPage = CurrentBrokenPage - 1\n if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"ToggleHudMode\" then\n if HUDMode == true then\n HUDMode = false\n forceRedraw = true\n HudDeselectElement()\n DrawScreens()\n else\n HUDMode = true\n forceRedraw = true\n HudDeselectElement()\n DrawScreens()\n end\n elseif HitTarget == \"ToggleSimulation\" or HitTarget == \"ToggleSimulation2\" then\n CurrentDamagedPage = 1\n CurrentBrokenPage = 1\n if SimulationMode == true then\n SimulationMode = false\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n HudDeselectElement()\n DrawScreens()\n else\n SimulationMode = true\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n HudDeselectElement()\n DrawScreens()\n end\n elseif HitTarget == \"ToggleElementLabel\" or HitTarget ==\n \"ToggleElementLabel2\" then\n if UseMyElementNames == true then\n UseMyElementNames = false\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n HudDeselectElement()\n DrawScreens()\n else\n UseMyElementNames = true\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n HudDeselectElement()\n DrawScreens()\n end\n end\nend\n\nfunction ToggleHUD()\n HideHighlight()\n CheckClick(nil, nil, \"ToggleHudMode\")\nend\n\nfunction HudDeselectElement()\n if HUDMode == true then\n hudSelectedType = 0\n hudSelectedIndex = 0\n HideHighlight()\n DrawScreens()\n end\nend\n\nfunction ChangeHudSelectedElement(step)\n if HUDMode == true and (#damagedElements or #brokenElements) then\n local damagedElementsHUD = 12\n if #damagedElements < 12 then\n damagedElementsHUD = #damagedElements\n end\n local brokenElementsHUD = 12\n if #brokenElements < 12 then brokenElementsHUD = #brokenElements end\n if step == 1 then\n if hudSelectedIndex == 0 then\n if damagedElementsHUD > 0 then\n hudSelectedType = 1\n hudSelectedIndex = 1\n elseif brokenElementsHUD > 0 then\n hudSelectedType = 2\n hudSelectedIndex = 1\n end\n elseif hudSelectedType == 1 then\n if damagedElementsHUD > hudSelectedIndex then\n hudSelectedIndex = hudSelectedIndex + 1\n elseif brokenElementsHUD > 0 then\n hudSelectedType = 2\n hudSelectedIndex = 1\n elseif damagedElementsHUD > 0 then\n hudSelectedIndex = 1\n end\n elseif hudSelectedType == 2 then\n if brokenElementsHUD > hudSelectedIndex then\n hudSelectedIndex = hudSelectedIndex + 1\n elseif damagedElementsHUD > 0 then\n hudSelectedType = 1\n hudSelectedIndex = 1\n elseif brokenElementsHUD > 0 then\n hudSelectedIndex = 1\n end\n end\n elseif step == -1 then\n if hudSelectedIndex == 0 then\n if brokenElementsHUD > 0 then\n hudSelectedType = 2\n hudSelectedIndex = 1\n elseif damagedElementsHUD > 0 then\n hudSelectedType = 1\n hudSelectedIndex = 1\n end\n elseif hudSelectedType == 1 then\n if hudSelectedIndex > 1 then\n hudSelectedIndex = hudSelectedIndex - 1\n elseif brokenElementsHUD > 0 then\n hudSelectedType = 2\n hudSelectedIndex = brokenElementsHUD\n elseif damagedElementsHUD > 0 then\n hudSelectedIndex = damagedElementsHUD\n end\n elseif hudSelectedType == 2 then\n if hudSelectedIndex > 1 then\n hudSelectedIndex = hudSelectedIndex - 1\n elseif damagedElementsHUD > 0 then\n hudSelectedType = 1\n hudSelectedIndex = damagedElementsHUD\n elseif brokenElementsHUD > 0 then\n hudSelectedIndex = brokenElementsHUD\n end\n end\n end\n HighlightElement()\n DrawScreens()\n -- PrintDebug(\"-> Type: \"..hudSelectedType.. \" Index: \"..hudSelectedIndex)\n end\nend\n\nfunction HideHighlight()\n if #hudArrowSticker > 0 then\n for i in pairs(hudArrowSticker) do\n core.deleteSticker(hudArrowSticker[i])\n end\n hudArrowSticker = {}\n end\nend\n\nfunction ShowHighlight()\n if highlightOn == true and highlightID > 0 then\n table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX + 2,\n highlightY,\n highlightZ, \"north\"))\n table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,\n highlightY - 2,\n highlightZ, \"east\"))\n table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX - 2,\n highlightY,\n highlightZ, \"south\"))\n table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,\n highlightY + 2,\n highlightZ, \"west\"))\n table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,\n highlightY,\n highlightZ - 2,\n \"up\"))\n table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,\n highlightY,\n highlightZ + 2,\n \"down\"))\n end\nend\n\nfunction ToggleHighlight()\n if highlightOn == true then\n highlightOn = false\n HideHighlight()\n else\n highlightOn = true\n ShowHighlight()\n end\nend\n\nfunction HighlightElement(elementID)\n elementID = elementID or 0\n local targetElement = {}\n\n if elementID == 0 then\n if hudSelectedType == 1 then\n elementID = damagedElements[(CurrentDamagedPage - 1) * 12 +\n hudSelectedIndex].id\n elseif hudSelectedType == 2 then\n elementID = brokenElements[(CurrentBrokenPage - 1) * 12 +\n hudSelectedIndex].id\n end\n\n if elementID ~= 0 then\n local bFound = false\n for k, v in pairs(damagedElements) do\n if v.id == elementID then\n targetElement = v\n bFound = true\n break\n end\n end\n if bFound == false then\n for k, v in pairs(brokenElements) do\n if v.id == elementID then\n targetElement = v\n bFound = true\n break\n end\n end\n end\n\n if bFound == true and AllowElementHighlighting == true then\n HideHighlight()\n elementPosition = vec3(targetElement.pos)\n highlightX = elementPosition.x - coreWorldOffset\n highlightY = elementPosition.y - coreWorldOffset\n highlightZ = elementPosition.z - coreWorldOffset\n highlightID = targetElement.id\n highlightOn = true\n ShowHighlight()\n end\n end\n end\nend\n\nfunction SortTables()\n -- Sort damaged elements descending by percent damaged according to setting\n if DamagedSortingMode == 1 then\n table.sort(damagedElements,\n function(a, b) return a.missinghp > b.missinghp end)\n elseif DamagedSortingMode == 2 then\n table.sort(damagedElements, function(a, b) return a.id < b.id end)\n else\n table.sort(damagedElements,\n function(a, b) return a.percent < b.percent end)\n end\n\n -- Sort broken elements descending according to setting\n if BrokenSortingMode == 1 then\n table.sort(brokenElements, function(a, b)\n return a.maxhp > b.maxhp\n end)\n else\n table.sort(brokenElements, function(a, b) return a.id < b.id end)\n end\nend\n\nfunction GenerateDamageData()\n if SimulationActive == true then return end\n\n local formerTotalShipHP = totalShipHP\n totalShipHP = 0\n totalShipMaxHP = 0\n totalShipIntegrity = 100\n elementsId = {}\n damagedElements = {}\n brokenElements = {}\n ElementCounter = 0\n healthyElements = 0\n\n elementsIdList = core.getElementIdList()\n\n for _, id in pairs(elementsIdList) do\n ElementCounter = ElementCounter + 1\n idHP = core.getElementHitPointsById(id) or 0\n idMaxHP = core.getElementMaxHitPointsById(id) or 0\n\n if SimulationMode then\n SimulationActive = true\n local dice = math.random(0, 10)\n if dice < 2 then\n idHP = 0\n elseif dice >= 2 and dice < 5 then\n idHP = idMaxHP\n else\n idHP = math.random(1, math.ceil(idMaxHP))\n end\n end\n\n totalShipHP = totalShipHP + idHP\n totalShipMaxHP = totalShipMaxHP + idMaxHP\n\n idName = core.getElementNameById(id)\n idType = core.getElementTypeById(id)\n\n -- Is element damaged?\n if idMaxHP > idHP then\n idPos = core.getElementPositionById(id)\n if idHP > 0 then\n table.insert(damagedElements, {\n id = id,\n name = idName,\n type = idType,\n counter = ElementCounter,\n hp = idHP,\n maxhp = idMaxHP,\n missinghp = idMaxHP - idHP,\n percent = math.ceil(100 / idMaxHP * idHP),\n pos = idPos\n })\n -- if DebugMode then PrintDebug(\"Damaged: \"..idName..\" --- Type: \"..idType..\"\") end\n -- Is element broken?\n else\n table.insert(brokenElements, {\n id = id,\n name = idName,\n type = idType,\n counter = ElementCounter,\n hp = idHP,\n maxhp = idMaxHP,\n missinghp = idMaxHP - idHP,\n percent = 0,\n pos = idPos\n })\n -- if DebugMode then PrintDebug(\"Broken: \"..idName..\" --- Type: \"..idType..\"\") end\n end\n else\n healthyElements = healthyElements + 1\n if id == highlightID then\n highlightID = 0\n end\n end\n end\n\n -- Sort tables by current settings \n SortTables()\n\n -- Update clickAreas\n\n -- Determine total ship integrity\n totalShipIntegrity = string.format(\"%2.0f\",\n 100 / totalShipMaxHP * totalShipHP)\n\n -- Has anything changes since last check? If yes, force redrawing the screens\n if formerTotalShipHP ~= totalShipHP then\n forceRedraw = true\n formerTotalShipHP = totalShipHP\n else\n forceRedraw = false\n end\nend\n\nfunction GetAllSystemsNominalBackground()\n local output = \"\"\n output = output .. [[\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ]]\n return output\nend\n\nfunction GetDRLogo()\n output =\n [[]]\n return output\nend\n\nfunction GenerateHUDOutput()\n\n local hudWidth = 300\n local hudHeight = 125\n if #damagedElements > 0 or #brokenElements > 0 then hudHeight = 780 end\n local screenHeight = 1080\n\n local healthyColor = \"#00aa00\"\n local brokenColor = \"#aa0000\"\n local damagedColor = \"#aaaa00\"\n local integrityColor = \"#aaaaaa\"\n local healthyTextColor = \"white\"\n local brokenTextColor = \"#ff4444\"\n local damagedTextColor = \"#ffff44\"\n local integrityTextColor = \"white\"\n\n if #damagedElements == 0 then\n damagedColor = \"#aaaaaa\"\n damagedTextColor = \"white\"\n end\n if #brokenElements == 0 then\n brokenColor = \"#aaaaaa\"\n brokenTextColor = \"white\"\n end\n\n local hudOutput = \"\"\n\n -- Draw Header\n hudOutput = hudOutput .. [[\n ]]\n\n hudOutput = hudOutput .. [[]] ..\n [[]] .. GetDRLogo() .. [[]]\n\n hudOutput = hudOutput .. [[\n \n ]] .. healthyElements ..\n [[\n \n ]] .. #damagedElements ..\n [[\n \n ]] .. #brokenElements ..\n [[]]\n if #damagedElements > 0 or #brokenElements > 0 then\n hudOutput = hudOutput ..\n [[ ]] ..\n [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", totalShipMaxHP - totalShipHP)) ..\n [[ HP damage in total]]\n else\n hudOutput = hudOutput .. [[]] ..\n OkayCenterMessage .. [[]] ..\n [[Ship stands ]] ..\n GenerateCommaValue(string.format(\"%.0f\", totalShipMaxHP)) ..\n [[ HP strong.]]\n\n end\n hudOutput = hudOutput .. [[]]\n\n hudRowDistance = 25\n if #damagedElements > 0 then\n local damagedElementsToDraw = #damagedElements\n if damagedElementsToDraw > 12 then damagedElementsToDraw = 12 end\n if CurrentDamagedPage == math.ceil(#damagedElements / 12) then\n damagedElementsToDraw = #damagedElements % 12\n end\n local i = 0\n hudOutput = hudOutput .. [[]] ..\n [[]]\n\n for j = 1 + (CurrentDamagedPage - 1) * 12, damagedElementsToDraw +\n (CurrentDamagedPage - 1) * 12, 1 do\n i = i + 1\n local DP = damagedElements[j]\n if (hudSelectedType == 1 and hudSelectedIndex == i) then\n hudOutput = hudOutput .. [[]]\n if UseMyElementNames == true then\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.name) ..\n [[]]\n else\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.type) ..\n [[]]\n end\n if (DamagedSortingMode == 3) then\n hudOutput = hudOutput .. [[]] .. DP.percent ..\n [[%]]\n else\n hudOutput = hudOutput .. [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", DP.missinghp)) ..\n [[]]\n end\n else\n if UseMyElementNames == true then\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.name) ..\n [[]]\n else\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.type) ..\n [[]]\n end\n if (DamagedSortingMode == 3) then\n hudOutput = hudOutput .. [[]] .. DP.percent ..\n [[%]]\n else\n hudOutput = hudOutput .. [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", DP.missinghp)) ..\n [[]]\n end\n hudOutput = hudOutput .. [[]]\n end\n end\n hudOutput = hudOutput .. [[]]\n end\n\n if #brokenElements > 0 then\n local brokenElementsToDraw = #brokenElements\n if brokenElementsToDraw > 12 then brokenElementsToDraw = 12 end\n if CurrentbrokenPage == math.ceil(#brokenElements / 12) then\n brokenElementsToDraw = #brokenElements % 12\n end\n local i = 0\n hudOutput = hudOutput .. [[]] ..\n [[]]\n\n for j = 1 + (CurrentBrokenPage - 1) * 12, brokenElementsToDraw +\n (CurrentBrokenPage - 1) * 12, 1 do\n i = i + 1\n local DP = brokenElements[j]\n if (hudSelectedType == 2 and hudSelectedIndex == i) then\n hudOutput = hudOutput .. [[]]\n if UseMyElementNames == true then\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.name) ..\n [[]]\n else\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.type) ..\n [[]]\n end\n if (brokenSortingMode == 3) then\n hudOutput = hudOutput .. [[]] .. DP.percent ..\n [[%]]\n else\n hudOutput = hudOutput .. [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", DP.missinghp)) ..\n [[]]\n end\n else\n if UseMyElementNames == true then\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.name) ..\n [[]]\n else\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.type) ..\n [[]]\n end\n if (brokenSortingMode == 3) then\n hudOutput = hudOutput .. [[]] .. DP.percent ..\n [[%]]\n else\n hudOutput = hudOutput .. [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", DP.missinghp)) ..\n [[]]\n end\n hudOutput = hudOutput .. [[]]\n end\n end\n hudOutput = hudOutput .. [[]]\n end\n\n if #damagedElements or #brokenElements then\n hudOutput = hudOutput .. [[]] ..\n [[Use up/down arrows to select element to find.]] ..\n [[Use right arrow to deselect.]] ..\n [[Use left arrow to exit HUD mode.]] ..\n [[]]\n end\n\n hudOutput = hudOutput .. [[]]\n\n return hudOutput\nend\n\nfunction DrawScreens()\n if #screens > 0 then\n\n local healthyColor = \"#00aa00\"\n local brokenColor = \"#aa0000\"\n local damagedColor = \"#aaaa00\"\n local integrityColor = \"#aaaaaa\"\n local healthyTextColor = \"white\"\n local brokenTextColor = \"#ff4444\"\n local damagedTextColor = \"#ffff44\"\n local integrityTextColor = \"white\"\n\n if #damagedElements == 0 then\n damagedColor = \"#aaaaaa\"\n damagedTextColor = \"white\"\n end\n if #brokenElements == 0 then\n brokenColor = \"#aaaaaa\"\n brokenTextColor = \"white\"\n end\n\n local screenOutput = \"\"\n\n -- Draw Header\n screenOutput = screenOutput ..\n [[\n ]]\n\n -- Draw main background\n screenOutput = screenOutput ..\n [[\n \n \n \n \n \n \n \n \n \n \n \n ]]\n\n -- Draw Title and summary\n if SimulationActive == true then\n screenOutput = screenOutput ..\n [[Simulated Report]]\n else\n screenOutput = screenOutput ..\n [[Damage Report]]\n end\n if YourShipsName == nil or YourShipsName == \"\" or YourShipsName ==\n \"Enter here\" then\n screenOutput = screenOutput ..\n [[SHIP ID ]] ..\n shipID .. [[]]\n else\n screenOutput = screenOutput ..\n [[]] ..\n YourShipsName .. [[]]\n end\n screenOutput = screenOutput .. [[\n Healthy\n ]] .. healthyElements ..\n [[\n\n Damaged\n ]] .. #damagedElements ..\n [[\n\n Broken\n ]] .. #brokenElements ..\n [[\n\n Integrity\n ]] .. totalShipIntegrity ..\n [[%]]\n\n -- Draw damage elements\n\n if #damagedElements > 0 then\n local damagedElementsToDraw = #damagedElements\n if damagedElementsToDraw > 12 then\n damagedElementsToDraw = 12\n end\n if CurrentDamagedPage == math.ceil(#damagedElements / 12) then\n damagedElementsToDraw = #damagedElements % 12\n end\n screenOutput = screenOutput ..\n [[]]\n screenOutput = screenOutput ..\n [[]]\n if (DamagedSortingMode == 2) then\n screenOutput = screenOutput ..\n [[ID]]\n else\n screenOutput = screenOutput ..\n [[ID]]\n end\n if UseMyElementNames == true then\n screenOutput = screenOutput ..\n [[Element Name]]\n else\n screenOutput = screenOutput ..\n [[Element Type]]\n end\n\n if (DamagedSortingMode == 3) then\n screenOutput = screenOutput ..\n [[Health]]\n else\n screenOutput = screenOutput ..\n [[Health]]\n end\n if (DamagedSortingMode == 1) then\n screenOutput = screenOutput ..\n [[Damage]]\n else\n screenOutput = screenOutput ..\n [[Damage]]\n end\n\n local i = 0\n for j = 1 + (CurrentDamagedPage - 1) * 12, damagedElementsToDraw +\n (CurrentDamagedPage - 1) * 12, 1 do\n i = i + 1\n local DP = damagedElements[j]\n screenOutput = screenOutput .. [[]] ..\n string.format(\"%03.0f\", DP.id) .. [[]]\n if UseMyElementNames == true then\n screenOutput = screenOutput .. [[]] ..\n string.format(\"%.25s\", DP.name) ..\n [[]]\n else\n screenOutput = screenOutput .. [[]] ..\n string.format(\"%.25s\", DP.type) ..\n [[]]\n end\n screenOutput = screenOutput .. [[]] ..\n DP.percent .. [[%]] ..\n [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", DP.missinghp)) ..\n [[]] ..\n [[]]\n end\n screenOutput = screenOutput ..\n [[\n \n ]]\n\n if #damagedElements > 12 then\n screenOutput = screenOutput ..\n [[Page ]] ..\n CurrentDamagedPage .. \" of \" ..\n math.ceil(#damagedElements / 12) ..\n [[]]\n\n if CurrentDamagedPage < math.ceil(#damagedElements / 12) then\n screenOutput = screenOutput .. [[\n \n \n ]]\n UpdateClickArea(\"DamagedPageDown\", {\n id = \"DamagedPageDown\",\n x1 = 70,\n x2 = 270,\n y1 = 350 + 11 + (damagedElementsToDraw + 1) * 50,\n y2 = 350 + 11 + 50 + (damagedElementsToDraw + 1) * 50\n })\n else\n DisableClickArea(\"DamagedPageDown\")\n end\n\n if CurrentDamagedPage > 1 then\n screenOutput = screenOutput .. [[\n \n \n ]]\n UpdateClickArea(\"DamagedPageUp\", {\n id = \"DamagedPageUp\",\n x1 = 280,\n x2 = 480,\n y1 = 350 + 11 + (damagedElementsToDraw + 1) * 50,\n y2 = 350 + 11 + 50 + (damagedElementsToDraw + 1) * 50\n })\n else\n DisableClickArea(\"DamagedPageUp\")\n end\n end\n end\n\n -- Draw broken elements\n if #brokenElements > 0 then\n local brokenElementsToDraw = #brokenElements\n if brokenElementsToDraw > 12 then\n brokenElementsToDraw = 12\n end\n if CurrentBrokenPage == math.ceil(#brokenElements / 12) then\n brokenElementsToDraw = #brokenElements % 12\n end\n screenOutput = screenOutput ..\n [[]]\n screenOutput = screenOutput ..\n [[]]\n if (BrokenSortingMode == 2) then\n screenOutput = screenOutput ..\n [[ID]]\n else\n screenOutput = screenOutput ..\n [[ID]]\n end\n if UseMyElementNames == true then\n screenOutput = screenOutput ..\n [[Element Name]]\n else\n screenOutput = screenOutput ..\n [[Element Type]]\n end\n if (BrokenSortingMode == 1) then\n screenOutput = screenOutput ..\n [[Damage]]\n else\n screenOutput = screenOutput ..\n [[Damage]]\n end\n\n local i = 0\n for j = 1 + (CurrentBrokenPage - 1) * 12, brokenElementsToDraw +\n (CurrentBrokenPage - 1) * 12, 1 do\n i = i + 1\n local DP = brokenElements[j]\n screenOutput = screenOutput .. [[]] ..\n string.format(\"%03.0f\", DP.id) .. [[]]\n if UseMyElementNames == true then\n screenOutput = screenOutput .. [[]] ..\n string.format(\"%.25s\", DP.name) ..\n [[]]\n else\n screenOutput = screenOutput .. [[]] ..\n string.format(\"%.25s\", DP.type) ..\n [[]]\n end\n screenOutput = screenOutput .. [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", DP.missinghp)) ..\n [[]] ..\n [[]]\n end\n\n screenOutput = screenOutput ..\n [[\n \n ]]\n\n if #brokenElements > 12 then\n screenOutput = screenOutput ..\n [[Page ]] ..\n CurrentBrokenPage .. \" of \" ..\n math.ceil(#brokenElements / 12) ..\n [[]]\n\n if CurrentBrokenPage > 1 then\n screenOutput = screenOutput .. [[\n \n \n ]]\n UpdateClickArea(\"BrokenPageUp\", {\n id = \"BrokenPageUp\",\n x1 = 1442,\n x2 = 1642,\n y1 = 350 + 11 + (brokenElementsToDraw + 1) * 50,\n y2 = 350 + 11 + 50 + (brokenElementsToDraw + 1) * 50\n })\n else\n DisableClickArea(\"BrokenPageUp\")\n end\n\n if CurrentBrokenPage < math.ceil(#brokenElements / 12) then\n screenOutput = screenOutput .. [[\n \n \n ]]\n UpdateClickArea(\"BrokenPageDown\", {\n id = \"BrokenPageDown\",\n x1 = 1652,\n x2 = 1852,\n y1 = 350 + 11 + (brokenElementsToDraw + 1) * 50,\n y2 = 350 + 11 + 50 + (brokenElementsToDraw + 1) * 50\n })\n else\n DisableClickArea(\"BrokenPageDown\")\n end\n end\n\n end\n\n -- Draw damage summary\n if #damagedElements > 0 or #brokenElements > 0 then\n screenOutput = screenOutput ..\n [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\",\n totalShipMaxHP - totalShipHP)) ..\n [[ HP damage in total]]\n else\n screenOutput = screenOutput .. [[]] ..\n GetAllSystemsNominalBackground() .. [[]] ..\n [[]] ..\n OkayCenterMessage .. [[]] ..\n [[Ship stands ]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", totalShipMaxHP)) ..\n [[ HP strong.]]\n end\n\n -- Draw Sim Mode button\n if SimulationMode == true then\n screenOutput = screenOutput ..\n [[]] ..\n [[Sim Mode]]\n\n else\n screenOutput = screenOutput ..\n [[]] ..\n [[Sim Mode]]\n end\n\n -- Draw HUD Mode button\n if HUDMode == true then\n screenOutput = screenOutput ..\n [[]] ..\n [[HUD Mode]]\n\n else\n screenOutput = screenOutput ..\n [[]] ..\n [[HUD Mode]]\n end\n\n screenOutput = screenOutput .. [[]]\n\n DrawSVG(screenOutput)\n\n forceRedraw = false\n end\nend\n\n-----------------------------------------------\n-- Execute\n-----------------------------------------------\n\nunit.hide()\nClearConsole()\nPrintDebug(\"SCRIPT STARTED\", true)\n\nInitiateSlots()\nSwitchScreens(true)\nInitiateClickAreas()\n\nif #screens ~= nil and #screens < 1 then\n HUDMode = true\nend\n\nif core == nil then\n DrawCenteredText(\"ERROR: No core connected.\")\n PrintError(\"ERROR: No core connected.\")\n goto exit\nelse\n shipID = core.getConstructId()\nend\n\nGenerateDamageData()\nif forceRedraw then DrawScreens() end\n\nunit.setTimer('UpdateData', UpdateInterval)\nunit.setTimer('UpdateHighlight', HighlightBlinkingInterval)\n\n::exit::\n",
- "filter": {
- "args": [],
- "signature": "start()",
- "slotKey": "-1"
- },
- "key": "9"
- },
- {
- "code": "HideHighlight()\nSwitchScreens(false)\n",
- "filter": {
- "args": [],
- "signature": "stop()",
- "slotKey": "-1"
- },
- "key": "10"
- },
- {
- "code": "GenerateDamageData()\nif forceRedraw then\n DrawScreens()\nend\nif HUDMode == true then\n system.setScreen(GenerateHUDOutput())\n system.showScreen(1)\nelse\n system.showScreen(0)\nend",
- "filter": {
- "args": [
- {
- "value": "UpdateData"
- }
- ],
- "signature": "tick(timerId)",
- "slotKey": "-1"
- },
- "key": "11"
- },
- {
- "code": "ToggleHighlight()",
- "filter": {
- "args": [
- {
- "value": "UpdateHighlight"
- }
- ],
- "signature": "tick(timerId)",
- "slotKey": "-1"
- },
- "key": "12"
- },
- {
- "code": "HudDeselectElement()",
- "filter": {
- "args": [
- {
- "value": "straferight"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "13"
- },
- {
- "code": "ToggleHUD()",
- "filter": {
- "args": [
- {
- "value": "strafeleft"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "14"
- },
- {
- "code": "ChangeHudSelectedElement(1)",
- "filter": {
- "args": [
- {
- "value": "down"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "15"
- },
- {
- "code": "ChangeHudSelectedElement(-1)",
- "filter": {
- "args": [
- {
- "value": "up"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "16"
- }
- ],
- "methods": [],
- "events": []
-}
\ No newline at end of file
diff --git a/versions/DamageReport_2_33.json b/versions/DamageReport_2_33.json
deleted file mode 100644
index a3e77dc..0000000
--- a/versions/DamageReport_2_33.json
+++ /dev/null
@@ -1,339 +0,0 @@
-{
- "slots": {
- "0": {
- "name": "core",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "1": {
- "name": "slot2",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "2": {
- "name": "slot3",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "3": {
- "name": "slot4",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "4": {
- "name": "slot5",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "5": {
- "name": "slot6",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "6": {
- "name": "slot7",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "7": {
- "name": "slot8",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "8": {
- "name": "slot9",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "9": {
- "name": "slot10",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-1": {
- "name": "unit",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-2": {
- "name": "system",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-3": {
- "name": "library",
- "type": {
- "events": [],
- "methods": []
- }
- }
- },
- "handlers": [
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "1"
- },
- "key": "0"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "2"
- },
- "key": "1"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "3"
- },
- "key": "2"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "4"
- },
- "key": "3"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "5"
- },
- "key": "4"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "6"
- },
- "key": "5"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "7"
- },
- "key": "6"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "8"
- },
- "key": "7"
- },
- {
- "code": "clickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "9"
- },
- "key": "8"
- },
- {
- "code": "--[[\n DamageReport v2.33\n Created By Dorian Gray\n\n Discord: Dorian Gray#2623\n InGame: DorianGray\n GitHub: https://github.com/DorianTheGrey/DU-DamageReport\n\n GNU Public License 3.0. Use whatever you want, be so kind to leave credit.\n\n Thanks to Jericho, Dmentia and Archaegeo for learning from their fine scripts.\n]] \n-----------------------------------------------\n-- CONFIG\n-----------------------------------------------\nUseMyElementNames = true --export: If you active this, the display will not show the element type of damaged/broken elements but the name you gave them (truncated to 25 characters)\nAllowElementHighlighting = true --export: Are you allowing damaged/broken elements to be highlighted in 3D space when selected in the HUD?\nUpdateInterval = 1 --export: Interval in seconds between updates of the calculations and (if anything changed) redrawing to the screen(s). You need to restart the script after changing this value.\nHighlightBlinkingInterval = 0.5 --export: If an element is marked, how fast do you want the arrows to blink?\nSimulationMode = false --export Randomize simluated damage on elements to check out the functionality of this script. And, no, your elements won't be harmed in the process :) You need to restart the script after changing this value.\nYourShipsName = \"Enter here\" --export Enter your ship name here if you want it displayed instead of the ship's ID. YOU NEED TO LEAVE THE QUOTATION MARKS.\nBackgroundColor = \"1e1e1e\" --export Set the background color of the screens. YOU NEED TO LEAVE THE QUOTATION MARKS.\n\nDebugMode = false -- Activate if you want some console messages\nVersionNumber = 2.33 -- Version number\n\ncore = nil\nscreens = {}\n\nshipID = 0\nforceRedraw = false\nSimulationActive = false\n\nclickAreas = {}\nDamagedSortingMode = 1 -- Define default sorting mode for damaged elements. 1 to sort by damage amount, 2 to sort by element id, 3 to sort by damage percent, \nBrokenSortingMode = 1 -- Define default sorting mode for broken elements. 1 to sort by damage amount, 2 to sort by element id\n\nHUDMode = false -- Is Hud active?\nhudSelectedIndex = 0 -- Which element is selected?\nhudSelectedType = 0 -- Is selected element damaged (1) or broken (2)\nhudArrowSticker = {}\nhighlightOn = false\nhighlightID = 0\nhighlightX = 0\nhighlightY = 0\nhighlightZ = 0\n\nCurrentDamagedPage = 1\nCurrentBrokenPage = 1\n\ncoreWorldOffset = 0\ntotalShipHP = 0\ntotalShipMaxHP = 0\ntotalShipIntegrity = 100\nelementsId = {}\ndamagedElements = {}\nbrokenElements = {}\nElementCounter = 0\nhealthyElements = 0\n\nOkayCenterMessage = \"All systems nominal.\"\n\n-----------------------------------------------\n-- FUNCTIONS\n-----------------------------------------------\n\nfunction GenerateCommaValue(amount)\n local formatted = amount\n while true do\n formatted, k = string.gsub(formatted, \"^(-?%d+)(%d%d%d)\", '%1,%2')\n if (k == 0) then break end\n end\n return formatted\nend\n\nfunction PrintDebug(output, highlight)\n highlight = highlight or false\n if DebugMode then\n if highlight then\n system.print(\n \"------------------------------------------------------------------------\")\n end\n system.print(output)\n if highlight then\n system.print(\n \"------------------------------------------------------------------------\")\n end\n end\nend\n\nfunction PrintError(output) system.print(output) end\n\nfunction DrawCenteredText(output)\n for i = 1, #screens, 1 do screens[i].setCenteredText(output) end\nend\n\nfunction DrawSVG(output) for i = 1, #screens, 1 do screens[i].setSVG(output) end end\n\nfunction ClearConsole() for i = 1, 10, 1 do PrintDebug() end end\n\nfunction SwitchScreens(state)\n state = state or true\n if #screens > 0 then\n for i = 1, #screens, 1 do\n if state==true then\n screens[i].clear()\n screens[i].activate()\n else\n screens[i].deactivate()\n screens[i].clear()\n end\n end\n end\nend\n\nfunction InitiateSlots()\n for slot_name, slot in pairs(unit) do\n if type(slot) == \"table\" and type(slot.export) == \"table\" and\n slot.getElementClass then\n if slot.getElementClass():lower():find(\"coreunit\") then\n core = slot\n local coreHP = core.getMaxHitPoints()\n if coreHP > 10000 then\n coreWorldOffset = 128\n elseif coreHP > 1000 then\n coreWorldOffset = 64\n elseif coreHP > 150 then\n coreWorldOffset = 32\n else\n coreWorldOffset = 16\n end\n end\n if slot.getElementClass():lower():find(\"screenunit\") then\n screens[#screens + 1] = slot\n end\n end\n end\nend\n\nfunction AddClickArea(newEntry) table.insert(clickAreas, newEntry) end\n\nfunction RemoveFromClickAreas(candidate)\n for k, v in pairs(clickAreas) do\n if v.id == candidate then\n clickAreas[k] = nil\n break\n end\n end\nend\n\nfunction UpdateClickArea(candidate, newEntry)\n for k, v in pairs(clickAreas) do\n if v.id == candidate then\n clickAreas[k] = newEntry\n break\n end\n end\nend\n\nfunction DisableClickArea(candidate)\n for k, v in pairs(clickAreas) do\n if v.id == candidate then\n UpdateClickArea(candidate, {\n id = candidate,\n x1 = -1,\n x2 = -1,\n y1 = -1,\n y2 = -1\n })\n break\n end\n end\nend\n\nfunction InitiateClickAreas()\n clickAreas = {}\n AddClickArea({id = \"DamagedDamage\", x1 = 725, x2 = 870, y1 = 380, y2 = 415})\n AddClickArea({id = \"DamagedHealth\", x1 = 520, x2 = 655, y1 = 380, y2 = 415})\n AddClickArea({id = \"DamagedID\", x1 = 90, x2 = 150, y1 = 380, y2 = 415})\n AddClickArea({id = \"BrokenDamage\", x1 = 1675, x2 = 1835, y1 = 380, y2 = 415})\n AddClickArea({id = \"BrokenID\", x1 = 1050, x2 = 1110, y1 = 380, y2 = 415})\n AddClickArea({id = \"ToggleSimulation\", x1 = 65, x2 = 660, y1 = 100, y2 = 145})\n AddClickArea({id = \"ToggleSimulation2\", x1 = 1650, x2 = 1850, y1 = 75, y2 = 117})\n AddClickArea({id = \"ToggleElementLabel\", x1 = 225, x2 = 460, y1 = 380, y2 = 415})\n AddClickArea({id = \"ToggleElementLabel2\", x1 = 1185, x2 = 1440, y1 = 380, y2 = 415})\n AddClickArea({id = \"ToggleHudMode\", x1 = 1650, x2 = 1850, y1 = 125, y2 = 167})\n AddClickArea({id = \"DamagedPageDown\", x1 = -1, x2 = -1, y1 = -1, y2 = -1})\n AddClickArea({id = \"DamagedPageUp\", x1 = -1, x2 = -1, y1 = -1, y2 = -1})\n AddClickArea({id = \"BrokenPageDown\", x1 = -1, x2 = -1, y1 = -1, y2 = -1})\n AddClickArea({id = \"BrokenPageUp\", x1 = -1, x2 = -1, y1 = -1, y2 = -1})\nend\n\nfunction FlushClickAreas() clickAreas = {} end\n\nfunction CheckClick(x, y, HitTarget)\n HitTarget = HitTarget or \"\"\n if HitTarget == \"\" then\n for k, v in pairs(clickAreas) do\n if v and x >= v.x1 and x <= v.x2 and y >= v.y1 and y <= v.y2 then\n HitTarget = v.id\n break\n end\n end\n end\n if HitTarget == \"DamagedDamage\" then\n DamagedSortingMode = 1\n CurrentDamagedPage = 1\n SortTables()\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"DamagedHealth\" then\n DamagedSortingMode = 3\n CurrentDamagedPage = 1\n SortTables()\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"DamagedID\" then\n DamagedSortingMode = 2\n CurrentDamagedPage = 1\n SortTables()\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"BrokenDamage\" then\n BrokenSortingMode = 1\n CurrentBrokenPage = 1\n SortTables()\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"BrokenID\" then\n BrokenSortingMode = 2\n CurrentBrokenPage = 1\n SortTables()\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"DamagedPageDown\" then\n CurrentDamagedPage = CurrentDamagedPage + 1\n if CurrentDamagedPage > math.ceil(#damagedElements / 12) then\n CurrentDamagedPage = math.ceil(#damagedElements / 12)\n end\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"DamagedPageUp\" then\n CurrentDamagedPage = CurrentDamagedPage - 1\n if CurrentDamagedPage < 1 then CurrentDamagedPage = 1 end\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"BrokenPageDown\" then\n CurrentBrokenPage = CurrentBrokenPage + 1\n if CurrentBrokenPage > math.ceil(#brokenElements / 12) then\n CurrentBrokenPage = math.ceil(#brokenElements / 12)\n end\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"BrokenPageUp\" then\n CurrentBrokenPage = CurrentBrokenPage - 1\n if CurrentBrokenPage < 1 then CurrentBrokenPage = 1 end\n HudDeselectElement()\n DrawScreens()\n elseif HitTarget == \"ToggleHudMode\" then\n if HUDMode == true then\n HUDMode = false\n forceRedraw = true\n HudDeselectElement()\n DrawScreens()\n else\n HUDMode = true\n forceRedraw = true\n HudDeselectElement()\n DrawScreens()\n end\n elseif HitTarget == \"ToggleSimulation\" or HitTarget == \"ToggleSimulation2\" then\n CurrentDamagedPage = 1\n CurrentBrokenPage = 1\n if SimulationMode == true then\n SimulationMode = false\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n HudDeselectElement()\n DrawScreens()\n else\n SimulationMode = true\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n HudDeselectElement()\n DrawScreens()\n end\n elseif HitTarget == \"ToggleElementLabel\" or HitTarget ==\n \"ToggleElementLabel2\" then\n if UseMyElementNames == true then\n UseMyElementNames = false\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n HudDeselectElement()\n DrawScreens()\n else\n UseMyElementNames = true\n SimulationActive = false\n GenerateDamageData()\n forceRedraw = true\n HudDeselectElement()\n DrawScreens()\n end\n end\nend\n\nfunction ToggleHUD()\n HideHighlight()\n CheckClick(nil, nil, \"ToggleHudMode\")\nend\n\nfunction HudDeselectElement()\n if HUDMode == true then\n hudSelectedType = 0\n hudSelectedIndex = 0\n HideHighlight()\n DrawScreens()\n end\nend\n\nfunction ChangeHudSelectedElement(step)\n if HUDMode == true and (#damagedElements or #brokenElements) then\n local damagedElementsHUD = 12\n if #damagedElements < 12 then\n damagedElementsHUD = #damagedElements\n end\n local brokenElementsHUD = 12\n if #brokenElements < 12 then brokenElementsHUD = #brokenElements end\n if step == 1 then\n if hudSelectedIndex == 0 then\n if damagedElementsHUD > 0 then\n hudSelectedType = 1\n hudSelectedIndex = 1\n elseif brokenElementsHUD > 0 then\n hudSelectedType = 2\n hudSelectedIndex = 1\n end\n elseif hudSelectedType == 1 then\n if damagedElementsHUD > hudSelectedIndex then\n hudSelectedIndex = hudSelectedIndex + 1\n elseif brokenElementsHUD > 0 then\n hudSelectedType = 2\n hudSelectedIndex = 1\n elseif damagedElementsHUD > 0 then\n hudSelectedIndex = 1\n end\n elseif hudSelectedType == 2 then\n if brokenElementsHUD > hudSelectedIndex then\n hudSelectedIndex = hudSelectedIndex + 1\n elseif damagedElementsHUD > 0 then\n hudSelectedType = 1\n hudSelectedIndex = 1\n elseif brokenElementsHUD > 0 then\n hudSelectedIndex = 1\n end\n end\n elseif step == -1 then\n if hudSelectedIndex == 0 then\n if brokenElementsHUD > 0 then\n hudSelectedType = 2\n hudSelectedIndex = 1\n elseif damagedElementsHUD > 0 then\n hudSelectedType = 1\n hudSelectedIndex = 1\n end\n elseif hudSelectedType == 1 then\n if hudSelectedIndex > 1 then\n hudSelectedIndex = hudSelectedIndex - 1\n elseif brokenElementsHUD > 0 then\n hudSelectedType = 2\n hudSelectedIndex = brokenElementsHUD\n elseif damagedElementsHUD > 0 then\n hudSelectedIndex = damagedElementsHUD\n end\n elseif hudSelectedType == 2 then\n if hudSelectedIndex > 1 then\n hudSelectedIndex = hudSelectedIndex - 1\n elseif damagedElementsHUD > 0 then\n hudSelectedType = 1\n hudSelectedIndex = damagedElementsHUD\n elseif brokenElementsHUD > 0 then\n hudSelectedIndex = brokenElementsHUD\n end\n end\n end\n HighlightElement()\n DrawScreens()\n -- PrintDebug(\"-> Type: \"..hudSelectedType.. \" Index: \"..hudSelectedIndex)\n end\nend\n\nfunction HideHighlight()\n if #hudArrowSticker > 0 then\n for i in pairs(hudArrowSticker) do\n core.deleteSticker(hudArrowSticker[i])\n end\n hudArrowSticker = {}\n end\nend\n\nfunction ShowHighlight()\n if highlightOn == true and highlightID > 0 then\n table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX + 2,\n highlightY,\n highlightZ, \"north\"))\n table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,\n highlightY - 2,\n highlightZ, \"east\"))\n table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX - 2,\n highlightY,\n highlightZ, \"south\"))\n table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,\n highlightY + 2,\n highlightZ, \"west\"))\n table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,\n highlightY,\n highlightZ - 2,\n \"up\"))\n table.insert(hudArrowSticker, core.spawnArrowSticker(highlightX,\n highlightY,\n highlightZ + 2,\n \"down\"))\n end\nend\n\nfunction ToggleHighlight()\n if highlightOn == true then\n highlightOn = false\n HideHighlight()\n else\n highlightOn = true\n ShowHighlight()\n end\nend\n\nfunction HighlightElement(elementID)\n elementID = elementID or 0\n local targetElement = {}\n\n if elementID == 0 then\n if hudSelectedType == 1 then\n elementID = damagedElements[(CurrentDamagedPage - 1) * 12 +\n hudSelectedIndex].id\n elseif hudSelectedType == 2 then\n elementID = brokenElements[(CurrentBrokenPage - 1) * 12 +\n hudSelectedIndex].id\n end\n\n if elementID ~= 0 then\n local bFound = false\n for k, v in pairs(damagedElements) do\n if v.id == elementID then\n targetElement = v\n bFound = true\n break\n end\n end\n if bFound == false then\n for k, v in pairs(brokenElements) do\n if v.id == elementID then\n targetElement = v\n bFound = true\n break\n end\n end\n end\n\n if bFound == true and AllowElementHighlighting == true then\n HideHighlight()\n elementPosition = vec3(targetElement.pos)\n highlightX = elementPosition.x - coreWorldOffset\n highlightY = elementPosition.y - coreWorldOffset\n highlightZ = elementPosition.z - coreWorldOffset\n highlightID = targetElement.id\n highlightOn = true\n ShowHighlight()\n end\n end\n end\nend\n\nfunction SortTables()\n -- Sort damaged elements descending by percent damaged according to setting\n if DamagedSortingMode == 1 then\n table.sort(damagedElements,\n function(a, b) return a.missinghp > b.missinghp end)\n elseif DamagedSortingMode == 2 then\n table.sort(damagedElements, function(a, b) return a.id < b.id end)\n else\n table.sort(damagedElements,\n function(a, b) return a.percent < b.percent end)\n end\n\n -- Sort broken elements descending according to setting\n if BrokenSortingMode == 1 then\n table.sort(brokenElements, function(a, b)\n return a.maxhp > b.maxhp\n end)\n else\n table.sort(brokenElements, function(a, b) return a.id < b.id end)\n end\nend\n\nfunction GenerateDamageData()\n if SimulationActive == true then return end\n\n local formerTotalShipHP = totalShipHP\n totalShipHP = 0\n totalShipMaxHP = 0\n totalShipIntegrity = 100\n elementsId = {}\n damagedElements = {}\n brokenElements = {}\n ElementCounter = 0\n healthyElements = 0\n\n elementsIdList = core.getElementIdList()\n\n for _, id in pairs(elementsIdList) do\n ElementCounter = ElementCounter + 1\n idHP = core.getElementHitPointsById(id) or 0\n idMaxHP = core.getElementMaxHitPointsById(id) or 0\n\n if SimulationMode then\n SimulationActive = true\n local dice = math.random(0, 10)\n if dice < 2 then\n idHP = 0\n elseif dice >= 2 and dice < 5 then\n idHP = idMaxHP\n else\n idHP = math.random(1, math.ceil(idMaxHP))\n end\n end\n\n totalShipHP = totalShipHP + idHP\n totalShipMaxHP = totalShipMaxHP + idMaxHP\n\n idName = core.getElementNameById(id)\n idType = core.getElementTypeById(id)\n\n -- Is element damaged?\n if idMaxHP > idHP then\n idPos = core.getElementPositionById(id)\n if idHP > 0 then\n table.insert(damagedElements, {\n id = id,\n name = idName,\n type = idType,\n counter = ElementCounter,\n hp = idHP,\n maxhp = idMaxHP,\n missinghp = idMaxHP - idHP,\n percent = math.ceil(100 / idMaxHP * idHP),\n pos = idPos\n })\n -- if DebugMode then PrintDebug(\"Damaged: \"..idName..\" --- Type: \"..idType..\"\") end\n -- Is element broken?\n else\n table.insert(brokenElements, {\n id = id,\n name = idName,\n type = idType,\n counter = ElementCounter,\n hp = idHP,\n maxhp = idMaxHP,\n missinghp = idMaxHP - idHP,\n percent = 0,\n pos = idPos\n })\n -- if DebugMode then PrintDebug(\"Broken: \"..idName..\" --- Type: \"..idType..\"\") end\n end\n else\n healthyElements = healthyElements + 1\n if id == highlightID then\n highlightID = 0\n end\n end\n end\n\n -- Sort tables by current settings \n SortTables()\n\n -- Update clickAreas\n\n -- Determine total ship integrity\n totalShipIntegrity = string.format(\"%2.0f\",\n 100 / totalShipMaxHP * totalShipHP)\n\n -- Has anything changes since last check? If yes, force redrawing the screens\n if formerTotalShipHP ~= totalShipHP then\n forceRedraw = true\n formerTotalShipHP = totalShipHP\n else\n forceRedraw = false\n end\nend\n\nfunction GetAllSystemsNominalBackground()\n local output = \"\"\n output = output .. [[\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ]]\n return output\nend\n\nfunction GetDRLogo()\n output =\n [[]]\n return output\nend\n\nfunction GenerateHUDOutput()\n\n local hudWidth = 300\n local hudHeight = 125\n if #damagedElements > 0 or #brokenElements > 0 then hudHeight = 780 end\n local screenHeight = 1080\n\n local healthyColor = \"#00aa00\"\n local brokenColor = \"#aa0000\"\n local damagedColor = \"#aaaa00\"\n local integrityColor = \"#aaaaaa\"\n local healthyTextColor = \"white\"\n local brokenTextColor = \"#ff4444\"\n local damagedTextColor = \"#ffff44\"\n local integrityTextColor = \"white\"\n\n if #damagedElements == 0 then\n damagedColor = \"#aaaaaa\"\n damagedTextColor = \"white\"\n end\n if #brokenElements == 0 then\n brokenColor = \"#aaaaaa\"\n brokenTextColor = \"white\"\n end\n\n local hudOutput = \"\"\n\n -- Draw Header\n hudOutput = hudOutput .. [[\n ]]\n\n hudOutput = hudOutput .. [[]] ..\n [[]] .. GetDRLogo() .. [[]]\n\n hudOutput = hudOutput .. [[\n \n ]] .. healthyElements ..\n [[\n \n ]] .. #damagedElements ..\n [[\n \n ]] .. #brokenElements ..\n [[]]\n if #damagedElements > 0 or #brokenElements > 0 then\n hudOutput = hudOutput ..\n [[ ]] ..\n [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", totalShipMaxHP - totalShipHP)) ..\n [[ HP damage in total]]\n else\n hudOutput = hudOutput .. [[]] ..\n OkayCenterMessage .. [[]] ..\n [[Ship stands ]] ..\n GenerateCommaValue(string.format(\"%.0f\", totalShipMaxHP)) ..\n [[ HP strong.]]\n\n end\n hudOutput = hudOutput .. [[]]\n\n hudRowDistance = 25\n if #damagedElements > 0 then\n local damagedElementsToDraw = #damagedElements\n if damagedElementsToDraw > 12 then damagedElementsToDraw = 12 end\n if CurrentDamagedPage == math.ceil(#damagedElements / 12) then\n damagedElementsToDraw = #damagedElements % 12\n end\n local i = 0\n hudOutput = hudOutput .. [[]] ..\n [[]]\n\n for j = 1 + (CurrentDamagedPage - 1) * 12, damagedElementsToDraw +\n (CurrentDamagedPage - 1) * 12, 1 do\n i = i + 1\n local DP = damagedElements[j]\n if (hudSelectedType == 1 and hudSelectedIndex == i) then\n hudOutput = hudOutput .. [[]]\n if UseMyElementNames == true then\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.name) ..\n [[]]\n else\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.type) ..\n [[]]\n end\n if (DamagedSortingMode == 3) then\n hudOutput = hudOutput .. [[]] .. DP.percent ..\n [[%]]\n else\n hudOutput = hudOutput .. [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", DP.missinghp)) ..\n [[]]\n end\n else\n if UseMyElementNames == true then\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.name) ..\n [[]]\n else\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.type) ..\n [[]]\n end\n if (DamagedSortingMode == 3) then\n hudOutput = hudOutput .. [[]] .. DP.percent ..\n [[%]]\n else\n hudOutput = hudOutput .. [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", DP.missinghp)) ..\n [[]]\n end\n hudOutput = hudOutput .. [[]]\n end\n end\n hudOutput = hudOutput .. [[]]\n end\n\n if #brokenElements > 0 then\n local brokenElementsToDraw = #brokenElements\n if brokenElementsToDraw > 12 then brokenElementsToDraw = 12 end\n if CurrentbrokenPage == math.ceil(#brokenElements / 12) then\n brokenElementsToDraw = #brokenElements % 12\n end\n local i = 0\n hudOutput = hudOutput .. [[]] ..\n [[]]\n\n for j = 1 + (CurrentBrokenPage - 1) * 12, brokenElementsToDraw +\n (CurrentBrokenPage - 1) * 12, 1 do\n i = i + 1\n local DP = brokenElements[j]\n if (hudSelectedType == 2 and hudSelectedIndex == i) then\n hudOutput = hudOutput .. [[]]\n if UseMyElementNames == true then\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.name) ..\n [[]]\n else\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.type) ..\n [[]]\n end\n if (brokenSortingMode == 3) then\n hudOutput = hudOutput .. [[]] .. DP.percent ..\n [[%]]\n else\n hudOutput = hudOutput .. [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", DP.missinghp)) ..\n [[]]\n end\n else\n if UseMyElementNames == true then\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.name) ..\n [[]]\n else\n hudOutput = hudOutput .. [[]] ..\n string.format(\"%.32s\", DP.type) ..\n [[]]\n end\n if (brokenSortingMode == 3) then\n hudOutput = hudOutput .. [[]] .. DP.percent ..\n [[%]]\n else\n hudOutput = hudOutput .. [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", DP.missinghp)) ..\n [[]]\n end\n hudOutput = hudOutput .. [[]]\n end\n end\n hudOutput = hudOutput .. [[]]\n end\n\n if #damagedElements or #brokenElements then\n hudOutput = hudOutput .. [[]] ..\n [[Use up/down arrows to select element to find.]] ..\n [[Use right arrow to deselect.]] ..\n [[Use left arrow to exit HUD mode.]] ..\n [[]]\n end\n\n hudOutput = hudOutput .. [[]]\n\n return hudOutput\nend\n\nfunction DrawScreens()\n if #screens > 0 then\n\n local healthyColor = \"#00aa00\"\n local brokenColor = \"#aa0000\"\n local damagedColor = \"#aaaa00\"\n local integrityColor = \"#aaaaaa\"\n local healthyTextColor = \"white\"\n local brokenTextColor = \"#ff4444\"\n local damagedTextColor = \"#ffff44\"\n local integrityTextColor = \"white\"\n\n if #damagedElements == 0 then\n damagedColor = \"#aaaaaa\"\n damagedTextColor = \"white\"\n end\n if #brokenElements == 0 then\n brokenColor = \"#aaaaaa\"\n brokenTextColor = \"white\"\n end\n\n local screenOutput = \"\"\n\n -- Draw Header\n screenOutput = screenOutput ..\n [[\n ]]\n\n -- Draw main background\n screenOutput = screenOutput ..\n [[\n \n \n \n \n \n \n \n \n \n \n \n ]]\n\n -- Draw Title and summary\n if SimulationActive == true then\n screenOutput = screenOutput ..\n [[Simulated Report]]\n else\n screenOutput = screenOutput ..\n [[Damage Report]]\n end\n if YourShipsName == nil or YourShipsName == \"\" or YourShipsName ==\n \"Enter here\" then\n screenOutput = screenOutput ..\n [[SHIP ID ]] ..\n shipID .. [[]]\n else\n screenOutput = screenOutput ..\n [[]] ..\n YourShipsName .. [[]]\n end\n screenOutput = screenOutput .. [[\n Healthy\n ]] .. healthyElements ..\n [[\n\n Damaged\n ]] .. #damagedElements ..\n [[\n\n Broken\n ]] .. #brokenElements ..\n [[\n\n Integrity\n ]] .. totalShipIntegrity ..\n [[%]]\n\n -- Draw damage elements\n\n if #damagedElements > 0 then\n local damagedElementsToDraw = #damagedElements\n if damagedElementsToDraw > 12 then\n damagedElementsToDraw = 12\n end\n if CurrentDamagedPage == math.ceil(#damagedElements / 12) then\n damagedElementsToDraw = #damagedElements % 12\n end\n screenOutput = screenOutput ..\n [[]]\n screenOutput = screenOutput ..\n [[]]\n if (DamagedSortingMode == 2) then\n screenOutput = screenOutput ..\n [[ID]]\n else\n screenOutput = screenOutput ..\n [[ID]]\n end\n if UseMyElementNames == true then\n screenOutput = screenOutput ..\n [[Element Name]]\n else\n screenOutput = screenOutput ..\n [[Element Type]]\n end\n\n if (DamagedSortingMode == 3) then\n screenOutput = screenOutput ..\n [[Health]]\n else\n screenOutput = screenOutput ..\n [[Health]]\n end\n if (DamagedSortingMode == 1) then\n screenOutput = screenOutput ..\n [[Damage]]\n else\n screenOutput = screenOutput ..\n [[Damage]]\n end\n\n local i = 0\n for j = 1 + (CurrentDamagedPage - 1) * 12, damagedElementsToDraw +\n (CurrentDamagedPage - 1) * 12, 1 do\n i = i + 1\n local DP = damagedElements[j]\n screenOutput = screenOutput .. [[]] ..\n string.format(\"%03.0f\", DP.id) .. [[]]\n if UseMyElementNames == true then\n screenOutput = screenOutput .. [[]] ..\n string.format(\"%.25s\", DP.name) ..\n [[]]\n else\n screenOutput = screenOutput .. [[]] ..\n string.format(\"%.25s\", DP.type) ..\n [[]]\n end\n screenOutput = screenOutput .. [[]] ..\n DP.percent .. [[%]] ..\n [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", DP.missinghp)) ..\n [[]] ..\n [[]]\n end\n screenOutput = screenOutput ..\n [[\n \n ]]\n\n if #damagedElements > 12 then\n screenOutput = screenOutput ..\n [[Page ]] ..\n CurrentDamagedPage .. \" of \" ..\n math.ceil(#damagedElements / 12) ..\n [[]]\n\n if CurrentDamagedPage < math.ceil(#damagedElements / 12) then\n screenOutput = screenOutput .. [[\n \n \n ]]\n UpdateClickArea(\"DamagedPageDown\", {\n id = \"DamagedPageDown\",\n x1 = 70,\n x2 = 270,\n y1 = 350 + 11 + (damagedElementsToDraw + 1) * 50,\n y2 = 350 + 11 + 50 + (damagedElementsToDraw + 1) * 50\n })\n else\n DisableClickArea(\"DamagedPageDown\")\n end\n\n if CurrentDamagedPage > 1 then\n screenOutput = screenOutput .. [[\n \n \n ]]\n UpdateClickArea(\"DamagedPageUp\", {\n id = \"DamagedPageUp\",\n x1 = 280,\n x2 = 480,\n y1 = 350 + 11 + (damagedElementsToDraw + 1) * 50,\n y2 = 350 + 11 + 50 + (damagedElementsToDraw + 1) * 50\n })\n else\n DisableClickArea(\"DamagedPageUp\")\n end\n end\n end\n\n -- Draw broken elements\n if #brokenElements > 0 then\n local brokenElementsToDraw = #brokenElements\n if brokenElementsToDraw > 12 then\n brokenElementsToDraw = 12\n end\n if CurrentBrokenPage == math.ceil(#brokenElements / 12) then\n brokenElementsToDraw = #brokenElements % 12\n end\n screenOutput = screenOutput ..\n [[]]\n screenOutput = screenOutput ..\n [[]]\n if (BrokenSortingMode == 2) then\n screenOutput = screenOutput ..\n [[ID]]\n else\n screenOutput = screenOutput ..\n [[ID]]\n end\n if UseMyElementNames == true then\n screenOutput = screenOutput ..\n [[Element Name]]\n else\n screenOutput = screenOutput ..\n [[Element Type]]\n end\n if (BrokenSortingMode == 1) then\n screenOutput = screenOutput ..\n [[Damage]]\n else\n screenOutput = screenOutput ..\n [[Damage]]\n end\n\n local i = 0\n for j = 1 + (CurrentBrokenPage - 1) * 12, brokenElementsToDraw +\n (CurrentBrokenPage - 1) * 12, 1 do\n i = i + 1\n local DP = brokenElements[j]\n screenOutput = screenOutput .. [[]] ..\n string.format(\"%03.0f\", DP.id) .. [[]]\n if UseMyElementNames == true then\n screenOutput = screenOutput .. [[]] ..\n string.format(\"%.25s\", DP.name) ..\n [[]]\n else\n screenOutput = screenOutput .. [[]] ..\n string.format(\"%.25s\", DP.type) ..\n [[]]\n end\n screenOutput = screenOutput .. [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", DP.missinghp)) ..\n [[]] ..\n [[]]\n end\n\n screenOutput = screenOutput ..\n [[\n \n ]]\n\n if #brokenElements > 12 then\n screenOutput = screenOutput ..\n [[Page ]] ..\n CurrentBrokenPage .. \" of \" ..\n math.ceil(#brokenElements / 12) ..\n [[]]\n\n if CurrentBrokenPage > 1 then\n screenOutput = screenOutput .. [[\n \n \n ]]\n UpdateClickArea(\"BrokenPageUp\", {\n id = \"BrokenPageUp\",\n x1 = 1442,\n x2 = 1642,\n y1 = 350 + 11 + (brokenElementsToDraw + 1) * 50,\n y2 = 350 + 11 + 50 + (brokenElementsToDraw + 1) * 50\n })\n else\n DisableClickArea(\"BrokenPageUp\")\n end\n\n if CurrentBrokenPage < math.ceil(#brokenElements / 12) then\n screenOutput = screenOutput .. [[\n \n \n ]]\n UpdateClickArea(\"BrokenPageDown\", {\n id = \"BrokenPageDown\",\n x1 = 1652,\n x2 = 1852,\n y1 = 350 + 11 + (brokenElementsToDraw + 1) * 50,\n y2 = 350 + 11 + 50 + (brokenElementsToDraw + 1) * 50\n })\n else\n DisableClickArea(\"BrokenPageDown\")\n end\n end\n\n end\n\n -- Draw damage summary\n if #damagedElements > 0 or #brokenElements > 0 then\n screenOutput = screenOutput ..\n [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\",\n totalShipMaxHP - totalShipHP)) ..\n [[ HP damage in total]]\n else\n screenOutput = screenOutput .. [[]] ..\n GetAllSystemsNominalBackground() .. [[]] ..\n [[]] ..\n OkayCenterMessage .. [[]] ..\n [[Ship stands ]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", totalShipMaxHP)) ..\n [[ HP strong.]]\n end\n\n -- Draw Sim Mode button\n if SimulationMode == true then\n screenOutput = screenOutput ..\n [[]] ..\n [[Sim Mode]]\n\n else\n screenOutput = screenOutput ..\n [[]] ..\n [[Sim Mode]]\n end\n\n -- Draw HUD Mode button\n if HUDMode == true then\n screenOutput = screenOutput ..\n [[]] ..\n [[HUD Mode]]\n\n else\n screenOutput = screenOutput ..\n [[]] ..\n [[HUD Mode]]\n end\n\n screenOutput = screenOutput .. [[]]\n\n DrawSVG(screenOutput)\n\n forceRedraw = false\n end\nend\n\n-----------------------------------------------\n-- Execute\n-----------------------------------------------\n\nunit.hide()\nClearConsole()\nPrintDebug(\"SCRIPT STARTED\", true)\n\nInitiateSlots()\nSwitchScreens(true)\nInitiateClickAreas()\n\nif #screens ~= nil and #screens < 1 then\n HUDMode = true\nend\n\nif core == nil then\n DrawCenteredText(\"ERROR: No core connected.\")\n PrintError(\"ERROR: No core connected.\")\n goto exit\nelse\n shipID = core.getConstructId()\nend\n\nGenerateDamageData()\nif forceRedraw then DrawScreens() end\n\nunit.setTimer('UpdateData', UpdateInterval)\nunit.setTimer('UpdateHighlight', HighlightBlinkingInterval)\n\n::exit::\n",
- "filter": {
- "args": [],
- "signature": "start()",
- "slotKey": "-1"
- },
- "key": "9"
- },
- {
- "code": "HideHighlight()\nSwitchScreens(false)\n",
- "filter": {
- "args": [],
- "signature": "stop()",
- "slotKey": "-1"
- },
- "key": "10"
- },
- {
- "code": "GenerateDamageData()\nif forceRedraw then\n DrawScreens()\nend\nif HUDMode == true then\n system.setScreen(GenerateHUDOutput())\n system.showScreen(1)\nelse\n system.showScreen(0)\nend",
- "filter": {
- "args": [
- {
- "value": "UpdateData"
- }
- ],
- "signature": "tick(timerId)",
- "slotKey": "-1"
- },
- "key": "11"
- },
- {
- "code": "ToggleHighlight()",
- "filter": {
- "args": [
- {
- "value": "UpdateHighlight"
- }
- ],
- "signature": "tick(timerId)",
- "slotKey": "-1"
- },
- "key": "12"
- },
- {
- "code": "HudDeselectElement()",
- "filter": {
- "args": [
- {
- "value": "straferight"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "13"
- },
- {
- "code": "ToggleHUD()",
- "filter": {
- "args": [
- {
- "value": "strafeleft"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "14"
- },
- {
- "code": "ChangeHudSelectedElement(1)",
- "filter": {
- "args": [
- {
- "value": "down"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "15"
- },
- {
- "code": "ChangeHudSelectedElement(-1)",
- "filter": {
- "args": [
- {
- "value": "up"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "16"
- }
- ],
- "methods": [],
- "events": []
-}
\ No newline at end of file
diff --git a/versions/DamageReport_3_00.conf b/versions/DamageReport_3_00.conf
deleted file mode 100644
index 44bab1a..0000000
--- a/versions/DamageReport_3_00.conf
+++ /dev/null
@@ -1,436 +0,0 @@
-{
- "slots": {
- "0": {
- "name": "slot1",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "1": {
- "name": "slot2",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "2": {
- "name": "slot3",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "3": {
- "name": "slot4",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "4": {
- "name": "slot5",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "5": {
- "name": "slot6",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "6": {
- "name": "slot7",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "7": {
- "name": "slot8",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "8": {
- "name": "slot9",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "9": {
- "name": "slot10",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-1": {
- "name": "unit",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-2": {
- "name": "system",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-3": {
- "name": "library",
- "type": {
- "events": [],
- "methods": []
- }
- }
- },
- "handlers": [
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "2"
- },
- "key": "0"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "3"
- },
- "key": "1"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "4"
- },
- "key": "2"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "5"
- },
- "key": "3"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "6"
- },
- "key": "4"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "7"
- },
- "key": "5"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "8"
- },
- "key": "6"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "9"
- },
- "key": "7"
- },
- {
- "code": "function GenerateCommaValue(a,b,c)b=b or false;c=c or 1;local d=a;if b==true then if string.len(a)>=4 then d=string.format(\"%.\"..c..\"fk\",a/1000)else d=string.format(\"%.\"..c..\"f\",a)end else while true do d,k=string.gsub(d,\"^(-?%d+)(%d%d%d)\",'%1,%2')if k==0 then break end end end;return d end;function PrintConsole(e,f)f=f or false;if f then system.print(\"------------------------------------------------------------------------\")end;system.print(e)if f then system.print(\"------------------------------------------------------------------------\")end end;function DrawCenteredText(e)if screens~=nil and#screens>0 then for g=1,#screens,1 do screens[g].element.setCenteredText(e)end end end;function ClearConsole()for g=1,10,1 do PrintConsole()end end;function SwitchScreens(h)h=h or\"on\"if screens~=nil and#screens>0 then for g=1,#screens,1 do if h==\"on\"then screens[g].element.clear()screens[g].element.activate()screens[g].active=true else screens[g].element.clear()screens[g].element.deactivate()screens[g].active=false end end end end;function GetSecondsString(i)local i=tonumber(i)if i==nil or i<=0 then return\"-\"else days=string.format(\"%2.f\",math.floor(i/(3600*24)))hours=string.format(\"%2.f\",math.floor(i/3600-days*24))mins=string.format(\"%2.f\",math.floor(i/60-hours*60-days*24*60))secs=string.format(\"%2.f\",math.floor(i-hours*3600-days*24*60*60-mins*60))str=\"\"if tonumber(days)>0 then str=str..days..\"d \"end;if tonumber(hours)>0 then str=str..hours..\"h \"end;if tonumber(mins)>0 then str=str..mins..\"m \"end;if tonumber(secs)>0 then str=str..secs..\"s\"end;return str end end;function replace_char(j,str,l)return str:sub(1,j-1)..l..str:sub(j+1)end;function epochTime()function rZ(m)if string.len(m)<=1 then return\"0\"..m else return m end end;function dPoint(n)if not(n==math.floor(n))then return true else return false end end;function lYear(year)if not dPoint(year/4)then if dPoint(year/100)then return true else if not dPoint(year/400)then return true else return false end end else return false end end;local o=5;local p=3600;local q=86400;local r=31536000;local s=31622400;local t=2419200;local g=2505600;local u=2592000;local k=2678400;local w={4,6,9,11}local x={1,3,5,7,8,10,12}local y=0;local z=1506816000;local A=system.getTime()_G[\"formerTime\"]=A;if AddSummertimeHour==true then A=A+3600 end;now=math.floor(A+z)year=1970;secs=0;y=0;while secs+s]]..hour..\":\"..minute..[[]]..[[]]..year..\"/\"..month..\"/\"..day..[[]]end;function ToggleHUD()if HUDMode==true then HUDMode=false;forceDamageRedraw=true;hudSelectedIndex=0;highlightID=0;HideHighlight()SetRefresh()RenderScreens()else HUDMode=true;forceDamageRedraw=true;hudSelectedIndex=0;highlightID=0;HideHighlight()SetRefresh()RenderScreens()end end;function HudDeselectElement()hudSelectedIndex=0;hudStartIndex=1;highlightID=0;HideHighlight()if HUDMode==true then SetRefresh(\"damage\")SetRefresh(\"damageoutline\")RenderScreens()end end;function ChangeHudSelectedElement(B)if HUDMode==true and#rE>0 then hudSelectedIndex=hudSelectedIndex+B;if hudSelectedIndex<1 then hudSelectedIndex=1 elseif hudSelectedIndex>#rE then hudSelectedIndex=#rE end;if hudSelectedIndex>9 then hudStartIndex=hudSelectedIndex-9 end;if hudSelectedIndex~=0 then highlightID=rE[hudSelectedIndex].id;if highlightID~=nil and highlightID~=0 then HideHighlight()elementPosition=vec3(rE[hudSelectedIndex].pos)highlightX=elementPosition.x-coreWorldOffset;highlightY=elementPosition.y-coreWorldOffset;highlightZ=elementPosition.z-coreWorldOffset;highlightOn=true;ShowHighlight()end end;SetRefresh(\"damage\")SetRefresh(\"damageoutline\")RenderScreens()end end;function HideHighlight()if#hudArrowSticker>0 then for g in pairs(hudArrowSticker)do core.deleteSticker(hudArrowSticker[g])end;hudArrowSticker={}end end;function ShowHighlight()if highlightOn==true and highlightID>0 then table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX+2,highlightY,highlightZ,\"north\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX,highlightY-2,highlightZ,\"east\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX-2,highlightY,highlightZ,\"south\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX,highlightY+2,highlightZ,\"west\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX,highlightY,highlightZ-2,\"up\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX,highlightY,highlightZ+2,\"down\"))end end;function ToggleHighlight()if highlightOn==true then highlightOn=false;HideHighlight()else highlightOn=true;ShowHighlight()end end;function SortDamageTables()table.sort(damagedElements,function(m,n)return m.missinghp>n.missinghp end)table.sort(brokenElements,function(m,n)return m.maxhp>n.maxhp end)end;function getScraps(C,D)D=D or false;C=C-SkillRepairToolOptimization*0.05*C;local E=math.ceil(C/(10*5^(ScrapTier-1)))if D==true then return GenerateCommaValue(string.format(\"%.0f\",E),false)else return E end end;function getRepairTime(C,F)F=F or false;C=C-SkillRepairToolOptimization*0.05*C;local E=math.ceil(C/ScrapTierRepairTimes[ScrapTier])E=E-SkillRepairToolEfficiency*0.1*E;if F==true then return GetSecondsString(string.format(\"%.0f\",E))else return E end end;function UpdateDataDamageoutline()dmgoElements={}for g,G in ipairs(brokenElements)do if#dmgoElementsShipXmax then ShipXmax=H end;if I>ShipYmax then ShipYmax=I end;if J>ShipZmax then ShipZmax=J end;table.insert(dmgoElements,{id=G.id,type=\"b\",size=G.maxhp,x=H,y=I,z=J,xp=0,yp=0,zp=0,u=0,v=0})end end;if#dmgoElementsShipXmax then ShipXmax=H end;if I>ShipYmax then ShipYmax=I end;if J>ShipZmax then ShipZmax=J end;table.insert(dmgoElements,{id=G.id,type=\"d\",size=G.maxhp,x=H,y=I,z=J,xp=0,yp=0,zp=0,u=0,v=0})end end end;if#dmgoElementsShipXmax then ShipXmax=H end;if I>ShipYmax then ShipYmax=I end;if J>ShipZmax then ShipZmax=J end;table.insert(dmgoElements,{id=G.id,type=\"h\",size=G.maxhp,x=H,y=I,z=J,xp=0,yp=0,zp=0,u=0,v=0})end end end;ShipX=math.abs(ShipXmax-ShipXmin)ShipY=math.abs(ShipYmax-ShipYmin)ShipZ=math.abs(ShipZmax-ShipZmin)for g,G in ipairs(dmgoElements)do dmgoElements[g].xp=math.abs(100/(ShipXmax-ShipXmin)*(G.x-ShipXmin))dmgoElements[g].yp=math.abs(100/(ShipYmax-ShipYmin)*(G.y-ShipYmin))dmgoElements[g].zp=math.abs(100/(ShipZmax-ShipZmin)*(G.z-ShipZmin))end end;function UpdateViewDamageoutline(K)UFrame=40;VFrame=40;UStart=20+UFrame;VStart=180+VFrame;UDim=1880-2*UFrame;VDim=840-2*VFrame;if K.submode==\"top\"then if DMGOStretch==false then local L=UDim/(ShipYmax-ShipYmin)local M=VDim/(ShipXmax-ShipXmin)if L>=M then local N=L/M;local O=math.floor(UDim/N)UStart=UStart+(UDim-O)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100/N*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100*G.xp+VStart)end else local N=M/L;local P=math.floor(VDim/N)VStart=VStart+(VDim-P)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100/N*G.xp+VStart)end end else for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100*G.xp+VStart)end end elseif K.submode==\"front\"then if DMGOStretch==false then local L=UDim/(ShipXmax-ShipXmin)local M=VDim/(ShipZmax-ShipZmin)if L>=M then local N=L/M;local O=math.floor(UDim/N)UStart=UStart+(UDim-O)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100/N*G.xp+UStart)dmgoElements[g].v=math.floor(VDim/100*(100-G.zp)+VStart)end else local N=M/L;local P=math.floor(VDim/N)VStart=VStart+(VDim-P)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.xp+UStart)dmgoElements[g].v=math.floor(VDim/100/N*(100-G.zp)+VStart)end end else for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.xp+UStart)dmgoElements[g].v=math.floor(VDim/100*(100-G.zp)+VStart)end end elseif K.submode==\"side\"then if DMGOStretch==false then local L=UDim/(ShipYmax-ShipYmin)local M=VDim/(ShipXmax-ShipZmin)if L>=M then local N=L/M;local O=math.floor(UDim/N)UStart=UStart+(UDim-O)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100/N*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100*(100-G.zp)+VStart)end else local N=M/L;local P=math.floor(VDim/N)VStart=VStart+(VDim-P)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100/N*(100-G.zp)+VStart)end end else for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100*(100-G.zp)+VStart)end end else DrawCenteredText(\"ERROR: non-existing DMGO mode set.\")PrintConsole(\"ERROR: non-existing DMGO mode set.\")unit.exit()end end;function GetDamageoutlineShip()local e=\"\"for g,G in ipairs(dmgoElements)do local Q=\"\"local R=1;if G.type==\"h\"then Q=\"ch\"elseif G.type==\"d\"then Q=\"cw\"else Q=\"cc\"end;if G.id==highlightID then Q=\"f2\"end;if G.size>0 and G.size<1000 then R=5 elseif G.size>=1000 and G.size<2000 then R=8 elseif G.size>=2000 and G.size<5000 then R=12 elseif G.size>=5000 and G.size<10000 then R=15 elseif G.size>=10000 and G.size<20000 then R=20 elseif G.size>=20000 then R=30 end;e=e..[[]]if G.id==highlightID then e=e..[[]]e=e..[[]]end end;return e end;function GetContentClickareas(K)local e=\"\"if K~=nil and K.ClickAreas~=nil and#K.ClickAreas>0 then for g,S in ipairs(K.ClickAreas)do e=e..[[]]end end;return e end;function GetElement1(H,I,T,U)H=H or 0;I=I or 0;T=T or 600;U=U or 600;local e=\"\"e=e..[[\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ]]return e end;function GetElement2(H,I)H=H or 0;I=I or 0;local e=\"\"e=e..[[]]return e end;function GetElementLogo(H,I,V,W,X)H=H or 812;I=I or 380;V=V or\"f\"W=W or\"f2\"X=X or\"f3\"local e=\"\"e=e..[[\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ]]return e end;function GetHeader(Y)Y=Y or\"ERROR: UNDEFINED\"local e=\"\"e=e..[[\n ]]..Y..[[]]return e end;function GetContentBackground(Z,_)bgColor=ColorBackgroundPattern;local e=\"\"if Z==\"dots\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' viewBox='0 0 4 4'%3E%3Cpath fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' d='M1 3h1v1H1V3zm2-2h1v1H3V1z'%3E%3C/path%3E%3C/svg%3E\");]]elseif Z==\"rain\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='12' height='16' viewBox='0 0 12 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 .99C4 .445 4.444 0 5 0c.552 0 1 .45 1 .99v4.02C6 5.555 5.556 6 5 6c-.552 0-1-.45-1-.99V.99zm6 8c0-.546.444-.99 1-.99.552 0 1 .45 1 .99v4.02c0 .546-.444.99-1 .99-.552 0-1-.45-1-.99V8.99z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E\");]]elseif Z==\"plus\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E\");]]elseif Z==\"signal\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='84' height='48' viewBox='0 0 84 48' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h12v6H0V0zm28 8h12v6H28V8zm14-8h12v6H42V0zm14 0h12v6H56V0zm0 8h12v6H56V8zM42 8h12v6H42V8zm0 16h12v6H42v-6zm14-8h12v6H56v-6zm14 0h12v6H70v-6zm0-16h12v6H70V0zM28 32h12v6H28v-6zM14 16h12v6H14v-6zM0 24h12v6H0v-6zm0 8h12v6H0v-6zm14 0h12v6H14v-6zm14 8h12v6H28v-6zm-14 0h12v6H14v-6zm28 0h12v6H42v-6zm14-8h12v6H56v-6zm0-8h12v6H56v-6zm14 8h12v6H70v-6zm0 8h12v6H70v-6zM14 24h12v6H14v-6zm14-8h12v6H28v-6zM14 8h12v6H14V8zM0 8h12v6H0V8z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E\");]]elseif Z==\"deathstar\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='105' viewBox='0 0 80 105'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M20 10a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm15 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zM20 75a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zm30-65a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm0 65a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zM35 10a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zM5 45a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zm60 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10z' /%3E%3C/g%3E%3C/g%3E%3C/svg%3E\");]]elseif Z==\"diamond\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='32' viewBox='0 0 16 32'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath fill-rule='evenodd' d='M0 24h4v2H0v-2zm0 4h6v2H0v-2zm0-8h2v2H0v-2zM0 0h4v2H0V0zm0 4h2v2H0V4zm16 20h-6v2h6v-2zm0 4H8v2h8v-2zm0-8h-4v2h4v-2zm0-20h-6v2h6V0zm0 4h-4v2h4V4zm-2 12h2v2h-2v-2zm0-8h2v2h-2V8zM2 8h10v2H2V8zm0 8h10v2H2v-2zm-2-4h14v2H0v-2zm4-8h6v2H4V4zm0 16h6v2H4v-2zM6 0h2v2H6V0zm0 24h2v2H6v-2z'/%3E%3C/g%3E%3C/svg%3E\");]]elseif Z==\"hexagon\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='49' viewBox='0 0 28 49'%3E%3Cg fill-rule='evenodd'%3E%3Cg id='hexagons' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='nonzero'%3E%3Cpath d='M13.99 9.25l13 7.5v15l-13 7.5L1 31.75v-15l12.99-7.5zM3 17.9v12.7l10.99 6.34 11-6.35V17.9l-11-6.34L3 17.9zM0 15l12.98-7.5V0h-2v6.35L0 12.69v2.3zm0 18.5L12.98 41v8h-2v-6.85L0 35.81v-2.3zM15 0v7.5L27.99 15H28v-2.31h-.01L17 6.35V0h-2zm0 49v-8l12.99-7.5H28v2.31h-.01L17 42.15V49h-2z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E\");]]elseif Z==\"capsule\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='32' height='26' viewBox='0 0 32 26' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M14 0v3.994C14 7.864 10.858 11 7 11c-3.866 0-7-3.138-7-7.006V0h2v4.005C2 6.765 4.24 9 7 9c2.756 0 5-2.236 5-4.995V0h2zm0 26v-5.994C14 16.138 10.866 13 7 13c-3.858 0-7 3.137-7 7.006V26h2v-6.005C2 17.235 4.244 15 7 15c2.76 0 5 2.236 5 4.995V26h2zm2-18.994C16 3.136 19.142 0 23 0c3.866 0 7 3.138 7 7.006v9.988C30 20.864 26.858 24 23 24c-3.866 0-7-3.138-7-7.006V7.006zm2-.01C18 4.235 20.244 2 23 2c2.76 0 5 2.236 5 4.995v10.01C28 19.765 25.756 22 23 22c-2.76 0-5-2.236-5-4.995V6.995z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E\");]]elseif Z==\"diagonal\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='6' height='6' viewBox='0 0 6 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'%3E%3Cpath d='M5 0h1L0 6V5zM6 5v1H5z'/%3E%3C/g%3E%3C/svg%3E\");]]end;return e end;function GetContentDamageHUDOutput()local a0=300;local a1=165;if#damagedElements>0 or#brokenElements>0 then a1=510 end;local e=\"\"e=e..[[\n \n ]]e=e..[[]]..[[]]..[[]]..[[]]..(YourShipsName==\"Enter here\"and\"Ship ID \"..ShipID or YourShipsName)..[[]]..[[]]if#brokenElements>0 then e=e..[[]]elseif#damagedElements>0 then e=e..[[]]else e=e..[[]]end;if#damagedElements>0 or#brokenElements>0 then e=e..[[Total Damage]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",totalShipMaxHP-totalShipHP))..[[]]e=e..[[T]]..ScrapTier..[[ Scrap Needed]]..[[]]..getScraps(totalShipMaxHP-totalShipHP,true)..[[]]e=e..[[Repair Time]]..[[]]..getRepairTime(totalShipMaxHP-totalShipHP,true)..[[]]e=e..[[]]..[[]]..[[]]..#healthyElements..[[]]..[[]]..[[]]..#damagedElements..[[]]..[[]]..[[]]..#brokenElements..[[]]local u=0;for a2=hudStartIndex,hudStartIndex+9,1 do if rE[a2]~=nil then v=rE[a2]if v.hp>0 then e=e..[[]]..[[]]..string.format(\"%.30s\",v.name)..[[]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",v.missinghp))..[[]]if v.id==highlightID then e=e..[[]]..[[]]..string.format(\"%.30s\",v.name)..[[]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",v.missinghp))..[[]]end else e=e..[[]]..[[]]..string.format(\"%.30s\",v.name)..[[]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",v.missinghp))..[[]]if v.id==highlightID then highlightX=elementPosition.x-coreWorldOffset;highlightY=elementPosition.y-coreWorldOffset;highlightZ=elementPosition.z-coreWorldOffset;e=e..[[]]..[[]]..string.format(\"%.30s\",v.name)..[[]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",v.missinghp))..[[]]end end;u=u+1 end end;e=e..[[]]..[[]]..[[]]..[[]]..[[Up/down arrows to highlight]]..[[CTRL + arrows to move HUD]]..[[Left arrow to toggle HUD Mode]]..[[ALT+1-4 to set Scrap Tier]]..[[ALT+8 to reset HUD position]]..[[ALT+9 to shut script off]]..[[]]..[[]]else e=e..[[]]..OkayCenterMessage..[[]]..[[]]..#healthyElements..[[ elements / ]]..GenerateCommaValue(string.format(\"%.0f\",totalShipMaxHP))..[[ HP.]]..[[]]..[[]]..[[]]..[[]]..[[Left arrow to toggle HUD Mode]]..[[CTRL + arrows to move HUD]]..[[ALT+8 to reset HUD position]]..[[ALT+9 to shut script off]]..[[]]..[[]]end;e=e..[[]]return e end;function GetContentDamageScreen()local a3=\"\"if#damagedElements>0 then local a4=#damagedElements;if a4>DamagePageSize then a4=DamagePageSize end;if CurrentDamagedPage==math.ceil(#damagedElements/DamagePageSize)then a4=#damagedElements%DamagePageSize+12;if a4>12 then a4=a4-12 end end;a3=a3 ..[[]]a3=a3 ..[[]]if UseMyElementNames==true then a3=a3 ..[[Damaged Name]]else a3=a3 ..[[Damaged Type]]end;a3=a3 ..[[HLTHDMG]]a3=a3 ..[[T]]..ScrapTier..[[ SCRREPTIME]]AddClickArea(\"damage\",{id=\"SwitchScrapTier\",mode=\"damage\",x1=650,x2=775,y1=315,y2=360})local g=0;for u=1+(CurrentDamagedPage-1)*DamagePageSize,a4+(CurrentDamagedPage-1)*DamagePageSize,1 do g=g+1;local a5=damagedElements[u]if UseMyElementNames==true then a3=a3 ..[[]]..string.format(\"%.23s\",a5.name)..[[]]else a3=a3 ..[[]]..string.format(\"%.23s\",a5.type)..[[]]end;a3=a3 ..[[]]..a5.percent..[[%]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",a5.missinghp),true)..[[]]..[[]]..getScraps(a5.missinghp,true)..[[]]..[[]]..getRepairTime(a5.missinghp,true)..[[]]..[[]]end;if#damagedElements>DamagePageSize then a3=a3 ..[[Page ]]..CurrentDamagedPage..\" of \"..math.ceil(#damagedElements/DamagePageSize)..[[]]if CurrentDamagedPage\n \n \n ]]AddClickArea(\"damage\",{id=\"DamagedPageDown\",mode=\"damage\",x1=65,x2=260,y1=290+(a4+1)*50,y2=290+50+(a4+1)*50})else DisableClickArea(\"DamagedPageDown\",\"damage\")end;if CurrentDamagedPage>1 then a3=a3 ..[[\n \n \n ]]AddClickArea(\"damage\",{id=\"DamagedPageUp\",mode=\"damage\",x1=750,x2=950,y1=290+(a4+1)*50,y2=290+50+(a4+1)*50})else DisableClickArea(\"DamagedPageUp\",\"damage\")end end end;if#brokenElements>0 then local a6=#brokenElements;if a6>DamagePageSize then a6=DamagePageSize end;if CurrentBrokenPage==math.ceil(#brokenElements/DamagePageSize)then a6=#brokenElements%DamagePageSize+12;if a6>12 then a6=a6-12 end end;a3=a3 ..[[]]a3=a3 ..[[]]if UseMyElementNames==true then a3=a3 ..[[Broken Name]]else a3=a3 ..[[Broken Type]]end;a3=a3 ..[[DMG]]a3=a3 ..[[T]]..ScrapTier..[[ SCRREPTIME]]AddClickArea(\"damage\",{id=\"SwitchScrapTier2\",mode=\"damage\",x1=1570,x2=1690,y1=315,y2=360})local g=0;for u=1+(CurrentBrokenPage-1)*DamagePageSize,a6+(CurrentBrokenPage-1)*DamagePageSize,1 do g=g+1;local a5=brokenElements[u]if UseMyElementNames==true then a3=a3 ..[[]]..string.format(\"%.30s\",a5.name)..[[]]else a3=a3 ..[[]]..string.format(\"%.30s\",a5.type)..[[]]end;a3=a3 ..[[]]..GenerateCommaValue(string.format(\"%.0f\",a5.missinghp),true)..[[]]..[[]]..getScraps(a5.missinghp,true)..[[]]..[[]]..getRepairTime(a5.missinghp,true)..[[]]..[[]]end;if#brokenElements>DamagePageSize then a3=a3 ..[[Page ]]..CurrentBrokenPage..\" of \"..math.ceil(#brokenElements/DamagePageSize)..[[]]if CurrentBrokenPage>1 then a3=a3 ..[[\n \n \n ]]AddClickArea(\"damage\",{id=\"BrokenPageUp\",mode=\"damage\",x1=1665,x2=1865,y1=290+(a6+1)*50,y2=290+50+(a6+1)*50})else DisableClickArea(\"BrokenPageUp\",\"damage\")end;if CurrentBrokenPage\n \n \n ]]AddClickArea(\"damage\",{id=\"BrokenPageDown\",mode=\"damage\",x1=980,x2=1180,y1=290+(a6+1)*50,y2=290+50+(a6+1)*50})else DisableClickArea(\"BrokenPageDown\",\"damage\")end end end;if#damagedElements>0 or#brokenElements>0 then local a7=math.floor(1878/#elementsIdList*#damagedElements)local a8=math.floor(1878/#elementsIdList*#brokenElements)local a9=1878-a7-a8+1;a3=a3 ..[[]]a3=a3 ..[[]]a3=a3 ..[[]]a3=a3 ..[[]]if#damagedElements>0 then a3=a3 ..[[]]..#damagedElements..[[]]end;if#healthyElements>0 then a3=a3 ..[[]]..#healthyElements..[[]]end;if#brokenElements>0 then a3=a3 ..[[]]..#brokenElements..[[]]end;a3=a3 ..[[]]a3=a3 ..[[]]..GenerateCommaValue(string.format(\"%.0f\",totalShipMaxHP-totalShipHP))..[[ HP damage in total ]]..getScraps(totalShipMaxHP-totalShipHP,true)..[[ T]]..ScrapTier..[[ scraps needed. ]]..getRepairTime(totalShipMaxHP-totalShipHP,true)..[[ projected repair time.]]else a3=a3 ..GetElementLogo(812,380,\"ch\",\"ch\",\"ch\")..[[]]..OkayCenterMessage..[[]]..[[]]..#healthyElements..[[ elements stand ]]..GenerateCommaValue(string.format(\"%.0f\",totalShipMaxHP))..[[ HP strong.]]end;forceDamageRedraw=false;return a3 end;function ActionStopengines()ToggleHUD()end;function ActionStrafeRight()if KeyCTRLPressed==true then if HUDShiftU<4000 then HUDShiftU=HUDShiftU+50;SaveToDatabank()RenderScreens()end else HudDeselectElement()end end;function ActionStrafeLeft()if KeyCTRLPressed==true then if HUDShiftU>=50 then HUDShiftU=HUDShiftU-50;SaveToDatabank()RenderScreens()end else ToggleHUD()end end;function ActionDown()if KeyCTRLPressed==true then if HUDShiftV<4000 then HUDShiftV=HUDShiftV+50;SaveToDatabank()RenderScreens()end else ChangeHudSelectedElement(1)end end;function ActionUp()if KeyCTRLPressed==true then if HUDShiftV>=50 then HUDShiftV=HUDShiftV-50;SaveToDatabank()RenderScreens()end else ChangeHudSelectedElement(-1)end end;function ActionOption1()ScrapTier=1;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption2()ScrapTier=2;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption3()ScrapTier=3;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption4()ScrapTier=4;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption8()HUDShiftU=0;HUDShiftV=0;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption9()SaveToDatabank()SwitchScreens(\"off\")unit.exit()end",
- "filter": {
- "args": [],
- "signature": "start()",
- "slotKey": "-1"
- },
- "key": "8"
- },
- {
- "code": "SaveToDatabank()\nSwitchScreens(\"off\")",
- "filter": {
- "args": [],
- "signature": "stop()",
- "slotKey": "-1"
- },
- "key": "9"
- },
- {
- "code": "OnTickData()\n",
- "filter": {
- "args": [
- {
- "value": "UpdateData"
- }
- ],
- "signature": "tick(timerId)",
- "slotKey": "-1"
- },
- "key": "10"
- },
- {
- "code": "ToggleHighlight()",
- "filter": {
- "args": [
- {
- "value": "UpdateHighlight"
- }
- ],
- "signature": "tick(timerId)",
- "slotKey": "-1"
- },
- "key": "11"
- },
- {
- "code": "--[[\n Damage Report 3.0\n A LUA script for Dual Universe\n\n Created By Dorian GrayY.percent\n Ingame: DorianGray\n Discord: Dorian Gray#2623\n\n You can find/update this script on GitHub. Explanations, installation and usage information as well as screenshots can be found there too.\n GitHub: https://github.com/DorianTheGrey/DU-DamageReport\n\n GNU Public License 3.0. Use whatever you want, be so kind to leave credit.\n \n Credits & thanks: \n Thanks to NovaQuark for creating the MMO of the century.\n Thanks to Jericho, Dmentia and Archaegeo for learning a lot from their fine scripts.\n Thanks to TheBlacklist for testing and wonderful suggestions.\n SVG patterns by Hero Patterns.\n DU atlas data from Jayle Break.\n \n]]\n\n--[[ 1. USER DEFINED VARIABLES ]]\n\nYourShipsName = \"Enter here\" --export Enter your ship name here if you want it displayed instead of the ship's ID. YOU NEED TO LEAVE THE QUOTATION MARKS.\nShowWelcomeMessage = true --export Do you want the welcome message on the start screen with your name?\nAddSummertimeHour = false --export: Is summertime currently enabled in your location? (Adds one hour.)\n\nUpdateDataInterval=1.0;HighlightBlinkingInterval=0.5;ColorPrimary=\"FF6700\"ColorSecondary=\"FFFFFF\"ColorTertiary=\"000000\"ColorHealthy=\"00FF00\"ColorWarning=\"FFFF00\"ColorCritical=\"FF0000\"ColorBackground=\"000000\"ColorBackgroundPattern=\"4F4F4F\"ColorFuelAtmospheric=\"004444\"ColorFuelSpace=\"444400\"ColorFuelRocket=\"440044\"VERSION=3.0;DebugMode=false;DebugRenderClickareas=true;DBData={}core=nil;db=nil;screens={}dscreens={}screenModes={[\"flight\"]={id=\"flight\"},[\"damage\"]={id=\"damage\"},[\"damageoutline\"]={id=\"damageoutline\"},[\"fuel\"]={id=\"fuel\"},[\"cargo\"]={id=\"cargo\"},[\"agg\"]={id=\"agg\"},[\"map\"]={id=\"map\"},[\"time\"]={id=\"time\",activetoggle=\"true\"},[\"settings1\"]={id=\"settings1\"},[\"startup\"]={id=\"startup\"}}backgroundModes={\"deathstar\",\"capsule\",\"rain\",\"signal\",\"hexagon\",\"diagonal\",\"diamond\",\"plus\",\"dots\"}BackgroundMode=\"deathstar\"BackgroundSelected=1;BackgroundModeOpacity=0.25;SaveVars={\"dscreens\",\"YourShipsName\",\"AddSummertimeHour\",\"ColorPrimary\",\"ColorSecondary\",\"ColorTertiary\",\"ColorHealthy\",\"ColorWarning\",\"ColorCritical\",\"ColorBackground\",\"ColorBackgroundPattern\",\"UpdateDataInterval\",\"HighlightBlinkingInterval\",\"ScrapTier\",\"HUDMode\",\"SimulationMode\",\"DMGOStretch\",\"HUDShiftU\",\"HUDShiftV\",\"colorIDIndex\",\"colorIDTable\",\"SkillRepairToolEfficiency\",\"SkillRepairToolOptimization\",\"SkillAtmosphericFuelEfficiency\",\"SkillSpaceFuelEfficiency\",\"SkillRocketFuelEfficiency\",\"StatAtmosphericFuelTankHandling\",\"StatSpaceFuelTankHandling\",\"StatRocketFuelTankHandling\",\"BackgroundMode\",\"BackgroundSelected\",\"BackgroundModeOpacity\"}HUDMode=false;HUDShiftU=0;HUDShiftV=0;hudSelectedIndex=0;hudStartIndex=1;hudArrowSticker={}highlightOn=false;highlightID=0;highlightX=0;highlightY=0;highlightZ=0;SimulationMode=false;OkayCenterMessage=\"All systems nominal.\"CurrentDamagedPage=1;CurrentBrokenPage=1;DamagePageSize=12;ScrapTier=1;totalScraps=0;ScrapTierRepairTimes={10,50,250,1250}coreWorldOffset=0;totalShipHP=0;formerTotalShipHP=-1;totalShipMaxHP=0;totalShipIntegrity=100;elementsId={}elementsIdList={}damagedElements={}brokenElements={}rE={}healthyElements={}typeElements={}ElementCounter=0;UseMyElementNames=true;dmgoElements={}DMGOMaxElements=250;DMGOStretch=false;ShipXmin=99999999;ShipXmax=-99999999;ShipYmin=99999999;ShipYmax=-99999999;ShipZmin=99999999;ShipZmax=-99999999;totalShipMass=0;formerTotalShipMass=-1;formerTime=-1;FuelAtmosphericTanks={}FuelSpaceTanks={}FuelRocketTanks={}FuelAtmosphericTotal=0;FuelSpaceTotal=0;FuelRocketTotal=0;FuelAtmosphericCurrent=0;FuelSpaceTotalCurrent=0;FuelRocketTotalCurrent=0;formerFuelAtmosphericTotal=-1;formerFuelSpaceTotal=-1;formerFuelRocketTotal=-1;SkillRepairToolEfficiency=0;SkillRepairToolOptimization=0;SkillAtmosphericFuelEfficiency=0;SkillSpaceFuelEfficiency=0;SkillRocketFuelEfficiency=0;StatAtmosphericFuelTankHandling=0;StatSpaceFuelTankHandling=0;StatRocketFuelTankHandling=0;hexTable={\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"A\",\"B\",\"C\",\"D\",\"E\",\"F\"}colorIDIndex=1;colorIDTable={[1]={id=\"ColorPrimary\",desc=\"Main HUD Color\",basec=\"FF6700\",newc=\"FF6700\"},[2]={id=\"ColorSecondary\",desc=\"Secondary HUD Color\",basec=\"FFFFFF\",newc=\"FFFFFF\"},[3]={id=\"ColorTertiary\",desc=\"Tertiary HUD Color\",basec=\"000000\",newc=\"000000\"},[4]={id=\"ColorHealthy\",desc=\"Color code for Healthy/Okay\",basec=\"00FF00\",newc=\"00FF00\"},[5]={id=\"ColorWarning\",desc=\"Color code for Damaged/Warning\",basec=\"FFFF00\",newc=\"FFFF00\"},[6]={id=\"ColorCritical\",desc=\"Color code for Broken/Critical\",basec=\"FF0000\",newc=\"FF0000\"},[7]={id=\"ColorBackground\",desc=\"Background Color\",basec=\"000000\",newc=\"000000\"},[8]={id=\"ColorBackgroundPattern\",desc=\"Background Pattern Color\",basec=\"4F4F4F\",newc=\"4F4F4F\"},[9]={id=\"ColorFuelAtmospheric\",desc=\"Color for Atmo Fuel/Elements\",basec=\"004444\",newc=\"004444\"},[10]={id=\"ColorFuelSpace\",desc=\"Color for Space Fuel/Elements\",basec=\"444400\",newc=\"444400\"},[11]={id=\"ColorFuelRocket\",desc=\"Color for Rocket Fuel/Elements\",basec=\"440044\",newc=\"440044\"}}function InitiateSlots()for a,b in pairs(unit)do if type(b)==\"table\"and type(b.export)==\"table\"and b.getElementClass then local c=b.getElementClass():lower()if c:find(\"coreunit\")then core=b;local d=core.getMaxHitPoints()if d>10000 then coreWorldOffset=128 elseif d>1000 then coreWorldOffset=64 elseif d>150 then coreWorldOffset=32 else coreWorldOffset=16 end elseif c=='databankunit'then db=b elseif c==\"screenunit\"then local e=\"startup\"screens[#screens+1]={element=b,id=b.getId(),mode=e,submode=\"\",ClickAreas={},refresh=true,active=false,fuelA=true,fuelS=true,fuelR=true,fuelIndex=1}end end end end;function LoadFromDatabank()if db==nil then return else for f,g in pairs(SaveVars)do if db.hasKey(g)then local h=json.decode(db.getStringValue(g))if h~=nil then if g==\"YourShipsName\"or g==\"AddSummertimeHour\"or g==\"UpdateDataInterval\"or g==\"HighlightBlinkingInterval\"then else _G[g]=h end end end end;for i,j in ipairs(screens)do for k,l in ipairs(dscreens)do if screens[i].id==dscreens[k].id then screens[i].mode=dscreens[k].mode;screens[i].submode=dscreens[k].submode;screens[i].active=dscreens[k].active;screens[i].refresh=true;screens[i].fuelA=dscreens[k].fuelA;screens[i].fuelS=dscreens[k].fuelS;screens[i].fuelR=dscreens[k].fuelR;screens[i].fuelIndex=dscreens[k].fuelIndex end end end end end;function SaveToDatabank()if db==nil then return else dscreens={}for i,m in ipairs(screens)do dscreens[i]={}dscreens[i].id=m.id;dscreens[i].mode=m.mode;dscreens[i].submode=m.submode;dscreens[i].active=m.active;dscreens[i].fuelA=m.fuelA;dscreens[i].fuelS=m.fuelS;dscreens[i].fuelR=m.fuelR;dscreens[i].fuelIndex=m.fuelIndex end;db.clear()for f,g in pairs(SaveVars)do if g==\"YourShipsName\"or g==\"AddSummertimeHour\"or g==\"UpdateDataInterval\"or g==\"HighlightBlinkingInterval\"then else db.setStringValue(g,json.encode(_G[g]))end end end end;function InitiateScreens()if screens~=nil and#screens>0 then for i=1,#screens,1 do screens[i]=CreateClickAreasForScreen(screens[i])end end end;function UpdateTypeData()FuelAtmosphericTanks={}FuelSpaceTanks={}FuelRocketTanks={}FuelAtmosphericTotal=0;FuelAtmosphericCurrent=0;FuelSpaceTotal=0;FuelSpaceCurrent=0;FuelRocketCurrent=0;FuelRocketTotal=0;local n=4;local o=6;local p=0.8;for i,q in ipairs(typeElements)do local r=core.getElementNameById(q)or\"\"local s=core.getElementTypeById(q)or\"\"local t=core.getElementPositionById(q)or 0;local u=core.getElementHitPointsById(q)or 0;local v=core.getElementMaxHitPointsById(q)or 0;local w=core.getElementMassById(q)or 0;local x=\"\"local y=0;local z=0;local A=0;local B=0;if s==\"atmospheric fuel-tank\"then if v==50 then x=\"XS\"z=35.03;y=100 elseif v==163 then x=\"S\"z=182.67;y=400 elseif v==1315 then x=\"M\"z=988.67;y=1600 elseif v==10461 then x=\"L\"z=5480;y=12800 end;if StatAtmosphericFuelTankHandling>0 then y=0.2*StatAtmosphericFuelTankHandling*y+y end;A=w-z;if A<=10 then A=0 end;B=string.format(\"%.0f\",A/n)cPercent=string.format(\"%.1f\",math.floor(100/y*tonumber(B)))table.insert(FuelAtmosphericTanks,{type=1,id=q,name=r,maxhp=v,hp=GetHPforElement(q),pos=t,size=x,mass=z,vol=y,cvol=B,percent=cPercent})if u>0 then FuelAtmosphericCurrent=FuelAtmosphericCurrent+B end;FuelAtmosphericTotal=FuelAtmosphericTotal+y elseif s==\"space fuel-tank\"then if v==187 then x=\"S\"z=182.67;y=400 elseif v==1496 then x=\"M\"z=988.67;y=1600 elseif v==15933 then x=\"L\"z=5480;y=12800 end;if StatSpaceFuelTankHandling>0 then y=0.2*StatSpaceFuelTankHandling*y+y end;A=w-z;if A<=10 then A=0 end;B=string.format(\"%.0f\",A/o)cPercent=string.format(\"%.1f\",100/y*tonumber(B))table.insert(FuelSpaceTanks,{type=2,id=q,name=r,maxhp=v,hp=GetHPforElement(q),pos=t,size=x,mass=z,vol=y,cvol=B,percent=cPercent})if u>0 then FuelSpaceCurrent=FuelSpaceCurrent+B end;FuelSpaceTotal=FuelSpaceTotal+y elseif s==\"rocket fuel-tank\"then if v==366 then x=\"XS\"z=173.42;y=400 elseif v==163 then x=\"S\"z=886.72;y=800 elseif v==6231 then x=\"M\"z=4720;y=6400 elseif v==10461 then x=\"L\"z=25740;y=50000 end;if StatRocketFuelTankHandling>0 then y=0.2*StatRocketFuelTankHandling*y+y end;A=w-z;if A<=10 then A=0 end;B=string.format(\"%.0f\",A/p)cPercent=string.format(\"%.1f\",100/y*tonumber(B))table.insert(FuelRocketTanks,{type=3,id=q,name=r,maxhp=v,hp=GetHPforElement(q),pos=t,size=x,mass=z,vol=y,cvol=B,percent=cPercent})if u>0 then FuelRocketCurrent=FuelRocketCurrent+B end;FuelRocketTotal=FuelRocketTotal+y end end;if FuelAtmosphericCurrent~=formerFuelAtmosphericCurrent then SetRefresh(\"fuel\")formerFuelAtmosphericCurrent=FuelAtmosphericCurrent end;if FuelSpaceCurrent~=formerFuelSpaceCurrent then SetRefresh(\"fuel\")formerFuelSpaceCurrent=FuelSpaceCurrent end;if FuelRocketCurrent~=formerFuelRocketCurrent then SetRefresh(\"fuel\")formerFuelRocketCurrent=FuelRocketCurrent end end;function UpdateDamageData(C)C=C or false;if SimulationActive==true then return end;local formerTotalShipHP=totalShipHP;totalShipHP=0;totalShipMaxHP=0;totalShipIntegrity=100;damagedElements={}brokenElements={}healthyElements={}ElementCounter=0;elementsIdList=core.getElementIdList()for i,q in pairs(elementsIdList)do ElementCounter=ElementCounter+1;local r=core.getElementNameById(q)local s=core.getElementTypeById(q)local t=core.getElementPositionById(q)local u=core.getElementHitPointsById(q)local v=core.getElementMaxHitPointsById(q)if SimulationMode==true then SimulationActive=true;local D=math.random(0,10)if D<2 and#brokenElements<30 then u=0 elseif D>=2 and D<4 and#damagedElements<30 then u=math.random(1,math.ceil(v))else u=v end end;totalShipHP=totalShipHP+u;totalShipMaxHP=totalShipMaxHP+v;if v-u>constants.epsilon then if u>0 then table.insert(damagedElements,{id=q,name=r,type=s,counter=ElementCounter,hp=u,maxhp=v,missinghp=v-u,percent=math.ceil(100/v*u),pos=t})else table.insert(brokenElements,{id=q,name=r,type=s,counter=ElementCounter,hp=u,maxhp=v,missinghp=v-u,percent=0,pos=t})end else table.insert(healthyElements,{id=q,name=r,type=s,counter=ElementCounter,hp=u,maxhp=v,pos=t})if q==highlightID then highlightID=0;highlightOn=false;HideHighlight()hudSelectedIndex=0 end end;if C==true then if s==\"atmospheric fuel-tank\"or s==\"space fuel-tank\"or s==\"rocket fuel-tank\"then table.insert(typeElements,q)end end end;SortDamageTables()rE={}if#brokenElements>0 then for f,j in ipairs(brokenElements)do table.insert(rE,{id=j.id,missinghp=j.missinghp,hp=j.hp,name=j.name,type=j.type,pos=j.pos})end end;if#damagedElements>0 then for f,j in ipairs(damagedElements)do table.insert(rE,{id=j.id,missinghp=j.missinghp,hp=j.hp,name=j.name,type=j.type,pos=j.pos})end end;if#rE>0 then table.sort(rE,function(E,F)return E.missinghp>F.missinghp end)end;totalShipIntegrity=string.format(\"%2.0f\",100/totalShipMaxHP*totalShipHP)if formerTotalShipHP~=totalShipHP then forceDamageRedraw=true;formerTotalShipHP=totalShipHP else forceDamageRedraw=false end end;function GetHPforElement(q)for i,j in ipairs(brokenElements)do if j.id==q then return 0 end end;for i,j in ipairs(damagedElements)do if j.id==q then return j.hp end end;for i,j in ipairs(healthyElements)do if j.id==q then return j.maxhp end end end;function UpdateClickArea(G,H,I)for i,m in ipairs(screens)do for J,j in pairs(screens[i].ClickAreas)do if j.id==G and j.mode==I then screens[i].ClickAreas[J]=H end end end end;function AddClickArea(I,H)for i,m in ipairs(screens)do if screens[i].mode==I then table.insert(screens[i].ClickAreas,H)end end end;function AddClickAreaForScreenID(K,H)for i,m in ipairs(screens)do if screens[i].id==K then table.insert(screens[i].ClickAreas,H)end end end;function DisableClickArea(G,I)UpdateClickArea(G,{id=G,mode=I,x1=-1,x2=-1,y1=-1,y2=-1})end;function SetRefresh(I,L)I=I or\"all\"L=L or\"all\"if screens~=nil and#screens>0 then for i=1,#screens,1 do if screens[i].mode==I or I==\"all\"then if screens[i].submode==L or L==\"all\"then screens[i].refresh=true end end end end end;function WipeClickAreasForScreen(m)m.ClickAreas={}return m end;function CreateBaseClickAreas(m)table.insert(m.ClickAreas,{mode=\"all\",id=\"ToggleHudMode\",x1=1537,x2=1728,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"damage\",x1=193,x2=384,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"damageoutline\",x1=385,x2=576,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"fuel\",x1=577,x2=768,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"time\",x1=0,x2=192,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"settings1\",x1=1729,x2=1920,y1=1015,y2=1075})return m end;function CreateClickAreasForScreen(m)if m==nil then return{}end;if m.mode==\"flight\"then elseif m.mode==\"damage\"then table.insert(m.ClickAreas,{mode=\"damage\",id=\"ToggleElementLabel\",x1=70,x2=425,y1=325,y2=355})table.insert(m.ClickAreas,{mode=\"damage\",id=\"ToggleElementLabel2\",x1=980,x2=1400,y1=325,y2=355})elseif m.mode==\"damageoutline\"then table.insert(m.ClickAreas,{mode=\"damageoutline\",id=\"DMGOChangeView\",param=\"top\",x1=60,x2=439,y1=150,y2=200})table.insert(m.ClickAreas,{mode=\"damageoutline\",id=\"DMGOChangeView\",param=\"side\",x1=440,x2=824,y1=150,y2=200})table.insert(m.ClickAreas,{mode=\"damageoutline\",id=\"DMGOChangeView\",param=\"front\",x1=825,x2=1215,y1=150,y2=200})table.insert(m.ClickAreas,{mode=\"damageoutline\",id=\"DMGOChangeStretch\",x1=1530,x2=1580,y1=150,y2=200})elseif m.mode==\"fuel\"then elseif m.mode==\"cargo\"then elseif m.mode==\"agg\"then elseif m.mode==\"map\"then elseif m.mode==\"time\"then elseif m.mode==\"settings1\"then table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ToggleBackground\",x1=75,x2=860,y1=170,y2=215})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"PreviousBackground\",x1=75,x2=460,y1=235,y2=285})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"NextBackground\",x1=480,x2=860,y1=235,y2=285})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"DecreaseOpacity\",x1=75,x2=460,y1=300,y2=350})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"IncreaseOpacity\",x1=480,x2=860,y1=300,y2=350})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ResetColors\",x1=75,x2=860,y1=370,y2=415})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"PreviousColorID\",x1=90,x2=140,y1=500,y2=550})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"NextColorID\",x1=795,x2=845,y1=500,y2=550})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"1\",x1=210,x2=290,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"2\",x1=300,x2=380,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"3\",x1=385,x2=465,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"4\",x1=470,x2=550,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"5\",x1=560,x2=640,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"6\",x1=645,x2=725,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"1\",x1=210,x2=290,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"2\",x1=300,x2=380,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"3\",x1=385,x2=465,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"4\",x1=470,x2=550,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"5\",x1=560,x2=640,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"6\",x1=645,x2=725,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ResetPosColor\",x1=160,x2=340,y1=885,y2=935})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ApplyPosColor\",x1=355,x2=780,y1=885,y2=935})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillRepairToolEfficiency\",0},x1=1060,x2=1115,y1=260,y2=280})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillRepairToolEfficiency\",1},x1=1215,x2=1295,y1=260,y2=280})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillRepairToolEfficiency\",2},x1=1305,x2=1385,y1=260,y2=280})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillRepairToolEfficiency\",3},x1=1390,x2=1470,y1=260,y2=280})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillRepairToolEfficiency\",4},x1=1475,x2=1555,y1=260,y2=280})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillRepairToolEfficiency\",5},x1=1565,x2=1645,y1=260,y2=280})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillRepairToolOptimization\",0},x1=1060,x2=1115,y1=325,y2=345})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillRepairToolOptimization\",1},x1=1215,x2=1295,y1=325,y2=345})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillRepairToolOptimization\",2},x1=1305,x2=1385,y1=325,y2=345})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillRepairToolOptimization\",3},x1=1390,x2=1470,y1=325,y2=345})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillRepairToolOptimization\",4},x1=1475,x2=1555,y1=325,y2=345})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillRepairToolOptimization\",5},x1=1565,x2=1645,y1=325,y2=345})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillAtmosphericFuelEfficiency\",0},x1=1060,x2=1115,y1=390,y2=410})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillAtmosphericFuelEfficiency\",1},x1=1215,x2=1295,y1=390,y2=410})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillAtmosphericFuelEfficiency\",2},x1=1305,x2=1385,y1=390,y2=410})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillAtmosphericFuelEfficiency\",3},x1=1390,x2=1470,y1=390,y2=410})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillAtmosphericFuelEfficiency\",4},x1=1475,x2=1555,y1=390,y2=410})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillAtmosphericFuelEfficiency\",5},x1=1565,x2=1645,y1=390,y2=410})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillSpaceFuelEfficiency\",0},x1=1060,x2=1115,y1=460,y2=480})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillSpaceFuelEfficiency\",1},x1=1215,x2=1295,y1=460,y2=480})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillSpaceFuelEfficiency\",2},x1=1305,x2=1385,y1=460,y2=480})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillSpaceFuelEfficiency\",3},x1=1390,x2=1470,y1=460,y2=480})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillSpaceFuelEfficiency\",4},x1=1475,x2=1555,y1=460,y2=480})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillSpaceFuelEfficiency\",5},x1=1565,x2=1645,y1=460,y2=480})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillRocketFuelEfficiency\",0},x1=1060,x2=1115,y1=525,y2=545})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillRocketFuelEfficiency\",1},x1=1215,x2=1295,y1=525,y2=545})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillRocketFuelEfficiency\",2},x1=1305,x2=1385,y1=525,y2=545})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillRocketFuelEfficiency\",3},x1=1390,x2=1470,y1=525,y2=545})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillRocketFuelEfficiency\",4},x1=1475,x2=1555,y1=525,y2=545})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillRocketFuelEfficiency\",5},x1=1565,x2=1645,y1=525,y2=545})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"StatAtmosphericFuelTankHandling\",0},x1=1060,x2=1115,y1=590,y2=610})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"StatAtmosphericFuelTankHandling\",1},x1=1215,x2=1295,y1=590,y2=610})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"StatAtmosphericFuelTankHandling\",2},x1=1305,x2=1385,y1=590,y2=610})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"StatAtmosphericFuelTankHandling\",3},x1=1390,x2=1470,y1=590,y2=610})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"StatAtmosphericFuelTankHandling\",4},x1=1475,x2=1555,y1=590,y2=610})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"StatAtmosphericFuelTankHandling\",5},x1=1565,x2=1645,y1=590,y2=610})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"StatSpaceFuelTankHandling\",0},x1=1060,x2=1115,y1=660,y2=680})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"StatSpaceFuelTankHandling\",1},x1=1215,x2=1295,y1=660,y2=680})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"StatSpaceFuelTankHandling\",2},x1=1305,x2=1385,y1=660,y2=680})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"StatSpaceFuelTankHandling\",3},x1=1390,x2=1470,y1=660,y2=680})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"StatSpaceFuelTankHandling\",4},x1=1475,x2=1555,y1=660,y2=680})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"StatSpaceFuelTankHandling\",5},x1=1565,x2=1645,y1=660,y2=680})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"StatRocketFuelTankHandling\",0},x1=1060,x2=1115,y1=720,y2=740})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"StatRocketFuelTankHandling\",1},x1=1215,x2=1295,y1=720,y2=740})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"StatRocketFuelTankHandling\",2},x1=1305,x2=1385,y1=720,y2=740})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"StatRocketFuelTankHandling\",3},x1=1390,x2=1470,y1=720,y2=740})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"StatRocketFuelTankHandling\",4},x1=1475,x2=1555,y1=720,y2=740})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"StatRocketFuelTankHandling\",5},x1=1565,x2=1645,y1=720,y2=740})elseif m.mode==\"startup\"then end;m=CreateBaseClickAreas(m)return m end;function CheckClick(M,N,O)M=M*1920;N=N*1120;O=O or\"\"HitPayload={}if screens~=nil and#screens>0 then for i=1,#screens,1 do if screens[i].active==true and screens[i].element.getMouseX()~=-1 and screens[i].element.getMouseY()~=-1 then if O==\"\"then for J,j in pairs(screens[i].ClickAreas)do if j~=nil and M>=j.x1 and M<=j.x2 and N>=j.y1 and N<=j.y2 then O=j.id;HitPayload=j;break end end end;if O==\"ButtonPress\"then if screens[i].mode==HitPayload.param then screens[i].mode=\"startup\"else screens[i].mode=HitPayload.param end;if screens[i].mode==\"damageoutline\"then if screens[i].submode==\"\"then screens[i].submode=\"top\"end end;screens[i].refresh=true;screens[i].ClickAreas={}SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"ToggleBackground\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundMode==\"\"then BackgroundSelected=1;BackgroundMode=backgroundModes[BackgroundSelected]else BackgroundSelected=1;BackgroundMode=\"\"end;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"PreviousBackground\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundMode==\"\"then BackgroundSelected=1;BackgroundMode=backgroundModes[BackgroundSelected]else if BackgroundSelected<=1 then BackgroundSelected=#backgroundModes else BackgroundSelected=BackgroundSelected-1 end;BackgroundMode=backgroundModes[BackgroundSelected]end;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"NextBackground\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundMode==\"\"then BackgroundSelected=1;BackgroundMode=backgroundModes[BackgroundSelected]else if BackgroundSelected>=#backgroundModes then BackgroundSelected=1 else BackgroundSelected=BackgroundSelected+1 end;BackgroundMode=backgroundModes[BackgroundSelected]end;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"DecreaseOpacity\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundModeOpacity>0.1 then BackgroundModeOpacity=BackgroundModeOpacity-0.05;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()end elseif O==\"IncreaseOpacity\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundModeOpacity<1.0 then BackgroundModeOpacity=BackgroundModeOpacity+0.05;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()end elseif O==\"ResetColors\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then db.clear()ColorPrimary=\"FF6700\"ColorSecondary=\"FFFFFF\"ColorTertiary=\"000000\"ColorHealthy=\"00FF00\"ColorWarning=\"FFFF00\"ColorCritical=\"FF0000\"ColorBackground=\"000000\"ColorBackgroundPattern=\"4f4f4f\"BackgroundMode=\"deathstar\"BackgroundSelected=1;BackgroundModeOpacity=0.25;colorIDTable={[1]={id=\"ColorPrimary\",desc=\"Main HUD Color\",basec=\"FF6700\",newc=\"FF6700\"},[2]={id=\"ColorSecondary\",desc=\"Secondary HUD Color\",basec=\"FFFFFF\",newc=\"FFFFFF\"},[3]={id=\"ColorTertiary\",desc=\"Tertiary HUD Color\",basec=\"000000\",newc=\"000000\"},[4]={id=\"ColorHealthy\",desc=\"Color code for Healthy/Okay\",basec=\"00FF00\",newc=\"00FF00\"},[5]={id=\"ColorWarning\",desc=\"Color code for Damaged/Warning\",basec=\"FFFF00\",newc=\"FFFF00\"},[6]={id=\"ColorCritical\",desc=\"Color code for Broken/Critical\",basec=\"FF0000\",newc=\"FF0000\"},[7]={id=\"ColorBackground\",desc=\"Background Color\",basec=\"000000\",newc=\"000000\"},[8]={id=\"ColorBackgroundPattern\",desc=\"Background Pattern Color\",basec=\"4F4F4F\",newc=\"4F4F4F\"},[9]={id=\"ColorFuelAtmospheric\",desc=\"Color for Atmo Fuel/Elements\",basec=\"004444\",newc=\"004444\"},[10]={id=\"ColorFuelSpace\",desc=\"Color for Space Fuel/Elements\",basec=\"444400\",newc=\"444400\"},[11]={id=\"ColorFuelRocket\",desc=\"Color for Rocket Fuel/Elements\",basec=\"440044\",newc=\"440044\"}}SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"PreviousColorID\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then colorIDIndex=colorIDIndex-1;if colorIDIndex<1 then colorIDIndex=#colorIDTable end;SaveToDatabank()SetRefresh(\"settings1\")RenderScreens(\"settings1\")elseif O==\"NextColorID\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then colorIDIndex=colorIDIndex+1;if colorIDIndex>#colorIDTable then colorIDIndex=1 end;SaveToDatabank()SetRefresh(\"settings1\")RenderScreens(\"settings1\")elseif O==\"ColorPosUp\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then local P=tonumber(string.sub(colorIDTable[colorIDIndex].newc,HitPayload.param,HitPayload.param),16)P=P+1;if P>15 then P=0 end;colorIDTable[colorIDIndex].newc=replace_char(HitPayload.param,colorIDTable[colorIDIndex].newc,hexTable[P+1])SaveToDatabank()SetRefresh(\"settings1\")RenderScreens(\"settings1\")elseif O==\"ColorPosDown\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then local P=tonumber(string.sub(colorIDTable[colorIDIndex].newc,HitPayload.param,HitPayload.param),16)P=P-1;if P<0 then P=15 end;colorIDTable[colorIDIndex].newc=replace_char(HitPayload.param,colorIDTable[colorIDIndex].newc,hexTable[P+1])SaveToDatabank()SetRefresh(\"settings1\")RenderScreens(\"settings1\")elseif O==\"ResetPosColor\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then colorIDTable[colorIDIndex].newc=colorIDTable[colorIDIndex].basec;_G[colorIDTable[colorIDIndex].id]=colorIDTable[colorIDIndex].basec;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"ApplyPosColor\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then _G[colorIDTable[colorIDIndex].id]=colorIDTable[colorIDIndex].newc;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"ChangeSkillPoint\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then _G[HitPayload.param[1]]=HitPayload.param[2]UpdateDamageData()UpdateTypeData()SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"DamagedPageDown\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentDamagedPage=CurrentDamagedPage+1;if CurrentDamagedPage>math.ceil(#damagedElements/DamagePageSize)then CurrentDamagedPage=math.ceil(#damagedElements/DamagePageSize)end;HudDeselectElement()SaveToDatabank()SetRefresh(\"damage\")RenderScreens(\"damage\")elseif O==\"DamagedPageUp\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentDamagedPage=CurrentDamagedPage-1;if CurrentDamagedPage<1 then CurrentDamagedPage=1 end;HudDeselectElement()SaveToDatabank()SetRefresh(\"damage\")RenderScreens(\"damage\")elseif O==\"BrokenPageDown\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentBrokenPage=CurrentBrokenPage+1;if CurrentBrokenPage>math.ceil(#brokenElements/DamagePageSize)then CurrentBrokenPage=math.ceil(#brokenElements/DamagePageSize)end;HudDeselectElement()SaveToDatabank()SetRefresh(\"damage\")RenderScreens(\"damage\")elseif O==\"BrokenPageUp\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentBrokenPage=CurrentBrokenPage-1;if CurrentBrokenPage<1 then CurrentBrokenPage=1 end;HudDeselectElement()SaveToDatabank()SetRefresh(\"damage\")RenderScreens(\"damage\")elseif O==\"DMGOChangeView\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then screens[i].submode=HitPayload.param;UpdateViewDamageoutline(screens[i])SaveToDatabank()SetRefresh(\"damageoutline\",screens[i].submode)RenderScreens(\"damageoutline\",screens[i].submode)elseif O==\"DMGOChangeStretch\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if DMGOStretch==true then DMGOStretch=false else DMGOStretch=true end;UpdateViewDamageoutline(screens[i])SaveToDatabank()SetRefresh(\"damageoutline\")RenderScreens(\"damageoutline\")elseif O==\"ToggleDisplayAtmosphere\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if screens[i].fuelA==true then screens[i].fuelA=false else screens[i].fuelA=true end;screens[i].fuelIndex=1;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"ToggleDisplaySpace\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if screens[i].fuelS==true then screens[i].fuelS=false else screens[i].fuelS=true end;screens[i].fuelIndex=1;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"ToggleDisplayRocket\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if screens[i].fuelR==true then screens[i].fuelR=false else screens[i].fuelR=true end;screens[i].fuelIndex=1;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"DecreaseFuelIndex\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then screens[i].fuelIndex=screens[i].fuelIndex-1;if screens[i].fuelIndex<1 then screens[i].fuelIndex=1 end;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"IncreaseFuelIndex\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then screens[i].fuelIndex=screens[i].fuelIndex+1;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"ToggleHudMode\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if HUDMode==true then HUDMode=false;forceDamageRedraw=true;HudDeselectElement()SaveToDatabank()SetRefresh()RenderScreens()else HUDMode=true;forceDamageRedraw=true;HudDeselectElement()SaveToDatabank()SetRefresh()RenderScreens()end elseif O==\"ToggleSimulation\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentDamagedPage=1;CurrentBrokenPage=1;if SimulationMode==true then SimulationMode=false;SimulationActive=false;UpdateDamageData()UpdateTypeData()forceDamageRedraw=true;HudDeselectElement()SetRefresh(\"damage\")SetRefresh(\"damageoutline\")SetRefresh(\"settings1\")SetRefresh(\"fuel\")SaveToDatabank()RenderScreens()else SimulationMode=true;SimulationActive=false;UpdateDamageData()UpdateTypeData()forceDamageRedraw=true;HudDeselectElement()SetRefresh(\"damage\")SetRefresh(\"damageoutline\")SetRefresh(\"settings1\")SetRefresh(\"fuel\")SaveToDatabank()RenderScreens()end elseif(O==\"ToggleElementLabel\"or O==\"ToggleElementLabel2\")and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if UseMyElementNames==true then UseMyElementNames=false;SetRefresh(\"damage\")RenderScreens(\"damage\")else UseMyElementNames=true;SetRefresh(\"damage\")RenderScreens(\"damage\")end elseif(O==\"SwitchScrapTier\"or O==\"SwitchScrapTier2\")and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then ScrapTier=ScrapTier+1;if ScrapTier>4 then ScrapTier=1 end;SetRefresh(\"damage\")RenderScreens(\"damage\")end end end end end;function GetContentFlight()local Q=\"\"Q=Q..GetHeader(\"Flight Data Report\")..[[\n \n ]]return Q end;function GetContentDamage()local Q=\"\"if SimulationMode==true then Q=Q..GetHeader(\"Damage Report (Simulated damage)\")..[[]]else Q=Q..GetHeader(\"Damage Report\")..[[]]end;Q=Q..GetContentDamageScreen()return Q end;function GetContentDamageoutline(m)UpdateDataDamageoutline()UpdateViewDamageoutline(m)local Q=\"\"Q=Q..GetHeader(\"Damage Ship Outline Report\")..GetDamageoutlineShip()..[[]]if m.submode==\"top\"then Q=Q..[[\n \n Top View\n \n Side View\n \n Front View\n ]]elseif m.submode==\"side\"then Q=Q..[[\n \n Top View\n \n Side View\n \n Front View\n ]]elseif m.submode==\"front\"then Q=Q..[[\n \n Top View\n \n Side View\n \n Front View\n ]]else end;Q=Q..[[]]..#dmgoElements..[[ of ]]..ElementCounter..[[ shown]]Q=Q..[[]]if DMGOStretch==true then Q=Q..[[]]end;Q=Q..[[Stretch both axis]]return Q end;function GetContentFuel(m)local R=0;local Q=\"\"local S={}FuelDisplay={m.fuelA,m.fuelS,m.fuelR}if FuelDisplay[1]==true and#FuelAtmosphericTanks>0 then table.insert(S,\"Atmospheric\")R=R+1 end;if FuelDisplay[2]==true and#FuelSpaceTanks>0 then table.insert(S,\"Space\")R=R+1 end;if FuelDisplay[3]==true and#FuelRocketTanks>0 then table.insert(S,\"Rocket\")R=R+1 end;Q=Q..GetHeader(\"Fuel Report (\"..table.concat(S,\", \")..\")\")..[[\n ]]local T=150;local U=0;local V=0;if FuelDisplay[1]==true and#FuelAtmosphericTanks>0 then if R==1 then V=50 elseif R==2 then V=6 elseif R==3 then V=0 end;Q=Q..[[\n \n \n \n ]]Q=Q..[[]]..GenerateCommaValue(FuelAtmosphericCurrent,true)..[[ of ]]..GenerateCommaValue(FuelAtmosphericTotal,true)..[[ | Total Atmospheric Fuel in ]]..#FuelAtmosphericTanks..[[ tank]]..(#FuelAtmosphericTanks==1 and\"\"or\"s\")..[[ (]]..math.floor(100/FuelAtmosphericTotal*FuelAtmosphericCurrent)..[[%)]]U=U+1 end;if FuelDisplay[2]==true and#FuelSpaceTanks>0 then if R==1 then V=50 elseif R==2 then V=6 elseif R==3 then V=0 end;Q=Q..[[\n \n \n \n ]]Q=Q..[[]]..GenerateCommaValue(FuelSpaceCurrent,true)..[[ of ]]..GenerateCommaValue(FuelSpaceTotal,true)..[[ | Total Space Fuel in ]]..#FuelSpaceTanks..[[ tank]]..(#FuelSpaceTanks==1 and\"\"or\"s\")..[[ (]]..math.floor(100/FuelSpaceTotal*FuelSpaceCurrent)..[[%)]]U=U+1 end;if FuelDisplay[3]==true and#FuelRocketTanks>0 then if R==1 then V=50 elseif R==2 then V=6 elseif R==3 then V=0 end;Q=Q..[[\n \n \n \n ]]Q=Q..[[]]..GenerateCommaValue(FuelRocketCurrent,true)..[[ of ]]..GenerateCommaValue(FuelRocketTotal,true)..[[ | Total Rocket Fuel in ]]..#FuelRocketTanks..[[ tank]]..(#FuelRocketTanks==1 and\"\"or\"s\")..[[ (]]..math.floor(100/FuelRocketTotal*FuelRocketCurrent)..[[%)]]end;Q=Q..[[\n \n \n \n ]]local W={}if m.fuelIndex==nil or m.fuelIndex<1 then m.fuelIndex=1 end;if FuelDisplay[1]==true then for f,j in ipairs(FuelAtmosphericTanks)do table.insert(W,j)end end;if FuelDisplay[2]==true then for f,j in ipairs(FuelSpaceTanks)do table.insert(W,j)end end;if FuelDisplay[3]==true then for f,j in ipairs(FuelRocketTanks)do table.insert(W,j)end end;table.sort(W,function(E,F)return E.type\n \n \n ]]if Y.hp==0 then Q=Q..[[]]elseif Y.maxhp-Y.hp>constants.epsilon then Q=Q..[[]]else Q=Q..[[]]end;if Y.hp==0 then Q=Q..[[]]..Y.size..[[]]else Q=Q..[[]]..Y.size..[[]]end;if Y.hp==0 then Q=Q..[[Broken]]..[[0 of ]]..GenerateCommaValue(Y.vol)..[[]]elseif tonumber(Y.percent)<10 then Q=Q..[[]]..Y.percent..[[%]]..[[]]..GenerateCommaValue(Y.cvol)..[[ of ]]..GenerateCommaValue(Y.vol)..[[]]elseif tonumber(Y.percent)<30 then Q=Q..[[]]..Y.percent..[[%]]..[[]]..GenerateCommaValue(Y.cvol)..[[ of ]]..GenerateCommaValue(Y.vol)..[[]]else Q=Q..[[]]..Y.percent..[[%]]..[[]]..GenerateCommaValue(Y.cvol)..[[ of ]]..GenerateCommaValue(Y.vol)..[[]]end;Q=Q..[[]]..Y.name..[[]]Q=Q..[[]]end end;if#FuelAtmosphericTanks>0 then Q=Q..[[]]if FuelDisplay[1]==true then Q=Q..[[]]end;Q=Q..[[ATM]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"ToggleDisplayAtmosphere\",x1=50,x2=100,y1=270,y2=320})end;if#FuelSpaceTanks>0 then Q=Q..[[]]if FuelDisplay[2]==true then Q=Q..[[]]end;Q=Q..[[SPC]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"ToggleDisplaySpace\",x1=200,x2=250,y1=270,y2=320})end;if#FuelRocketTanks>0 then Q=Q..[[]]if FuelDisplay[3]==true then Q=Q..[[]]end;Q=Q..[[RKT]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"ToggleDisplayRocket\",x1=350,x2=400,y1=270,y2=320})end;if m.fuelIndex>1 then Q=Q..[[\n \n \n ]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"DecreaseFuelIndex\",x1=1470,x2=1670,y1=270,y2=320})end;if m.fuelIndex+X-1<#W then Q=Q..[[\n \n \n ]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"IncreaseFuelIndex\",x1=1680,x2=1880,y1=270,y2=320})end;if X>0 then Q=Q..[[]]..#W..[[ Tank]]..(#W==1 and\"\"or\"s\")..[[ (Showing ]]..m.fuelIndex..[[ to ]]..m.fuelIndex+X-1 ..[[)]]end;return Q end;function GetContentCargo()local Q=\"\"Q=Q..GetHeader(\"Cargo Report\")..[[\n \n ]]return Q end;function GetContentAGG()local Q=\"\"Q=Q..GetHeader(\"Anti-Grav Control\")..[[\n \n ]]return Q end;function GetContentMap()local Q=\"\"Q=Q..GetHeader(\"Map Overview\")..[[\n \n ]]return Q end;function GetContentTime()local Q=\"\"Q=Q..GetHeader(\"Time\")..epochTime()Q=Q..[[\n \n \n \n \n \n \n \n \n \n \n \n \n ]]return Q end;function GetContentSettings1()local Q=\"\"Q=Q..GetHeader(\"Settings\")..[[]]if BackgroundMode==\"\"then Q=Q..[[Activate background]]else Q=Q..[[Deactivate background (']]..BackgroundMode..[[', ]]..string.format(\"%.0f\",BackgroundModeOpacity*100)..[[%)]]end;Q=Q..[[\n \n Previous background\n \n Next background\n\n \n Decrease Opacity\n \n Increase Opacity\n ]]Q=Q..[[]]..[[Reset background and all colors]]Q=Q..[[]]..[[]]..[[]]..[[Select and change any of the ]]..#colorIDTable..[[ HUD colors]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..colorIDTable[colorIDIndex].desc..[[]]..[[]]..[[Current color]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[#]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,1,1)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,2,2)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,3,3)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,4,4)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,5,5)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,6,6)..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[New color]]..[[]]..[[Apply new color]]..[[]]..[[Reset]]..[[]]Q=Q..[[]]..[[]]..[[]]..[[Enter your skills and placed element levels]]Q=Q..[[]]..[[Skill: Equipment Manager >> Repair Tool Efficiency:]]local _=SkillRepairToolEfficiency;Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]..[[Skill: Equipment Manager >> Repair Tool Optimization:]]local _=SkillRepairToolOptimization;Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]..[[Skill: Atmospheric Engine Pilot >> Atmospheric Fuel Efficiency:]]local _=SkillAtmosphericFuelEfficiency;Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]..[[Skill: Space Engine Pilot >> Space Fuel Efficiency:]]local _=SkillSpaceFuelEfficiency;Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]..[[Skill: Rocket Scientists >> Rocket Fuel Efficiency:]]local _=SkillRocketFuelEfficiency;Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]..[[Stat: Level of Atmo Tanks (Atmospheric Fuel Tank Handling):]]local _=StatAtmosphericFuelTankHandling;Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]..[[Stat: Level of Space Tanks (Space Fuel Tank Handling):]]local _=StatSpaceFuelTankHandling;Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]..[[Stat: Level of Rocket Tanks (Rocket Fuel Tank Handling):]]local _=StatRocketFuelTankHandling;Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]if SimulationMode==true then Q=Q..[[Simulating Damage to elements]]AddClickArea(\"settings1\",{id=\"ToggleSimulation\",mode=\"settings1\",x1=940,x2=1850,y1=919,y2=969})else Q=Q..[[Simulate Damage to elements]]AddClickArea(\"settings1\",{id=\"ToggleSimulation\",mode=\"settings1\",x1=940,x2=1850,y1=919,y2=969})end;return Q end;function GetContentStartup()local Q=\"\"Q=Q..GetElementLogo(812,380,\"f\",\"f\",\"f\")if YourShipsName==\"Enter here\"then Q=Q..[[Spaceship ID ]]..ShipID..[[]]else Q=Q..[[]]..YourShipsName..[[]]end;if ShowWelcomeMessage==true then Q=Q..[[Greetings, Commander ]]..PlayerName..[[.]]end;Q=Q..[[Damage Report v]]..VERSION..[[, by Scion Interstellar, DorianGray - Discord: Dorian Gray#2623. Under GNU Public License 3.0.]]return Q end;function RenderScreen(m,a0)if a0==nil then PrintConsole(\"ERROR: contentToRender is nil.\")unit.exit()end;CreateClickAreasForScreen(m)local Q=\"\"Q=Q..[[\n \n \n ]]Q=Q..a0;if m.mode==\"startup\"then Q=Q..[[]]else Q=Q..[[]]end;Q=Q..[[\n \n ]]Q=Q..[[]]local a1=string.len(Q)m.element.setSVG(Q)end;function RenderScreens(a2,a3)a2=a2 or\"all\"a3=a3 or\"all\"if screens~=nil and#screens>0 then local a4=\"\"local a5=\"\"local a6=\"\"local a7=\"\"local a8=\"\"local a9=\"\"local aa=\"\"local ab=\"\"local ac=\"\"local ad=\"\"local ae=\"\"local af=\"\"for J,m in pairs(screens)do if m.refresh==true then local a0=\"\"if m.mode==\"flight\"and(a2==\"flight\"or a2==\"all\")then if a4==\"\"then a4=GetContentFlight()end;a0=a4 elseif m.mode==\"damage\"and(a2==\"damage\"or a2==\"all\")then if a5==\"\"then a5=GetContentDamage()end;a0=a5 elseif m.mode==\"damageoutline\"and(a2==\"damageoutline\"or a2==\"all\")then if m.submode==\"\"then m.submode=\"top\"screens[J].submode=\"top\"end;if m.submode==\"top\"and(a3==\"top\"or a3==\"all\")then if a6==\"\"then a6=GetContentDamageoutline(m)end;a0=a6 end;if m.submode==\"side\"and(a3==\"side\"or a3==\"all\")then if a7==\"\"then a7=GetContentDamageoutline(m)end;a0=a7 end;if m.submode==\"front\"and(a3==\"front\"or a3==\"all\")then if a8==\"\"then a8=GetContentDamageoutline(m)end;a0=a8 end elseif m.mode==\"fuel\"and(a2==\"fuel\"or a2==\"all\")then m=WipeClickAreasForScreen(screens[J])a0=GetContentFuel(m)elseif m.mode==\"cargo\"and(a2==\"cargo\"or a2==\"all\")then if aa==\"\"then aa=GetContentCargo()end;a0=aa elseif m.mode==\"agg\"and(a2==\"agg\"or a2==\"all\")then if ab==\"\"then ab=GetContentAGG()end;a0=ab elseif m.mode==\"map\"and(a2==\"map\"or a2==\"all\")then if ac==\"\"then ac=GetContentMap()end;a0=ac elseif m.mode==\"time\"and(a2==\"time\"or a2==\"all\")then if ad==\"\"then ad=GetContentTime()end;a0=ad elseif m.mode==\"settings1\"and(a2==\"settings1\"or a2==\"all\")then if ae==\"\"then ae=GetContentSettings1()end;a0=ae elseif m.mode==\"startup\"and(a2==\"startup\"or a2==\"all\")then if af==\"\"then af=GetContentStartup()end;a0=af else a0=\"Invalid screen mode. ('\"..m.mode..\"')\"end;if a0~=\"\"then RenderScreen(m,a0)else DrawCenteredText(\"ERROR: No contentToRender delivered for \"..m.mode)PrintConsole(\"ERROR: No contentToRender delivered for \"..m.mode)unit.exit()end;screens[J].refresh=false end end end;if HUDMode==true then system.setScreen(GetContentDamageHUDOutput())system.showScreen(1)else system.showScreen(0)end end;function OnTickData(C)if formerTime+60=4 then d=string.format(\"%.\"..c..\"fk\",a/1000)else d=string.format(\"%.\"..c..\"f\",a)end else while true do d,k=string.gsub(d,\"^(-?%d+)(%d%d%d)\",'%1,%2')if k==0 then break end end end;return d end;function PrintConsole(e,f)f=f or false;if f then system.print(\"------------------------------------------------------------------------\")end;system.print(e)if f then system.print(\"------------------------------------------------------------------------\")end end;function DrawCenteredText(e)if screens~=nil and#screens>0 then for g=1,#screens,1 do screens[g].element.setCenteredText(e)end end end;function ClearConsole()for g=1,10,1 do PrintConsole()end end;function SwitchScreens(h)h=h or\"on\"if screens~=nil and#screens>0 then for g=1,#screens,1 do if h==\"on\"then screens[g].element.clear()screens[g].element.activate()screens[g].active=true else screens[g].element.clear()screens[g].element.deactivate()screens[g].active=false end end end end;function GetSecondsString(i)local i=tonumber(i)if i==nil or i<=0 then return\"-\"else days=string.format(\"%2.f\",math.floor(i/(3600*24)))hours=string.format(\"%2.f\",math.floor(i/3600-days*24))mins=string.format(\"%2.f\",math.floor(i/60-hours*60-days*24*60))secs=string.format(\"%2.f\",math.floor(i-hours*3600-days*24*60*60-mins*60))str=\"\"if tonumber(days)>0 then str=str..days..\"d \"end;if tonumber(hours)>0 then str=str..hours..\"h \"end;if tonumber(mins)>0 then str=str..mins..\"m \"end;if tonumber(secs)>0 then str=str..secs..\"s\"end;return str end end;function replace_char(j,str,l)return str:sub(1,j-1)..l..str:sub(j+1)end;function epochTime()function rZ(m)if string.len(m)<=1 then return\"0\"..m else return m end end;function dPoint(n)if not(n==math.floor(n))then return true else return false end end;function lYear(year)if not dPoint(year/4)then if dPoint(year/100)then return true else if not dPoint(year/400)then return true else return false end end else return false end end;local o=5;local p=3600;local q=86400;local r=31536000;local s=31622400;local t=2419200;local g=2505600;local u=2592000;local k=2678400;local w={4,6,9,11}local x={1,3,5,7,8,10,12}local y=0;local z=1506816000;local A=system.getTime()_G[\"formerTime\"]=A;if AddSummertimeHour==true then A=A+3600 end;now=math.floor(A+z)year=1970;secs=0;y=0;while secs+s]]..hour..\":\"..minute..[[]]..[[]]..year..\"/\"..month..\"/\"..day..[[]]end;function ToggleHUD()if HUDMode==true then HUDMode=false;forceDamageRedraw=true;hudSelectedIndex=0;highlightID=0;HideHighlight()SetRefresh()RenderScreens()else HUDMode=true;forceDamageRedraw=true;hudSelectedIndex=0;highlightID=0;HideHighlight()SetRefresh()RenderScreens()end end;function HudDeselectElement()hudSelectedIndex=0;hudStartIndex=1;highlightID=0;HideHighlight()if HUDMode==true then SetRefresh(\"damage\")SetRefresh(\"damageoutline\")RenderScreens()end end;function ChangeHudSelectedElement(B)if HUDMode==true and#rE>0 then hudSelectedIndex=hudSelectedIndex+B;if hudSelectedIndex<1 then hudSelectedIndex=1 elseif hudSelectedIndex>#rE then hudSelectedIndex=#rE end;if hudSelectedIndex>9 then hudStartIndex=hudSelectedIndex-9 end;if hudSelectedIndex~=0 then highlightID=rE[hudSelectedIndex].id;if highlightID~=nil and highlightID~=0 then HideHighlight()elementPosition=vec3(rE[hudSelectedIndex].pos)highlightX=elementPosition.x-coreWorldOffset;highlightY=elementPosition.y-coreWorldOffset;highlightZ=elementPosition.z-coreWorldOffset;highlightOn=true;ShowHighlight()end end;SetRefresh(\"damage\")SetRefresh(\"damageoutline\")RenderScreens()end end;function HideHighlight()if#hudArrowSticker>0 then for g in pairs(hudArrowSticker)do core.deleteSticker(hudArrowSticker[g])end;hudArrowSticker={}end end;function ShowHighlight()if highlightOn==true and highlightID>0 then table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX+2,highlightY,highlightZ,\"north\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX,highlightY-2,highlightZ,\"east\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX-2,highlightY,highlightZ,\"south\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX,highlightY+2,highlightZ,\"west\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX,highlightY,highlightZ-2,\"up\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX,highlightY,highlightZ+2,\"down\"))end end;function ToggleHighlight()if highlightOn==true then highlightOn=false;HideHighlight()else highlightOn=true;ShowHighlight()end end;function SortDamageTables()table.sort(damagedElements,function(m,n)return m.missinghp>n.missinghp end)table.sort(brokenElements,function(m,n)return m.maxhp>n.maxhp end)end;function getScraps(C,D)D=D or false;C=C-SkillRepairToolOptimization*0.05*C;local E=math.ceil(C/(10*5^(ScrapTier-1)))if D==true then return GenerateCommaValue(string.format(\"%.0f\",E),false)else return E end end;function getRepairTime(C,F)F=F or false;C=C-SkillRepairToolOptimization*0.05*C;local E=math.ceil(C/ScrapTierRepairTimes[ScrapTier])E=E-SkillRepairToolEfficiency*0.1*E;if F==true then return GetSecondsString(string.format(\"%.0f\",E))else return E end end;function UpdateDataDamageoutline()dmgoElements={}for g,G in ipairs(brokenElements)do if#dmgoElementsShipXmax then ShipXmax=H end;if I>ShipYmax then ShipYmax=I end;if J>ShipZmax then ShipZmax=J end;table.insert(dmgoElements,{id=G.id,type=\"b\",size=G.maxhp,x=H,y=I,z=J,xp=0,yp=0,zp=0,u=0,v=0})end end;if#dmgoElementsShipXmax then ShipXmax=H end;if I>ShipYmax then ShipYmax=I end;if J>ShipZmax then ShipZmax=J end;table.insert(dmgoElements,{id=G.id,type=\"d\",size=G.maxhp,x=H,y=I,z=J,xp=0,yp=0,zp=0,u=0,v=0})end end end;if#dmgoElementsShipXmax then ShipXmax=H end;if I>ShipYmax then ShipYmax=I end;if J>ShipZmax then ShipZmax=J end;table.insert(dmgoElements,{id=G.id,type=\"h\",size=G.maxhp,x=H,y=I,z=J,xp=0,yp=0,zp=0,u=0,v=0})end end end;ShipX=math.abs(ShipXmax-ShipXmin)ShipY=math.abs(ShipYmax-ShipYmin)ShipZ=math.abs(ShipZmax-ShipZmin)for g,G in ipairs(dmgoElements)do dmgoElements[g].xp=math.abs(100/(ShipXmax-ShipXmin)*(G.x-ShipXmin))dmgoElements[g].yp=math.abs(100/(ShipYmax-ShipYmin)*(G.y-ShipYmin))dmgoElements[g].zp=math.abs(100/(ShipZmax-ShipZmin)*(G.z-ShipZmin))end end;function UpdateViewDamageoutline(K)UFrame=40;VFrame=40;UStart=20+UFrame;VStart=180+VFrame;UDim=1880-2*UFrame;VDim=840-2*VFrame;if K.submode==\"top\"then if DMGOStretch==false then local L=UDim/(ShipYmax-ShipYmin)local M=VDim/(ShipXmax-ShipXmin)if L>=M then local N=L/M;local O=math.floor(UDim/N)UStart=UStart+(UDim-O)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100/N*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100*G.xp+VStart)end else local N=M/L;local P=math.floor(VDim/N)VStart=VStart+(VDim-P)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100/N*G.xp+VStart)end end else for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100*G.xp+VStart)end end elseif K.submode==\"front\"then if DMGOStretch==false then local L=UDim/(ShipXmax-ShipXmin)local M=VDim/(ShipZmax-ShipZmin)if L>=M then local N=L/M;local O=math.floor(UDim/N)UStart=UStart+(UDim-O)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100/N*G.xp+UStart)dmgoElements[g].v=math.floor(VDim/100*(100-G.zp)+VStart)end else local N=M/L;local P=math.floor(VDim/N)VStart=VStart+(VDim-P)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.xp+UStart)dmgoElements[g].v=math.floor(VDim/100/N*(100-G.zp)+VStart)end end else for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.xp+UStart)dmgoElements[g].v=math.floor(VDim/100*(100-G.zp)+VStart)end end elseif K.submode==\"side\"then if DMGOStretch==false then local L=UDim/(ShipYmax-ShipYmin)local M=VDim/(ShipXmax-ShipZmin)if L>=M then local N=L/M;local O=math.floor(UDim/N)UStart=UStart+(UDim-O)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100/N*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100*(100-G.zp)+VStart)end else local N=M/L;local P=math.floor(VDim/N)VStart=VStart+(VDim-P)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100/N*(100-G.zp)+VStart)end end else for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100*(100-G.zp)+VStart)end end else DrawCenteredText(\"ERROR: non-existing DMGO mode set.\")PrintConsole(\"ERROR: non-existing DMGO mode set.\")unit.exit()end end;function GetDamageoutlineShip()local e=\"\"for g,G in ipairs(dmgoElements)do local Q=\"\"local R=1;if G.type==\"h\"then Q=\"ch\"elseif G.type==\"d\"then Q=\"cw\"else Q=\"cc\"end;if G.id==highlightID then Q=\"f2\"end;if G.size>0 and G.size<1000 then R=5 elseif G.size>=1000 and G.size<2000 then R=8 elseif G.size>=2000 and G.size<5000 then R=12 elseif G.size>=5000 and G.size<10000 then R=15 elseif G.size>=10000 and G.size<20000 then R=20 elseif G.size>=20000 then R=30 end;e=e..[[]]if G.id==highlightID then e=e..[[]]e=e..[[]]end end;return e end;function GetContentClickareas(K)local e=\"\"if K~=nil and K.ClickAreas~=nil and#K.ClickAreas>0 then for g,S in ipairs(K.ClickAreas)do e=e..[[]]end end;return e end;function GetElement1(H,I,T,U)H=H or 0;I=I or 0;T=T or 600;U=U or 600;local e=\"\"e=e..[[\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ]]return e end;function GetElement2(H,I)H=H or 0;I=I or 0;local e=\"\"e=e..[[]]return e end;function GetElementLogo(H,I,V,W,X)H=H or 812;I=I or 380;V=V or\"f\"W=W or\"f2\"X=X or\"f3\"local e=\"\"e=e..[[\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ]]return e end;function GetHeader(Y)Y=Y or\"ERROR: UNDEFINED\"local e=\"\"e=e..[[\n ]]..Y..[[]]return e end;function GetContentBackground(Z,_)bgColor=ColorBackgroundPattern;local e=\"\"if Z==\"dots\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' viewBox='0 0 4 4'%3E%3Cpath fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' d='M1 3h1v1H1V3zm2-2h1v1H3V1z'%3E%3C/path%3E%3C/svg%3E\");]]elseif Z==\"rain\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='12' height='16' viewBox='0 0 12 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 .99C4 .445 4.444 0 5 0c.552 0 1 .45 1 .99v4.02C6 5.555 5.556 6 5 6c-.552 0-1-.45-1-.99V.99zm6 8c0-.546.444-.99 1-.99.552 0 1 .45 1 .99v4.02c0 .546-.444.99-1 .99-.552 0-1-.45-1-.99V8.99z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E\");]]elseif Z==\"plus\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E\");]]elseif Z==\"signal\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='84' height='48' viewBox='0 0 84 48' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h12v6H0V0zm28 8h12v6H28V8zm14-8h12v6H42V0zm14 0h12v6H56V0zm0 8h12v6H56V8zM42 8h12v6H42V8zm0 16h12v6H42v-6zm14-8h12v6H56v-6zm14 0h12v6H70v-6zm0-16h12v6H70V0zM28 32h12v6H28v-6zM14 16h12v6H14v-6zM0 24h12v6H0v-6zm0 8h12v6H0v-6zm14 0h12v6H14v-6zm14 8h12v6H28v-6zm-14 0h12v6H14v-6zm28 0h12v6H42v-6zm14-8h12v6H56v-6zm0-8h12v6H56v-6zm14 8h12v6H70v-6zm0 8h12v6H70v-6zM14 24h12v6H14v-6zm14-8h12v6H28v-6zM14 8h12v6H14V8zM0 8h12v6H0V8z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E\");]]elseif Z==\"deathstar\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='105' viewBox='0 0 80 105'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M20 10a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm15 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zM20 75a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zm30-65a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm0 65a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zM35 10a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zM5 45a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zm60 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10z' /%3E%3C/g%3E%3C/g%3E%3C/svg%3E\");]]elseif Z==\"diamond\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='32' viewBox='0 0 16 32'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath fill-rule='evenodd' d='M0 24h4v2H0v-2zm0 4h6v2H0v-2zm0-8h2v2H0v-2zM0 0h4v2H0V0zm0 4h2v2H0V4zm16 20h-6v2h6v-2zm0 4H8v2h8v-2zm0-8h-4v2h4v-2zm0-20h-6v2h6V0zm0 4h-4v2h4V4zm-2 12h2v2h-2v-2zm0-8h2v2h-2V8zM2 8h10v2H2V8zm0 8h10v2H2v-2zm-2-4h14v2H0v-2zm4-8h6v2H4V4zm0 16h6v2H4v-2zM6 0h2v2H6V0zm0 24h2v2H6v-2z'/%3E%3C/g%3E%3C/svg%3E\");]]elseif Z==\"hexagon\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='49' viewBox='0 0 28 49'%3E%3Cg fill-rule='evenodd'%3E%3Cg id='hexagons' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='nonzero'%3E%3Cpath d='M13.99 9.25l13 7.5v15l-13 7.5L1 31.75v-15l12.99-7.5zM3 17.9v12.7l10.99 6.34 11-6.35V17.9l-11-6.34L3 17.9zM0 15l12.98-7.5V0h-2v6.35L0 12.69v2.3zm0 18.5L12.98 41v8h-2v-6.85L0 35.81v-2.3zM15 0v7.5L27.99 15H28v-2.31h-.01L17 6.35V0h-2zm0 49v-8l12.99-7.5H28v2.31h-.01L17 42.15V49h-2z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E\");]]elseif Z==\"capsule\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='32' height='26' viewBox='0 0 32 26' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M14 0v3.994C14 7.864 10.858 11 7 11c-3.866 0-7-3.138-7-7.006V0h2v4.005C2 6.765 4.24 9 7 9c2.756 0 5-2.236 5-4.995V0h2zm0 26v-5.994C14 16.138 10.866 13 7 13c-3.858 0-7 3.137-7 7.006V26h2v-6.005C2 17.235 4.244 15 7 15c2.76 0 5 2.236 5 4.995V26h2zm2-18.994C16 3.136 19.142 0 23 0c3.866 0 7 3.138 7 7.006v9.988C30 20.864 26.858 24 23 24c-3.866 0-7-3.138-7-7.006V7.006zm2-.01C18 4.235 20.244 2 23 2c2.76 0 5 2.236 5 4.995v10.01C28 19.765 25.756 22 23 22c-2.76 0-5-2.236-5-4.995V6.995z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E\");]]elseif Z==\"diagonal\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='6' height='6' viewBox='0 0 6 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'%3E%3Cpath d='M5 0h1L0 6V5zM6 5v1H5z'/%3E%3C/g%3E%3C/svg%3E\");]]end;return e end;function GetContentDamageHUDOutput()local a0=300;local a1=165;if#damagedElements>0 or#brokenElements>0 then a1=510 end;local e=\"\"e=e..[[\n \n ]]e=e..[[]]..[[]]..[[]]..[[]]..(YourShipsName==\"Enter here\"and\"Ship ID \"..ShipID or YourShipsName)..[[]]..[[]]if#brokenElements>0 then e=e..[[]]elseif#damagedElements>0 then e=e..[[]]else e=e..[[]]end;if#damagedElements>0 or#brokenElements>0 then e=e..[[Total Damage]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",totalShipMaxHP-totalShipHP))..[[]]e=e..[[T]]..ScrapTier..[[ Scrap Needed]]..[[]]..getScraps(totalShipMaxHP-totalShipHP,true)..[[]]e=e..[[Repair Time]]..[[]]..getRepairTime(totalShipMaxHP-totalShipHP,true)..[[]]e=e..[[]]..[[]]..[[]]..#healthyElements..[[]]..[[]]..[[]]..#damagedElements..[[]]..[[]]..[[]]..#brokenElements..[[]]local u=0;for a2=hudStartIndex,hudStartIndex+9,1 do if rE[a2]~=nil then v=rE[a2]if v.hp>0 then e=e..[[]]..[[]]..string.format(\"%.30s\",v.name)..[[]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",v.missinghp))..[[]]if v.id==highlightID then e=e..[[]]..[[]]..string.format(\"%.30s\",v.name)..[[]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",v.missinghp))..[[]]end else e=e..[[]]..[[]]..string.format(\"%.30s\",v.name)..[[]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",v.missinghp))..[[]]if v.id==highlightID then highlightX=elementPosition.x-coreWorldOffset;highlightY=elementPosition.y-coreWorldOffset;highlightZ=elementPosition.z-coreWorldOffset;e=e..[[]]..[[]]..string.format(\"%.30s\",v.name)..[[]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",v.missinghp))..[[]]end end;u=u+1 end end;e=e..[[]]..[[]]..[[]]..[[]]..[[Up/down arrows to highlight]]..[[CTRL + arrows to move HUD]]..[[Left arrow to toggle HUD Mode]]..[[ALT+1-4 to set Scrap Tier]]..[[ALT+8 to reset HUD position]]..[[ALT+9 to shut script off]]..[[]]..[[]]else e=e..[[]]..OkayCenterMessage..[[]]..[[]]..#healthyElements..[[ elements / ]]..GenerateCommaValue(string.format(\"%.0f\",totalShipMaxHP))..[[ HP.]]..[[]]..[[]]..[[]]..[[]]..[[Left arrow to toggle HUD Mode]]..[[CTRL + arrows to move HUD]]..[[ALT+8 to reset HUD position]]..[[ALT+9 to shut script off]]..[[]]..[[]]end;e=e..[[]]return e end;function GetContentDamageScreen()local a3=\"\"if#damagedElements>0 then local a4=#damagedElements;if a4>DamagePageSize then a4=DamagePageSize end;if CurrentDamagedPage==math.ceil(#damagedElements/DamagePageSize)then a4=#damagedElements%DamagePageSize+12;if a4>12 then a4=a4-12 end end;a3=a3 ..[[]]a3=a3 ..[[]]if UseMyElementNames==true then a3=a3 ..[[Damaged Name]]else a3=a3 ..[[Damaged Type]]end;a3=a3 ..[[HLTHDMG]]a3=a3 ..[[T]]..ScrapTier..[[ SCRREPTIME]]AddClickArea(\"damage\",{id=\"SwitchScrapTier\",mode=\"damage\",x1=650,x2=775,y1=315,y2=360})local g=0;for u=1+(CurrentDamagedPage-1)*DamagePageSize,a4+(CurrentDamagedPage-1)*DamagePageSize,1 do g=g+1;local a5=damagedElements[u]if UseMyElementNames==true then a3=a3 ..[[]]..string.format(\"%.23s\",a5.name)..[[]]else a3=a3 ..[[]]..string.format(\"%.23s\",a5.type)..[[]]end;a3=a3 ..[[]]..a5.percent..[[%]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",a5.missinghp),true)..[[]]..[[]]..getScraps(a5.missinghp,true)..[[]]..[[]]..getRepairTime(a5.missinghp,true)..[[]]..[[]]end;if#damagedElements>DamagePageSize then a3=a3 ..[[Page ]]..CurrentDamagedPage..\" of \"..math.ceil(#damagedElements/DamagePageSize)..[[]]if CurrentDamagedPage\n \n \n ]]AddClickArea(\"damage\",{id=\"DamagedPageDown\",mode=\"damage\",x1=65,x2=260,y1=290+(a4+1)*50,y2=290+50+(a4+1)*50})else DisableClickArea(\"DamagedPageDown\",\"damage\")end;if CurrentDamagedPage>1 then a3=a3 ..[[\n \n \n ]]AddClickArea(\"damage\",{id=\"DamagedPageUp\",mode=\"damage\",x1=750,x2=950,y1=290+(a4+1)*50,y2=290+50+(a4+1)*50})else DisableClickArea(\"DamagedPageUp\",\"damage\")end end end;if#brokenElements>0 then local a6=#brokenElements;if a6>DamagePageSize then a6=DamagePageSize end;if CurrentBrokenPage==math.ceil(#brokenElements/DamagePageSize)then a6=#brokenElements%DamagePageSize+12;if a6>12 then a6=a6-12 end end;a3=a3 ..[[]]a3=a3 ..[[]]if UseMyElementNames==true then a3=a3 ..[[Broken Name]]else a3=a3 ..[[Broken Type]]end;a3=a3 ..[[DMG]]a3=a3 ..[[T]]..ScrapTier..[[ SCRREPTIME]]AddClickArea(\"damage\",{id=\"SwitchScrapTier2\",mode=\"damage\",x1=1570,x2=1690,y1=315,y2=360})local g=0;for u=1+(CurrentBrokenPage-1)*DamagePageSize,a6+(CurrentBrokenPage-1)*DamagePageSize,1 do g=g+1;local a5=brokenElements[u]if UseMyElementNames==true then a3=a3 ..[[]]..string.format(\"%.30s\",a5.name)..[[]]else a3=a3 ..[[]]..string.format(\"%.30s\",a5.type)..[[]]end;a3=a3 ..[[]]..GenerateCommaValue(string.format(\"%.0f\",a5.missinghp),true)..[[]]..[[]]..getScraps(a5.missinghp,true)..[[]]..[[]]..getRepairTime(a5.missinghp,true)..[[]]..[[]]end;if#brokenElements>DamagePageSize then a3=a3 ..[[Page ]]..CurrentBrokenPage..\" of \"..math.ceil(#brokenElements/DamagePageSize)..[[]]if CurrentBrokenPage>1 then a3=a3 ..[[\n \n \n ]]AddClickArea(\"damage\",{id=\"BrokenPageUp\",mode=\"damage\",x1=1665,x2=1865,y1=290+(a6+1)*50,y2=290+50+(a6+1)*50})else DisableClickArea(\"BrokenPageUp\",\"damage\")end;if CurrentBrokenPage\n \n \n ]]AddClickArea(\"damage\",{id=\"BrokenPageDown\",mode=\"damage\",x1=980,x2=1180,y1=290+(a6+1)*50,y2=290+50+(a6+1)*50})else DisableClickArea(\"BrokenPageDown\",\"damage\")end end end;if#damagedElements>0 or#brokenElements>0 then local a7=math.floor(1878/#elementsIdList*#damagedElements)local a8=math.floor(1878/#elementsIdList*#brokenElements)local a9=1878-a7-a8+1;a3=a3 ..[[]]a3=a3 ..[[]]a3=a3 ..[[]]a3=a3 ..[[]]if#damagedElements>0 then a3=a3 ..[[]]..#damagedElements..[[]]end;if#healthyElements>0 then a3=a3 ..[[]]..#healthyElements..[[]]end;if#brokenElements>0 then a3=a3 ..[[]]..#brokenElements..[[]]end;a3=a3 ..[[]]a3=a3 ..[[]]..GenerateCommaValue(string.format(\"%.0f\",totalShipMaxHP-totalShipHP))..[[ HP damage in total ]]..getScraps(totalShipMaxHP-totalShipHP,true)..[[ T]]..ScrapTier..[[ scraps needed. ]]..getRepairTime(totalShipMaxHP-totalShipHP,true)..[[ projected repair time.]]else a3=a3 ..GetElementLogo(812,380,\"ch\",\"ch\",\"ch\")..[[]]..OkayCenterMessage..[[]]..[[]]..#healthyElements..[[ elements stand ]]..GenerateCommaValue(string.format(\"%.0f\",totalShipMaxHP))..[[ HP strong.]]end;forceDamageRedraw=false;return a3 end;function ActionStopengines()ToggleHUD()end;function ActionStrafeRight()if KeyCTRLPressed==true then if HUDShiftU<4000 then HUDShiftU=HUDShiftU+50;SaveToDatabank()RenderScreens()end else HudDeselectElement()end end;function ActionStrafeLeft()if KeyCTRLPressed==true then if HUDShiftU>=50 then HUDShiftU=HUDShiftU-50;SaveToDatabank()RenderScreens()end else ToggleHUD()end end;function ActionDown()if KeyCTRLPressed==true then if HUDShiftV<4000 then HUDShiftV=HUDShiftV+50;SaveToDatabank()RenderScreens()end else ChangeHudSelectedElement(1)end end;function ActionUp()if KeyCTRLPressed==true then if HUDShiftV>=50 then HUDShiftV=HUDShiftV-50;SaveToDatabank()RenderScreens()end else ChangeHudSelectedElement(-1)end end;function ActionOption1()ScrapTier=1;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption2()ScrapTier=2;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption3()ScrapTier=3;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption4()ScrapTier=4;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption8()HUDShiftU=0;HUDShiftV=0;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption9()SaveToDatabank()SwitchScreens(\"off\")unit.exit()end",
- "filter": {
- "args": [],
- "signature": "start()",
- "slotKey": "-1"
- },
- "key": "10"
- },
- {
- "code": "SaveToDatabank()\nSwitchScreens(\"off\")",
- "filter": {
- "args": [],
- "signature": "stop()",
- "slotKey": "-1"
- },
- "key": "11"
- },
- {
- "code": "OnTickData()\n",
- "filter": {
- "args": [
- {
- "value": "UpdateData"
- }
- ],
- "signature": "tick(timerId)",
- "slotKey": "-1"
- },
- "key": "12"
- },
- {
- "code": "ToggleHighlight()",
- "filter": {
- "args": [
- {
- "value": "UpdateHighlight"
- }
- ],
- "signature": "tick(timerId)",
- "slotKey": "-1"
- },
- "key": "13"
- },
- {
- "code": "--[[\n Damage Report 3.01\n A LUA script for Dual Universe\n\n Created By Dorian GrayY.percent\n Ingame: DorianGray\n Discord: Dorian Gray#2623\n\n You can find/update this script on GitHub. Explanations, installation and usage information as well as screenshots can be found there too.\n GitHub: https://github.com/DorianTheGrey/DU-DamageReport\n\n GNU Public License 3.0. Use whatever you want, be so kind to leave credit.\n \n Credits & thanks: \n Thanks to NovaQuark for creating the MMO of the century.\n Thanks to Jericho, Dmentia and Archaegeo for learning a lot from their fine scripts.\n Thanks to TheBlacklist for testing and wonderful suggestions.\n SVG patterns by Hero Patterns.\n DU atlas data from Jayle Break.\n \n]]\n\n--[[ 1. USER DEFINED VARIABLES ]]\n\nYourShipsName = \"Enter here\" --export Enter your ship name here if you want it displayed instead of the ship's ID. YOU NEED TO LEAVE THE QUOTATION MARKS.\nShowWelcomeMessage = true --export Do you want the welcome message on the start screen with your name?\nAddSummertimeHour = false --export: Is summertime currently enabled in your location? (Adds one hour.)\n\nUpdateDataInterval=1.0;HighlightBlinkingInterval=0.5;ColorPrimary=\"FF6700\"ColorSecondary=\"FFFFFF\"ColorTertiary=\"000000\"ColorHealthy=\"00FF00\"ColorWarning=\"FFFF00\"ColorCritical=\"FF0000\"ColorBackground=\"000000\"ColorBackgroundPattern=\"4F4F4F\"ColorFuelAtmospheric=\"004444\"ColorFuelSpace=\"444400\"ColorFuelRocket=\"440044\"VERSION=3.01;DebugMode=false;DebugRenderClickareas=true;DBData={}core=nil;db=nil;screens={}dscreens={}screenModes={[\"flight\"]={id=\"flight\"},[\"damage\"]={id=\"damage\"},[\"damageoutline\"]={id=\"damageoutline\"},[\"fuel\"]={id=\"fuel\"},[\"cargo\"]={id=\"cargo\"},[\"agg\"]={id=\"agg\"},[\"map\"]={id=\"map\"},[\"time\"]={id=\"time\",activetoggle=\"true\"},[\"settings1\"]={id=\"settings1\"},[\"startup\"]={id=\"startup\"}}backgroundModes={\"deathstar\",\"capsule\",\"rain\",\"signal\",\"hexagon\",\"diagonal\",\"diamond\",\"plus\",\"dots\"}BackgroundMode=\"deathstar\"BackgroundSelected=1;BackgroundModeOpacity=0.25;SaveVars={\"dscreens\",\"YourShipsName\",\"AddSummertimeHour\",\"ColorPrimary\",\"ColorSecondary\",\"ColorTertiary\",\"ColorHealthy\",\"ColorWarning\",\"ColorCritical\",\"ColorBackground\",\"ColorBackgroundPattern\",\"UpdateDataInterval\",\"HighlightBlinkingInterval\",\"ScrapTier\",\"HUDMode\",\"SimulationMode\",\"DMGOStretch\",\"HUDShiftU\",\"HUDShiftV\",\"colorIDIndex\",\"colorIDTable\",\"SkillRepairToolEfficiency\",\"SkillRepairToolOptimization\",\"SkillAtmosphericFuelEfficiency\",\"SkillSpaceFuelEfficiency\",\"SkillRocketFuelEfficiency\",\"StatAtmosphericFuelTankHandling\",\"StatSpaceFuelTankHandling\",\"StatRocketFuelTankHandling\",\"BackgroundMode\",\"BackgroundSelected\",\"BackgroundModeOpacity\"}HUDMode=false;HUDShiftU=0;HUDShiftV=0;hudSelectedIndex=0;hudStartIndex=1;hudArrowSticker={}highlightOn=false;highlightID=0;highlightX=0;highlightY=0;highlightZ=0;SimulationMode=false;OkayCenterMessage=\"All systems nominal.\"CurrentDamagedPage=1;CurrentBrokenPage=1;DamagePageSize=12;ScrapTier=1;totalScraps=0;ScrapTierRepairTimes={10,50,250,1250}coreWorldOffset=0;totalShipHP=0;formerTotalShipHP=-1;totalShipMaxHP=0;totalShipIntegrity=100;elementsId={}elementsIdList={}damagedElements={}brokenElements={}rE={}healthyElements={}typeElements={}ElementCounter=0;UseMyElementNames=true;dmgoElements={}DMGOMaxElements=250;DMGOStretch=false;ShipXmin=99999999;ShipXmax=-99999999;ShipYmin=99999999;ShipYmax=-99999999;ShipZmin=99999999;ShipZmax=-99999999;totalShipMass=0;formerTotalShipMass=-1;formerTime=-1;FuelAtmosphericTanks={}FuelSpaceTanks={}FuelRocketTanks={}FuelAtmosphericTotal=0;FuelSpaceTotal=0;FuelRocketTotal=0;FuelAtmosphericCurrent=0;FuelSpaceTotalCurrent=0;FuelRocketTotalCurrent=0;formerFuelAtmosphericTotal=-1;formerFuelSpaceTotal=-1;formerFuelRocketTotal=-1;SkillRepairToolEfficiency=0;SkillRepairToolOptimization=0;SkillAtmosphericFuelEfficiency=0;SkillSpaceFuelEfficiency=0;SkillRocketFuelEfficiency=0;StatAtmosphericFuelTankHandling=0;StatSpaceFuelTankHandling=0;StatRocketFuelTankHandling=0;hexTable={\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"A\",\"B\",\"C\",\"D\",\"E\",\"F\"}colorIDIndex=1;colorIDTable={[1]={id=\"ColorPrimary\",desc=\"Main HUD Color\",basec=\"FF6700\",newc=\"FF6700\"},[2]={id=\"ColorSecondary\",desc=\"Secondary HUD Color\",basec=\"FFFFFF\",newc=\"FFFFFF\"},[3]={id=\"ColorTertiary\",desc=\"Tertiary HUD Color\",basec=\"000000\",newc=\"000000\"},[4]={id=\"ColorHealthy\",desc=\"Color code for Healthy/Okay\",basec=\"00FF00\",newc=\"00FF00\"},[5]={id=\"ColorWarning\",desc=\"Color code for Damaged/Warning\",basec=\"FFFF00\",newc=\"FFFF00\"},[6]={id=\"ColorCritical\",desc=\"Color code for Broken/Critical\",basec=\"FF0000\",newc=\"FF0000\"},[7]={id=\"ColorBackground\",desc=\"Background Color\",basec=\"000000\",newc=\"000000\"},[8]={id=\"ColorBackgroundPattern\",desc=\"Background Pattern Color\",basec=\"4F4F4F\",newc=\"4F4F4F\"},[9]={id=\"ColorFuelAtmospheric\",desc=\"Color for Atmo Fuel/Elements\",basec=\"004444\",newc=\"004444\"},[10]={id=\"ColorFuelSpace\",desc=\"Color for Space Fuel/Elements\",basec=\"444400\",newc=\"444400\"},[11]={id=\"ColorFuelRocket\",desc=\"Color for Rocket Fuel/Elements\",basec=\"440044\",newc=\"440044\"}}function InitiateSlots()for a,b in pairs(unit)do if type(b)==\"table\"and type(b.export)==\"table\"and b.getElementClass then local c=b.getElementClass():lower()if c:find(\"coreunit\")then core=b;local d=core.getMaxHitPoints()if d>10000 then coreWorldOffset=128 elseif d>1000 then coreWorldOffset=64 elseif d>150 then coreWorldOffset=32 else coreWorldOffset=16 end elseif c=='databankunit'then db=b elseif c==\"screenunit\"then local e=\"startup\"screens[#screens+1]={element=b,id=b.getId(),mode=e,submode=\"\",ClickAreas={},refresh=true,active=false,fuelA=true,fuelS=true,fuelR=true,fuelIndex=1}end end end end;function LoadFromDatabank()if db==nil then return else for f,g in pairs(SaveVars)do if db.hasKey(g)then local h=json.decode(db.getStringValue(g))if h~=nil then if g==\"YourShipsName\"or g==\"AddSummertimeHour\"or g==\"UpdateDataInterval\"or g==\"HighlightBlinkingInterval\"then else _G[g]=h end end end end;for i,j in ipairs(screens)do for k,l in ipairs(dscreens)do if screens[i].id==dscreens[k].id then screens[i].mode=dscreens[k].mode;screens[i].submode=dscreens[k].submode;screens[i].active=dscreens[k].active;screens[i].refresh=true;screens[i].fuelA=dscreens[k].fuelA;screens[i].fuelS=dscreens[k].fuelS;screens[i].fuelR=dscreens[k].fuelR;screens[i].fuelIndex=dscreens[k].fuelIndex end end end end end;function SaveToDatabank()if db==nil then return else dscreens={}for i,m in ipairs(screens)do dscreens[i]={}dscreens[i].id=m.id;dscreens[i].mode=m.mode;dscreens[i].submode=m.submode;dscreens[i].active=m.active;dscreens[i].fuelA=m.fuelA;dscreens[i].fuelS=m.fuelS;dscreens[i].fuelR=m.fuelR;dscreens[i].fuelIndex=m.fuelIndex end;db.clear()for f,g in pairs(SaveVars)do if g==\"YourShipsName\"or g==\"AddSummertimeHour\"or g==\"UpdateDataInterval\"or g==\"HighlightBlinkingInterval\"then else db.setStringValue(g,json.encode(_G[g]))end end end end;function InitiateScreens()if screens~=nil and#screens>0 then for i=1,#screens,1 do screens[i]=CreateClickAreasForScreen(screens[i])end end end;function UpdateTypeData()FuelAtmosphericTanks={}FuelSpaceTanks={}FuelRocketTanks={}FuelAtmosphericTotal=0;FuelAtmosphericCurrent=0;FuelSpaceTotal=0;FuelSpaceCurrent=0;FuelRocketCurrent=0;FuelRocketTotal=0;local n=4;local o=6;local p=0.8;for i,q in ipairs(typeElements)do local r=core.getElementNameById(q)or\"\"local s=core.getElementTypeById(q)or\"\"local t=core.getElementPositionById(q)or 0;local u=core.getElementHitPointsById(q)or 0;local v=core.getElementMaxHitPointsById(q)or 0;local w=core.getElementMassById(q)or 0;local x=\"\"local y=0;local z=0;local A=0;local B=0;if s==\"atmospheric fuel-tank\"then if v>10000 then x=\"L\"z=5480;y=12800 elseif v>1300 then x=\"M\"z=988.67;y=1600 elseif v>150 then x=\"S\"z=182.67;y=400 else x=\"XS\"z=35.03;y=100 end;if StatAtmosphericFuelTankHandling>0 then y=0.2*StatAtmosphericFuelTankHandling*y+y end;A=w-z;if A<=10 then A=0 end;B=string.format(\"%.0f\",A/n)cPercent=string.format(\"%.1f\",math.floor(100/y*tonumber(B)))table.insert(FuelAtmosphericTanks,{type=1,id=q,name=r,maxhp=v,hp=GetHPforElement(q),pos=t,size=x,mass=z,vol=y,cvol=B,percent=cPercent})if u>0 then FuelAtmosphericCurrent=FuelAtmosphericCurrent+B end;FuelAtmosphericTotal=FuelAtmosphericTotal+y elseif s==\"space fuel-tank\"then if v>10000 then x=\"L\"z=5480;y=12800 elseif v>1300 then x=\"M\"z=988.67;y=1600 else x=\"S\"z=182.67;y=400 end;if StatSpaceFuelTankHandling>0 then y=0.2*StatSpaceFuelTankHandling*y+y end;A=w-z;if A<=10 then A=0 end;B=string.format(\"%.0f\",A/o)cPercent=string.format(\"%.1f\",100/y*tonumber(B))table.insert(FuelSpaceTanks,{type=2,id=q,name=r,maxhp=v,hp=GetHPforElement(q),pos=t,size=x,mass=z,vol=y,cvol=B,percent=cPercent})if u>0 then FuelSpaceCurrent=FuelSpaceCurrent+B end;FuelSpaceTotal=FuelSpaceTotal+y elseif s==\"rocket fuel-tank\"then if v>65000 then x=\"L\"z=25740;y=50000 elseif v>6000 then x=\"M\"z=4720;y=6400 elseif v==700 then x=\"S\"z=886.72;y=800 else x=\"XS\"z=173.42;y=400 end;if StatRocketFuelTankHandling>0 then y=0.2*StatRocketFuelTankHandling*y+y end;A=w-z;if A<=10 then A=0 end;B=string.format(\"%.0f\",A/p)cPercent=string.format(\"%.1f\",100/y*tonumber(B))table.insert(FuelRocketTanks,{type=3,id=q,name=r,maxhp=v,hp=GetHPforElement(q),pos=t,size=x,mass=z,vol=y,cvol=B,percent=cPercent})if u>0 then FuelRocketCurrent=FuelRocketCurrent+B end;FuelRocketTotal=FuelRocketTotal+y end end;if FuelAtmosphericCurrent~=formerFuelAtmosphericCurrent then SetRefresh(\"fuel\")formerFuelAtmosphericCurrent=FuelAtmosphericCurrent end;if FuelSpaceCurrent~=formerFuelSpaceCurrent then SetRefresh(\"fuel\")formerFuelSpaceCurrent=FuelSpaceCurrent end;if FuelRocketCurrent~=formerFuelRocketCurrent then SetRefresh(\"fuel\")formerFuelRocketCurrent=FuelRocketCurrent end end;function UpdateDamageData(C)C=C or false;if SimulationActive==true then return end;local formerTotalShipHP=totalShipHP;totalShipHP=0;totalShipMaxHP=0;totalShipIntegrity=100;damagedElements={}brokenElements={}healthyElements={}ElementCounter=0;elementsIdList=core.getElementIdList()for i,q in pairs(elementsIdList)do ElementCounter=ElementCounter+1;local r=core.getElementNameById(q)local s=core.getElementTypeById(q)local t=core.getElementPositionById(q)local u=core.getElementHitPointsById(q)local v=core.getElementMaxHitPointsById(q)if SimulationMode==true then SimulationActive=true;local D=math.random(0,10)if D<2 and#brokenElements<30 then u=0 elseif D>=2 and D<4 and#damagedElements<30 then u=math.random(1,math.ceil(v))else u=v end end;totalShipHP=totalShipHP+u;totalShipMaxHP=totalShipMaxHP+v;if v-u>constants.epsilon then if u>0 then table.insert(damagedElements,{id=q,name=r,type=s,counter=ElementCounter,hp=u,maxhp=v,missinghp=v-u,percent=math.ceil(100/v*u),pos=t})else table.insert(brokenElements,{id=q,name=r,type=s,counter=ElementCounter,hp=u,maxhp=v,missinghp=v-u,percent=0,pos=t})end else table.insert(healthyElements,{id=q,name=r,type=s,counter=ElementCounter,hp=u,maxhp=v,pos=t})if q==highlightID then highlightID=0;highlightOn=false;HideHighlight()hudSelectedIndex=0 end end;if C==true then if s==\"atmospheric fuel-tank\"or s==\"space fuel-tank\"or s==\"rocket fuel-tank\"then table.insert(typeElements,q)end end end;SortDamageTables()rE={}if#brokenElements>0 then for f,j in ipairs(brokenElements)do table.insert(rE,{id=j.id,missinghp=j.missinghp,hp=j.hp,name=j.name,type=j.type,pos=j.pos})end end;if#damagedElements>0 then for f,j in ipairs(damagedElements)do table.insert(rE,{id=j.id,missinghp=j.missinghp,hp=j.hp,name=j.name,type=j.type,pos=j.pos})end end;if#rE>0 then table.sort(rE,function(E,F)return E.missinghp>F.missinghp end)end;totalShipIntegrity=string.format(\"%2.0f\",100/totalShipMaxHP*totalShipHP)if formerTotalShipHP~=totalShipHP then forceDamageRedraw=true;formerTotalShipHP=totalShipHP else forceDamageRedraw=false end end;function GetHPforElement(q)for i,j in ipairs(brokenElements)do if j.id==q then return 0 end end;for i,j in ipairs(damagedElements)do if j.id==q then return j.hp end end;for i,j in ipairs(healthyElements)do if j.id==q then return j.maxhp end end end;function UpdateClickArea(G,H,I)for i,m in ipairs(screens)do for J,j in pairs(screens[i].ClickAreas)do if j.id==G and j.mode==I then screens[i].ClickAreas[J]=H end end end end;function AddClickArea(I,H)for i,m in ipairs(screens)do if screens[i].mode==I then table.insert(screens[i].ClickAreas,H)end end end;function AddClickAreaForScreenID(K,H)for i,m in ipairs(screens)do if screens[i].id==K then table.insert(screens[i].ClickAreas,H)end end end;function DisableClickArea(G,I)UpdateClickArea(G,{id=G,mode=I,x1=-1,x2=-1,y1=-1,y2=-1})end;function SetRefresh(I,L)I=I or\"all\"L=L or\"all\"if screens~=nil and#screens>0 then for i=1,#screens,1 do if screens[i].mode==I or I==\"all\"then if screens[i].submode==L or L==\"all\"then screens[i].refresh=true end end end end end;function WipeClickAreasForScreen(m)m.ClickAreas={}return m end;function CreateBaseClickAreas(m)table.insert(m.ClickAreas,{mode=\"all\",id=\"ToggleHudMode\",x1=1537,x2=1728,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"damage\",x1=193,x2=384,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"damageoutline\",x1=385,x2=576,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"fuel\",x1=577,x2=768,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"time\",x1=0,x2=192,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"settings1\",x1=1729,x2=1920,y1=1015,y2=1075})return m end;function CreateClickAreasForScreen(m)if m==nil then return{}end;if m.mode==\"flight\"then elseif m.mode==\"damage\"then table.insert(m.ClickAreas,{mode=\"damage\",id=\"ToggleElementLabel\",x1=70,x2=425,y1=325,y2=355})table.insert(m.ClickAreas,{mode=\"damage\",id=\"ToggleElementLabel2\",x1=980,x2=1400,y1=325,y2=355})elseif m.mode==\"damageoutline\"then table.insert(m.ClickAreas,{mode=\"damageoutline\",id=\"DMGOChangeView\",param=\"top\",x1=60,x2=439,y1=150,y2=200})table.insert(m.ClickAreas,{mode=\"damageoutline\",id=\"DMGOChangeView\",param=\"side\",x1=440,x2=824,y1=150,y2=200})table.insert(m.ClickAreas,{mode=\"damageoutline\",id=\"DMGOChangeView\",param=\"front\",x1=825,x2=1215,y1=150,y2=200})table.insert(m.ClickAreas,{mode=\"damageoutline\",id=\"DMGOChangeStretch\",x1=1530,x2=1580,y1=150,y2=200})elseif m.mode==\"fuel\"then elseif m.mode==\"cargo\"then elseif m.mode==\"agg\"then elseif m.mode==\"map\"then elseif m.mode==\"time\"then elseif m.mode==\"settings1\"then table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ToggleBackground\",x1=75,x2=860,y1=170,y2=215})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"PreviousBackground\",x1=75,x2=460,y1=235,y2=285})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"NextBackground\",x1=480,x2=860,y1=235,y2=285})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"DecreaseOpacity\",x1=75,x2=460,y1=300,y2=350})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"IncreaseOpacity\",x1=480,x2=860,y1=300,y2=350})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ResetColors\",x1=75,x2=860,y1=370,y2=415})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"PreviousColorID\",x1=90,x2=140,y1=500,y2=550})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"NextColorID\",x1=795,x2=845,y1=500,y2=550})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"1\",x1=210,x2=290,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"2\",x1=300,x2=380,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"3\",x1=385,x2=465,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"4\",x1=470,x2=550,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"5\",x1=560,x2=640,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"6\",x1=645,x2=725,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"1\",x1=210,x2=290,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"2\",x1=300,x2=380,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"3\",x1=385,x2=465,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"4\",x1=470,x2=550,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"5\",x1=560,x2=640,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"6\",x1=645,x2=725,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ResetPosColor\",x1=160,x2=340,y1=885,y2=935})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ApplyPosColor\",x1=355,x2=780,y1=885,y2=935})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillRepairToolEfficiency\",0},x1=1060,x2=1115,y1=260,y2=280})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillRepairToolEfficiency\",1},x1=1215,x2=1295,y1=260,y2=280})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillRepairToolEfficiency\",2},x1=1305,x2=1385,y1=260,y2=280})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillRepairToolEfficiency\",3},x1=1390,x2=1470,y1=260,y2=280})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillRepairToolEfficiency\",4},x1=1475,x2=1555,y1=260,y2=280})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillRepairToolEfficiency\",5},x1=1565,x2=1645,y1=260,y2=280})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillRepairToolOptimization\",0},x1=1060,x2=1115,y1=325,y2=345})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillRepairToolOptimization\",1},x1=1215,x2=1295,y1=325,y2=345})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillRepairToolOptimization\",2},x1=1305,x2=1385,y1=325,y2=345})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillRepairToolOptimization\",3},x1=1390,x2=1470,y1=325,y2=345})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillRepairToolOptimization\",4},x1=1475,x2=1555,y1=325,y2=345})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillRepairToolOptimization\",5},x1=1565,x2=1645,y1=325,y2=345})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillAtmosphericFuelEfficiency\",0},x1=1060,x2=1115,y1=390,y2=410})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillAtmosphericFuelEfficiency\",1},x1=1215,x2=1295,y1=390,y2=410})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillAtmosphericFuelEfficiency\",2},x1=1305,x2=1385,y1=390,y2=410})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillAtmosphericFuelEfficiency\",3},x1=1390,x2=1470,y1=390,y2=410})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillAtmosphericFuelEfficiency\",4},x1=1475,x2=1555,y1=390,y2=410})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillAtmosphericFuelEfficiency\",5},x1=1565,x2=1645,y1=390,y2=410})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillSpaceFuelEfficiency\",0},x1=1060,x2=1115,y1=460,y2=480})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillSpaceFuelEfficiency\",1},x1=1215,x2=1295,y1=460,y2=480})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillSpaceFuelEfficiency\",2},x1=1305,x2=1385,y1=460,y2=480})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillSpaceFuelEfficiency\",3},x1=1390,x2=1470,y1=460,y2=480})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillSpaceFuelEfficiency\",4},x1=1475,x2=1555,y1=460,y2=480})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillSpaceFuelEfficiency\",5},x1=1565,x2=1645,y1=460,y2=480})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillRocketFuelEfficiency\",0},x1=1060,x2=1115,y1=525,y2=545})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillRocketFuelEfficiency\",1},x1=1215,x2=1295,y1=525,y2=545})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillRocketFuelEfficiency\",2},x1=1305,x2=1385,y1=525,y2=545})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillRocketFuelEfficiency\",3},x1=1390,x2=1470,y1=525,y2=545})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillRocketFuelEfficiency\",4},x1=1475,x2=1555,y1=525,y2=545})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"SkillRocketFuelEfficiency\",5},x1=1565,x2=1645,y1=525,y2=545})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"StatAtmosphericFuelTankHandling\",0},x1=1060,x2=1115,y1=590,y2=610})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"StatAtmosphericFuelTankHandling\",1},x1=1215,x2=1295,y1=590,y2=610})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"StatAtmosphericFuelTankHandling\",2},x1=1305,x2=1385,y1=590,y2=610})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"StatAtmosphericFuelTankHandling\",3},x1=1390,x2=1470,y1=590,y2=610})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"StatAtmosphericFuelTankHandling\",4},x1=1475,x2=1555,y1=590,y2=610})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"StatAtmosphericFuelTankHandling\",5},x1=1565,x2=1645,y1=590,y2=610})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"StatSpaceFuelTankHandling\",0},x1=1060,x2=1115,y1=660,y2=680})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"StatSpaceFuelTankHandling\",1},x1=1215,x2=1295,y1=660,y2=680})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"StatSpaceFuelTankHandling\",2},x1=1305,x2=1385,y1=660,y2=680})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"StatSpaceFuelTankHandling\",3},x1=1390,x2=1470,y1=660,y2=680})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"StatSpaceFuelTankHandling\",4},x1=1475,x2=1555,y1=660,y2=680})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"StatSpaceFuelTankHandling\",5},x1=1565,x2=1645,y1=660,y2=680})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"StatRocketFuelTankHandling\",0},x1=1060,x2=1115,y1=720,y2=740})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"StatRocketFuelTankHandling\",1},x1=1215,x2=1295,y1=720,y2=740})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"StatRocketFuelTankHandling\",2},x1=1305,x2=1385,y1=720,y2=740})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"StatRocketFuelTankHandling\",3},x1=1390,x2=1470,y1=720,y2=740})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"StatRocketFuelTankHandling\",4},x1=1475,x2=1555,y1=720,y2=740})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ChangeSkillPoint\",param={\"StatRocketFuelTankHandling\",5},x1=1565,x2=1645,y1=720,y2=740})elseif m.mode==\"startup\"then end;m=CreateBaseClickAreas(m)return m end;function CheckClick(M,N,O)M=M*1920;N=N*1120;O=O or\"\"HitPayload={}if screens~=nil and#screens>0 then for i=1,#screens,1 do if screens[i].active==true and screens[i].element.getMouseX()~=-1 and screens[i].element.getMouseY()~=-1 then if O==\"\"then for J,j in pairs(screens[i].ClickAreas)do if j~=nil and M>=j.x1 and M<=j.x2 and N>=j.y1 and N<=j.y2 then O=j.id;HitPayload=j;break end end end;if O==\"ButtonPress\"then if screens[i].mode==HitPayload.param then screens[i].mode=\"startup\"else screens[i].mode=HitPayload.param end;if screens[i].mode==\"damageoutline\"then if screens[i].submode==\"\"then screens[i].submode=\"top\"end end;screens[i].refresh=true;screens[i].ClickAreas={}SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"ToggleBackground\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundMode==\"\"then BackgroundSelected=1;BackgroundMode=backgroundModes[BackgroundSelected]else BackgroundSelected=1;BackgroundMode=\"\"end;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"PreviousBackground\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundMode==\"\"then BackgroundSelected=1;BackgroundMode=backgroundModes[BackgroundSelected]else if BackgroundSelected<=1 then BackgroundSelected=#backgroundModes else BackgroundSelected=BackgroundSelected-1 end;BackgroundMode=backgroundModes[BackgroundSelected]end;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"NextBackground\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundMode==\"\"then BackgroundSelected=1;BackgroundMode=backgroundModes[BackgroundSelected]else if BackgroundSelected>=#backgroundModes then BackgroundSelected=1 else BackgroundSelected=BackgroundSelected+1 end;BackgroundMode=backgroundModes[BackgroundSelected]end;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"DecreaseOpacity\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundModeOpacity>0.1 then BackgroundModeOpacity=BackgroundModeOpacity-0.05;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()end elseif O==\"IncreaseOpacity\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundModeOpacity<1.0 then BackgroundModeOpacity=BackgroundModeOpacity+0.05;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()end elseif O==\"ResetColors\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then db.clear()ColorPrimary=\"FF6700\"ColorSecondary=\"FFFFFF\"ColorTertiary=\"000000\"ColorHealthy=\"00FF00\"ColorWarning=\"FFFF00\"ColorCritical=\"FF0000\"ColorBackground=\"000000\"ColorBackgroundPattern=\"4f4f4f\"BackgroundMode=\"deathstar\"BackgroundSelected=1;BackgroundModeOpacity=0.25;colorIDTable={[1]={id=\"ColorPrimary\",desc=\"Main HUD Color\",basec=\"FF6700\",newc=\"FF6700\"},[2]={id=\"ColorSecondary\",desc=\"Secondary HUD Color\",basec=\"FFFFFF\",newc=\"FFFFFF\"},[3]={id=\"ColorTertiary\",desc=\"Tertiary HUD Color\",basec=\"000000\",newc=\"000000\"},[4]={id=\"ColorHealthy\",desc=\"Color code for Healthy/Okay\",basec=\"00FF00\",newc=\"00FF00\"},[5]={id=\"ColorWarning\",desc=\"Color code for Damaged/Warning\",basec=\"FFFF00\",newc=\"FFFF00\"},[6]={id=\"ColorCritical\",desc=\"Color code for Broken/Critical\",basec=\"FF0000\",newc=\"FF0000\"},[7]={id=\"ColorBackground\",desc=\"Background Color\",basec=\"000000\",newc=\"000000\"},[8]={id=\"ColorBackgroundPattern\",desc=\"Background Pattern Color\",basec=\"4F4F4F\",newc=\"4F4F4F\"},[9]={id=\"ColorFuelAtmospheric\",desc=\"Color for Atmo Fuel/Elements\",basec=\"004444\",newc=\"004444\"},[10]={id=\"ColorFuelSpace\",desc=\"Color for Space Fuel/Elements\",basec=\"444400\",newc=\"444400\"},[11]={id=\"ColorFuelRocket\",desc=\"Color for Rocket Fuel/Elements\",basec=\"440044\",newc=\"440044\"}}SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"PreviousColorID\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then colorIDIndex=colorIDIndex-1;if colorIDIndex<1 then colorIDIndex=#colorIDTable end;SaveToDatabank()SetRefresh(\"settings1\")RenderScreens(\"settings1\")elseif O==\"NextColorID\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then colorIDIndex=colorIDIndex+1;if colorIDIndex>#colorIDTable then colorIDIndex=1 end;SaveToDatabank()SetRefresh(\"settings1\")RenderScreens(\"settings1\")elseif O==\"ColorPosUp\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then local P=tonumber(string.sub(colorIDTable[colorIDIndex].newc,HitPayload.param,HitPayload.param),16)P=P+1;if P>15 then P=0 end;colorIDTable[colorIDIndex].newc=replace_char(HitPayload.param,colorIDTable[colorIDIndex].newc,hexTable[P+1])SaveToDatabank()SetRefresh(\"settings1\")RenderScreens(\"settings1\")elseif O==\"ColorPosDown\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then local P=tonumber(string.sub(colorIDTable[colorIDIndex].newc,HitPayload.param,HitPayload.param),16)P=P-1;if P<0 then P=15 end;colorIDTable[colorIDIndex].newc=replace_char(HitPayload.param,colorIDTable[colorIDIndex].newc,hexTable[P+1])SaveToDatabank()SetRefresh(\"settings1\")RenderScreens(\"settings1\")elseif O==\"ResetPosColor\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then colorIDTable[colorIDIndex].newc=colorIDTable[colorIDIndex].basec;_G[colorIDTable[colorIDIndex].id]=colorIDTable[colorIDIndex].basec;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"ApplyPosColor\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then _G[colorIDTable[colorIDIndex].id]=colorIDTable[colorIDIndex].newc;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"ChangeSkillPoint\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then _G[HitPayload.param[1]]=HitPayload.param[2]UpdateDamageData()UpdateTypeData()SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"DamagedPageDown\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentDamagedPage=CurrentDamagedPage+1;if CurrentDamagedPage>math.ceil(#damagedElements/DamagePageSize)then CurrentDamagedPage=math.ceil(#damagedElements/DamagePageSize)end;HudDeselectElement()SaveToDatabank()SetRefresh(\"damage\")RenderScreens(\"damage\")elseif O==\"DamagedPageUp\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentDamagedPage=CurrentDamagedPage-1;if CurrentDamagedPage<1 then CurrentDamagedPage=1 end;HudDeselectElement()SaveToDatabank()SetRefresh(\"damage\")RenderScreens(\"damage\")elseif O==\"BrokenPageDown\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentBrokenPage=CurrentBrokenPage+1;if CurrentBrokenPage>math.ceil(#brokenElements/DamagePageSize)then CurrentBrokenPage=math.ceil(#brokenElements/DamagePageSize)end;HudDeselectElement()SaveToDatabank()SetRefresh(\"damage\")RenderScreens(\"damage\")elseif O==\"BrokenPageUp\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentBrokenPage=CurrentBrokenPage-1;if CurrentBrokenPage<1 then CurrentBrokenPage=1 end;HudDeselectElement()SaveToDatabank()SetRefresh(\"damage\")RenderScreens(\"damage\")elseif O==\"DMGOChangeView\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then screens[i].submode=HitPayload.param;UpdateViewDamageoutline(screens[i])SaveToDatabank()SetRefresh(\"damageoutline\",screens[i].submode)RenderScreens(\"damageoutline\",screens[i].submode)elseif O==\"DMGOChangeStretch\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if DMGOStretch==true then DMGOStretch=false else DMGOStretch=true end;UpdateViewDamageoutline(screens[i])SaveToDatabank()SetRefresh(\"damageoutline\")RenderScreens(\"damageoutline\")elseif O==\"ToggleDisplayAtmosphere\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if screens[i].fuelA==true then screens[i].fuelA=false else screens[i].fuelA=true end;screens[i].fuelIndex=1;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"ToggleDisplaySpace\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if screens[i].fuelS==true then screens[i].fuelS=false else screens[i].fuelS=true end;screens[i].fuelIndex=1;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"ToggleDisplayRocket\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if screens[i].fuelR==true then screens[i].fuelR=false else screens[i].fuelR=true end;screens[i].fuelIndex=1;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"DecreaseFuelIndex\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then screens[i].fuelIndex=screens[i].fuelIndex-1;if screens[i].fuelIndex<1 then screens[i].fuelIndex=1 end;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"IncreaseFuelIndex\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then screens[i].fuelIndex=screens[i].fuelIndex+1;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"ToggleHudMode\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if HUDMode==true then HUDMode=false;forceDamageRedraw=true;HudDeselectElement()SaveToDatabank()SetRefresh()RenderScreens()else HUDMode=true;forceDamageRedraw=true;HudDeselectElement()SaveToDatabank()SetRefresh()RenderScreens()end elseif O==\"ToggleSimulation\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentDamagedPage=1;CurrentBrokenPage=1;if SimulationMode==true then SimulationMode=false;SimulationActive=false;UpdateDamageData()UpdateTypeData()forceDamageRedraw=true;HudDeselectElement()SetRefresh(\"damage\")SetRefresh(\"damageoutline\")SetRefresh(\"settings1\")SetRefresh(\"fuel\")SaveToDatabank()RenderScreens()else SimulationMode=true;SimulationActive=false;UpdateDamageData()UpdateTypeData()forceDamageRedraw=true;HudDeselectElement()SetRefresh(\"damage\")SetRefresh(\"damageoutline\")SetRefresh(\"settings1\")SetRefresh(\"fuel\")SaveToDatabank()RenderScreens()end elseif(O==\"ToggleElementLabel\"or O==\"ToggleElementLabel2\")and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if UseMyElementNames==true then UseMyElementNames=false;SetRefresh(\"damage\")RenderScreens(\"damage\")else UseMyElementNames=true;SetRefresh(\"damage\")RenderScreens(\"damage\")end elseif(O==\"SwitchScrapTier\"or O==\"SwitchScrapTier2\")and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then ScrapTier=ScrapTier+1;if ScrapTier>4 then ScrapTier=1 end;SetRefresh(\"damage\")RenderScreens(\"damage\")end end end end end;function GetContentFlight()local Q=\"\"Q=Q..GetHeader(\"Flight Data Report\")..[[\n \n ]]return Q end;function GetContentDamage()local Q=\"\"if SimulationMode==true then Q=Q..GetHeader(\"Damage Report (Simulated damage)\")..[[]]else Q=Q..GetHeader(\"Damage Report\")..[[]]end;Q=Q..GetContentDamageScreen()return Q end;function GetContentDamageoutline(m)UpdateDataDamageoutline()UpdateViewDamageoutline(m)local Q=\"\"Q=Q..GetHeader(\"Damage Ship Outline Report\")..GetDamageoutlineShip()..[[]]if m.submode==\"top\"then Q=Q..[[\n \n Top View\n \n Side View\n \n Front View\n ]]elseif m.submode==\"side\"then Q=Q..[[\n \n Top View\n \n Side View\n \n Front View\n ]]elseif m.submode==\"front\"then Q=Q..[[\n \n Top View\n \n Side View\n \n Front View\n ]]else end;Q=Q..[[]]..#dmgoElements..[[ of ]]..ElementCounter..[[ shown]]Q=Q..[[]]if DMGOStretch==true then Q=Q..[[]]end;Q=Q..[[Stretch both axis]]return Q end;function GetContentFuel(m)if#FuelAtmosphericTanks<1 and#FuelSpaceTanks<1 and#FuelRocketTanks<1 then return\"\"end;local R=0;local Q=\"\"local S={}FuelDisplay={m.fuelA,m.fuelS,m.fuelR}if FuelDisplay[1]==true and#FuelAtmosphericTanks>0 then table.insert(S,\"Atmospheric\")R=R+1 end;if FuelDisplay[2]==true and#FuelSpaceTanks>0 then table.insert(S,\"Space\")R=R+1 end;if FuelDisplay[3]==true and#FuelRocketTanks>0 then table.insert(S,\"Rocket\")R=R+1 end;Q=Q..GetHeader(\"Fuel Report (\"..table.concat(S,\", \")..\")\")..[[\n ]]local T=150;local U=0;local V=0;if FuelDisplay[1]==true and#FuelAtmosphericTanks>0 then if R==1 then V=50 elseif R==2 then V=6 elseif R==3 then V=0 end;Q=Q..[[\n \n \n \n ]]Q=Q..[[]]..GenerateCommaValue(FuelAtmosphericCurrent,true)..[[ of ]]..GenerateCommaValue(FuelAtmosphericTotal,true)..[[ | Total Atmospheric Fuel in ]]..#FuelAtmosphericTanks..[[ tank]]..(#FuelAtmosphericTanks==1 and\"\"or\"s\")..[[ (]]..math.floor(100/FuelAtmosphericTotal*FuelAtmosphericCurrent)..[[%)]]U=U+1 end;if FuelDisplay[2]==true and#FuelSpaceTanks>0 then if R==1 then V=50 elseif R==2 then V=6 elseif R==3 then V=0 end;Q=Q..[[\n \n \n \n ]]Q=Q..[[]]..GenerateCommaValue(FuelSpaceCurrent,true)..[[ of ]]..GenerateCommaValue(FuelSpaceTotal,true)..[[ | Total Space Fuel in ]]..#FuelSpaceTanks..[[ tank]]..(#FuelSpaceTanks==1 and\"\"or\"s\")..[[ (]]..math.floor(100/FuelSpaceTotal*FuelSpaceCurrent)..[[%)]]U=U+1 end;if FuelDisplay[3]==true and#FuelRocketTanks>0 then if R==1 then V=50 elseif R==2 then V=6 elseif R==3 then V=0 end;Q=Q..[[\n \n \n \n ]]Q=Q..[[]]..GenerateCommaValue(FuelRocketCurrent,true)..[[ of ]]..GenerateCommaValue(FuelRocketTotal,true)..[[ | Total Rocket Fuel in ]]..#FuelRocketTanks..[[ tank]]..(#FuelRocketTanks==1 and\"\"or\"s\")..[[ (]]..math.floor(100/FuelRocketTotal*FuelRocketCurrent)..[[%)]]end;Q=Q..[[\n \n \n \n ]]local W={}if m.fuelIndex==nil or m.fuelIndex<1 then m.fuelIndex=1 end;if FuelDisplay[1]==true then for f,j in ipairs(FuelAtmosphericTanks)do table.insert(W,j)end end;if FuelDisplay[2]==true then for f,j in ipairs(FuelSpaceTanks)do table.insert(W,j)end end;if FuelDisplay[3]==true then for f,j in ipairs(FuelRocketTanks)do table.insert(W,j)end end;table.sort(W,function(E,F)return E.type\n \n \n ]]if Y.hp==0 then Q=Q..[[]]elseif Y.maxhp-Y.hp>constants.epsilon then Q=Q..[[]]else Q=Q..[[]]end;if Y.hp==0 then Q=Q..[[]]..Y.size..[[]]else Q=Q..[[]]..Y.size..[[]]end;if Y.hp==0 then Q=Q..[[Broken]]..[[0 of ]]..GenerateCommaValue(Y.vol)..[[]]elseif tonumber(Y.percent)<10 then Q=Q..[[]]..Y.percent..[[%]]..[[]]..GenerateCommaValue(Y.cvol)..[[ of ]]..GenerateCommaValue(Y.vol)..[[]]elseif tonumber(Y.percent)<30 then Q=Q..[[]]..Y.percent..[[%]]..[[]]..GenerateCommaValue(Y.cvol)..[[ of ]]..GenerateCommaValue(Y.vol)..[[]]else Q=Q..[[]]..Y.percent..[[%]]..[[]]..GenerateCommaValue(Y.cvol)..[[ of ]]..GenerateCommaValue(Y.vol)..[[]]end;Q=Q..[[]]..Y.name..[[]]Q=Q..[[]]end end;if#FuelAtmosphericTanks>0 then Q=Q..[[]]if FuelDisplay[1]==true then Q=Q..[[]]end;Q=Q..[[ATM]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"ToggleDisplayAtmosphere\",x1=50,x2=100,y1=270,y2=320})end;if#FuelSpaceTanks>0 then Q=Q..[[]]if FuelDisplay[2]==true then Q=Q..[[]]end;Q=Q..[[SPC]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"ToggleDisplaySpace\",x1=200,x2=250,y1=270,y2=320})end;if#FuelRocketTanks>0 then Q=Q..[[]]if FuelDisplay[3]==true then Q=Q..[[]]end;Q=Q..[[RKT]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"ToggleDisplayRocket\",x1=350,x2=400,y1=270,y2=320})end;if m.fuelIndex>1 then Q=Q..[[\n \n \n ]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"DecreaseFuelIndex\",x1=1470,x2=1670,y1=270,y2=320})end;if m.fuelIndex+X-1<#W then Q=Q..[[\n \n \n ]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"IncreaseFuelIndex\",x1=1680,x2=1880,y1=270,y2=320})end;if X>0 then Q=Q..[[]]..#W..[[ Tank]]..(#W==1 and\"\"or\"s\")..[[ (Showing ]]..m.fuelIndex..[[ to ]]..m.fuelIndex+X-1 ..[[)]]end;return Q end;function GetContentCargo()local Q=\"\"Q=Q..GetHeader(\"Cargo Report\")..[[\n \n ]]return Q end;function GetContentAGG()local Q=\"\"Q=Q..GetHeader(\"Anti-Grav Control\")..[[\n \n ]]return Q end;function GetContentMap()local Q=\"\"Q=Q..GetHeader(\"Map Overview\")..[[\n \n ]]return Q end;function GetContentTime()local Q=\"\"Q=Q..GetHeader(\"Time\")..epochTime()Q=Q..[[\n \n \n \n \n \n \n \n \n \n \n \n \n ]]return Q end;function GetContentSettings1()local Q=\"\"Q=Q..GetHeader(\"Settings\")..[[]]if BackgroundMode==\"\"then Q=Q..[[Activate background]]else Q=Q..[[Deactivate background (']]..BackgroundMode..[[', ]]..string.format(\"%.0f\",BackgroundModeOpacity*100)..[[%)]]end;Q=Q..[[\n \n Previous background\n \n Next background\n\n \n Decrease Opacity\n \n Increase Opacity\n ]]Q=Q..[[]]..[[Reset background and all colors]]Q=Q..[[]]..[[]]..[[]]..[[Select and change any of the ]]..#colorIDTable..[[ HUD colors]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..colorIDTable[colorIDIndex].desc..[[]]..[[]]..[[Current color]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[#]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,1,1)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,2,2)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,3,3)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,4,4)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,5,5)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,6,6)..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[New color]]..[[]]..[[Apply new color]]..[[]]..[[Reset]]..[[]]Q=Q..[[]]..[[]]..[[]]..[[Enter your skills and placed element levels]]Q=Q..[[]]..[[Skill: Equipment Manager >> Repair Tool Efficiency:]]local a0=SkillRepairToolEfficiency;Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]..[[Skill: Equipment Manager >> Repair Tool Optimization:]]local a0=SkillRepairToolOptimization;Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]..[[Skill: Atmospheric Engine Pilot >> Atmospheric Fuel Efficiency:]]local a0=SkillAtmosphericFuelEfficiency;Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]..[[Skill: Space Engine Pilot >> Space Fuel Efficiency:]]local a0=SkillSpaceFuelEfficiency;Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]..[[Skill: Rocket Scientists >> Rocket Fuel Efficiency:]]local a0=SkillRocketFuelEfficiency;Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]..[[Stat: Level of Atmo Tanks (Atmospheric Fuel Tank Handling):]]local a0=StatAtmosphericFuelTankHandling;Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]..[[Stat: Level of Space Tanks (Space Fuel Tank Handling):]]local a0=StatSpaceFuelTankHandling;Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]..[[Stat: Level of Rocket Tanks (Rocket Fuel Tank Handling):]]local a0=StatRocketFuelTankHandling;Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]Q=Q..[[]]if SimulationMode==true then Q=Q..[[Simulating Damage to elements]]AddClickArea(\"settings1\",{id=\"ToggleSimulation\",mode=\"settings1\",x1=940,x2=1850,y1=919,y2=969})else Q=Q..[[Simulate Damage to elements]]AddClickArea(\"settings1\",{id=\"ToggleSimulation\",mode=\"settings1\",x1=940,x2=1850,y1=919,y2=969})end;return Q end;function GetContentStartup()local Q=\"\"Q=Q..GetElementLogo(812,380,\"f\",\"f\",\"f\")if YourShipsName==\"Enter here\"then Q=Q..[[Spaceship ID ]]..ShipID..[[]]else Q=Q..[[]]..YourShipsName..[[]]end;if ShowWelcomeMessage==true then Q=Q..[[Greetings, Commander ]]..PlayerName..[[.]]end;Q=Q..[[Damage Report v]]..VERSION..[[, by Scion Interstellar, DorianGray - Discord: Dorian Gray#2623. Under GNU Public License 3.0.]]return Q end;function RenderScreen(m,a1)if a1==nil then PrintConsole(\"ERROR: contentToRender is nil.\")unit.exit()end;CreateClickAreasForScreen(m)local Q=\"\"Q=Q..[[\n \n \n ]]Q=Q..a1;if m.mode==\"startup\"then Q=Q..[[]]else Q=Q..[[]]end;Q=Q..[[\n \n ]]Q=Q..[[]]local a2=string.len(Q)m.element.setSVG(Q)end;function RenderScreens(a3,a4)a3=a3 or\"all\"a4=a4 or\"all\"if screens~=nil and#screens>0 then local a5=\"\"local a6=\"\"local a7=\"\"local a8=\"\"local a9=\"\"local aa=\"\"local ab=\"\"local ac=\"\"local ad=\"\"local ae=\"\"local af=\"\"local ag=\"\"for J,m in pairs(screens)do if m.refresh==true then local a1=\"\"if m.mode==\"flight\"and(a3==\"flight\"or a3==\"all\")then if a5==\"\"then a5=GetContentFlight()end;a1=a5 elseif m.mode==\"damage\"and(a3==\"damage\"or a3==\"all\")then if a6==\"\"then a6=GetContentDamage()end;a1=a6 elseif m.mode==\"damageoutline\"and(a3==\"damageoutline\"or a3==\"all\")then if m.submode==\"\"then m.submode=\"top\"screens[J].submode=\"top\"end;if m.submode==\"top\"and(a4==\"top\"or a4==\"all\")then if a7==\"\"then a7=GetContentDamageoutline(m)end;a1=a7 end;if m.submode==\"side\"and(a4==\"side\"or a4==\"all\")then if a8==\"\"then a8=GetContentDamageoutline(m)end;a1=a8 end;if m.submode==\"front\"and(a4==\"front\"or a4==\"all\")then if a9==\"\"then a9=GetContentDamageoutline(m)end;a1=a9 end elseif m.mode==\"fuel\"and(a3==\"fuel\"or a3==\"all\")then m=WipeClickAreasForScreen(screens[J])a1=GetContentFuel(m)elseif m.mode==\"cargo\"and(a3==\"cargo\"or a3==\"all\")then if ab==\"\"then ab=GetContentCargo()end;a1=ab elseif m.mode==\"agg\"and(a3==\"agg\"or a3==\"all\")then if ac==\"\"then ac=GetContentAGG()end;a1=ac elseif m.mode==\"map\"and(a3==\"map\"or a3==\"all\")then if ad==\"\"then ad=GetContentMap()end;a1=ad elseif m.mode==\"time\"and(a3==\"time\"or a3==\"all\")then if ae==\"\"then ae=GetContentTime()end;a1=ae elseif m.mode==\"settings1\"and(a3==\"settings1\"or a3==\"all\")then if af==\"\"then af=GetContentSettings1()end;a1=af elseif m.mode==\"startup\"and(a3==\"startup\"or a3==\"all\")then if ag==\"\"then ag=GetContentStartup()end;a1=ag else a1=\"Invalid screen mode. ('\"..m.mode..\"')\"end;if a1~=\"\"then RenderScreen(m,a1)else DrawCenteredText(\"ERROR: No contentToRender delivered for \"..m.mode)PrintConsole(\"ERROR: No contentToRender delivered for \"..m.mode)unit.exit()end;screens[J].refresh=false end end end;if HUDMode==true then system.setScreen(GetContentDamageHUDOutput())system.showScreen(1)else system.showScreen(0)end end;function OnTickData(C)if formerTime+60=4 then d=string.format(\"%.\"..c..\"fk\",a/1000)else d=string.format(\"%.\"..c..\"f\",a)end else while true do d,k=string.gsub(d,\"^(-?%d+)(%d%d%d)\",'%1,%2')if k==0 then break end end end;return d end;function PrintConsole(e,f)f=f or false;if f then system.print(\"------------------------------------------------------------------------\")end;system.print(e)if f then system.print(\"------------------------------------------------------------------------\")end end;function DrawCenteredText(e)if screens~=nil and#screens>0 then for g=1,#screens,1 do screens[g].element.setCenteredText(e)end end end;function ClearConsole()for g=1,10,1 do PrintConsole()end end;function SwitchScreens(h)h=h or\"on\"if screens~=nil and#screens>0 then for g=1,#screens,1 do if h==\"on\"then screens[g].element.clear()screens[g].element.activate()screens[g].active=true else screens[g].element.clear()screens[g].element.deactivate()screens[g].active=false end end end end;function GetSecondsString(i)local i=tonumber(i)if i==nil or i<=0 then return\"-\"else days=string.format(\"%2.f\",math.floor(i/(3600*24)))hours=string.format(\"%2.f\",math.floor(i/3600-days*24))mins=string.format(\"%2.f\",math.floor(i/60-hours*60-days*24*60))secs=string.format(\"%2.f\",math.floor(i-hours*3600-days*24*60*60-mins*60))str=\"\"if tonumber(days)>0 then str=str..days..\"d \"end;if tonumber(hours)>0 then str=str..hours..\"h \"end;if tonumber(mins)>0 then str=str..mins..\"m \"end;if tonumber(secs)>0 then str=str..secs..\"s\"end;return str end end;function replace_char(j,str,l)return str:sub(1,j-1)..l..str:sub(j+1)end;function epochTime()function rZ(m)if string.len(m)<=1 then return\"0\"..m else return m end end;function dPoint(n)if not(n==math.floor(n))then return true else return false end end;function lYear(year)if not dPoint(year/4)then if dPoint(year/100)then return true else if not dPoint(year/400)then return true else return false end end else return false end end;local o=5;local p=3600;local q=86400;local r=31536000;local s=31622400;local t=2419200;local g=2505600;local u=2592000;local k=2678400;local w={4,6,9,11}local x={1,3,5,7,8,10,12}local y=0;local z=1506816000;local A=system.getTime()_G[\"formerTime\"]=A;if AddSummertimeHour==true then A=A+3600 end;now=math.floor(A+z)year=1970;secs=0;y=0;while secs+s]]..hour..\":\"..minute..[[]]..[[]]..year..\"/\"..month..\"/\"..day..[[]]end;function ToggleHUD()if HUDMode==true then HUDMode=false;forceDamageRedraw=true;hudSelectedIndex=0;highlightID=0;HideHighlight()SetRefresh()RenderScreens()else HUDMode=true;forceDamageRedraw=true;hudSelectedIndex=0;highlightID=0;HideHighlight()SetRefresh()RenderScreens()end end;function HudDeselectElement()hudSelectedIndex=0;hudStartIndex=1;highlightID=0;HideHighlight()if HUDMode==true then SetRefresh(\"damage\")SetRefresh(\"damageoutline\")RenderScreens()end end;function ChangeHudSelectedElement(B)if HUDMode==true and#rE>0 then hudSelectedIndex=hudSelectedIndex+B;if hudSelectedIndex<1 then hudSelectedIndex=1 elseif hudSelectedIndex>#rE then hudSelectedIndex=#rE end;if hudSelectedIndex>9 then hudStartIndex=hudSelectedIndex-9 end;if hudSelectedIndex~=0 then highlightID=rE[hudSelectedIndex].id;if highlightID~=nil and highlightID~=0 then HideHighlight()elementPosition=vec3(rE[hudSelectedIndex].pos)highlightX=elementPosition.x-coreWorldOffset;highlightY=elementPosition.y-coreWorldOffset;highlightZ=elementPosition.z-coreWorldOffset;highlightOn=true;ShowHighlight()end end;SetRefresh(\"damage\")SetRefresh(\"damageoutline\")RenderScreens()end end;function HideHighlight()if#hudArrowSticker>0 then for g in pairs(hudArrowSticker)do core.deleteSticker(hudArrowSticker[g])end;hudArrowSticker={}end end;function ShowHighlight()if highlightOn==true and highlightID>0 then table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX+2,highlightY,highlightZ,\"north\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX,highlightY-2,highlightZ,\"east\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX-2,highlightY,highlightZ,\"south\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX,highlightY+2,highlightZ,\"west\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX,highlightY,highlightZ-2,\"up\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX,highlightY,highlightZ+2,\"down\"))end end;function ToggleHighlight()if highlightOn==true then highlightOn=false;HideHighlight()else highlightOn=true;ShowHighlight()end end;function SortDamageTables()table.sort(damagedElements,function(m,n)return m.missinghp>n.missinghp end)table.sort(brokenElements,function(m,n)return m.maxhp>n.maxhp end)end;function getScraps(C,D)D=D or false;C=C-SkillRepairToolOptimization*0.05*C;local E=math.ceil(C/(10*5^(ScrapTier-1)))if D==true then return GenerateCommaValue(string.format(\"%.0f\",E),false)else return E end end;function getRepairTime(C,F)F=F or false;C=C-SkillRepairToolOptimization*0.05*C;local E=math.ceil(C/ScrapTierRepairTimes[ScrapTier])E=E-SkillRepairToolEfficiency*0.1*E;if F==true then return GetSecondsString(string.format(\"%.0f\",E))else return E end end;function UpdateDataDamageoutline()dmgoElements={}for g,G in ipairs(brokenElements)do if#dmgoElementsShipXmax then ShipXmax=H end;if I>ShipYmax then ShipYmax=I end;if J>ShipZmax then ShipZmax=J end;table.insert(dmgoElements,{id=G.id,type=\"b\",size=G.maxhp,x=H,y=I,z=J,xp=0,yp=0,zp=0,u=0,v=0})end end;if#dmgoElementsShipXmax then ShipXmax=H end;if I>ShipYmax then ShipYmax=I end;if J>ShipZmax then ShipZmax=J end;table.insert(dmgoElements,{id=G.id,type=\"d\",size=G.maxhp,x=H,y=I,z=J,xp=0,yp=0,zp=0,u=0,v=0})end end end;if#dmgoElementsShipXmax then ShipXmax=H end;if I>ShipYmax then ShipYmax=I end;if J>ShipZmax then ShipZmax=J end;table.insert(dmgoElements,{id=G.id,type=\"h\",size=G.maxhp,x=H,y=I,z=J,xp=0,yp=0,zp=0,u=0,v=0})end end end;ShipX=math.abs(ShipXmax-ShipXmin)ShipY=math.abs(ShipYmax-ShipYmin)ShipZ=math.abs(ShipZmax-ShipZmin)for g,G in ipairs(dmgoElements)do dmgoElements[g].xp=math.abs(100/(ShipXmax-ShipXmin)*(G.x-ShipXmin))dmgoElements[g].yp=math.abs(100/(ShipYmax-ShipYmin)*(G.y-ShipYmin))dmgoElements[g].zp=math.abs(100/(ShipZmax-ShipZmin)*(G.z-ShipZmin))end end;function UpdateViewDamageoutline(K)UFrame=40;VFrame=40;UStart=20+UFrame;VStart=180+VFrame;UDim=1880-2*UFrame;VDim=840-2*VFrame;if K.submode==\"top\"then if DMGOStretch==false then local L=UDim/(ShipYmax-ShipYmin)local M=VDim/(ShipXmax-ShipXmin)if L>=M then local N=L/M;local O=math.floor(UDim/N)UStart=UStart+(UDim-O)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100/N*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100*G.xp+VStart)end else local N=M/L;local P=math.floor(VDim/N)VStart=VStart+(VDim-P)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100/N*G.xp+VStart)end end else for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100*G.xp+VStart)end end elseif K.submode==\"front\"then if DMGOStretch==false then local L=UDim/(ShipXmax-ShipXmin)local M=VDim/(ShipZmax-ShipZmin)if L>=M then local N=L/M;local O=math.floor(UDim/N)UStart=UStart+(UDim-O)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100/N*G.xp+UStart)dmgoElements[g].v=math.floor(VDim/100*(100-G.zp)+VStart)end else local N=M/L;local P=math.floor(VDim/N)VStart=VStart+(VDim-P)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.xp+UStart)dmgoElements[g].v=math.floor(VDim/100/N*(100-G.zp)+VStart)end end else for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.xp+UStart)dmgoElements[g].v=math.floor(VDim/100*(100-G.zp)+VStart)end end elseif K.submode==\"side\"then if DMGOStretch==false then local L=UDim/(ShipYmax-ShipYmin)local M=VDim/(ShipXmax-ShipZmin)if L>=M then local N=L/M;local O=math.floor(UDim/N)UStart=UStart+(UDim-O)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100/N*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100*(100-G.zp)+VStart)end else local N=M/L;local P=math.floor(VDim/N)VStart=VStart+(VDim-P)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100/N*(100-G.zp)+VStart)end end else for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100*(100-G.zp)+VStart)end end else DrawCenteredText(\"ERROR: non-existing DMGO mode set.\")PrintConsole(\"ERROR: non-existing DMGO mode set.\")unit.exit()end end;function GetDamageoutlineShip()local e=\"\"for g,G in ipairs(dmgoElements)do local Q=\"\"local R=1;if G.type==\"h\"then Q=\"ch\"elseif G.type==\"d\"then Q=\"cw\"else Q=\"cc\"end;if G.id==highlightID then Q=\"f2\"end;if G.size>0 and G.size<1000 then R=5 elseif G.size>=1000 and G.size<2000 then R=8 elseif G.size>=2000 and G.size<5000 then R=12 elseif G.size>=5000 and G.size<10000 then R=15 elseif G.size>=10000 and G.size<20000 then R=20 elseif G.size>=20000 then R=30 end;e=e..[[]]if G.id==highlightID then e=e..[[]]e=e..[[]]end end;return e end;function GetContentClickareas(K)local e=\"\"if K~=nil and K.ClickAreas~=nil and#K.ClickAreas>0 then for g,S in ipairs(K.ClickAreas)do e=e..[[]]end end;return e end;function GetElement1(H,I,T,U)H=H or 0;I=I or 0;T=T or 600;U=U or 600;local e=\"\"e=e..[[\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ]]return e end;function GetElement2(H,I)H=H or 0;I=I or 0;local e=\"\"e=e..[[]]return e end;function GetElementLogo(H,I,V,W,X)H=H or 812;I=I or 380;V=V or\"f\"W=W or\"f2\"X=X or\"f3\"local e=\"\"e=e..[[\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ]]return e end;function GetHeader(Y)Y=Y or\"ERROR: UNDEFINED\"local e=\"\"e=e..[[\n ]]..Y..[[]]return e end;function GetContentBackground(Z,_)bgColor=ColorBackgroundPattern;local e=\"\"if Z==\"dots\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' viewBox='0 0 4 4'%3E%3Cpath fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' d='M1 3h1v1H1V3zm2-2h1v1H3V1z'%3E%3C/path%3E%3C/svg%3E\");]]elseif Z==\"rain\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='12' height='16' viewBox='0 0 12 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 .99C4 .445 4.444 0 5 0c.552 0 1 .45 1 .99v4.02C6 5.555 5.556 6 5 6c-.552 0-1-.45-1-.99V.99zm6 8c0-.546.444-.99 1-.99.552 0 1 .45 1 .99v4.02c0 .546-.444.99-1 .99-.552 0-1-.45-1-.99V8.99z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E\");]]elseif Z==\"plus\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E\");]]elseif Z==\"signal\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='84' height='48' viewBox='0 0 84 48' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h12v6H0V0zm28 8h12v6H28V8zm14-8h12v6H42V0zm14 0h12v6H56V0zm0 8h12v6H56V8zM42 8h12v6H42V8zm0 16h12v6H42v-6zm14-8h12v6H56v-6zm14 0h12v6H70v-6zm0-16h12v6H70V0zM28 32h12v6H28v-6zM14 16h12v6H14v-6zM0 24h12v6H0v-6zm0 8h12v6H0v-6zm14 0h12v6H14v-6zm14 8h12v6H28v-6zm-14 0h12v6H14v-6zm28 0h12v6H42v-6zm14-8h12v6H56v-6zm0-8h12v6H56v-6zm14 8h12v6H70v-6zm0 8h12v6H70v-6zM14 24h12v6H14v-6zm14-8h12v6H28v-6zM14 8h12v6H14V8zM0 8h12v6H0V8z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E\");]]elseif Z==\"deathstar\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='105' viewBox='0 0 80 105'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M20 10a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm15 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zM20 75a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zm30-65a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm0 65a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zM35 10a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zM5 45a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zm60 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10z' /%3E%3C/g%3E%3C/g%3E%3C/svg%3E\");]]elseif Z==\"diamond\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='32' viewBox='0 0 16 32'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath fill-rule='evenodd' d='M0 24h4v2H0v-2zm0 4h6v2H0v-2zm0-8h2v2H0v-2zM0 0h4v2H0V0zm0 4h2v2H0V4zm16 20h-6v2h6v-2zm0 4H8v2h8v-2zm0-8h-4v2h4v-2zm0-20h-6v2h6V0zm0 4h-4v2h4V4zm-2 12h2v2h-2v-2zm0-8h2v2h-2V8zM2 8h10v2H2V8zm0 8h10v2H2v-2zm-2-4h14v2H0v-2zm4-8h6v2H4V4zm0 16h6v2H4v-2zM6 0h2v2H6V0zm0 24h2v2H6v-2z'/%3E%3C/g%3E%3C/svg%3E\");]]elseif Z==\"hexagon\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='49' viewBox='0 0 28 49'%3E%3Cg fill-rule='evenodd'%3E%3Cg id='hexagons' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='nonzero'%3E%3Cpath d='M13.99 9.25l13 7.5v15l-13 7.5L1 31.75v-15l12.99-7.5zM3 17.9v12.7l10.99 6.34 11-6.35V17.9l-11-6.34L3 17.9zM0 15l12.98-7.5V0h-2v6.35L0 12.69v2.3zm0 18.5L12.98 41v8h-2v-6.85L0 35.81v-2.3zM15 0v7.5L27.99 15H28v-2.31h-.01L17 6.35V0h-2zm0 49v-8l12.99-7.5H28v2.31h-.01L17 42.15V49h-2z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E\");]]elseif Z==\"capsule\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='32' height='26' viewBox='0 0 32 26' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M14 0v3.994C14 7.864 10.858 11 7 11c-3.866 0-7-3.138-7-7.006V0h2v4.005C2 6.765 4.24 9 7 9c2.756 0 5-2.236 5-4.995V0h2zm0 26v-5.994C14 16.138 10.866 13 7 13c-3.858 0-7 3.137-7 7.006V26h2v-6.005C2 17.235 4.244 15 7 15c2.76 0 5 2.236 5 4.995V26h2zm2-18.994C16 3.136 19.142 0 23 0c3.866 0 7 3.138 7 7.006v9.988C30 20.864 26.858 24 23 24c-3.866 0-7-3.138-7-7.006V7.006zm2-.01C18 4.235 20.244 2 23 2c2.76 0 5 2.236 5 4.995v10.01C28 19.765 25.756 22 23 22c-2.76 0-5-2.236-5-4.995V6.995z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E\");]]elseif Z==\"diagonal\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='6' height='6' viewBox='0 0 6 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'%3E%3Cpath d='M5 0h1L0 6V5zM6 5v1H5z'/%3E%3C/g%3E%3C/svg%3E\");]]end;return e end;function GetContentDamageHUDOutput()local a0=300;local a1=165;if#damagedElements>0 or#brokenElements>0 then a1=510 end;local e=\"\"e=e..[[\n \n ]]e=e..[[]]..[[]]..[[]]..[[]]..(YourShipsName==\"Enter here\"and\"Ship ID \"..ShipID or YourShipsName)..[[]]..[[]]if#brokenElements>0 then e=e..[[]]elseif#damagedElements>0 then e=e..[[]]else e=e..[[]]end;if#damagedElements>0 or#brokenElements>0 then e=e..[[Total Damage]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",totalShipMaxHP-totalShipHP))..[[]]e=e..[[T]]..ScrapTier..[[ Scrap Needed]]..[[]]..getScraps(totalShipMaxHP-totalShipHP,true)..[[]]e=e..[[Repair Time]]..[[]]..getRepairTime(totalShipMaxHP-totalShipHP,true)..[[]]e=e..[[]]..[[]]..[[]]..#healthyElements..[[]]..[[]]..[[]]..#damagedElements..[[]]..[[]]..[[]]..#brokenElements..[[]]local u=0;for a2=hudStartIndex,hudStartIndex+9,1 do if rE[a2]~=nil then v=rE[a2]if v.hp>0 then e=e..[[]]..[[]]..string.format(\"%.30s\",v.name)..[[]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",v.missinghp))..[[]]if v.id==highlightID then e=e..[[]]..[[]]..string.format(\"%.30s\",v.name)..[[]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",v.missinghp))..[[]]end else e=e..[[]]..[[]]..string.format(\"%.30s\",v.name)..[[]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",v.missinghp))..[[]]if v.id==highlightID then highlightX=elementPosition.x-coreWorldOffset;highlightY=elementPosition.y-coreWorldOffset;highlightZ=elementPosition.z-coreWorldOffset;e=e..[[]]..[[]]..string.format(\"%.30s\",v.name)..[[]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",v.missinghp))..[[]]end end;u=u+1 end end;e=e..[[]]..[[]]..[[]]..[[]]..[[Up/down arrows to highlight]]..[[CTRL + arrows to move HUD]]..[[Left arrow to toggle HUD Mode]]..[[ALT+1-4 to set Scrap Tier]]..[[ALT+8 to reset HUD position]]..[[ALT+9 to shut script off]]..[[]]..[[]]else e=e..[[]]..OkayCenterMessage..[[]]..[[]]..#healthyElements..[[ elements / ]]..GenerateCommaValue(string.format(\"%.0f\",totalShipMaxHP))..[[ HP.]]..[[]]..[[]]..[[]]..[[]]..[[Left arrow to toggle HUD Mode]]..[[CTRL + arrows to move HUD]]..[[ALT+8 to reset HUD position]]..[[ALT+9 to shut script off]]..[[]]..[[]]end;e=e..[[]]return e end;function GetContentDamageScreen()local a3=\"\"if#damagedElements>0 then local a4=#damagedElements;if a4>DamagePageSize then a4=DamagePageSize end;if CurrentDamagedPage==math.ceil(#damagedElements/DamagePageSize)then a4=#damagedElements%DamagePageSize+12;if a4>12 then a4=a4-12 end end;a3=a3 ..[[]]a3=a3 ..[[]]if UseMyElementNames==true then a3=a3 ..[[Damaged Name]]else a3=a3 ..[[Damaged Type]]end;a3=a3 ..[[HLTHDMG]]a3=a3 ..[[T]]..ScrapTier..[[ SCRREPTIME]]AddClickArea(\"damage\",{id=\"SwitchScrapTier\",mode=\"damage\",x1=650,x2=775,y1=315,y2=360})local g=0;for u=1+(CurrentDamagedPage-1)*DamagePageSize,a4+(CurrentDamagedPage-1)*DamagePageSize,1 do g=g+1;local a5=damagedElements[u]if UseMyElementNames==true then a3=a3 ..[[]]..string.format(\"%.23s\",a5.name)..[[]]else a3=a3 ..[[]]..string.format(\"%.23s\",a5.type)..[[]]end;a3=a3 ..[[]]..a5.percent..[[%]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",a5.missinghp),true)..[[]]..[[]]..getScraps(a5.missinghp,true)..[[]]..[[]]..getRepairTime(a5.missinghp,true)..[[]]..[[]]end;if#damagedElements>DamagePageSize then a3=a3 ..[[Page ]]..CurrentDamagedPage..\" of \"..math.ceil(#damagedElements/DamagePageSize)..[[]]if CurrentDamagedPage\n \n \n ]]AddClickArea(\"damage\",{id=\"DamagedPageDown\",mode=\"damage\",x1=65,x2=260,y1=290+(a4+1)*50,y2=290+50+(a4+1)*50})else DisableClickArea(\"DamagedPageDown\",\"damage\")end;if CurrentDamagedPage>1 then a3=a3 ..[[\n \n \n ]]AddClickArea(\"damage\",{id=\"DamagedPageUp\",mode=\"damage\",x1=750,x2=950,y1=290+(a4+1)*50,y2=290+50+(a4+1)*50})else DisableClickArea(\"DamagedPageUp\",\"damage\")end end end;if#brokenElements>0 then local a6=#brokenElements;if a6>DamagePageSize then a6=DamagePageSize end;if CurrentBrokenPage==math.ceil(#brokenElements/DamagePageSize)then a6=#brokenElements%DamagePageSize+12;if a6>12 then a6=a6-12 end end;a3=a3 ..[[]]a3=a3 ..[[]]if UseMyElementNames==true then a3=a3 ..[[Broken Name]]else a3=a3 ..[[Broken Type]]end;a3=a3 ..[[DMG]]a3=a3 ..[[T]]..ScrapTier..[[ SCRREPTIME]]AddClickArea(\"damage\",{id=\"SwitchScrapTier2\",mode=\"damage\",x1=1570,x2=1690,y1=315,y2=360})local g=0;for u=1+(CurrentBrokenPage-1)*DamagePageSize,a6+(CurrentBrokenPage-1)*DamagePageSize,1 do g=g+1;local a5=brokenElements[u]if UseMyElementNames==true then a3=a3 ..[[]]..string.format(\"%.30s\",a5.name)..[[]]else a3=a3 ..[[]]..string.format(\"%.30s\",a5.type)..[[]]end;a3=a3 ..[[]]..GenerateCommaValue(string.format(\"%.0f\",a5.missinghp),true)..[[]]..[[]]..getScraps(a5.missinghp,true)..[[]]..[[]]..getRepairTime(a5.missinghp,true)..[[]]..[[]]end;if#brokenElements>DamagePageSize then a3=a3 ..[[Page ]]..CurrentBrokenPage..\" of \"..math.ceil(#brokenElements/DamagePageSize)..[[]]if CurrentBrokenPage>1 then a3=a3 ..[[\n \n \n ]]AddClickArea(\"damage\",{id=\"BrokenPageUp\",mode=\"damage\",x1=1665,x2=1865,y1=290+(a6+1)*50,y2=290+50+(a6+1)*50})else DisableClickArea(\"BrokenPageUp\",\"damage\")end;if CurrentBrokenPage\n \n \n ]]AddClickArea(\"damage\",{id=\"BrokenPageDown\",mode=\"damage\",x1=980,x2=1180,y1=290+(a6+1)*50,y2=290+50+(a6+1)*50})else DisableClickArea(\"BrokenPageDown\",\"damage\")end end end;if#damagedElements>0 or#brokenElements>0 then local a7=math.floor(1878/#elementsIdList*#damagedElements)local a8=math.floor(1878/#elementsIdList*#brokenElements)local a9=1878-a7-a8+1;a3=a3 ..[[]]a3=a3 ..[[]]a3=a3 ..[[]]a3=a3 ..[[]]if#damagedElements>0 then a3=a3 ..[[]]..#damagedElements..[[]]end;if#healthyElements>0 then a3=a3 ..[[]]..#healthyElements..[[]]end;if#brokenElements>0 then a3=a3 ..[[]]..#brokenElements..[[]]end;a3=a3 ..[[]]a3=a3 ..[[]]..GenerateCommaValue(string.format(\"%.0f\",totalShipMaxHP-totalShipHP))..[[ HP damage in total ]]..getScraps(totalShipMaxHP-totalShipHP,true)..[[ T]]..ScrapTier..[[ scraps needed. ]]..getRepairTime(totalShipMaxHP-totalShipHP,true)..[[ projected repair time.]]else a3=a3 ..GetElementLogo(812,380,\"ch\",\"ch\",\"ch\")..[[]]..OkayCenterMessage..[[]]..[[]]..#healthyElements..[[ elements stand ]]..GenerateCommaValue(string.format(\"%.0f\",totalShipMaxHP))..[[ HP strong.]]end;forceDamageRedraw=false;return a3 end;function ActionStopengines()ToggleHUD()end;function ActionStrafeRight()if KeyCTRLPressed==true then if HUDShiftU<4000 then HUDShiftU=HUDShiftU+50;SaveToDatabank()RenderScreens()end else HudDeselectElement()end end;function ActionStrafeLeft()if KeyCTRLPressed==true then if HUDShiftU>=50 then HUDShiftU=HUDShiftU-50;SaveToDatabank()RenderScreens()end else ToggleHUD()end end;function ActionDown()if KeyCTRLPressed==true then if HUDShiftV<4000 then HUDShiftV=HUDShiftV+50;SaveToDatabank()RenderScreens()end else ChangeHudSelectedElement(1)end end;function ActionUp()if KeyCTRLPressed==true then if HUDShiftV>=50 then HUDShiftV=HUDShiftV-50;SaveToDatabank()RenderScreens()end else ChangeHudSelectedElement(-1)end end;function ActionOption1()ScrapTier=1;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption2()ScrapTier=2;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption3()ScrapTier=3;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption4()ScrapTier=4;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption8()HUDShiftU=0;HUDShiftV=0;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption9()SaveToDatabank()SwitchScreens(\"off\")unit.exit()end",
- "filter": {
- "args": [],
- "signature": "start()",
- "slotKey": "-1"
- },
- "key": "9"
- },
- {
- "code": "SaveToDatabank()\nSwitchScreens(\"off\")",
- "filter": {
- "args": [],
- "signature": "stop()",
- "slotKey": "-1"
- },
- "key": "10"
- },
- {
- "code": "OnTickData()\n",
- "filter": {
- "args": [
- {
- "value": "UpdateData"
- }
- ],
- "signature": "tick(timerId)",
- "slotKey": "-1"
- },
- "key": "11"
- },
- {
- "code": "ToggleHighlight()",
- "filter": {
- "args": [
- {
- "value": "UpdateHighlight"
- }
- ],
- "signature": "tick(timerId)",
- "slotKey": "-1"
- },
- "key": "12"
- },
- {
- "code": "--[[\n Damage Report 3.02\n A LUA script for Dual Universe\n\n Created By Dorian Gray\n Ingame: DorianGray\n Discord: Dorian Gray#2623\n\n You can find/update this script on GitHub. Explanations, installation and usage information as well as screenshots can be found there too.\n GitHub: https://github.com/DorianTheGrey/DU-DamageReport\n\n GNU Public License 3.0. Use whatever you want, be so kind to leave credit.\n \n Credits & thanks: \n Thanks to NovaQuark for creating the MMO of the century.\n Thanks to Jericho, Dmentia and Archaegeo for learning a lot from their fine scripts.\n Thanks to TheBlacklist for testing and wonderful suggestions.\n SVG patterns by Hero Patterns.\n DU atlas data from Jayle Break.\n \n]]\n\n--[[ 1. USER DEFINED VARIABLES ]]\n\nYourShipsName = \"Enter here\" --export Enter your ship name here if you want it displayed instead of the ship's ID. YOU NEED TO LEAVE THE QUOTATION MARKS.\n\nSkillRepairToolEfficiency = 0 --export Enter (0-5) your talent \"Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency\"\nSkillRepairToolOptimization = 0 --export Enter your talent \"Mining and Inventory -> Equipment Manager -> Repair Tool Optimization\"\n\n-- SkillAtmosphericFuelEfficiency = 0 --export Enter (0-5) your talent \"Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency\"\n-- SkillSpaceFuelEfficiency = 0 --export Enter (0-5) your talent \"Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency\"\n-- SkillRocketFuelEfficiency = 0 --export Enter (0-5) your talent \"Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency\"\n\nStatAtmosphericFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED ATMOSPHERIC FUEL TANKS (from the builders talent \"Piloting -> Atmospheric Flight Technician -> Atmospheric Fuel-Tank Handling\")\nStatSpaceFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL SPACE TANKS (from the builders talent \"Piloting -> Atmospheric Engine Technician -> Space Fuel-Tank Handling\")\nStatRocketFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL ROCKET TANKS (from the builders talent \"Piloting -> Rocket Scientist -> Rocket Booster Fuel Tank Handling\")\nStatFuelTankOptimization = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL TANKS \"from the builders talent Mining and Inventory -> Stock Control -> Fuel Tank Optimization\"\n\nShowWelcomeMessage = true --export Do you want the welcome message on the start screen with your name?\nAddSummertimeHour = false --export: Is summertime currently enabled in your location? (Adds one hour.)\n\nUpdateDataInterval=1.0;HighlightBlinkingInterval=0.5;ColorPrimary=\"FF6700\"ColorSecondary=\"FFFFFF\"ColorTertiary=\"000000\"ColorHealthy=\"00FF00\"ColorWarning=\"FFFF00\"ColorCritical=\"FF0000\"ColorBackground=\"000000\"ColorBackgroundPattern=\"4F4F4F\"ColorFuelAtmospheric=\"004444\"ColorFuelSpace=\"444400\"ColorFuelRocket=\"440044\"VERSION=3.02;DebugMode=false;DebugRenderClickareas=true;DBData={}core=nil;db=nil;screens={}dscreens={}Warnings={}screenModes={[\"flight\"]={id=\"flight\"},[\"damage\"]={id=\"damage\"},[\"damageoutline\"]={id=\"damageoutline\"},[\"fuel\"]={id=\"fuel\"},[\"cargo\"]={id=\"cargo\"},[\"agg\"]={id=\"agg\"},[\"map\"]={id=\"map\"},[\"time\"]={id=\"time\",activetoggle=\"true\"},[\"settings1\"]={id=\"settings1\"},[\"startup\"]={id=\"startup\"}}backgroundModes={\"deathstar\",\"capsule\",\"rain\",\"signal\",\"hexagon\",\"diagonal\",\"diamond\",\"plus\",\"dots\"}BackgroundMode=\"deathstar\"BackgroundSelected=1;BackgroundModeOpacity=0.25;SaveVars={\"dscreens\",\"ColorPrimary\",\"ColorSecondary\",\"ColorTertiary\",\"ColorHealthy\",\"ColorWarning\",\"ColorCritical\",\"ColorBackground\",\"ColorBackgroundPattern\",\"ScrapTier\",\"HUDMode\",\"SimulationMode\",\"DMGOStretch\",\"HUDShiftU\",\"HUDShiftV\",\"colorIDIndex\",\"colorIDTable\",\"BackgroundMode\",\"BackgroundSelected\",\"BackgroundModeOpacity\"}HUDMode=false;HUDShiftU=0;HUDShiftV=0;hudSelectedIndex=0;hudStartIndex=1;hudArrowSticker={}highlightOn=false;highlightID=0;highlightX=0;highlightY=0;highlightZ=0;SimulationMode=false;OkayCenterMessage=\"All systems nominal.\"CurrentDamagedPage=1;CurrentBrokenPage=1;DamagePageSize=12;ScrapTier=1;totalScraps=0;ScrapTierRepairTimes={10,50,250,1250}coreWorldOffset=0;totalShipHP=0;formerTotalShipHP=-1;totalShipMaxHP=0;totalShipIntegrity=100;elementsId={}elementsIdList={}damagedElements={}brokenElements={}rE={}healthyElements={}typeElements={}ElementCounter=0;UseMyElementNames=true;dmgoElements={}DMGOMaxElements=250;DMGOStretch=false;ShipXmin=99999999;ShipXmax=-99999999;ShipYmin=99999999;ShipYmax=-99999999;ShipZmin=99999999;ShipZmax=-99999999;totalShipMass=0;formerTotalShipMass=-1;formerTime=-1;FuelAtmosphericTanks={}FuelSpaceTanks={}FuelRocketTanks={}FuelAtmosphericTotal=0;FuelSpaceTotal=0;FuelRocketTotal=0;FuelAtmosphericCurrent=0;FuelSpaceTotalCurrent=0;FuelRocketTotalCurrent=0;formerFuelAtmosphericTotal=-1;formerFuelSpaceTotal=-1;formerFuelRocketTotal=-1;hexTable={\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"A\",\"B\",\"C\",\"D\",\"E\",\"F\"}colorIDIndex=1;colorIDTable={[1]={id=\"ColorPrimary\",desc=\"Main HUD Color\",basec=\"FF6700\",newc=\"FF6700\"},[2]={id=\"ColorSecondary\",desc=\"Secondary HUD Color\",basec=\"FFFFFF\",newc=\"FFFFFF\"},[3]={id=\"ColorTertiary\",desc=\"Tertiary HUD Color\",basec=\"000000\",newc=\"000000\"},[4]={id=\"ColorHealthy\",desc=\"Color code for Healthy/Okay\",basec=\"00FF00\",newc=\"00FF00\"},[5]={id=\"ColorWarning\",desc=\"Color code for Damaged/Warning\",basec=\"FFFF00\",newc=\"FFFF00\"},[6]={id=\"ColorCritical\",desc=\"Color code for Broken/Critical\",basec=\"FF0000\",newc=\"FF0000\"},[7]={id=\"ColorBackground\",desc=\"Background Color\",basec=\"000000\",newc=\"000000\"},[8]={id=\"ColorBackgroundPattern\",desc=\"Background Pattern Color\",basec=\"4F4F4F\",newc=\"4F4F4F\"},[9]={id=\"ColorFuelAtmospheric\",desc=\"Color for Atmo Fuel/Elements\",basec=\"004444\",newc=\"004444\"},[10]={id=\"ColorFuelSpace\",desc=\"Color for Space Fuel/Elements\",basec=\"444400\",newc=\"444400\"},[11]={id=\"ColorFuelRocket\",desc=\"Color for Rocket Fuel/Elements\",basec=\"440044\",newc=\"440044\"}}function InitiateSlots()for a,b in pairs(unit)do if type(b)==\"table\"and type(b.export)==\"table\"and b.getElementClass then local c=b.getElementClass():lower()if c:find(\"coreunit\")then core=b;local d=core.getMaxHitPoints()if d>10000 then coreWorldOffset=128 elseif d>1000 then coreWorldOffset=64 elseif d>150 then coreWorldOffset=32 else coreWorldOffset=16 end elseif c=='databankunit'then db=b elseif c==\"screenunit\"then local e=\"startup\"screens[#screens+1]={element=b,id=b.getId(),mode=e,submode=\"\",ClickAreas={},refresh=true,active=false,fuelA=true,fuelS=true,fuelR=true,fuelIndex=1}end end end end;function LoadFromDatabank()if db==nil then return else for f,g in pairs(SaveVars)do if db.hasKey(g)then local h=json.decode(db.getStringValue(g))if h~=nil then if g==\"YourShipsName\"or g==\"AddSummertimeHour\"or g==\"UpdateDataInterval\"or g==\"HighlightBlinkingInterval\"or g==\"SkillRepairToolEfficiency\"or g==\"SkillRepairToolOptimization\"or g==\"SkillAtmosphericFuelEfficiency\"or g==\"SkillSpaceFuelEfficiency\"or g==\"SkillRocketFuelEfficiency\"or g==\"StatAtmosphericFuelTankHandling\"or g==\"StatSpaceFuelTankHandling\"or g==\"StatRocketFuelTankHandling\"then else _G[g]=h end end end end;for i,j in ipairs(screens)do for k,l in ipairs(dscreens)do if screens[i].id==dscreens[k].id then screens[i].mode=dscreens[k].mode;screens[i].submode=dscreens[k].submode;screens[i].active=dscreens[k].active;screens[i].refresh=true;screens[i].fuelA=dscreens[k].fuelA;screens[i].fuelS=dscreens[k].fuelS;screens[i].fuelR=dscreens[k].fuelR;screens[i].fuelIndex=dscreens[k].fuelIndex end end end end end;function SaveToDatabank()if db==nil then return else dscreens={}for i,m in ipairs(screens)do dscreens[i]={}dscreens[i].id=m.id;dscreens[i].mode=m.mode;dscreens[i].submode=m.submode;dscreens[i].active=m.active;dscreens[i].fuelA=m.fuelA;dscreens[i].fuelS=m.fuelS;dscreens[i].fuelR=m.fuelR;dscreens[i].fuelIndex=m.fuelIndex end;db.clear()for f,g in pairs(SaveVars)do db.setStringValue(g,json.encode(_G[g]))end end end;function InitiateScreens()if screens~=nil and#screens>0 then for i=1,#screens,1 do screens[i]=CreateClickAreasForScreen(screens[i])end end end;function UpdateTypeData()FuelAtmosphericTanks={}FuelSpaceTanks={}FuelRocketTanks={}FuelAtmosphericTotal=0;FuelAtmosphericCurrent=0;FuelSpaceTotal=0;FuelSpaceCurrent=0;FuelRocketCurrent=0;FuelRocketTotal=0;local n=4;local o=6;local p=0.8;for i,q in ipairs(typeElements)do local r=core.getElementNameById(q)or\"\"local s=core.getElementTypeById(q)or\"\"local t=core.getElementPositionById(q)or 0;local u=core.getElementHitPointsById(q)or 0;local v=core.getElementMaxHitPointsById(q)or 0;local w=core.getElementMassById(q)or 0;local x=\"\"local y=0;local z=0;local A=0;local B=0;if s==\"atmospheric fuel-tank\"then if v>10000 then x=\"L\"z=5480;y=12800 elseif v>1300 then x=\"M\"z=988.67;y=1600 elseif v>150 then x=\"S\"z=182.67;y=400 else x=\"XS\"z=35.03;y=100 end;if StatAtmosphericFuelTankHandling>0 then y=0.2*StatAtmosphericFuelTankHandling*y+y end;A=w-z;if A<=10 then A=0 else if StatFuelTankOptimization>0 then A=0.05*StatFuelTankOptimization*A+A end end;B=string.format(\"%.0f\",A/n)cPercent=string.format(\"%.1f\",math.floor(100/y*tonumber(B)))table.insert(FuelAtmosphericTanks,{type=1,id=q,name=r,maxhp=v,hp=GetHPforElement(q),pos=t,size=x,mass=z,vol=y,cvol=B,percent=cPercent})if u>0 then FuelAtmosphericCurrent=FuelAtmosphericCurrent+B end;FuelAtmosphericTotal=FuelAtmosphericTotal+y elseif s==\"space fuel-tank\"then if v>10000 then x=\"L\"z=5480;y=12800 elseif v>1300 then x=\"M\"z=988.67;y=1600 else x=\"S\"z=182.67;y=400 end;if StatFuelTankOptimization>0 then A=0.05*StatFuelTankOptimization*A+A end;if StatSpaceFuelTankHandling>0 then y=0.2*StatSpaceFuelTankHandling*y+y end;A=w-z;if A<=10 then A=0 else if StatFuelTankOptimization>0 then A=0.05*StatFuelTankOptimization*A+A end end;B=string.format(\"%.0f\",A/o)cPercent=string.format(\"%.1f\",100/y*tonumber(B))table.insert(FuelSpaceTanks,{type=2,id=q,name=r,maxhp=v,hp=GetHPforElement(q),pos=t,size=x,mass=z,vol=y,cvol=B,percent=cPercent})if u>0 then FuelSpaceCurrent=FuelSpaceCurrent+B end;FuelSpaceTotal=FuelSpaceTotal+y elseif s==\"rocket fuel-tank\"then if v>65000 then x=\"L\"z=25740;y=50000 elseif v>6000 then x=\"M\"z=4720;y=6400 elseif v>700 then x=\"S\"z=886.72;y=800 else x=\"XS\"z=173.42;y=400 end;if StatRocketFuelTankHandling>0 then y=0.2*StatRocketFuelTankHandling*y+y end;A=w-z;if A<=10 then A=0 else if StatFuelTankOptimization>0 then A=0.05*StatFuelTankOptimization*A+A end end;if A<=10 then A=0 end;B=string.format(\"%.0f\",A/p)cPercent=string.format(\"%.1f\",100/y*tonumber(B))table.insert(FuelRocketTanks,{type=3,id=q,name=r,maxhp=v,hp=GetHPforElement(q),pos=t,size=x,mass=z,vol=y,cvol=B,percent=cPercent})if u>0 then FuelRocketCurrent=FuelRocketCurrent+B end;FuelRocketTotal=FuelRocketTotal+y end end;if FuelAtmosphericCurrent~=formerFuelAtmosphericCurrent then SetRefresh(\"fuel\")formerFuelAtmosphericCurrent=FuelAtmosphericCurrent end;if FuelSpaceCurrent~=formerFuelSpaceCurrent then SetRefresh(\"fuel\")formerFuelSpaceCurrent=FuelSpaceCurrent end;if FuelRocketCurrent~=formerFuelRocketCurrent then SetRefresh(\"fuel\")formerFuelRocketCurrent=FuelRocketCurrent end end;function UpdateDamageData(C)C=C or false;if SimulationActive==true then return end;local formerTotalShipHP=totalShipHP;totalShipHP=0;totalShipMaxHP=0;totalShipIntegrity=100;damagedElements={}brokenElements={}healthyElements={}ElementCounter=0;elementsIdList=core.getElementIdList()for i,q in pairs(elementsIdList)do ElementCounter=ElementCounter+1;local r=core.getElementNameById(q)local s=core.getElementTypeById(q)local t=core.getElementPositionById(q)local u=core.getElementHitPointsById(q)local v=core.getElementMaxHitPointsById(q)if SimulationMode==true then SimulationActive=true;local D=math.random(0,10)if D<2 and#brokenElements<30 then u=0 elseif D>=2 and D<4 and#damagedElements<30 then u=math.random(1,math.ceil(v))else u=v end end;totalShipHP=totalShipHP+u;totalShipMaxHP=totalShipMaxHP+v;if v-u>constants.epsilon then if u>0 then table.insert(damagedElements,{id=q,name=r,type=s,counter=ElementCounter,hp=u,maxhp=v,missinghp=v-u,percent=math.ceil(100/v*u),pos=t})else table.insert(brokenElements,{id=q,name=r,type=s,counter=ElementCounter,hp=u,maxhp=v,missinghp=v-u,percent=0,pos=t})end else table.insert(healthyElements,{id=q,name=r,type=s,counter=ElementCounter,hp=u,maxhp=v,pos=t})if q==highlightID then highlightID=0;highlightOn=false;HideHighlight()hudSelectedIndex=0 end end;if C==true then if s==\"atmospheric fuel-tank\"or s==\"space fuel-tank\"or s==\"rocket fuel-tank\"then table.insert(typeElements,q)end end end;SortDamageTables()rE={}if#brokenElements>0 then for f,j in ipairs(brokenElements)do table.insert(rE,{id=j.id,missinghp=j.missinghp,hp=j.hp,name=j.name,type=j.type,pos=j.pos})end end;if#damagedElements>0 then for f,j in ipairs(damagedElements)do table.insert(rE,{id=j.id,missinghp=j.missinghp,hp=j.hp,name=j.name,type=j.type,pos=j.pos})end end;if#rE>0 then table.sort(rE,function(E,F)return E.missinghp>F.missinghp end)end;totalShipIntegrity=string.format(\"%2.0f\",100/totalShipMaxHP*totalShipHP)if formerTotalShipHP~=totalShipHP then forceDamageRedraw=true;formerTotalShipHP=totalShipHP else forceDamageRedraw=false end end;function GetHPforElement(q)for i,j in ipairs(brokenElements)do if j.id==q then return 0 end end;for i,j in ipairs(damagedElements)do if j.id==q then return j.hp end end;for i,j in ipairs(healthyElements)do if j.id==q then return j.maxhp end end end;function UpdateClickArea(G,H,I)for i,m in ipairs(screens)do for J,j in pairs(screens[i].ClickAreas)do if j.id==G and j.mode==I then screens[i].ClickAreas[J]=H end end end end;function AddClickArea(I,H)for i,m in ipairs(screens)do if screens[i].mode==I then table.insert(screens[i].ClickAreas,H)end end end;function AddClickAreaForScreenID(K,H)for i,m in ipairs(screens)do if screens[i].id==K then table.insert(screens[i].ClickAreas,H)end end end;function DisableClickArea(G,I)UpdateClickArea(G,{id=G,mode=I,x1=-1,x2=-1,y1=-1,y2=-1})end;function SetRefresh(I,L)I=I or\"all\"L=L or\"all\"if screens~=nil and#screens>0 then for i=1,#screens,1 do if screens[i].mode==I or I==\"all\"then if screens[i].submode==L or L==\"all\"then screens[i].refresh=true end end end end end;function WipeClickAreasForScreen(m)m.ClickAreas={}return m end;function CreateBaseClickAreas(m)table.insert(m.ClickAreas,{mode=\"all\",id=\"ToggleHudMode\",x1=1537,x2=1728,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"damage\",x1=193,x2=384,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"damageoutline\",x1=385,x2=576,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"fuel\",x1=577,x2=768,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"time\",x1=0,x2=192,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"settings1\",x1=1729,x2=1920,y1=1015,y2=1075})return m end;function CreateClickAreasForScreen(m)if m==nil then return{}end;if m.mode==\"flight\"then elseif m.mode==\"damage\"then table.insert(m.ClickAreas,{mode=\"damage\",id=\"ToggleElementLabel\",x1=70,x2=425,y1=325,y2=355})table.insert(m.ClickAreas,{mode=\"damage\",id=\"ToggleElementLabel2\",x1=980,x2=1400,y1=325,y2=355})elseif m.mode==\"damageoutline\"then table.insert(m.ClickAreas,{mode=\"damageoutline\",id=\"DMGOChangeView\",param=\"top\",x1=60,x2=439,y1=150,y2=200})table.insert(m.ClickAreas,{mode=\"damageoutline\",id=\"DMGOChangeView\",param=\"side\",x1=440,x2=824,y1=150,y2=200})table.insert(m.ClickAreas,{mode=\"damageoutline\",id=\"DMGOChangeView\",param=\"front\",x1=825,x2=1215,y1=150,y2=200})table.insert(m.ClickAreas,{mode=\"damageoutline\",id=\"DMGOChangeStretch\",x1=1530,x2=1580,y1=150,y2=200})elseif m.mode==\"fuel\"then elseif m.mode==\"cargo\"then elseif m.mode==\"agg\"then elseif m.mode==\"map\"then elseif m.mode==\"time\"then elseif m.mode==\"settings1\"then table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ToggleBackground\",x1=75,x2=860,y1=170,y2=215})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"PreviousBackground\",x1=75,x2=460,y1=235,y2=285})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"NextBackground\",x1=480,x2=860,y1=235,y2=285})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"DecreaseOpacity\",x1=75,x2=460,y1=300,y2=350})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"IncreaseOpacity\",x1=480,x2=860,y1=300,y2=350})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ResetColors\",x1=75,x2=860,y1=370,y2=415})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"PreviousColorID\",x1=90,x2=140,y1=500,y2=550})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"NextColorID\",x1=795,x2=845,y1=500,y2=550})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"1\",x1=210,x2=290,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"2\",x1=300,x2=380,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"3\",x1=385,x2=465,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"4\",x1=470,x2=550,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"5\",x1=560,x2=640,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"6\",x1=645,x2=725,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"1\",x1=210,x2=290,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"2\",x1=300,x2=380,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"3\",x1=385,x2=465,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"4\",x1=470,x2=550,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"5\",x1=560,x2=640,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"6\",x1=645,x2=725,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ResetPosColor\",x1=160,x2=340,y1=885,y2=935})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ApplyPosColor\",x1=355,x2=780,y1=885,y2=935})elseif m.mode==\"startup\"then end;m=CreateBaseClickAreas(m)return m end;function CheckClick(M,N,O)M=M*1920;N=N*1120;O=O or\"\"HitPayload={}if screens~=nil and#screens>0 then for i=1,#screens,1 do if screens[i].active==true and screens[i].element.getMouseX()~=-1 and screens[i].element.getMouseY()~=-1 then if O==\"\"then for J,j in pairs(screens[i].ClickAreas)do if j~=nil and M>=j.x1 and M<=j.x2 and N>=j.y1 and N<=j.y2 then O=j.id;HitPayload=j;break end end end;if O==\"ButtonPress\"then if screens[i].mode==HitPayload.param then screens[i].mode=\"startup\"else screens[i].mode=HitPayload.param end;if screens[i].mode==\"damageoutline\"then if screens[i].submode==\"\"then screens[i].submode=\"top\"end end;screens[i].refresh=true;screens[i].ClickAreas={}SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"ToggleBackground\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundMode==\"\"then BackgroundSelected=1;BackgroundMode=backgroundModes[BackgroundSelected]else BackgroundSelected=1;BackgroundMode=\"\"end;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"PreviousBackground\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundMode==\"\"then BackgroundSelected=1;BackgroundMode=backgroundModes[BackgroundSelected]else if BackgroundSelected<=1 then BackgroundSelected=#backgroundModes else BackgroundSelected=BackgroundSelected-1 end;BackgroundMode=backgroundModes[BackgroundSelected]end;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"NextBackground\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundMode==\"\"then BackgroundSelected=1;BackgroundMode=backgroundModes[BackgroundSelected]else if BackgroundSelected>=#backgroundModes then BackgroundSelected=1 else BackgroundSelected=BackgroundSelected+1 end;BackgroundMode=backgroundModes[BackgroundSelected]end;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"DecreaseOpacity\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundModeOpacity>0.1 then BackgroundModeOpacity=BackgroundModeOpacity-0.05;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()end elseif O==\"IncreaseOpacity\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundModeOpacity<1.0 then BackgroundModeOpacity=BackgroundModeOpacity+0.05;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()end elseif O==\"ResetColors\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then db.clear()ColorPrimary=\"FF6700\"ColorSecondary=\"FFFFFF\"ColorTertiary=\"000000\"ColorHealthy=\"00FF00\"ColorWarning=\"FFFF00\"ColorCritical=\"FF0000\"ColorBackground=\"000000\"ColorBackgroundPattern=\"4f4f4f\"BackgroundMode=\"deathstar\"BackgroundSelected=1;BackgroundModeOpacity=0.25;colorIDTable={[1]={id=\"ColorPrimary\",desc=\"Main HUD Color\",basec=\"FF6700\",newc=\"FF6700\"},[2]={id=\"ColorSecondary\",desc=\"Secondary HUD Color\",basec=\"FFFFFF\",newc=\"FFFFFF\"},[3]={id=\"ColorTertiary\",desc=\"Tertiary HUD Color\",basec=\"000000\",newc=\"000000\"},[4]={id=\"ColorHealthy\",desc=\"Color code for Healthy/Okay\",basec=\"00FF00\",newc=\"00FF00\"},[5]={id=\"ColorWarning\",desc=\"Color code for Damaged/Warning\",basec=\"FFFF00\",newc=\"FFFF00\"},[6]={id=\"ColorCritical\",desc=\"Color code for Broken/Critical\",basec=\"FF0000\",newc=\"FF0000\"},[7]={id=\"ColorBackground\",desc=\"Background Color\",basec=\"000000\",newc=\"000000\"},[8]={id=\"ColorBackgroundPattern\",desc=\"Background Pattern Color\",basec=\"4F4F4F\",newc=\"4F4F4F\"},[9]={id=\"ColorFuelAtmospheric\",desc=\"Color for Atmo Fuel/Elements\",basec=\"004444\",newc=\"004444\"},[10]={id=\"ColorFuelSpace\",desc=\"Color for Space Fuel/Elements\",basec=\"444400\",newc=\"444400\"},[11]={id=\"ColorFuelRocket\",desc=\"Color for Rocket Fuel/Elements\",basec=\"440044\",newc=\"440044\"}}SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"PreviousColorID\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then colorIDIndex=colorIDIndex-1;if colorIDIndex<1 then colorIDIndex=#colorIDTable end;SaveToDatabank()SetRefresh(\"settings1\")RenderScreens(\"settings1\")elseif O==\"NextColorID\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then colorIDIndex=colorIDIndex+1;if colorIDIndex>#colorIDTable then colorIDIndex=1 end;SaveToDatabank()SetRefresh(\"settings1\")RenderScreens(\"settings1\")elseif O==\"ColorPosUp\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then local P=tonumber(string.sub(colorIDTable[colorIDIndex].newc,HitPayload.param,HitPayload.param),16)P=P+1;if P>15 then P=0 end;colorIDTable[colorIDIndex].newc=replace_char(HitPayload.param,colorIDTable[colorIDIndex].newc,hexTable[P+1])SaveToDatabank()SetRefresh(\"settings1\")RenderScreens(\"settings1\")elseif O==\"ColorPosDown\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then local P=tonumber(string.sub(colorIDTable[colorIDIndex].newc,HitPayload.param,HitPayload.param),16)P=P-1;if P<0 then P=15 end;colorIDTable[colorIDIndex].newc=replace_char(HitPayload.param,colorIDTable[colorIDIndex].newc,hexTable[P+1])SaveToDatabank()SetRefresh(\"settings1\")RenderScreens(\"settings1\")elseif O==\"ResetPosColor\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then colorIDTable[colorIDIndex].newc=colorIDTable[colorIDIndex].basec;_G[colorIDTable[colorIDIndex].id]=colorIDTable[colorIDIndex].basec;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"ApplyPosColor\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then _G[colorIDTable[colorIDIndex].id]=colorIDTable[colorIDIndex].newc;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"DamagedPageDown\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentDamagedPage=CurrentDamagedPage+1;if CurrentDamagedPage>math.ceil(#damagedElements/DamagePageSize)then CurrentDamagedPage=math.ceil(#damagedElements/DamagePageSize)end;HudDeselectElement()SaveToDatabank()SetRefresh(\"damage\")RenderScreens(\"damage\")elseif O==\"DamagedPageUp\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentDamagedPage=CurrentDamagedPage-1;if CurrentDamagedPage<1 then CurrentDamagedPage=1 end;HudDeselectElement()SaveToDatabank()SetRefresh(\"damage\")RenderScreens(\"damage\")elseif O==\"BrokenPageDown\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentBrokenPage=CurrentBrokenPage+1;if CurrentBrokenPage>math.ceil(#brokenElements/DamagePageSize)then CurrentBrokenPage=math.ceil(#brokenElements/DamagePageSize)end;HudDeselectElement()SaveToDatabank()SetRefresh(\"damage\")RenderScreens(\"damage\")elseif O==\"BrokenPageUp\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentBrokenPage=CurrentBrokenPage-1;if CurrentBrokenPage<1 then CurrentBrokenPage=1 end;HudDeselectElement()SaveToDatabank()SetRefresh(\"damage\")RenderScreens(\"damage\")elseif O==\"DMGOChangeView\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then screens[i].submode=HitPayload.param;UpdateViewDamageoutline(screens[i])SaveToDatabank()SetRefresh(\"damageoutline\",screens[i].submode)RenderScreens(\"damageoutline\",screens[i].submode)elseif O==\"DMGOChangeStretch\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if DMGOStretch==true then DMGOStretch=false else DMGOStretch=true end;UpdateViewDamageoutline(screens[i])SaveToDatabank()SetRefresh(\"damageoutline\")RenderScreens(\"damageoutline\")elseif O==\"ToggleDisplayAtmosphere\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if screens[i].fuelA==true then screens[i].fuelA=false else screens[i].fuelA=true end;screens[i].fuelIndex=1;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"ToggleDisplaySpace\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if screens[i].fuelS==true then screens[i].fuelS=false else screens[i].fuelS=true end;screens[i].fuelIndex=1;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"ToggleDisplayRocket\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if screens[i].fuelR==true then screens[i].fuelR=false else screens[i].fuelR=true end;screens[i].fuelIndex=1;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"DecreaseFuelIndex\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then screens[i].fuelIndex=screens[i].fuelIndex-1;if screens[i].fuelIndex<1 then screens[i].fuelIndex=1 end;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"IncreaseFuelIndex\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then screens[i].fuelIndex=screens[i].fuelIndex+1;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"ToggleHudMode\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if HUDMode==true then HUDMode=false;forceDamageRedraw=true;HudDeselectElement()SaveToDatabank()SetRefresh()RenderScreens()else HUDMode=true;forceDamageRedraw=true;HudDeselectElement()SaveToDatabank()SetRefresh()RenderScreens()end elseif O==\"ToggleSimulation\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentDamagedPage=1;CurrentBrokenPage=1;if SimulationMode==true then SimulationMode=false;SimulationActive=false;UpdateDamageData()UpdateTypeData()forceDamageRedraw=true;HudDeselectElement()SetRefresh(\"damage\")SetRefresh(\"damageoutline\")SetRefresh(\"settings1\")SetRefresh(\"fuel\")SaveToDatabank()RenderScreens()else SimulationMode=true;SimulationActive=false;UpdateDamageData()UpdateTypeData()forceDamageRedraw=true;HudDeselectElement()SetRefresh(\"damage\")SetRefresh(\"damageoutline\")SetRefresh(\"settings1\")SetRefresh(\"fuel\")SaveToDatabank()RenderScreens()end elseif(O==\"ToggleElementLabel\"or O==\"ToggleElementLabel2\")and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if UseMyElementNames==true then UseMyElementNames=false;SetRefresh(\"damage\")RenderScreens(\"damage\")else UseMyElementNames=true;SetRefresh(\"damage\")RenderScreens(\"damage\")end elseif(O==\"SwitchScrapTier\"or O==\"SwitchScrapTier2\")and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then ScrapTier=ScrapTier+1;if ScrapTier>4 then ScrapTier=1 end;SetRefresh(\"damage\")RenderScreens(\"damage\")end end end end end;function GetContentFlight()local Q=\"\"Q=Q..GetHeader(\"Flight Data Report\")..[[\n \n ]]return Q end;function GetContentDamage()local Q=\"\"if SimulationMode==true then Q=Q..GetHeader(\"Damage Report (Simulated damage)\")..[[]]else Q=Q..GetHeader(\"Damage Report\")..[[]]end;Q=Q..GetContentDamageScreen()return Q end;function GetContentDamageoutline(m)UpdateDataDamageoutline()UpdateViewDamageoutline(m)local Q=\"\"Q=Q..GetHeader(\"Damage Ship Outline Report\")..GetDamageoutlineShip()..[[]]if m.submode==\"top\"then Q=Q..[[\n \n Top View\n \n Side View\n \n Front View\n ]]elseif m.submode==\"side\"then Q=Q..[[\n \n Top View\n \n Side View\n \n Front View\n ]]elseif m.submode==\"front\"then Q=Q..[[\n \n Top View\n \n Side View\n \n Front View\n ]]else end;Q=Q..[[]]..#dmgoElements..[[ of ]]..ElementCounter..[[ shown]]Q=Q..[[]]if DMGOStretch==true then Q=Q..[[]]end;Q=Q..[[Stretch both axis]]return Q end;function GetContentFuel(m)if#FuelAtmosphericTanks<1 and#FuelSpaceTanks<1 and#FuelRocketTanks<1 then return\"\"end;local R=0;local Q=\"\"local S={}FuelDisplay={m.fuelA,m.fuelS,m.fuelR}if FuelDisplay[1]==true and#FuelAtmosphericTanks>0 then table.insert(S,\"Atmospheric\")R=R+1 end;if FuelDisplay[2]==true and#FuelSpaceTanks>0 then table.insert(S,\"Space\")R=R+1 end;if FuelDisplay[3]==true and#FuelRocketTanks>0 then table.insert(S,\"Rocket\")R=R+1 end;Q=Q..GetHeader(\"Fuel Report (\"..table.concat(S,\", \")..\")\")..[[\n ]]local T=150;local U=0;local V=0;if FuelDisplay[1]==true and#FuelAtmosphericTanks>0 then if R==1 then V=50 elseif R==2 then V=6 elseif R==3 then V=0 end;Q=Q..[[\n \n \n \n ]]Q=Q..[[]]..GenerateCommaValue(FuelAtmosphericCurrent,true)..[[ of ]]..GenerateCommaValue(FuelAtmosphericTotal,true)..[[ | Total Atmospheric Fuel in ]]..#FuelAtmosphericTanks..[[ tank]]..(#FuelAtmosphericTanks==1 and\"\"or\"s\")..[[ (]]..math.floor(100/FuelAtmosphericTotal*FuelAtmosphericCurrent)..[[%)]]U=U+1 end;if FuelDisplay[2]==true and#FuelSpaceTanks>0 then if R==1 then V=50 elseif R==2 then V=6 elseif R==3 then V=0 end;Q=Q..[[\n \n \n \n ]]Q=Q..[[]]..GenerateCommaValue(FuelSpaceCurrent,true)..[[ of ]]..GenerateCommaValue(FuelSpaceTotal,true)..[[ | Total Space Fuel in ]]..#FuelSpaceTanks..[[ tank]]..(#FuelSpaceTanks==1 and\"\"or\"s\")..[[ (]]..math.floor(100/FuelSpaceTotal*FuelSpaceCurrent)..[[%)]]U=U+1 end;if FuelDisplay[3]==true and#FuelRocketTanks>0 then if R==1 then V=50 elseif R==2 then V=6 elseif R==3 then V=0 end;Q=Q..[[\n \n \n \n ]]Q=Q..[[]]..GenerateCommaValue(FuelRocketCurrent,true)..[[ of ]]..GenerateCommaValue(FuelRocketTotal,true)..[[ | Total Rocket Fuel in ]]..#FuelRocketTanks..[[ tank]]..(#FuelRocketTanks==1 and\"\"or\"s\")..[[ (]]..math.floor(100/FuelRocketTotal*FuelRocketCurrent)..[[%)]]end;Q=Q..[[\n \n \n \n ]]local W={}if m.fuelIndex==nil or m.fuelIndex<1 then m.fuelIndex=1 end;if FuelDisplay[1]==true then for f,j in ipairs(FuelAtmosphericTanks)do table.insert(W,j)end end;if FuelDisplay[2]==true then for f,j in ipairs(FuelSpaceTanks)do table.insert(W,j)end end;if FuelDisplay[3]==true then for f,j in ipairs(FuelRocketTanks)do table.insert(W,j)end end;table.sort(W,function(E,F)return E.type\n \n \n ]]if Y.hp==0 then Q=Q..[[]]elseif Y.maxhp-Y.hp>constants.epsilon then Q=Q..[[]]else Q=Q..[[]]end;if Y.hp==0 then Q=Q..[[]]..Y.size..[[]]else Q=Q..[[]]..Y.size..[[]]end;if Y.hp==0 then Q=Q..[[Broken]]..[[0 of ]]..GenerateCommaValue(Y.vol)..[[]]elseif tonumber(Y.percent)<10 then Q=Q..[[]]..Y.percent..[[%]]..[[]]..GenerateCommaValue(Y.cvol)..[[ of ]]..GenerateCommaValue(Y.vol)..[[]]elseif tonumber(Y.percent)<30 then Q=Q..[[]]..Y.percent..[[%]]..[[]]..GenerateCommaValue(Y.cvol)..[[ of ]]..GenerateCommaValue(Y.vol)..[[]]else Q=Q..[[]]..Y.percent..[[%]]..[[]]..GenerateCommaValue(Y.cvol)..[[ of ]]..GenerateCommaValue(Y.vol)..[[]]end;Q=Q..[[]]..Y.name..[[]]Q=Q..[[]]end end;if#FuelAtmosphericTanks>0 then Q=Q..[[]]if FuelDisplay[1]==true then Q=Q..[[]]end;Q=Q..[[ATM]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"ToggleDisplayAtmosphere\",x1=50,x2=100,y1=270,y2=320})end;if#FuelSpaceTanks>0 then Q=Q..[[]]if FuelDisplay[2]==true then Q=Q..[[]]end;Q=Q..[[SPC]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"ToggleDisplaySpace\",x1=200,x2=250,y1=270,y2=320})end;if#FuelRocketTanks>0 then Q=Q..[[]]if FuelDisplay[3]==true then Q=Q..[[]]end;Q=Q..[[RKT]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"ToggleDisplayRocket\",x1=350,x2=400,y1=270,y2=320})end;if m.fuelIndex>1 then Q=Q..[[\n \n \n ]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"DecreaseFuelIndex\",x1=1470,x2=1670,y1=270,y2=320})end;if m.fuelIndex+X-1<#W then Q=Q..[[\n \n \n ]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"IncreaseFuelIndex\",x1=1680,x2=1880,y1=270,y2=320})end;if X>0 then Q=Q..[[]]..#W..[[ Tank]]..(#W==1 and\"\"or\"s\")..[[ (Showing ]]..m.fuelIndex..[[ to ]]..m.fuelIndex+X-1 ..[[)]]end;return Q end;function GetContentCargo()local Q=\"\"Q=Q..GetHeader(\"Cargo Report\")..[[\n \n ]]return Q end;function GetContentAGG()local Q=\"\"Q=Q..GetHeader(\"Anti-Grav Control\")..[[\n \n ]]return Q end;function GetContentMap()local Q=\"\"Q=Q..GetHeader(\"Map Overview\")..[[\n \n ]]return Q end;function GetContentTime()local Q=\"\"Q=Q..GetHeader(\"Time\")..epochTime()Q=Q..[[\n \n \n \n \n \n \n \n \n \n \n \n \n ]]return Q end;function GetContentSettings1()local Q=\"\"Q=Q..GetHeader(\"Settings\")..[[]]if BackgroundMode==\"\"then Q=Q..[[Activate background]]else Q=Q..[[Deactivate background (']]..BackgroundMode..[[', ]]..string.format(\"%.0f\",BackgroundModeOpacity*100)..[[%)]]end;Q=Q..[[\n \n Previous background\n \n Next background\n\n \n Decrease Opacity\n \n Increase Opacity\n ]]Q=Q..[[]]..[[Reset background and all colors]]Q=Q..[[]]..[[]]..[[]]..[[Select and change any of the ]]..#colorIDTable..[[ HUD colors]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..colorIDTable[colorIDIndex].desc..[[]]..[[]]..[[Current color]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[#]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,1,1)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,2,2)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,3,3)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,4,4)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,5,5)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,6,6)..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[New color]]..[[]]..[[Apply new color]]..[[]]..[[Reset]]..[[]]Q=Q..[[]]..[[]]..[[]]..[[Explanation / Hints]]..[[Coming soon.]]Q=Q..[[]]if SimulationMode==true then Q=Q..[[Simulating Damage to elements]]AddClickArea(\"settings1\",{id=\"ToggleSimulation\",mode=\"settings1\",x1=940,x2=1850,y1=919,y2=969})else Q=Q..[[Simulate Damage to elements]]AddClickArea(\"settings1\",{id=\"ToggleSimulation\",mode=\"settings1\",x1=940,x2=1850,y1=919,y2=969})end;return Q end;function GetContentStartup()local Q=\"\"Q=Q..GetElementLogo(812,380,\"f\",\"f\",\"f\")if YourShipsName==\"Enter here\"then Q=Q..[[Spaceship ID ]]..ShipID..[[]]else Q=Q..[[]]..YourShipsName..[[]]end;if ShowWelcomeMessage==true then Q=Q..[[Greetings, Commander ]]..PlayerName..[[.]]end;if#Warnings>0 then Q=Q..[[Warning: ]]..table.concat(Warnings,\" \")..[[]]end;Q=Q..[[Damage Report v]]..VERSION..[[, by Scion Interstellar, DorianGray - Discord: Dorian Gray#2623. Under GNU Public License 3.0.]]return Q end;function RenderScreen(m,a0)if a0==nil then PrintConsole(\"ERROR: contentToRender is nil.\")unit.exit()end;CreateClickAreasForScreen(m)local Q=\"\"Q=Q..[[\n \n \n ]]Q=Q..a0;if m.mode==\"startup\"then Q=Q..[[]]else Q=Q..[[]]end;Q=Q..[[\n \n ]]Q=Q..[[]]local a1=string.len(Q)m.element.setSVG(Q)end;function RenderScreens(a2,a3)a2=a2 or\"all\"a3=a3 or\"all\"if screens~=nil and#screens>0 then local a4=\"\"local a5=\"\"local a6=\"\"local a7=\"\"local a8=\"\"local a9=\"\"local aa=\"\"local ab=\"\"local ac=\"\"local ad=\"\"local ae=\"\"local af=\"\"for J,m in pairs(screens)do if m.refresh==true then local a0=\"\"if m.mode==\"flight\"and(a2==\"flight\"or a2==\"all\")then if a4==\"\"then a4=GetContentFlight()end;a0=a4 elseif m.mode==\"damage\"and(a2==\"damage\"or a2==\"all\")then if a5==\"\"then a5=GetContentDamage()end;a0=a5 elseif m.mode==\"damageoutline\"and(a2==\"damageoutline\"or a2==\"all\")then if m.submode==\"\"then m.submode=\"top\"screens[J].submode=\"top\"end;if m.submode==\"top\"and(a3==\"top\"or a3==\"all\")then if a6==\"\"then a6=GetContentDamageoutline(m)end;a0=a6 end;if m.submode==\"side\"and(a3==\"side\"or a3==\"all\")then if a7==\"\"then a7=GetContentDamageoutline(m)end;a0=a7 end;if m.submode==\"front\"and(a3==\"front\"or a3==\"all\")then if a8==\"\"then a8=GetContentDamageoutline(m)end;a0=a8 end elseif m.mode==\"fuel\"and(a2==\"fuel\"or a2==\"all\")then m=WipeClickAreasForScreen(screens[J])a0=GetContentFuel(m)elseif m.mode==\"cargo\"and(a2==\"cargo\"or a2==\"all\")then if aa==\"\"then aa=GetContentCargo()end;a0=aa elseif m.mode==\"agg\"and(a2==\"agg\"or a2==\"all\")then if ab==\"\"then ab=GetContentAGG()end;a0=ab elseif m.mode==\"map\"and(a2==\"map\"or a2==\"all\")then if ac==\"\"then ac=GetContentMap()end;a0=ac elseif m.mode==\"time\"and(a2==\"time\"or a2==\"all\")then if ad==\"\"then ad=GetContentTime()end;a0=ad elseif m.mode==\"settings1\"and(a2==\"settings1\"or a2==\"all\")then if ae==\"\"then ae=GetContentSettings1()end;a0=ae elseif m.mode==\"startup\"and(a2==\"startup\"or a2==\"all\")then if af==\"\"then af=GetContentStartup()end;a0=af else a0=\"Invalid screen mode. ('\"..m.mode..\"')\"end;if a0~=\"\"then RenderScreen(m,a0)else DrawCenteredText(\"ERROR: No contentToRender delivered for \"..m.mode)PrintConsole(\"ERROR: No contentToRender delivered for \"..m.mode)unit.exit()end;screens[J].refresh=false end end end;if HUDMode==true then system.setScreen(GetContentDamageHUDOutput())system.showScreen(1)else system.showScreen(0)end end;function OnTickData(C)if formerTime+605 or SkillRepairToolOptimization>5 or StatFuelTankOptimization>5 or StatAtmosphericFuelTankHandling>5 or StatSpaceFuelTankHandling>5 or StatRocketFuelTankHandling>5 then PrintConsole(\"ERROR: Talents/stats can only range from 0 to 5. Please set correctly in LUA settings and reactivate script.\")unit.exit()end;if screens==nil or#screens==0 then HUDMode=true;PrintConsole(\"Warning: No screens connected. Entering HUD mode only.\")end;OnTickData(true)unit.setTimer('UpdateData',UpdateDataInterval)unit.setTimer('UpdateHighlight',HighlightBlinkingInterval)",
- "filter": {
- "args": [],
- "signature": "start()",
- "slotKey": "-1"
- },
- "key": "13"
- },
- {
- "code": "ActionUp()",
- "filter": {
- "args": [
- {
- "value": "up"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "14"
- },
- {
- "code": "ActionDown()",
- "filter": {
- "args": [
- {
- "value": "down"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "15"
- },
- {
- "code": "ActionStrafeLeft()",
- "filter": {
- "args": [
- {
- "value": "strafeleft"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "16"
- },
- {
- "code": "ActionStrafeRight()",
- "filter": {
- "args": [
- {
- "value": "straferight"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "17"
- },
- {
- "code": "KeyCTRLPressed = true",
- "filter": {
- "args": [
- {
- "value": "brake"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "18"
- },
- {
- "code": "KeyCTRLPressed = false",
- "filter": {
- "args": [
- {
- "value": "brake"
- }
- ],
- "signature": "actionStop(action)",
- "slotKey": "-2"
- },
- "key": "19"
- },
- {
- "code": "ActionOption1()",
- "filter": {
- "args": [
- {
- "value": "option1"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "20"
- },
- {
- "code": "ActionOption2()",
- "filter": {
- "args": [
- {
- "value": "option2"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "21"
- },
- {
- "code": "ActionOption3()",
- "filter": {
- "args": [
- {
- "value": "option3"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "22"
- },
- {
- "code": "ActionOption4()",
- "filter": {
- "args": [
- {
- "value": "option4"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "23"
- },
- {
- "code": "ActionOption9()",
- "filter": {
- "args": [
- {
- "value": "option9"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "24"
- },
- {
- "code": "ActionOption8()",
- "filter": {
- "args": [
- {
- "value": "option8"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "25"
- }
- ],
- "methods": [],
- "events": []
-}
\ No newline at end of file
diff --git a/versions/DamageReport_3_03.conf b/versions/DamageReport_3_03.conf
deleted file mode 100644
index d79d38a..0000000
--- a/versions/DamageReport_3_03.conf
+++ /dev/null
@@ -1,452 +0,0 @@
-{
- "slots": {
- "0": {
- "name": "slot1",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "1": {
- "name": "slot2",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "2": {
- "name": "slot3",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "3": {
- "name": "slot4",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "4": {
- "name": "slot5",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "5": {
- "name": "slot6",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "6": {
- "name": "slot7",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "7": {
- "name": "slot8",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "8": {
- "name": "slot9",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "9": {
- "name": "slot10",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-1": {
- "name": "unit",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-2": {
- "name": "system",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-3": {
- "name": "library",
- "type": {
- "events": [],
- "methods": []
- }
- }
- },
- "handlers": [
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "0"
- },
- "key": "0"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "2"
- },
- "key": "1"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "3"
- },
- "key": "2"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "4"
- },
- "key": "3"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "5"
- },
- "key": "4"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "6"
- },
- "key": "5"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "7"
- },
- "key": "6"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "8"
- },
- "key": "7"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "9"
- },
- "key": "8"
- },
- {
- "code": "function GenerateCommaValue(a,b,c)b=b or false;c=c or 1;local d=a;if b==true then if string.len(a)>=4 then d=string.format(\"%.\"..c..\"fk\",a/1000)else d=string.format(\"%.\"..c..\"f\",a)end else while true do d,k=string.gsub(d,\"^(-?%d+)(%d%d%d)\",'%1,%2')if k==0 then break end end end;return d end;function PrintConsole(e,f)f=f or false;if f then system.print(\"------------------------------------------------------------------------\")end;system.print(e)if f then system.print(\"------------------------------------------------------------------------\")end end;function DrawCenteredText(e)if screens~=nil and#screens>0 then for g=1,#screens,1 do screens[g].element.setCenteredText(e)end end end;function ClearConsole()for g=1,10,1 do PrintConsole()end end;function SwitchScreens(h)h=h or\"on\"if screens~=nil and#screens>0 then for g=1,#screens,1 do if h==\"on\"then screens[g].element.clear()screens[g].element.activate()screens[g].active=true else screens[g].element.clear()screens[g].element.deactivate()screens[g].active=false end end end end;function GetSecondsString(i)local i=tonumber(i)if i==nil or i<=0 then return\"-\"else days=string.format(\"%2.f\",math.floor(i/(3600*24)))hours=string.format(\"%2.f\",math.floor(i/3600-days*24))mins=string.format(\"%2.f\",math.floor(i/60-hours*60-days*24*60))secs=string.format(\"%2.f\",math.floor(i-hours*3600-days*24*60*60-mins*60))str=\"\"if tonumber(days)>0 then str=str..days..\"d \"end;if tonumber(hours)>0 then str=str..hours..\"h \"end;if tonumber(mins)>0 then str=str..mins..\"m \"end;if tonumber(secs)>0 then str=str..secs..\"s\"end;return str end end;function replace_char(j,str,l)return str:sub(1,j-1)..l..str:sub(j+1)end;function epochTime()function rZ(m)if string.len(m)<=1 then return\"0\"..m else return m end end;function dPoint(n)if not(n==math.floor(n))then return true else return false end end;function lYear(year)if not dPoint(year/4)then if dPoint(year/100)then return true else if not dPoint(year/400)then return true else return false end end else return false end end;local o=5;local p=3600;local q=86400;local r=31536000;local s=31622400;local t=2419200;local g=2505600;local u=2592000;local k=2678400;local w={4,6,9,11}local x={1,3,5,7,8,10,12}local y=0;local z=1506816000;local A=system.getTime()_G[\"formerTime\"]=A;if AddSummertimeHour==true then A=A+3600 end;now=math.floor(A+z)year=1970;secs=0;y=0;while secs+s]]..hour..\":\"..minute..[[]]..[[]]..year..\"/\"..month..\"/\"..day..[[]]end;function ToggleHUD()if HUDMode==true then HUDMode=false;forceDamageRedraw=true;hudSelectedIndex=0;highlightID=0;HideHighlight()SetRefresh()RenderScreens()else HUDMode=true;forceDamageRedraw=true;hudSelectedIndex=0;highlightID=0;HideHighlight()SetRefresh()RenderScreens()end end;function HudDeselectElement()hudSelectedIndex=0;hudStartIndex=1;highlightID=0;HideHighlight()if HUDMode==true then SetRefresh(\"damage\")SetRefresh(\"damageoutline\")RenderScreens()end end;function ChangeHudSelectedElement(B)if HUDMode==true and#rE>0 then hudSelectedIndex=hudSelectedIndex+B;if hudSelectedIndex<1 then hudSelectedIndex=1 elseif hudSelectedIndex>#rE then hudSelectedIndex=#rE end;if hudSelectedIndex>9 then hudStartIndex=hudSelectedIndex-9 end;if hudSelectedIndex~=0 then highlightID=rE[hudSelectedIndex].id;if highlightID~=nil and highlightID~=0 then HideHighlight()elementPosition=vec3(rE[hudSelectedIndex].pos)highlightX=elementPosition.x-coreWorldOffset;highlightY=elementPosition.y-coreWorldOffset;highlightZ=elementPosition.z-coreWorldOffset;highlightOn=true;ShowHighlight()end end;SetRefresh(\"damage\")SetRefresh(\"damageoutline\")RenderScreens()end end;function HideHighlight()if#hudArrowSticker>0 then for g in pairs(hudArrowSticker)do core.deleteSticker(hudArrowSticker[g])end;hudArrowSticker={}end end;function ShowHighlight()if highlightOn==true and highlightID>0 then table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX+2,highlightY,highlightZ,\"north\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX,highlightY-2,highlightZ,\"east\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX-2,highlightY,highlightZ,\"south\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX,highlightY+2,highlightZ,\"west\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX,highlightY,highlightZ-2,\"up\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX,highlightY,highlightZ+2,\"down\"))end end;function ToggleHighlight()if highlightOn==true then highlightOn=false;HideHighlight()else highlightOn=true;ShowHighlight()end end;function SortDamageTables()table.sort(damagedElements,function(m,n)return m.missinghp>n.missinghp end)table.sort(brokenElements,function(m,n)return m.maxhp>n.maxhp end)end;function getScraps(C,D)D=D or false;C=C-SkillRepairToolOptimization*0.05*C;local E=math.ceil(C/(10*5^(ScrapTier-1)))if D==true then return GenerateCommaValue(string.format(\"%.0f\",E),false)else return E end end;function getRepairTime(C,F)F=F or false;C=C-SkillRepairToolOptimization*0.05*C;local E=math.ceil(C/ScrapTierRepairTimes[ScrapTier])E=E-SkillRepairToolEfficiency*0.1*E;if F==true then return GetSecondsString(string.format(\"%.0f\",E))else return E end end;function UpdateDataDamageoutline()dmgoElements={}for g,G in ipairs(brokenElements)do if#dmgoElementsShipXmax then ShipXmax=H end;if I>ShipYmax then ShipYmax=I end;if J>ShipZmax then ShipZmax=J end;table.insert(dmgoElements,{id=G.id,type=\"b\",size=G.maxhp,x=H,y=I,z=J,xp=0,yp=0,zp=0,u=0,v=0})end end;if#dmgoElementsShipXmax then ShipXmax=H end;if I>ShipYmax then ShipYmax=I end;if J>ShipZmax then ShipZmax=J end;table.insert(dmgoElements,{id=G.id,type=\"d\",size=G.maxhp,x=H,y=I,z=J,xp=0,yp=0,zp=0,u=0,v=0})end end end;if#dmgoElementsShipXmax then ShipXmax=H end;if I>ShipYmax then ShipYmax=I end;if J>ShipZmax then ShipZmax=J end;table.insert(dmgoElements,{id=G.id,type=\"h\",size=G.maxhp,x=H,y=I,z=J,xp=0,yp=0,zp=0,u=0,v=0})end end end;ShipX=math.abs(ShipXmax-ShipXmin)ShipY=math.abs(ShipYmax-ShipYmin)ShipZ=math.abs(ShipZmax-ShipZmin)for g,G in ipairs(dmgoElements)do dmgoElements[g].xp=math.abs(100/(ShipXmax-ShipXmin)*(G.x-ShipXmin))dmgoElements[g].yp=math.abs(100/(ShipYmax-ShipYmin)*(G.y-ShipYmin))dmgoElements[g].zp=math.abs(100/(ShipZmax-ShipZmin)*(G.z-ShipZmin))end end;function UpdateViewDamageoutline(K)UFrame=40;VFrame=40;UStart=20+UFrame;VStart=180+VFrame;UDim=1880-2*UFrame;VDim=840-2*VFrame;if K.submode==\"top\"then if DMGOStretch==false then local L=UDim/(ShipYmax-ShipYmin)local M=VDim/(ShipXmax-ShipXmin)if L>=M then local N=L/M;local O=math.floor(UDim/N)UStart=UStart+(UDim-O)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100/N*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100*G.xp+VStart)end else local N=M/L;local P=math.floor(VDim/N)VStart=VStart+(VDim-P)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100/N*G.xp+VStart)end end else for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100*G.xp+VStart)end end elseif K.submode==\"front\"then if DMGOStretch==false then local L=UDim/(ShipXmax-ShipXmin)local M=VDim/(ShipZmax-ShipZmin)if L>=M then local N=L/M;local O=math.floor(UDim/N)UStart=UStart+(UDim-O)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100/N*G.xp+UStart)dmgoElements[g].v=math.floor(VDim/100*(100-G.zp)+VStart)end else local N=M/L;local P=math.floor(VDim/N)VStart=VStart+(VDim-P)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.xp+UStart)dmgoElements[g].v=math.floor(VDim/100/N*(100-G.zp)+VStart)end end else for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.xp+UStart)dmgoElements[g].v=math.floor(VDim/100*(100-G.zp)+VStart)end end elseif K.submode==\"side\"then if DMGOStretch==false then local L=UDim/(ShipYmax-ShipYmin)local M=VDim/(ShipXmax-ShipZmin)if L>=M then local N=L/M;local O=math.floor(UDim/N)UStart=UStart+(UDim-O)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100/N*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100*(100-G.zp)+VStart)end else local N=M/L;local P=math.floor(VDim/N)VStart=VStart+(VDim-P)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100/N*(100-G.zp)+VStart)end end else for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100*(100-G.zp)+VStart)end end else DrawCenteredText(\"ERROR: non-existing DMGO mode set.\")PrintConsole(\"ERROR: non-existing DMGO mode set.\")unit.exit()end end;function GetDamageoutlineShip()local e=\"\"for g,G in ipairs(dmgoElements)do local Q=\"\"local R=1;if G.type==\"h\"then Q=\"ch\"elseif G.type==\"d\"then Q=\"cw\"else Q=\"cc\"end;if G.id==highlightID then Q=\"f2\"end;if G.size>0 and G.size<1000 then R=5 elseif G.size>=1000 and G.size<2000 then R=8 elseif G.size>=2000 and G.size<5000 then R=12 elseif G.size>=5000 and G.size<10000 then R=15 elseif G.size>=10000 and G.size<20000 then R=20 elseif G.size>=20000 then R=30 end;e=e..[[]]if G.id==highlightID then e=e..[[]]e=e..[[]]end end;return e end;function GetContentClickareas(K)local e=\"\"if K~=nil and K.ClickAreas~=nil and#K.ClickAreas>0 then for g,S in ipairs(K.ClickAreas)do e=e..[[]]end end;return e end;function GetElement1(H,I,T,U)H=H or 0;I=I or 0;T=T or 600;U=U or 600;local e=\"\"e=e..[[\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ]]return e end;function GetElement2(H,I)H=H or 0;I=I or 0;local e=\"\"e=e..[[]]return e end;function GetElementLogo(H,I,V,W,X)H=H or 812;I=I or 380;V=V or\"f\"W=W or\"f2\"X=X or\"f3\"local e=\"\"e=e..[[\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ]]return e end;function GetHeader(Y)Y=Y or\"ERROR: UNDEFINED\"local e=\"\"e=e..[[\n ]]..Y..[[]]return e end;function GetContentBackground(Z,_)bgColor=ColorBackgroundPattern;local e=\"\"if Z==\"dots\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' viewBox='0 0 4 4'%3E%3Cpath fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' d='M1 3h1v1H1V3zm2-2h1v1H3V1z'%3E%3C/path%3E%3C/svg%3E\");]]elseif Z==\"rain\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='12' height='16' viewBox='0 0 12 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 .99C4 .445 4.444 0 5 0c.552 0 1 .45 1 .99v4.02C6 5.555 5.556 6 5 6c-.552 0-1-.45-1-.99V.99zm6 8c0-.546.444-.99 1-.99.552 0 1 .45 1 .99v4.02c0 .546-.444.99-1 .99-.552 0-1-.45-1-.99V8.99z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E\");]]elseif Z==\"plus\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E\");]]elseif Z==\"signal\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='84' height='48' viewBox='0 0 84 48' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h12v6H0V0zm28 8h12v6H28V8zm14-8h12v6H42V0zm14 0h12v6H56V0zm0 8h12v6H56V8zM42 8h12v6H42V8zm0 16h12v6H42v-6zm14-8h12v6H56v-6zm14 0h12v6H70v-6zm0-16h12v6H70V0zM28 32h12v6H28v-6zM14 16h12v6H14v-6zM0 24h12v6H0v-6zm0 8h12v6H0v-6zm14 0h12v6H14v-6zm14 8h12v6H28v-6zm-14 0h12v6H14v-6zm28 0h12v6H42v-6zm14-8h12v6H56v-6zm0-8h12v6H56v-6zm14 8h12v6H70v-6zm0 8h12v6H70v-6zM14 24h12v6H14v-6zm14-8h12v6H28v-6zM14 8h12v6H14V8zM0 8h12v6H0V8z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E\");]]elseif Z==\"deathstar\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='105' viewBox='0 0 80 105'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M20 10a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm15 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zM20 75a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zm30-65a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm0 65a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zM35 10a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zM5 45a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zm60 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10z' /%3E%3C/g%3E%3C/g%3E%3C/svg%3E\");]]elseif Z==\"diamond\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='32' viewBox='0 0 16 32'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath fill-rule='evenodd' d='M0 24h4v2H0v-2zm0 4h6v2H0v-2zm0-8h2v2H0v-2zM0 0h4v2H0V0zm0 4h2v2H0V4zm16 20h-6v2h6v-2zm0 4H8v2h8v-2zm0-8h-4v2h4v-2zm0-20h-6v2h6V0zm0 4h-4v2h4V4zm-2 12h2v2h-2v-2zm0-8h2v2h-2V8zM2 8h10v2H2V8zm0 8h10v2H2v-2zm-2-4h14v2H0v-2zm4-8h6v2H4V4zm0 16h6v2H4v-2zM6 0h2v2H6V0zm0 24h2v2H6v-2z'/%3E%3C/g%3E%3C/svg%3E\");]]elseif Z==\"hexagon\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='49' viewBox='0 0 28 49'%3E%3Cg fill-rule='evenodd'%3E%3Cg id='hexagons' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='nonzero'%3E%3Cpath d='M13.99 9.25l13 7.5v15l-13 7.5L1 31.75v-15l12.99-7.5zM3 17.9v12.7l10.99 6.34 11-6.35V17.9l-11-6.34L3 17.9zM0 15l12.98-7.5V0h-2v6.35L0 12.69v2.3zm0 18.5L12.98 41v8h-2v-6.85L0 35.81v-2.3zM15 0v7.5L27.99 15H28v-2.31h-.01L17 6.35V0h-2zm0 49v-8l12.99-7.5H28v2.31h-.01L17 42.15V49h-2z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E\");]]elseif Z==\"capsule\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='32' height='26' viewBox='0 0 32 26' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M14 0v3.994C14 7.864 10.858 11 7 11c-3.866 0-7-3.138-7-7.006V0h2v4.005C2 6.765 4.24 9 7 9c2.756 0 5-2.236 5-4.995V0h2zm0 26v-5.994C14 16.138 10.866 13 7 13c-3.858 0-7 3.137-7 7.006V26h2v-6.005C2 17.235 4.244 15 7 15c2.76 0 5 2.236 5 4.995V26h2zm2-18.994C16 3.136 19.142 0 23 0c3.866 0 7 3.138 7 7.006v9.988C30 20.864 26.858 24 23 24c-3.866 0-7-3.138-7-7.006V7.006zm2-.01C18 4.235 20.244 2 23 2c2.76 0 5 2.236 5 4.995v10.01C28 19.765 25.756 22 23 22c-2.76 0-5-2.236-5-4.995V6.995z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E\");]]elseif Z==\"diagonal\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='6' height='6' viewBox='0 0 6 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'%3E%3Cpath d='M5 0h1L0 6V5zM6 5v1H5z'/%3E%3C/g%3E%3C/svg%3E\");]]end;return e end;function GetContentDamageHUDOutput()local a0=300;local a1=165;if#damagedElements>0 or#brokenElements>0 then a1=510 end;local e=\"\"e=e..[[\n \n ]]e=e..[[]]..[[]]..[[]]..[[]]..(YourShipsName==\"Enter here\"and\"Ship ID \"..ShipID or YourShipsName)..[[]]..[[]]if#brokenElements>0 then e=e..[[]]elseif#damagedElements>0 then e=e..[[]]else e=e..[[]]end;if#damagedElements>0 or#brokenElements>0 then e=e..[[Total Damage]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",totalShipMaxHP-totalShipHP))..[[]]e=e..[[T]]..ScrapTier..[[ Scrap Needed]]..[[]]..getScraps(totalShipMaxHP-totalShipHP,true)..[[]]e=e..[[Repair Time]]..[[]]..getRepairTime(totalShipMaxHP-totalShipHP,true)..[[]]e=e..[[]]..[[]]..[[]]..#healthyElements..[[]]..[[]]..[[]]..#damagedElements..[[]]..[[]]..[[]]..#brokenElements..[[]]local u=0;for a2=hudStartIndex,hudStartIndex+9,1 do if rE[a2]~=nil then v=rE[a2]if v.hp>0 then e=e..[[]]..[[]]..string.format(\"%.30s\",v.name)..[[]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",v.missinghp))..[[]]if v.id==highlightID then e=e..[[]]..[[]]..string.format(\"%.30s\",v.name)..[[]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",v.missinghp))..[[]]end else e=e..[[]]..[[]]..string.format(\"%.30s\",v.name)..[[]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",v.missinghp))..[[]]if v.id==highlightID then highlightX=elementPosition.x-coreWorldOffset;highlightY=elementPosition.y-coreWorldOffset;highlightZ=elementPosition.z-coreWorldOffset;e=e..[[]]..[[]]..string.format(\"%.30s\",v.name)..[[]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",v.missinghp))..[[]]end end;u=u+1 end end;e=e..[[]]..[[]]..[[]]..[[]]..[[Up/down arrows to highlight]]..[[CTRL + arrows to move HUD]]..[[Left arrow to toggle HUD Mode]]..[[ALT+1-4 to set Scrap Tier]]..[[ALT+8 to reset HUD position]]..[[ALT+9 to shut script off]]..[[]]..[[]]else e=e..[[]]..OkayCenterMessage..[[]]..[[]]..#healthyElements..[[ elements / ]]..GenerateCommaValue(string.format(\"%.0f\",totalShipMaxHP))..[[ HP.]]..[[]]..[[]]..[[]]..[[]]..[[Left arrow to toggle HUD Mode]]..[[CTRL + arrows to move HUD]]..[[ALT+8 to reset HUD position]]..[[ALT+9 to shut script off]]..[[]]..[[]]end;e=e..[[]]return e end;function GetContentDamageScreen()local a3=\"\"if#damagedElements>0 then local a4=#damagedElements;if a4>DamagePageSize then a4=DamagePageSize end;if CurrentDamagedPage==math.ceil(#damagedElements/DamagePageSize)then a4=#damagedElements%DamagePageSize+12;if a4>12 then a4=a4-12 end end;a3=a3 ..[[]]a3=a3 ..[[]]if UseMyElementNames==true then a3=a3 ..[[Damaged Name]]else a3=a3 ..[[Damaged Type]]end;a3=a3 ..[[HLTHDMG]]a3=a3 ..[[T]]..ScrapTier..[[ SCRREPTIME]]AddClickArea(\"damage\",{id=\"SwitchScrapTier\",mode=\"damage\",x1=650,x2=775,y1=315,y2=360})local g=0;for u=1+(CurrentDamagedPage-1)*DamagePageSize,a4+(CurrentDamagedPage-1)*DamagePageSize,1 do g=g+1;local a5=damagedElements[u]if UseMyElementNames==true then a3=a3 ..[[]]..string.format(\"%.23s\",a5.name)..[[]]else a3=a3 ..[[]]..string.format(\"%.23s\",a5.type)..[[]]end;a3=a3 ..[[]]..a5.percent..[[%]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",a5.missinghp),true)..[[]]..[[]]..getScraps(a5.missinghp,true)..[[]]..[[]]..getRepairTime(a5.missinghp,true)..[[]]..[[]]end;if#damagedElements>DamagePageSize then a3=a3 ..[[Page ]]..CurrentDamagedPage..\" of \"..math.ceil(#damagedElements/DamagePageSize)..[[]]if CurrentDamagedPage\n \n \n ]]AddClickArea(\"damage\",{id=\"DamagedPageDown\",mode=\"damage\",x1=65,x2=260,y1=290+(a4+1)*50,y2=290+50+(a4+1)*50})else DisableClickArea(\"DamagedPageDown\",\"damage\")end;if CurrentDamagedPage>1 then a3=a3 ..[[\n \n \n ]]AddClickArea(\"damage\",{id=\"DamagedPageUp\",mode=\"damage\",x1=750,x2=950,y1=290+(a4+1)*50,y2=290+50+(a4+1)*50})else DisableClickArea(\"DamagedPageUp\",\"damage\")end end end;if#brokenElements>0 then local a6=#brokenElements;if a6>DamagePageSize then a6=DamagePageSize end;if CurrentBrokenPage==math.ceil(#brokenElements/DamagePageSize)then a6=#brokenElements%DamagePageSize+12;if a6>12 then a6=a6-12 end end;a3=a3 ..[[]]a3=a3 ..[[]]if UseMyElementNames==true then a3=a3 ..[[Broken Name]]else a3=a3 ..[[Broken Type]]end;a3=a3 ..[[DMG]]a3=a3 ..[[T]]..ScrapTier..[[ SCRREPTIME]]AddClickArea(\"damage\",{id=\"SwitchScrapTier2\",mode=\"damage\",x1=1570,x2=1690,y1=315,y2=360})local g=0;for u=1+(CurrentBrokenPage-1)*DamagePageSize,a6+(CurrentBrokenPage-1)*DamagePageSize,1 do g=g+1;local a5=brokenElements[u]if UseMyElementNames==true then a3=a3 ..[[]]..string.format(\"%.30s\",a5.name)..[[]]else a3=a3 ..[[]]..string.format(\"%.30s\",a5.type)..[[]]end;a3=a3 ..[[]]..GenerateCommaValue(string.format(\"%.0f\",a5.missinghp),true)..[[]]..[[]]..getScraps(a5.missinghp,true)..[[]]..[[]]..getRepairTime(a5.missinghp,true)..[[]]..[[]]end;if#brokenElements>DamagePageSize then a3=a3 ..[[Page ]]..CurrentBrokenPage..\" of \"..math.ceil(#brokenElements/DamagePageSize)..[[]]if CurrentBrokenPage>1 then a3=a3 ..[[\n \n \n ]]AddClickArea(\"damage\",{id=\"BrokenPageUp\",mode=\"damage\",x1=1665,x2=1865,y1=290+(a6+1)*50,y2=290+50+(a6+1)*50})else DisableClickArea(\"BrokenPageUp\",\"damage\")end;if CurrentBrokenPage\n \n \n ]]AddClickArea(\"damage\",{id=\"BrokenPageDown\",mode=\"damage\",x1=980,x2=1180,y1=290+(a6+1)*50,y2=290+50+(a6+1)*50})else DisableClickArea(\"BrokenPageDown\",\"damage\")end end end;if#damagedElements>0 or#brokenElements>0 then local a7=math.floor(1878/#elementsIdList*#damagedElements)local a8=math.floor(1878/#elementsIdList*#brokenElements)local a9=1878-a7-a8+1;a3=a3 ..[[]]a3=a3 ..[[]]a3=a3 ..[[]]a3=a3 ..[[]]if#damagedElements>0 then a3=a3 ..[[]]..#damagedElements..[[]]end;if#healthyElements>0 then a3=a3 ..[[]]..#healthyElements..[[]]end;if#brokenElements>0 then a3=a3 ..[[]]..#brokenElements..[[]]end;a3=a3 ..[[]]a3=a3 ..[[]]..GenerateCommaValue(string.format(\"%.0f\",totalShipMaxHP-totalShipHP))..[[ HP damage in total ]]..getScraps(totalShipMaxHP-totalShipHP,true)..[[ T]]..ScrapTier..[[ scraps needed. ]]..getRepairTime(totalShipMaxHP-totalShipHP,true)..[[ projected repair time.]]else a3=a3 ..GetElementLogo(812,380,\"ch\",\"ch\",\"ch\")..[[]]..OkayCenterMessage..[[]]..[[]]..#healthyElements..[[ elements stand ]]..GenerateCommaValue(string.format(\"%.0f\",totalShipMaxHP))..[[ HP strong.]]end;forceDamageRedraw=false;return a3 end;function ActionStopengines()ToggleHUD()end;function ActionStrafeRight()if KeyCTRLPressed==true then if HUDShiftU<4000 then HUDShiftU=HUDShiftU+50;SaveToDatabank()RenderScreens()end else HudDeselectElement()end end;function ActionStrafeLeft()if KeyCTRLPressed==true then if HUDShiftU>=50 then HUDShiftU=HUDShiftU-50;SaveToDatabank()RenderScreens()end else ToggleHUD()end end;function ActionDown()if KeyCTRLPressed==true then if HUDShiftV<4000 then HUDShiftV=HUDShiftV+50;SaveToDatabank()RenderScreens()end else ChangeHudSelectedElement(1)end end;function ActionUp()if KeyCTRLPressed==true then if HUDShiftV>=50 then HUDShiftV=HUDShiftV-50;SaveToDatabank()RenderScreens()end else ChangeHudSelectedElement(-1)end end;function ActionOption1()ScrapTier=1;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption2()ScrapTier=2;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption3()ScrapTier=3;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption4()ScrapTier=4;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption8()HUDShiftU=0;HUDShiftV=0;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption9()SaveToDatabank()SwitchScreens(\"off\")unit.exit()end",
- "filter": {
- "args": [],
- "signature": "start()",
- "slotKey": "-1"
- },
- "key": "9"
- },
- {
- "code": "SaveToDatabank()\nSwitchScreens(\"off\")",
- "filter": {
- "args": [],
- "signature": "stop()",
- "slotKey": "-1"
- },
- "key": "10"
- },
- {
- "code": "OnTickData()\n",
- "filter": {
- "args": [
- {
- "value": "UpdateData"
- }
- ],
- "signature": "tick(timerId)",
- "slotKey": "-1"
- },
- "key": "11"
- },
- {
- "code": "ToggleHighlight()",
- "filter": {
- "args": [
- {
- "value": "UpdateHighlight"
- }
- ],
- "signature": "tick(timerId)",
- "slotKey": "-1"
- },
- "key": "12"
- },
- {
- "code": "--[[\n Damage Report 3.03\n A LUA script for Dual Universe\n\n Created By Dorian Gray\n Ingame: DorianGray\n Discord: Dorian Gray#2623\n\n You can find/update this script on GitHub. Explanations, installation and usage information as well as screenshots can be found there too.\n GitHub: https://github.com/DorianTheGrey/DU-DamageReport\n\n GNU Public License 3.0. Use whatever you want, be so kind to leave credit.\n \n Credits & thanks: \n Thanks to NovaQuark for creating the MMO of the century.\n Thanks to Jericho, Dmentia and Archaegeo for learning a lot from their fine scripts.\n Thanks to TheBlacklist for testing and wonderful suggestions.\n SVG patterns by Hero Patterns.\n DU atlas data from Jayle Break.\n \n]]\n\n--[[ 1. USER DEFINED VARIABLES ]]\n\nYourShipsName = \"Enter here\" --export Enter your ship name here if you want it displayed instead of the ship's ID. YOU NEED TO LEAVE THE QUOTATION MARKS.\n\nSkillRepairToolEfficiency = 0 --export Enter (0-5) your talent \"Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency\"\nSkillRepairToolOptimization = 0 --export Enter your talent \"Mining and Inventory -> Equipment Manager -> Repair Tool Optimization\"\n\nStatAtmosphericFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED ATMOSPHERIC FUEL TANKS (from the builders talent \"Piloting -> Atmospheric Flight Technician -> Atmospheric Fuel-Tank Handling\")\nStatSpaceFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL SPACE TANKS (from the builders talent \"Piloting -> Atmospheric Engine Technician -> Space Fuel-Tank Handling\")\nStatRocketFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL ROCKET TANKS (from the builders talent \"Piloting -> Rocket Scientist -> Rocket Booster Fuel Tank Handling\")\nStatFuelTankOptimization = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL TANKS \"from the builders talent Mining and Inventory -> Stock Control -> Fuel Tank Optimization\"\n\nShowWelcomeMessage = true --export Do you want the welcome message on the start screen with your name?\nAddSummertimeHour = false --export: Is summertime currently enabled in your location? (Adds one hour.)\n\nUpdateDataInterval=1.0;HighlightBlinkingInterval=0.5;ColorPrimary=\"FF6700\"ColorSecondary=\"FFFFFF\"ColorTertiary=\"000000\"ColorHealthy=\"00FF00\"ColorWarning=\"FFFF00\"ColorCritical=\"FF0000\"ColorBackground=\"000000\"ColorBackgroundPattern=\"4F4F4F\"ColorFuelAtmospheric=\"004444\"ColorFuelSpace=\"444400\"ColorFuelRocket=\"440044\"VERSION=3.03;DebugMode=false;DebugRenderClickareas=true;DBData={}core=nil;db=nil;screens={}dscreens={}Warnings={}screenModes={[\"flight\"]={id=\"flight\"},[\"damage\"]={id=\"damage\"},[\"damageoutline\"]={id=\"damageoutline\"},[\"fuel\"]={id=\"fuel\"},[\"cargo\"]={id=\"cargo\"},[\"agg\"]={id=\"agg\"},[\"map\"]={id=\"map\"},[\"time\"]={id=\"time\",activetoggle=\"true\"},[\"settings1\"]={id=\"settings1\"},[\"startup\"]={id=\"startup\"}}backgroundModes={\"deathstar\",\"capsule\",\"rain\",\"signal\",\"hexagon\",\"diagonal\",\"diamond\",\"plus\",\"dots\"}BackgroundMode=\"deathstar\"BackgroundSelected=1;BackgroundModeOpacity=0.25;SaveVars={\"dscreens\",\"ColorPrimary\",\"ColorSecondary\",\"ColorTertiary\",\"ColorHealthy\",\"ColorWarning\",\"ColorCritical\",\"ColorBackground\",\"ColorBackgroundPattern\",\"ScrapTier\",\"HUDMode\",\"SimulationMode\",\"DMGOStretch\",\"HUDShiftU\",\"HUDShiftV\",\"colorIDIndex\",\"colorIDTable\",\"BackgroundMode\",\"BackgroundSelected\",\"BackgroundModeOpacity\"}HUDMode=false;HUDShiftU=0;HUDShiftV=0;hudSelectedIndex=0;hudStartIndex=1;hudArrowSticker={}highlightOn=false;highlightID=0;highlightX=0;highlightY=0;highlightZ=0;SimulationMode=false;OkayCenterMessage=\"All systems nominal.\"CurrentDamagedPage=1;CurrentBrokenPage=1;DamagePageSize=12;ScrapTier=1;totalScraps=0;ScrapTierRepairTimes={10,50,250,1250}coreWorldOffset=0;totalShipHP=0;formerTotalShipHP=-1;totalShipMaxHP=0;totalShipIntegrity=100;elementsId={}elementsIdList={}damagedElements={}brokenElements={}rE={}healthyElements={}typeElements={}ElementCounter=0;UseMyElementNames=true;dmgoElements={}DMGOMaxElements=250;DMGOStretch=false;ShipXmin=99999999;ShipXmax=-99999999;ShipYmin=99999999;ShipYmax=-99999999;ShipZmin=99999999;ShipZmax=-99999999;totalShipMass=0;formerTotalShipMass=-1;formerTime=-1;FuelAtmosphericTanks={}FuelSpaceTanks={}FuelRocketTanks={}FuelAtmosphericTotal=0;FuelSpaceTotal=0;FuelRocketTotal=0;FuelAtmosphericCurrent=0;FuelSpaceTotalCurrent=0;FuelRocketTotalCurrent=0;formerFuelAtmosphericTotal=-1;formerFuelSpaceTotal=-1;formerFuelRocketTotal=-1;hexTable={\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"A\",\"B\",\"C\",\"D\",\"E\",\"F\"}colorIDIndex=1;colorIDTable={[1]={id=\"ColorPrimary\",desc=\"Main HUD Color\",basec=\"FF6700\",newc=\"FF6700\"},[2]={id=\"ColorSecondary\",desc=\"Secondary HUD Color\",basec=\"FFFFFF\",newc=\"FFFFFF\"},[3]={id=\"ColorTertiary\",desc=\"Tertiary HUD Color\",basec=\"000000\",newc=\"000000\"},[4]={id=\"ColorHealthy\",desc=\"Color code for Healthy/Okay\",basec=\"00FF00\",newc=\"00FF00\"},[5]={id=\"ColorWarning\",desc=\"Color code for Damaged/Warning\",basec=\"FFFF00\",newc=\"FFFF00\"},[6]={id=\"ColorCritical\",desc=\"Color code for Broken/Critical\",basec=\"FF0000\",newc=\"FF0000\"},[7]={id=\"ColorBackground\",desc=\"Background Color\",basec=\"000000\",newc=\"000000\"},[8]={id=\"ColorBackgroundPattern\",desc=\"Background Pattern Color\",basec=\"4F4F4F\",newc=\"4F4F4F\"},[9]={id=\"ColorFuelAtmospheric\",desc=\"Color for Atmo Fuel/Elements\",basec=\"004444\",newc=\"004444\"},[10]={id=\"ColorFuelSpace\",desc=\"Color for Space Fuel/Elements\",basec=\"444400\",newc=\"444400\"},[11]={id=\"ColorFuelRocket\",desc=\"Color for Rocket Fuel/Elements\",basec=\"440044\",newc=\"440044\"}}function InitiateSlots()for a,b in pairs(unit)do if type(b)==\"table\"and type(b.export)==\"table\"and b.getElementClass then local c=b.getElementClass():lower()if c:find(\"coreunit\")then core=b;local d=core.getMaxHitPoints()if d>10000 then coreWorldOffset=128 elseif d>1000 then coreWorldOffset=64 elseif d>150 then coreWorldOffset=32 else coreWorldOffset=16 end elseif c=='databankunit'then db=b elseif c==\"screenunit\"then local e=\"startup\"screens[#screens+1]={element=b,id=b.getId(),mode=e,submode=\"\",ClickAreas={},refresh=true,active=false,fuelA=true,fuelS=true,fuelR=true,fuelIndex=1}end end end end;function LoadFromDatabank()if db==nil then return else for f,g in pairs(SaveVars)do if db.hasKey(g)then local h=json.decode(db.getStringValue(g))if h~=nil then if g==\"YourShipsName\"or g==\"AddSummertimeHour\"or g==\"UpdateDataInterval\"or g==\"HighlightBlinkingInterval\"or g==\"SkillRepairToolEfficiency\"or g==\"SkillRepairToolOptimization\"or g==\"SkillAtmosphericFuelEfficiency\"or g==\"SkillSpaceFuelEfficiency\"or g==\"SkillRocketFuelEfficiency\"or g==\"StatAtmosphericFuelTankHandling\"or g==\"StatSpaceFuelTankHandling\"or g==\"StatRocketFuelTankHandling\"then else _G[g]=h end end end end;for i,j in ipairs(screens)do for k,l in ipairs(dscreens)do if screens[i].id==dscreens[k].id then screens[i].mode=dscreens[k].mode;screens[i].submode=dscreens[k].submode;screens[i].active=dscreens[k].active;screens[i].refresh=true;screens[i].fuelA=dscreens[k].fuelA;screens[i].fuelS=dscreens[k].fuelS;screens[i].fuelR=dscreens[k].fuelR;screens[i].fuelIndex=dscreens[k].fuelIndex end end end end end;function SaveToDatabank()if db==nil then return else dscreens={}for i,m in ipairs(screens)do dscreens[i]={}dscreens[i].id=m.id;dscreens[i].mode=m.mode;dscreens[i].submode=m.submode;dscreens[i].active=m.active;dscreens[i].fuelA=m.fuelA;dscreens[i].fuelS=m.fuelS;dscreens[i].fuelR=m.fuelR;dscreens[i].fuelIndex=m.fuelIndex end;db.clear()for f,g in pairs(SaveVars)do db.setStringValue(g,json.encode(_G[g]))end end end;function InitiateScreens()if screens~=nil and#screens>0 then for i=1,#screens,1 do screens[i]=CreateClickAreasForScreen(screens[i])end end end;function UpdateTypeData()FuelAtmosphericTanks={}FuelSpaceTanks={}FuelRocketTanks={}FuelAtmosphericTotal=0;FuelAtmosphericCurrent=0;FuelSpaceTotal=0;FuelSpaceCurrent=0;FuelRocketCurrent=0;FuelRocketTotal=0;local n=4;local o=6;local p=0.8;if StatFuelTankOptimization>0 then n=n-0.09*StatFuelTankOptimization*n;o=o-0.09*StatFuelTankOptimization*o;p=p-0.09*StatFuelTankOptimization*p end;for i,q in ipairs(typeElements)do local r=core.getElementNameById(q)or\"\"local s=core.getElementTypeById(q)or\"\"local t=core.getElementPositionById(q)or 0;local u=core.getElementHitPointsById(q)or 0;local v=core.getElementMaxHitPointsById(q)or 0;local w=core.getElementMassById(q)or 0;local x=\"\"local y=0;local z=0;local A=0;local B=0;if s==\"atmospheric fuel-tank\"then if v>10000 then x=\"L\"z=5480;y=12800 elseif v>1300 then x=\"M\"z=988.67;y=1600 elseif v>150 then x=\"S\"z=182.67;y=400 else x=\"XS\"z=35.03;y=100 end;if StatAtmosphericFuelTankHandling>0 then y=0.2*StatAtmosphericFuelTankHandling*y+y end;A=w-z;if A<=10 then A=0 end;B=string.format(\"%.0f\",A/n)cPercent=string.format(\"%.1f\",math.floor(100/y*tonumber(B)))table.insert(FuelAtmosphericTanks,{type=1,id=q,name=r,maxhp=v,hp=GetHPforElement(q),pos=t,size=x,mass=z,vol=y,cvol=B,percent=cPercent})if u>0 then FuelAtmosphericCurrent=FuelAtmosphericCurrent+B end;FuelAtmosphericTotal=FuelAtmosphericTotal+y elseif s==\"space fuel-tank\"then if v>10000 then x=\"L\"z=5480;y=12800 elseif v>1300 then x=\"M\"z=988.67;y=1600 else x=\"S\"z=182.67;y=400 end;if StatSpaceFuelTankHandling>0 then y=0.2*StatSpaceFuelTankHandling*y+y end;A=w-z;if A<=10 then A=0 end;B=string.format(\"%.0f\",A/o)cPercent=string.format(\"%.1f\",100/y*tonumber(B))table.insert(FuelSpaceTanks,{type=2,id=q,name=r,maxhp=v,hp=GetHPforElement(q),pos=t,size=x,mass=z,vol=y,cvol=B,percent=cPercent})if u>0 then FuelSpaceCurrent=FuelSpaceCurrent+B end;FuelSpaceTotal=FuelSpaceTotal+y elseif s==\"rocket fuel-tank\"then if v>65000 then x=\"L\"z=25740;y=50000 elseif v>6000 then x=\"M\"z=4720;y=6400 elseif v>700 then x=\"S\"z=886.72;y=800 else x=\"XS\"z=173.42;y=400 end;if StatRocketFuelTankHandling>0 then y=0.2*StatRocketFuelTankHandling*y+y end;A=w-z;if A<=10 then A=0 end;B=string.format(\"%.0f\",A/p)cPercent=string.format(\"%.1f\",100/y*tonumber(B))table.insert(FuelRocketTanks,{type=3,id=q,name=r,maxhp=v,hp=GetHPforElement(q),pos=t,size=x,mass=z,vol=y,cvol=B,percent=cPercent})if u>0 then FuelRocketCurrent=FuelRocketCurrent+B end;FuelRocketTotal=FuelRocketTotal+y end end;if FuelAtmosphericCurrent~=formerFuelAtmosphericCurrent then SetRefresh(\"fuel\")formerFuelAtmosphericCurrent=FuelAtmosphericCurrent end;if FuelSpaceCurrent~=formerFuelSpaceCurrent then SetRefresh(\"fuel\")formerFuelSpaceCurrent=FuelSpaceCurrent end;if FuelRocketCurrent~=formerFuelRocketCurrent then SetRefresh(\"fuel\")formerFuelRocketCurrent=FuelRocketCurrent end end;function UpdateDamageData(C)C=C or false;if SimulationActive==true then return end;local formerTotalShipHP=totalShipHP;totalShipHP=0;totalShipMaxHP=0;totalShipIntegrity=100;damagedElements={}brokenElements={}healthyElements={}ElementCounter=0;elementsIdList=core.getElementIdList()for i,q in pairs(elementsIdList)do ElementCounter=ElementCounter+1;local r=core.getElementNameById(q)local s=core.getElementTypeById(q)local t=core.getElementPositionById(q)local u=core.getElementHitPointsById(q)local v=core.getElementMaxHitPointsById(q)if SimulationMode==true then SimulationActive=true;local D=math.random(0,10)if D<2 and#brokenElements<30 then u=0 elseif D>=2 and D<4 and#damagedElements<30 then u=math.random(1,math.ceil(v))else u=v end end;totalShipHP=totalShipHP+u;totalShipMaxHP=totalShipMaxHP+v;if v-u>constants.epsilon then if u>0 then table.insert(damagedElements,{id=q,name=r,type=s,counter=ElementCounter,hp=u,maxhp=v,missinghp=v-u,percent=math.ceil(100/v*u),pos=t})else table.insert(brokenElements,{id=q,name=r,type=s,counter=ElementCounter,hp=u,maxhp=v,missinghp=v-u,percent=0,pos=t})end else table.insert(healthyElements,{id=q,name=r,type=s,counter=ElementCounter,hp=u,maxhp=v,pos=t})if q==highlightID then highlightID=0;highlightOn=false;HideHighlight()hudSelectedIndex=0 end end;if C==true then if s==\"atmospheric fuel-tank\"or s==\"space fuel-tank\"or s==\"rocket fuel-tank\"then table.insert(typeElements,q)end end end;SortDamageTables()rE={}if#brokenElements>0 then for f,j in ipairs(brokenElements)do table.insert(rE,{id=j.id,missinghp=j.missinghp,hp=j.hp,name=j.name,type=j.type,pos=j.pos})end end;if#damagedElements>0 then for f,j in ipairs(damagedElements)do table.insert(rE,{id=j.id,missinghp=j.missinghp,hp=j.hp,name=j.name,type=j.type,pos=j.pos})end end;if#rE>0 then table.sort(rE,function(E,F)return E.missinghp>F.missinghp end)end;totalShipIntegrity=string.format(\"%2.0f\",100/totalShipMaxHP*totalShipHP)if formerTotalShipHP~=totalShipHP then forceDamageRedraw=true;formerTotalShipHP=totalShipHP else forceDamageRedraw=false end end;function GetHPforElement(q)for i,j in ipairs(brokenElements)do if j.id==q then return 0 end end;for i,j in ipairs(damagedElements)do if j.id==q then return j.hp end end;for i,j in ipairs(healthyElements)do if j.id==q then return j.maxhp end end end;function UpdateClickArea(G,H,I)for i,m in ipairs(screens)do for J,j in pairs(screens[i].ClickAreas)do if j.id==G and j.mode==I then screens[i].ClickAreas[J]=H end end end end;function AddClickArea(I,H)for i,m in ipairs(screens)do if screens[i].mode==I then table.insert(screens[i].ClickAreas,H)end end end;function AddClickAreaForScreenID(K,H)for i,m in ipairs(screens)do if screens[i].id==K then table.insert(screens[i].ClickAreas,H)end end end;function DisableClickArea(G,I)UpdateClickArea(G,{id=G,mode=I,x1=-1,x2=-1,y1=-1,y2=-1})end;function SetRefresh(I,L)I=I or\"all\"L=L or\"all\"if screens~=nil and#screens>0 then for i=1,#screens,1 do if screens[i].mode==I or I==\"all\"then if screens[i].submode==L or L==\"all\"then screens[i].refresh=true end end end end end;function WipeClickAreasForScreen(m)m.ClickAreas={}return m end;function CreateBaseClickAreas(m)table.insert(m.ClickAreas,{mode=\"all\",id=\"ToggleHudMode\",x1=1537,x2=1728,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"damage\",x1=193,x2=384,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"damageoutline\",x1=385,x2=576,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"fuel\",x1=577,x2=768,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"time\",x1=0,x2=192,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"settings1\",x1=1729,x2=1920,y1=1015,y2=1075})return m end;function CreateClickAreasForScreen(m)if m==nil then return{}end;if m.mode==\"flight\"then elseif m.mode==\"damage\"then table.insert(m.ClickAreas,{mode=\"damage\",id=\"ToggleElementLabel\",x1=70,x2=425,y1=325,y2=355})table.insert(m.ClickAreas,{mode=\"damage\",id=\"ToggleElementLabel2\",x1=980,x2=1400,y1=325,y2=355})elseif m.mode==\"damageoutline\"then table.insert(m.ClickAreas,{mode=\"damageoutline\",id=\"DMGOChangeView\",param=\"top\",x1=60,x2=439,y1=150,y2=200})table.insert(m.ClickAreas,{mode=\"damageoutline\",id=\"DMGOChangeView\",param=\"side\",x1=440,x2=824,y1=150,y2=200})table.insert(m.ClickAreas,{mode=\"damageoutline\",id=\"DMGOChangeView\",param=\"front\",x1=825,x2=1215,y1=150,y2=200})table.insert(m.ClickAreas,{mode=\"damageoutline\",id=\"DMGOChangeStretch\",x1=1530,x2=1580,y1=150,y2=200})elseif m.mode==\"fuel\"then elseif m.mode==\"cargo\"then elseif m.mode==\"agg\"then elseif m.mode==\"map\"then elseif m.mode==\"time\"then elseif m.mode==\"settings1\"then table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ToggleBackground\",x1=75,x2=860,y1=170,y2=215})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"PreviousBackground\",x1=75,x2=460,y1=235,y2=285})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"NextBackground\",x1=480,x2=860,y1=235,y2=285})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"DecreaseOpacity\",x1=75,x2=460,y1=300,y2=350})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"IncreaseOpacity\",x1=480,x2=860,y1=300,y2=350})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ResetColors\",x1=75,x2=860,y1=370,y2=415})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"PreviousColorID\",x1=90,x2=140,y1=500,y2=550})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"NextColorID\",x1=795,x2=845,y1=500,y2=550})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"1\",x1=210,x2=290,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"2\",x1=300,x2=380,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"3\",x1=385,x2=465,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"4\",x1=470,x2=550,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"5\",x1=560,x2=640,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"6\",x1=645,x2=725,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"1\",x1=210,x2=290,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"2\",x1=300,x2=380,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"3\",x1=385,x2=465,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"4\",x1=470,x2=550,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"5\",x1=560,x2=640,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"6\",x1=645,x2=725,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ResetPosColor\",x1=160,x2=340,y1=885,y2=935})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ApplyPosColor\",x1=355,x2=780,y1=885,y2=935})elseif m.mode==\"startup\"then end;m=CreateBaseClickAreas(m)return m end;function CheckClick(M,N,O)M=M*1920;N=N*1120;O=O or\"\"HitPayload={}if screens~=nil and#screens>0 then for i=1,#screens,1 do if screens[i].active==true and screens[i].element.getMouseX()~=-1 and screens[i].element.getMouseY()~=-1 then if O==\"\"then for J,j in pairs(screens[i].ClickAreas)do if j~=nil and M>=j.x1 and M<=j.x2 and N>=j.y1 and N<=j.y2 then O=j.id;HitPayload=j;break end end end;if O==\"ButtonPress\"then if screens[i].mode==HitPayload.param then screens[i].mode=\"startup\"else screens[i].mode=HitPayload.param end;if screens[i].mode==\"damageoutline\"then if screens[i].submode==\"\"then screens[i].submode=\"top\"end end;screens[i].refresh=true;screens[i].ClickAreas={}SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"ToggleBackground\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundMode==\"\"then BackgroundSelected=1;BackgroundMode=backgroundModes[BackgroundSelected]else BackgroundSelected=1;BackgroundMode=\"\"end;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"PreviousBackground\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundMode==\"\"then BackgroundSelected=1;BackgroundMode=backgroundModes[BackgroundSelected]else if BackgroundSelected<=1 then BackgroundSelected=#backgroundModes else BackgroundSelected=BackgroundSelected-1 end;BackgroundMode=backgroundModes[BackgroundSelected]end;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"NextBackground\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundMode==\"\"then BackgroundSelected=1;BackgroundMode=backgroundModes[BackgroundSelected]else if BackgroundSelected>=#backgroundModes then BackgroundSelected=1 else BackgroundSelected=BackgroundSelected+1 end;BackgroundMode=backgroundModes[BackgroundSelected]end;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"DecreaseOpacity\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundModeOpacity>0.1 then BackgroundModeOpacity=BackgroundModeOpacity-0.05;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()end elseif O==\"IncreaseOpacity\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundModeOpacity<1.0 then BackgroundModeOpacity=BackgroundModeOpacity+0.05;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()end elseif O==\"ResetColors\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then db.clear()ColorPrimary=\"FF6700\"ColorSecondary=\"FFFFFF\"ColorTertiary=\"000000\"ColorHealthy=\"00FF00\"ColorWarning=\"FFFF00\"ColorCritical=\"FF0000\"ColorBackground=\"000000\"ColorBackgroundPattern=\"4f4f4f\"BackgroundMode=\"deathstar\"BackgroundSelected=1;BackgroundModeOpacity=0.25;colorIDTable={[1]={id=\"ColorPrimary\",desc=\"Main HUD Color\",basec=\"FF6700\",newc=\"FF6700\"},[2]={id=\"ColorSecondary\",desc=\"Secondary HUD Color\",basec=\"FFFFFF\",newc=\"FFFFFF\"},[3]={id=\"ColorTertiary\",desc=\"Tertiary HUD Color\",basec=\"000000\",newc=\"000000\"},[4]={id=\"ColorHealthy\",desc=\"Color code for Healthy/Okay\",basec=\"00FF00\",newc=\"00FF00\"},[5]={id=\"ColorWarning\",desc=\"Color code for Damaged/Warning\",basec=\"FFFF00\",newc=\"FFFF00\"},[6]={id=\"ColorCritical\",desc=\"Color code for Broken/Critical\",basec=\"FF0000\",newc=\"FF0000\"},[7]={id=\"ColorBackground\",desc=\"Background Color\",basec=\"000000\",newc=\"000000\"},[8]={id=\"ColorBackgroundPattern\",desc=\"Background Pattern Color\",basec=\"4F4F4F\",newc=\"4F4F4F\"},[9]={id=\"ColorFuelAtmospheric\",desc=\"Color for Atmo Fuel/Elements\",basec=\"004444\",newc=\"004444\"},[10]={id=\"ColorFuelSpace\",desc=\"Color for Space Fuel/Elements\",basec=\"444400\",newc=\"444400\"},[11]={id=\"ColorFuelRocket\",desc=\"Color for Rocket Fuel/Elements\",basec=\"440044\",newc=\"440044\"}}SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"PreviousColorID\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then colorIDIndex=colorIDIndex-1;if colorIDIndex<1 then colorIDIndex=#colorIDTable end;SaveToDatabank()SetRefresh(\"settings1\")RenderScreens(\"settings1\")elseif O==\"NextColorID\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then colorIDIndex=colorIDIndex+1;if colorIDIndex>#colorIDTable then colorIDIndex=1 end;SaveToDatabank()SetRefresh(\"settings1\")RenderScreens(\"settings1\")elseif O==\"ColorPosUp\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then local P=tonumber(string.sub(colorIDTable[colorIDIndex].newc,HitPayload.param,HitPayload.param),16)P=P+1;if P>15 then P=0 end;colorIDTable[colorIDIndex].newc=replace_char(HitPayload.param,colorIDTable[colorIDIndex].newc,hexTable[P+1])SaveToDatabank()SetRefresh(\"settings1\")RenderScreens(\"settings1\")elseif O==\"ColorPosDown\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then local P=tonumber(string.sub(colorIDTable[colorIDIndex].newc,HitPayload.param,HitPayload.param),16)P=P-1;if P<0 then P=15 end;colorIDTable[colorIDIndex].newc=replace_char(HitPayload.param,colorIDTable[colorIDIndex].newc,hexTable[P+1])SaveToDatabank()SetRefresh(\"settings1\")RenderScreens(\"settings1\")elseif O==\"ResetPosColor\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then colorIDTable[colorIDIndex].newc=colorIDTable[colorIDIndex].basec;_G[colorIDTable[colorIDIndex].id]=colorIDTable[colorIDIndex].basec;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"ApplyPosColor\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then _G[colorIDTable[colorIDIndex].id]=colorIDTable[colorIDIndex].newc;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"DamagedPageDown\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentDamagedPage=CurrentDamagedPage+1;if CurrentDamagedPage>math.ceil(#damagedElements/DamagePageSize)then CurrentDamagedPage=math.ceil(#damagedElements/DamagePageSize)end;HudDeselectElement()SaveToDatabank()SetRefresh(\"damage\")RenderScreens(\"damage\")elseif O==\"DamagedPageUp\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentDamagedPage=CurrentDamagedPage-1;if CurrentDamagedPage<1 then CurrentDamagedPage=1 end;HudDeselectElement()SaveToDatabank()SetRefresh(\"damage\")RenderScreens(\"damage\")elseif O==\"BrokenPageDown\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentBrokenPage=CurrentBrokenPage+1;if CurrentBrokenPage>math.ceil(#brokenElements/DamagePageSize)then CurrentBrokenPage=math.ceil(#brokenElements/DamagePageSize)end;HudDeselectElement()SaveToDatabank()SetRefresh(\"damage\")RenderScreens(\"damage\")elseif O==\"BrokenPageUp\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentBrokenPage=CurrentBrokenPage-1;if CurrentBrokenPage<1 then CurrentBrokenPage=1 end;HudDeselectElement()SaveToDatabank()SetRefresh(\"damage\")RenderScreens(\"damage\")elseif O==\"DMGOChangeView\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then screens[i].submode=HitPayload.param;UpdateViewDamageoutline(screens[i])SaveToDatabank()SetRefresh(\"damageoutline\",screens[i].submode)RenderScreens(\"damageoutline\",screens[i].submode)elseif O==\"DMGOChangeStretch\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if DMGOStretch==true then DMGOStretch=false else DMGOStretch=true end;UpdateViewDamageoutline(screens[i])SaveToDatabank()SetRefresh(\"damageoutline\")RenderScreens(\"damageoutline\")elseif O==\"ToggleDisplayAtmosphere\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if screens[i].fuelA==true then screens[i].fuelA=false else screens[i].fuelA=true end;screens[i].fuelIndex=1;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"ToggleDisplaySpace\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if screens[i].fuelS==true then screens[i].fuelS=false else screens[i].fuelS=true end;screens[i].fuelIndex=1;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"ToggleDisplayRocket\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if screens[i].fuelR==true then screens[i].fuelR=false else screens[i].fuelR=true end;screens[i].fuelIndex=1;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"DecreaseFuelIndex\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then screens[i].fuelIndex=screens[i].fuelIndex-1;if screens[i].fuelIndex<1 then screens[i].fuelIndex=1 end;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"IncreaseFuelIndex\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then screens[i].fuelIndex=screens[i].fuelIndex+1;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"ToggleHudMode\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if HUDMode==true then HUDMode=false;forceDamageRedraw=true;HudDeselectElement()SaveToDatabank()SetRefresh()RenderScreens()else HUDMode=true;forceDamageRedraw=true;HudDeselectElement()SaveToDatabank()SetRefresh()RenderScreens()end elseif O==\"ToggleSimulation\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentDamagedPage=1;CurrentBrokenPage=1;if SimulationMode==true then SimulationMode=false;SimulationActive=false;UpdateDamageData()UpdateTypeData()forceDamageRedraw=true;HudDeselectElement()SetRefresh(\"damage\")SetRefresh(\"damageoutline\")SetRefresh(\"settings1\")SetRefresh(\"fuel\")SaveToDatabank()RenderScreens()else SimulationMode=true;SimulationActive=false;UpdateDamageData()UpdateTypeData()forceDamageRedraw=true;HudDeselectElement()SetRefresh(\"damage\")SetRefresh(\"damageoutline\")SetRefresh(\"settings1\")SetRefresh(\"fuel\")SaveToDatabank()RenderScreens()end elseif(O==\"ToggleElementLabel\"or O==\"ToggleElementLabel2\")and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if UseMyElementNames==true then UseMyElementNames=false;SetRefresh(\"damage\")RenderScreens(\"damage\")else UseMyElementNames=true;SetRefresh(\"damage\")RenderScreens(\"damage\")end elseif(O==\"SwitchScrapTier\"or O==\"SwitchScrapTier2\")and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then ScrapTier=ScrapTier+1;if ScrapTier>4 then ScrapTier=1 end;SetRefresh(\"damage\")RenderScreens(\"damage\")end end end end end;function GetContentFlight()local Q=\"\"Q=Q..GetHeader(\"Flight Data Report\")..[[\n \n ]]return Q end;function GetContentDamage()local Q=\"\"if SimulationMode==true then Q=Q..GetHeader(\"Damage Report (Simulated damage)\")..[[]]else Q=Q..GetHeader(\"Damage Report\")..[[]]end;Q=Q..GetContentDamageScreen()return Q end;function GetContentDamageoutline(m)UpdateDataDamageoutline()UpdateViewDamageoutline(m)local Q=\"\"Q=Q..GetHeader(\"Damage Ship Outline Report\")..GetDamageoutlineShip()..[[]]if m.submode==\"top\"then Q=Q..[[\n \n Top View\n \n Side View\n \n Front View\n ]]elseif m.submode==\"side\"then Q=Q..[[\n \n Top View\n \n Side View\n \n Front View\n ]]elseif m.submode==\"front\"then Q=Q..[[\n \n Top View\n \n Side View\n \n Front View\n ]]else end;Q=Q..[[]]..#dmgoElements..[[ of ]]..ElementCounter..[[ shown]]Q=Q..[[]]if DMGOStretch==true then Q=Q..[[]]end;Q=Q..[[Stretch both axis]]return Q end;function GetContentFuel(m)if#FuelAtmosphericTanks<1 and#FuelSpaceTanks<1 and#FuelRocketTanks<1 then return\"\"end;local R=0;local Q=\"\"local S={}FuelDisplay={m.fuelA,m.fuelS,m.fuelR}if FuelDisplay[1]==true and#FuelAtmosphericTanks>0 then table.insert(S,\"Atmospheric\")R=R+1 end;if FuelDisplay[2]==true and#FuelSpaceTanks>0 then table.insert(S,\"Space\")R=R+1 end;if FuelDisplay[3]==true and#FuelRocketTanks>0 then table.insert(S,\"Rocket\")R=R+1 end;Q=Q..GetHeader(\"Fuel Report (\"..table.concat(S,\", \")..\")\")..[[\n ]]local T=150;local U=0;local V=0;if FuelDisplay[1]==true and#FuelAtmosphericTanks>0 then if R==1 then V=50 elseif R==2 then V=6 elseif R==3 then V=0 end;Q=Q..[[\n \n \n \n ]]Q=Q..[[]]..GenerateCommaValue(FuelAtmosphericCurrent,true)..[[ of ]]..GenerateCommaValue(FuelAtmosphericTotal,true)..[[ | Total Atmospheric Fuel in ]]..#FuelAtmosphericTanks..[[ tank]]..(#FuelAtmosphericTanks==1 and\"\"or\"s\")..[[ (]]..math.floor(100/FuelAtmosphericTotal*FuelAtmosphericCurrent)..[[%)]]U=U+1 end;if FuelDisplay[2]==true and#FuelSpaceTanks>0 then if R==1 then V=50 elseif R==2 then V=6 elseif R==3 then V=0 end;Q=Q..[[\n \n \n \n ]]Q=Q..[[]]..GenerateCommaValue(FuelSpaceCurrent,true)..[[ of ]]..GenerateCommaValue(FuelSpaceTotal,true)..[[ | Total Space Fuel in ]]..#FuelSpaceTanks..[[ tank]]..(#FuelSpaceTanks==1 and\"\"or\"s\")..[[ (]]..math.floor(100/FuelSpaceTotal*FuelSpaceCurrent)..[[%)]]U=U+1 end;if FuelDisplay[3]==true and#FuelRocketTanks>0 then if R==1 then V=50 elseif R==2 then V=6 elseif R==3 then V=0 end;Q=Q..[[\n \n \n \n ]]Q=Q..[[]]..GenerateCommaValue(FuelRocketCurrent,true)..[[ of ]]..GenerateCommaValue(FuelRocketTotal,true)..[[ | Total Rocket Fuel in ]]..#FuelRocketTanks..[[ tank]]..(#FuelRocketTanks==1 and\"\"or\"s\")..[[ (]]..math.floor(100/FuelRocketTotal*FuelRocketCurrent)..[[%)]]end;Q=Q..[[\n \n \n \n ]]local W={}if m.fuelIndex==nil or m.fuelIndex<1 then m.fuelIndex=1 end;if FuelDisplay[1]==true then for f,j in ipairs(FuelAtmosphericTanks)do table.insert(W,j)end end;if FuelDisplay[2]==true then for f,j in ipairs(FuelSpaceTanks)do table.insert(W,j)end end;if FuelDisplay[3]==true then for f,j in ipairs(FuelRocketTanks)do table.insert(W,j)end end;table.sort(W,function(E,F)return E.type\n \n \n ]]if Y.hp==0 then Q=Q..[[]]elseif Y.maxhp-Y.hp>constants.epsilon then Q=Q..[[]]else Q=Q..[[]]end;if Y.hp==0 then Q=Q..[[]]..Y.size..[[]]else Q=Q..[[]]..Y.size..[[]]end;if Y.hp==0 then Q=Q..[[Broken]]..[[0 of ]]..GenerateCommaValue(Y.vol)..[[]]elseif tonumber(Y.percent)<10 then Q=Q..[[]]..Y.percent..[[%]]..[[]]..GenerateCommaValue(Y.cvol)..[[ of ]]..GenerateCommaValue(Y.vol)..[[]]elseif tonumber(Y.percent)<30 then Q=Q..[[]]..Y.percent..[[%]]..[[]]..GenerateCommaValue(Y.cvol)..[[ of ]]..GenerateCommaValue(Y.vol)..[[]]else Q=Q..[[]]..Y.percent..[[%]]..[[]]..GenerateCommaValue(Y.cvol)..[[ of ]]..GenerateCommaValue(Y.vol)..[[]]end;Q=Q..[[]]..Y.name..[[]]Q=Q..[[]]end end;if#FuelAtmosphericTanks>0 then Q=Q..[[]]if FuelDisplay[1]==true then Q=Q..[[]]end;Q=Q..[[ATM]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"ToggleDisplayAtmosphere\",x1=50,x2=100,y1=270,y2=320})end;if#FuelSpaceTanks>0 then Q=Q..[[]]if FuelDisplay[2]==true then Q=Q..[[]]end;Q=Q..[[SPC]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"ToggleDisplaySpace\",x1=200,x2=250,y1=270,y2=320})end;if#FuelRocketTanks>0 then Q=Q..[[]]if FuelDisplay[3]==true then Q=Q..[[]]end;Q=Q..[[RKT]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"ToggleDisplayRocket\",x1=350,x2=400,y1=270,y2=320})end;if m.fuelIndex>1 then Q=Q..[[\n \n \n ]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"DecreaseFuelIndex\",x1=1470,x2=1670,y1=270,y2=320})end;if m.fuelIndex+X-1<#W then Q=Q..[[\n \n \n ]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"IncreaseFuelIndex\",x1=1680,x2=1880,y1=270,y2=320})end;if X>0 then Q=Q..[[]]..#W..[[ Tank]]..(#W==1 and\"\"or\"s\")..[[ (Showing ]]..m.fuelIndex..[[ to ]]..m.fuelIndex+X-1 ..[[)]]end;return Q end;function GetContentCargo()local Q=\"\"Q=Q..GetHeader(\"Cargo Report\")..[[\n \n ]]return Q end;function GetContentAGG()local Q=\"\"Q=Q..GetHeader(\"Anti-Grav Control\")..[[\n \n ]]return Q end;function GetContentMap()local Q=\"\"Q=Q..GetHeader(\"Map Overview\")..[[\n \n ]]return Q end;function GetContentTime()local Q=\"\"Q=Q..GetHeader(\"Time\")..epochTime()Q=Q..[[\n \n \n \n \n \n \n \n \n \n \n \n \n ]]return Q end;function GetContentSettings1()local Q=\"\"Q=Q..GetHeader(\"Settings\")..[[]]if BackgroundMode==\"\"then Q=Q..[[Activate background]]else Q=Q..[[Deactivate background (']]..BackgroundMode..[[', ]]..string.format(\"%.0f\",BackgroundModeOpacity*100)..[[%)]]end;Q=Q..[[\n \n Previous background\n \n Next background\n\n \n Decrease Opacity\n \n Increase Opacity\n ]]Q=Q..[[]]..[[Reset background and all colors]]Q=Q..[[]]..[[]]..[[]]..[[Select and change any of the ]]..#colorIDTable..[[ HUD colors]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..colorIDTable[colorIDIndex].desc..[[]]..[[]]..[[Current color]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[#]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,1,1)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,2,2)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,3,3)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,4,4)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,5,5)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,6,6)..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[New color]]..[[]]..[[Apply new color]]..[[]]..[[Reset]]..[[]]Q=Q..[[]]..[[]]..[[]]..[[Explanation / Hints]]..[[Coming soon.]]Q=Q..[[]]if SimulationMode==true then Q=Q..[[Simulating Damage to elements]]AddClickArea(\"settings1\",{id=\"ToggleSimulation\",mode=\"settings1\",x1=940,x2=1850,y1=919,y2=969})else Q=Q..[[Simulate Damage to elements]]AddClickArea(\"settings1\",{id=\"ToggleSimulation\",mode=\"settings1\",x1=940,x2=1850,y1=919,y2=969})end;return Q end;function GetContentStartup()local Q=\"\"Q=Q..GetElementLogo(812,380,\"f\",\"f\",\"f\")if YourShipsName==\"Enter here\"then Q=Q..[[Spaceship ID ]]..ShipID..[[]]else Q=Q..[[]]..YourShipsName..[[]]end;if ShowWelcomeMessage==true then Q=Q..[[Greetings, Commander ]]..PlayerName..[[.]]end;if#Warnings>0 then Q=Q..[[Warning: ]]..table.concat(Warnings,\" \")..[[]]end;Q=Q..[[Damage Report v]]..VERSION..[[, by Scion Interstellar, DorianGray - Discord: Dorian Gray#2623. Under GNU Public License 3.0.]]return Q end;function RenderScreen(m,a0)if a0==nil then PrintConsole(\"ERROR: contentToRender is nil.\")unit.exit()end;CreateClickAreasForScreen(m)local Q=\"\"Q=Q..[[\n \n \n ]]Q=Q..a0;if m.mode==\"startup\"then Q=Q..[[]]else Q=Q..[[]]end;Q=Q..[[\n \n ]]Q=Q..[[]]local a1=string.len(Q)m.element.setSVG(Q)end;function RenderScreens(a2,a3)a2=a2 or\"all\"a3=a3 or\"all\"if screens~=nil and#screens>0 then local a4=\"\"local a5=\"\"local a6=\"\"local a7=\"\"local a8=\"\"local a9=\"\"local aa=\"\"local ab=\"\"local ac=\"\"local ad=\"\"local ae=\"\"local af=\"\"for J,m in pairs(screens)do if m.refresh==true then local a0=\"\"if m.mode==\"flight\"and(a2==\"flight\"or a2==\"all\")then if a4==\"\"then a4=GetContentFlight()end;a0=a4 elseif m.mode==\"damage\"and(a2==\"damage\"or a2==\"all\")then if a5==\"\"then a5=GetContentDamage()end;a0=a5 elseif m.mode==\"damageoutline\"and(a2==\"damageoutline\"or a2==\"all\")then if m.submode==\"\"then m.submode=\"top\"screens[J].submode=\"top\"end;if m.submode==\"top\"and(a3==\"top\"or a3==\"all\")then if a6==\"\"then a6=GetContentDamageoutline(m)end;a0=a6 end;if m.submode==\"side\"and(a3==\"side\"or a3==\"all\")then if a7==\"\"then a7=GetContentDamageoutline(m)end;a0=a7 end;if m.submode==\"front\"and(a3==\"front\"or a3==\"all\")then if a8==\"\"then a8=GetContentDamageoutline(m)end;a0=a8 end elseif m.mode==\"fuel\"and(a2==\"fuel\"or a2==\"all\")then m=WipeClickAreasForScreen(screens[J])a0=GetContentFuel(m)elseif m.mode==\"cargo\"and(a2==\"cargo\"or a2==\"all\")then if aa==\"\"then aa=GetContentCargo()end;a0=aa elseif m.mode==\"agg\"and(a2==\"agg\"or a2==\"all\")then if ab==\"\"then ab=GetContentAGG()end;a0=ab elseif m.mode==\"map\"and(a2==\"map\"or a2==\"all\")then if ac==\"\"then ac=GetContentMap()end;a0=ac elseif m.mode==\"time\"and(a2==\"time\"or a2==\"all\")then if ad==\"\"then ad=GetContentTime()end;a0=ad elseif m.mode==\"settings1\"and(a2==\"settings1\"or a2==\"all\")then if ae==\"\"then ae=GetContentSettings1()end;a0=ae elseif m.mode==\"startup\"and(a2==\"startup\"or a2==\"all\")then if af==\"\"then af=GetContentStartup()end;a0=af else a0=\"Invalid screen mode. ('\"..m.mode..\"')\"end;if a0~=\"\"then RenderScreen(m,a0)else DrawCenteredText(\"ERROR: No contentToRender delivered for \"..m.mode)PrintConsole(\"ERROR: No contentToRender delivered for \"..m.mode)unit.exit()end;screens[J].refresh=false end end end;if HUDMode==true then system.setScreen(GetContentDamageHUDOutput())system.showScreen(1)else system.showScreen(0)end end;function OnTickData(C)if formerTime+605 or SkillRepairToolOptimization>5 or StatFuelTankOptimization>5 or StatAtmosphericFuelTankHandling>5 or StatSpaceFuelTankHandling>5 or StatRocketFuelTankHandling>5 then PrintConsole(\"ERROR: Talents/stats can only range from 0 to 5. Please set correctly in LUA settings and reactivate script.\")unit.exit()end;if screens==nil or#screens==0 then HUDMode=true;PrintConsole(\"Warning: No screens connected. Entering HUD mode only.\")end;OnTickData(true)unit.setTimer('UpdateData',UpdateDataInterval)unit.setTimer('UpdateHighlight',HighlightBlinkingInterval)",
- "filter": {
- "args": [],
- "signature": "start()",
- "slotKey": "-1"
- },
- "key": "13"
- },
- {
- "code": "ActionUp()",
- "filter": {
- "args": [
- {
- "value": "up"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "14"
- },
- {
- "code": "ActionDown()",
- "filter": {
- "args": [
- {
- "value": "down"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "15"
- },
- {
- "code": "ActionStrafeLeft()",
- "filter": {
- "args": [
- {
- "value": "strafeleft"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "16"
- },
- {
- "code": "ActionStrafeRight()",
- "filter": {
- "args": [
- {
- "value": "straferight"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "17"
- },
- {
- "code": "KeyCTRLPressed = true",
- "filter": {
- "args": [
- {
- "value": "brake"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "18"
- },
- {
- "code": "KeyCTRLPressed = false",
- "filter": {
- "args": [
- {
- "value": "brake"
- }
- ],
- "signature": "actionStop(action)",
- "slotKey": "-2"
- },
- "key": "19"
- },
- {
- "code": "ActionOption1()",
- "filter": {
- "args": [
- {
- "value": "option1"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "20"
- },
- {
- "code": "ActionOption2()",
- "filter": {
- "args": [
- {
- "value": "option2"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "21"
- },
- {
- "code": "ActionOption3()",
- "filter": {
- "args": [
- {
- "value": "option3"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "22"
- },
- {
- "code": "ActionOption4()",
- "filter": {
- "args": [
- {
- "value": "option4"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "23"
- },
- {
- "code": "ActionOption9()",
- "filter": {
- "args": [
- {
- "value": "option9"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "24"
- },
- {
- "code": "ActionOption8()",
- "filter": {
- "args": [
- {
- "value": "option8"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "25"
- }
- ],
- "methods": [],
- "events": []
-}
\ No newline at end of file
diff --git a/versions/DamageReport_3_04.conf b/versions/DamageReport_3_04.conf
deleted file mode 100644
index 48b8185..0000000
--- a/versions/DamageReport_3_04.conf
+++ /dev/null
@@ -1,452 +0,0 @@
-{
- "slots": {
- "0": {
- "name": "slot1",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "1": {
- "name": "slot2",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "2": {
- "name": "slot3",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "3": {
- "name": "slot4",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "4": {
- "name": "slot5",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "5": {
- "name": "slot6",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "6": {
- "name": "slot7",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "7": {
- "name": "slot8",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "8": {
- "name": "slot9",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "9": {
- "name": "slot10",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-1": {
- "name": "unit",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-2": {
- "name": "system",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-3": {
- "name": "library",
- "type": {
- "events": [],
- "methods": []
- }
- }
- },
- "handlers": [
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "0"
- },
- "key": "0"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "2"
- },
- "key": "1"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "3"
- },
- "key": "2"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "4"
- },
- "key": "3"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "5"
- },
- "key": "4"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "6"
- },
- "key": "5"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "7"
- },
- "key": "6"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "8"
- },
- "key": "7"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "9"
- },
- "key": "8"
- },
- {
- "code": "function GenerateCommaValue(a,b,c)b=b or false;c=c or 1;local d=a;if b==true then if string.len(a)>=4 then d=string.format(\"%.\"..c..\"fk\",a/1000)else d=string.format(\"%.\"..c..\"f\",a)end else while true do d,k=string.gsub(d,\"^(-?%d+)(%d%d%d)\",'%1,%2')if k==0 then break end end end;return d end;function PrintConsole(e,f)f=f or false;if f then system.print(\"------------------------------------------------------------------------\")end;system.print(e)if f then system.print(\"------------------------------------------------------------------------\")end end;function DrawCenteredText(e)if screens~=nil and#screens>0 then for g=1,#screens,1 do screens[g].element.setCenteredText(e)end end end;function ClearConsole()for g=1,10,1 do PrintConsole()end end;function SwitchScreens(h)h=h or\"on\"if screens~=nil and#screens>0 then for g=1,#screens,1 do if h==\"on\"then screens[g].element.clear()screens[g].element.activate()screens[g].active=true else screens[g].element.clear()screens[g].element.deactivate()screens[g].active=false end end end end;function GetSecondsString(i)local i=tonumber(i)if i==nil or i<=0 then return\"-\"else days=string.format(\"%2.f\",math.floor(i/(3600*24)))hours=string.format(\"%2.f\",math.floor(i/3600-days*24))mins=string.format(\"%2.f\",math.floor(i/60-hours*60-days*24*60))secs=string.format(\"%2.f\",math.floor(i-hours*3600-days*24*60*60-mins*60))str=\"\"if tonumber(days)>0 then str=str..days..\"d \"end;if tonumber(hours)>0 then str=str..hours..\"h \"end;if tonumber(mins)>0 then str=str..mins..\"m \"end;if tonumber(secs)>0 then str=str..secs..\"s\"end;return str end end;function replace_char(j,str,l)return str:sub(1,j-1)..l..str:sub(j+1)end;function epochTime()function rZ(m)if string.len(m)<=1 then return\"0\"..m else return m end end;function dPoint(n)if not(n==math.floor(n))then return true else return false end end;function lYear(year)if not dPoint(year/4)then if dPoint(year/100)then return true else if not dPoint(year/400)then return true else return false end end else return false end end;local o=5;local p=3600;local q=86400;local r=31536000;local s=31622400;local t=2419200;local g=2505600;local u=2592000;local k=2678400;local w={4,6,9,11}local x={1,3,5,7,8,10,12}local y=0;local z=1506816000;local A=system.getTime()_G[\"formerTime\"]=A;if AddSummertimeHour==true then A=A+3600 end;now=math.floor(A+z)year=1970;secs=0;y=0;while secs+s]]..hour..\":\"..minute..[[]]..[[]]..year..\"/\"..month..\"/\"..day..[[]]end;function ToggleHUD()if HUDMode==true then HUDMode=false;forceDamageRedraw=true;hudSelectedIndex=0;highlightID=0;HideHighlight()SetRefresh()RenderScreens()else HUDMode=true;forceDamageRedraw=true;hudSelectedIndex=0;highlightID=0;HideHighlight()SetRefresh()RenderScreens()end end;function HudDeselectElement()hudSelectedIndex=0;hudStartIndex=1;highlightID=0;HideHighlight()if HUDMode==true then SetRefresh(\"damage\")SetRefresh(\"damageoutline\")RenderScreens()end end;function ChangeHudSelectedElement(B)if HUDMode==true and#rE>0 then hudSelectedIndex=hudSelectedIndex+B;if hudSelectedIndex<1 then hudSelectedIndex=1 elseif hudSelectedIndex>#rE then hudSelectedIndex=#rE end;if hudSelectedIndex>9 then hudStartIndex=hudSelectedIndex-9 end;if hudSelectedIndex~=0 then highlightID=rE[hudSelectedIndex].id;if highlightID~=nil and highlightID~=0 then HideHighlight()elementPosition=vec3(rE[hudSelectedIndex].pos)highlightX=elementPosition.x-coreWorldOffset;highlightY=elementPosition.y-coreWorldOffset;highlightZ=elementPosition.z-coreWorldOffset;highlightOn=true;ShowHighlight()end end;SetRefresh(\"damage\")SetRefresh(\"damageoutline\")RenderScreens()end end;function HideHighlight()if#hudArrowSticker>0 then for g in pairs(hudArrowSticker)do core.deleteSticker(hudArrowSticker[g])end;hudArrowSticker={}end end;function ShowHighlight()if highlightOn==true and highlightID>0 then table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX+2,highlightY,highlightZ,\"north\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX,highlightY-2,highlightZ,\"east\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX-2,highlightY,highlightZ,\"south\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX,highlightY+2,highlightZ,\"west\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX,highlightY,highlightZ-2,\"up\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX,highlightY,highlightZ+2,\"down\"))end end;function ToggleHighlight()if highlightOn==true then highlightOn=false;HideHighlight()else highlightOn=true;ShowHighlight()end end;function SortDamageTables()table.sort(damagedElements,function(m,n)return m.missinghp>n.missinghp end)table.sort(brokenElements,function(m,n)return m.maxhp>n.maxhp end)end;function getScraps(C,D)D=D or false;C=C-SkillRepairToolOptimization*0.05*C;local E=math.ceil(C/(10*5^(ScrapTier-1)))if D==true then return GenerateCommaValue(string.format(\"%.0f\",E),false)else return E end end;function getRepairTime(C,F)F=F or false;C=C-SkillRepairToolOptimization*0.05*C;local E=math.ceil(C/ScrapTierRepairTimes[ScrapTier])E=E-SkillRepairToolEfficiency*0.1*E;if F==true then return GetSecondsString(string.format(\"%.0f\",E))else return E end end;function UpdateDataDamageoutline()dmgoElements={}for g,G in ipairs(brokenElements)do if#dmgoElementsShipXmax then ShipXmax=H end;if I>ShipYmax then ShipYmax=I end;if J>ShipZmax then ShipZmax=J end;table.insert(dmgoElements,{id=G.id,type=\"b\",size=G.maxhp,x=H,y=I,z=J,xp=0,yp=0,zp=0,u=0,v=0})end end;if#dmgoElementsShipXmax then ShipXmax=H end;if I>ShipYmax then ShipYmax=I end;if J>ShipZmax then ShipZmax=J end;table.insert(dmgoElements,{id=G.id,type=\"d\",size=G.maxhp,x=H,y=I,z=J,xp=0,yp=0,zp=0,u=0,v=0})end end end;if#dmgoElementsShipXmax then ShipXmax=H end;if I>ShipYmax then ShipYmax=I end;if J>ShipZmax then ShipZmax=J end;table.insert(dmgoElements,{id=G.id,type=\"h\",size=G.maxhp,x=H,y=I,z=J,xp=0,yp=0,zp=0,u=0,v=0})end end end;ShipX=math.abs(ShipXmax-ShipXmin)ShipY=math.abs(ShipYmax-ShipYmin)ShipZ=math.abs(ShipZmax-ShipZmin)for g,G in ipairs(dmgoElements)do dmgoElements[g].xp=math.abs(100/(ShipXmax-ShipXmin)*(G.x-ShipXmin))dmgoElements[g].yp=math.abs(100/(ShipYmax-ShipYmin)*(G.y-ShipYmin))dmgoElements[g].zp=math.abs(100/(ShipZmax-ShipZmin)*(G.z-ShipZmin))end end;function UpdateViewDamageoutline(K)UFrame=40;VFrame=40;UStart=20+UFrame;VStart=180+VFrame;UDim=1880-2*UFrame;VDim=840-2*VFrame;if K.submode==\"top\"then if DMGOStretch==false then local L=UDim/(ShipYmax-ShipYmin)local M=VDim/(ShipXmax-ShipXmin)if L>=M then local N=L/M;local O=math.floor(UDim/N)UStart=UStart+(UDim-O)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100/N*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100*G.xp+VStart)end else local N=M/L;local P=math.floor(VDim/N)VStart=VStart+(VDim-P)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100/N*G.xp+VStart)end end else for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100*G.xp+VStart)end end elseif K.submode==\"front\"then if DMGOStretch==false then local L=UDim/(ShipXmax-ShipXmin)local M=VDim/(ShipZmax-ShipZmin)if L>=M then local N=L/M;local O=math.floor(UDim/N)UStart=UStart+(UDim-O)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100/N*G.xp+UStart)dmgoElements[g].v=math.floor(VDim/100*(100-G.zp)+VStart)end else local N=M/L;local P=math.floor(VDim/N)VStart=VStart+(VDim-P)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.xp+UStart)dmgoElements[g].v=math.floor(VDim/100/N*(100-G.zp)+VStart)end end else for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.xp+UStart)dmgoElements[g].v=math.floor(VDim/100*(100-G.zp)+VStart)end end elseif K.submode==\"side\"then if DMGOStretch==false then local L=UDim/(ShipYmax-ShipYmin)local M=VDim/(ShipXmax-ShipZmin)if L>=M then local N=L/M;local O=math.floor(UDim/N)UStart=UStart+(UDim-O)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100/N*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100*(100-G.zp)+VStart)end else local N=M/L;local P=math.floor(VDim/N)VStart=VStart+(VDim-P)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100/N*(100-G.zp)+VStart)end end else for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100*(100-G.zp)+VStart)end end else DrawCenteredText(\"ERROR: non-existing DMGO mode set.\")PrintConsole(\"ERROR: non-existing DMGO mode set.\")unit.exit()end end;function GetDamageoutlineShip()local e=\"\"for g,G in ipairs(dmgoElements)do local Q=\"\"local R=1;if G.type==\"h\"then Q=\"ch\"elseif G.type==\"d\"then Q=\"cw\"else Q=\"cc\"end;if G.id==highlightID then Q=\"f2\"end;if G.size>0 and G.size<1000 then R=5 elseif G.size>=1000 and G.size<2000 then R=8 elseif G.size>=2000 and G.size<5000 then R=12 elseif G.size>=5000 and G.size<10000 then R=15 elseif G.size>=10000 and G.size<20000 then R=20 elseif G.size>=20000 then R=30 end;e=e..[[]]if G.id==highlightID then e=e..[[]]e=e..[[]]end end;return e end;function GetContentClickareas(K)local e=\"\"if K~=nil and K.ClickAreas~=nil and#K.ClickAreas>0 then for g,S in ipairs(K.ClickAreas)do e=e..[[]]end end;return e end;function GetElement1(H,I,T,U)H=H or 0;I=I or 0;T=T or 600;U=U or 600;local e=\"\"e=e..[[\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ]]return e end;function GetElement2(H,I)H=H or 0;I=I or 0;local e=\"\"e=e..[[]]return e end;function GetElementLogo(H,I,V,W,X)H=H or 812;I=I or 380;V=V or\"f\"W=W or\"f2\"X=X or\"f3\"local e=\"\"e=e..[[\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ]]return e end;function GetHeader(Y)Y=Y or\"ERROR: UNDEFINED\"local e=\"\"e=e..[[\n ]]..Y..[[]]return e end;function GetContentBackground(Z,_)bgColor=ColorBackgroundPattern;local e=\"\"if Z==\"dots\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' viewBox='0 0 4 4'%3E%3Cpath fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' d='M1 3h1v1H1V3zm2-2h1v1H3V1z'%3E%3C/path%3E%3C/svg%3E\");]]elseif Z==\"rain\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='12' height='16' viewBox='0 0 12 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 .99C4 .445 4.444 0 5 0c.552 0 1 .45 1 .99v4.02C6 5.555 5.556 6 5 6c-.552 0-1-.45-1-.99V.99zm6 8c0-.546.444-.99 1-.99.552 0 1 .45 1 .99v4.02c0 .546-.444.99-1 .99-.552 0-1-.45-1-.99V8.99z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E\");]]elseif Z==\"plus\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E\");]]elseif Z==\"signal\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='84' height='48' viewBox='0 0 84 48' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h12v6H0V0zm28 8h12v6H28V8zm14-8h12v6H42V0zm14 0h12v6H56V0zm0 8h12v6H56V8zM42 8h12v6H42V8zm0 16h12v6H42v-6zm14-8h12v6H56v-6zm14 0h12v6H70v-6zm0-16h12v6H70V0zM28 32h12v6H28v-6zM14 16h12v6H14v-6zM0 24h12v6H0v-6zm0 8h12v6H0v-6zm14 0h12v6H14v-6zm14 8h12v6H28v-6zm-14 0h12v6H14v-6zm28 0h12v6H42v-6zm14-8h12v6H56v-6zm0-8h12v6H56v-6zm14 8h12v6H70v-6zm0 8h12v6H70v-6zM14 24h12v6H14v-6zm14-8h12v6H28v-6zM14 8h12v6H14V8zM0 8h12v6H0V8z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E\");]]elseif Z==\"deathstar\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='105' viewBox='0 0 80 105'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M20 10a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm15 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zM20 75a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zm30-65a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm0 65a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zM35 10a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zM5 45a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zm60 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10z' /%3E%3C/g%3E%3C/g%3E%3C/svg%3E\");]]elseif Z==\"diamond\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='32' viewBox='0 0 16 32'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath fill-rule='evenodd' d='M0 24h4v2H0v-2zm0 4h6v2H0v-2zm0-8h2v2H0v-2zM0 0h4v2H0V0zm0 4h2v2H0V4zm16 20h-6v2h6v-2zm0 4H8v2h8v-2zm0-8h-4v2h4v-2zm0-20h-6v2h6V0zm0 4h-4v2h4V4zm-2 12h2v2h-2v-2zm0-8h2v2h-2V8zM2 8h10v2H2V8zm0 8h10v2H2v-2zm-2-4h14v2H0v-2zm4-8h6v2H4V4zm0 16h6v2H4v-2zM6 0h2v2H6V0zm0 24h2v2H6v-2z'/%3E%3C/g%3E%3C/svg%3E\");]]elseif Z==\"hexagon\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='49' viewBox='0 0 28 49'%3E%3Cg fill-rule='evenodd'%3E%3Cg id='hexagons' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='nonzero'%3E%3Cpath d='M13.99 9.25l13 7.5v15l-13 7.5L1 31.75v-15l12.99-7.5zM3 17.9v12.7l10.99 6.34 11-6.35V17.9l-11-6.34L3 17.9zM0 15l12.98-7.5V0h-2v6.35L0 12.69v2.3zm0 18.5L12.98 41v8h-2v-6.85L0 35.81v-2.3zM15 0v7.5L27.99 15H28v-2.31h-.01L17 6.35V0h-2zm0 49v-8l12.99-7.5H28v2.31h-.01L17 42.15V49h-2z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E\");]]elseif Z==\"capsule\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='32' height='26' viewBox='0 0 32 26' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M14 0v3.994C14 7.864 10.858 11 7 11c-3.866 0-7-3.138-7-7.006V0h2v4.005C2 6.765 4.24 9 7 9c2.756 0 5-2.236 5-4.995V0h2zm0 26v-5.994C14 16.138 10.866 13 7 13c-3.858 0-7 3.137-7 7.006V26h2v-6.005C2 17.235 4.244 15 7 15c2.76 0 5 2.236 5 4.995V26h2zm2-18.994C16 3.136 19.142 0 23 0c3.866 0 7 3.138 7 7.006v9.988C30 20.864 26.858 24 23 24c-3.866 0-7-3.138-7-7.006V7.006zm2-.01C18 4.235 20.244 2 23 2c2.76 0 5 2.236 5 4.995v10.01C28 19.765 25.756 22 23 22c-2.76 0-5-2.236-5-4.995V6.995z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E\");]]elseif Z==\"diagonal\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='6' height='6' viewBox='0 0 6 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'%3E%3Cpath d='M5 0h1L0 6V5zM6 5v1H5z'/%3E%3C/g%3E%3C/svg%3E\");]]end;return e end;function GetContentDamageHUDOutput()local a0=300;local a1=165;if#damagedElements>0 or#brokenElements>0 then a1=510 end;local e=\"\"e=e..[[\n \n ]]e=e..[[]]..[[]]..[[]]..[[]]..(YourShipsName==\"Enter here\"and\"Ship ID \"..ShipID or YourShipsName)..[[]]..[[]]if#brokenElements>0 then e=e..[[]]elseif#damagedElements>0 then e=e..[[]]else e=e..[[]]end;if#damagedElements>0 or#brokenElements>0 then e=e..[[Total Damage]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",totalShipMaxHP-totalShipHP))..[[]]e=e..[[T]]..ScrapTier..[[ Scrap Needed]]..[[]]..getScraps(totalShipMaxHP-totalShipHP,true)..[[]]e=e..[[Repair Time]]..[[]]..getRepairTime(totalShipMaxHP-totalShipHP,true)..[[]]e=e..[[]]..[[]]..[[]]..#healthyElements..[[]]..[[]]..[[]]..#damagedElements..[[]]..[[]]..[[]]..#brokenElements..[[]]local u=0;for a2=hudStartIndex,hudStartIndex+9,1 do if rE[a2]~=nil then v=rE[a2]if v.hp>0 then e=e..[[]]..[[]]..string.format(\"%.30s\",v.name)..[[]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",v.missinghp))..[[]]if v.id==highlightID then e=e..[[]]..[[]]..string.format(\"%.30s\",v.name)..[[]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",v.missinghp))..[[]]end else e=e..[[]]..[[]]..string.format(\"%.30s\",v.name)..[[]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",v.missinghp))..[[]]if v.id==highlightID then highlightX=elementPosition.x-coreWorldOffset;highlightY=elementPosition.y-coreWorldOffset;highlightZ=elementPosition.z-coreWorldOffset;e=e..[[]]..[[]]..string.format(\"%.30s\",v.name)..[[]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",v.missinghp))..[[]]end end;u=u+1 end end;e=e..[[]]..[[]]..[[]]..[[]]..[[Up/down arrows to highlight]]..[[CTRL + arrows to move HUD]]..[[Left arrow to toggle HUD Mode]]..[[ALT+1-4 to set Scrap Tier]]..[[ALT+8 to reset HUD position]]..[[ALT+9 to shut script off]]..[[]]..[[]]else e=e..[[]]..OkayCenterMessage..[[]]..[[]]..#healthyElements..[[ elements / ]]..GenerateCommaValue(string.format(\"%.0f\",totalShipMaxHP))..[[ HP.]]..[[]]..[[]]..[[]]..[[]]..[[Left arrow to toggle HUD Mode]]..[[CTRL + arrows to move HUD]]..[[ALT+8 to reset HUD position]]..[[ALT+9 to shut script off]]..[[]]..[[]]end;e=e..[[]]return e end;function GetContentDamageScreen()local a3=\"\"if#damagedElements>0 then local a4=#damagedElements;if a4>DamagePageSize then a4=DamagePageSize end;if CurrentDamagedPage==math.ceil(#damagedElements/DamagePageSize)then a4=#damagedElements%DamagePageSize+12;if a4>12 then a4=a4-12 end end;a3=a3 ..[[]]a3=a3 ..[[]]if UseMyElementNames==true then a3=a3 ..[[Damaged Name]]else a3=a3 ..[[Damaged Type]]end;a3=a3 ..[[HLTHDMG]]a3=a3 ..[[T]]..ScrapTier..[[ SCRREPTIME]]AddClickArea(\"damage\",{id=\"SwitchScrapTier\",mode=\"damage\",x1=650,x2=775,y1=315,y2=360})local g=0;for u=1+(CurrentDamagedPage-1)*DamagePageSize,a4+(CurrentDamagedPage-1)*DamagePageSize,1 do g=g+1;local a5=damagedElements[u]if UseMyElementNames==true then a3=a3 ..[[]]..string.format(\"%.23s\",a5.name)..[[]]else a3=a3 ..[[]]..string.format(\"%.23s\",a5.type)..[[]]end;a3=a3 ..[[]]..a5.percent..[[%]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",a5.missinghp),true)..[[]]..[[]]..getScraps(a5.missinghp,true)..[[]]..[[]]..getRepairTime(a5.missinghp,true)..[[]]..[[]]end;if#damagedElements>DamagePageSize then a3=a3 ..[[Page ]]..CurrentDamagedPage..\" of \"..math.ceil(#damagedElements/DamagePageSize)..[[]]if CurrentDamagedPage\n \n \n ]]AddClickArea(\"damage\",{id=\"DamagedPageDown\",mode=\"damage\",x1=65,x2=260,y1=290+(a4+1)*50,y2=290+50+(a4+1)*50})else DisableClickArea(\"DamagedPageDown\",\"damage\")end;if CurrentDamagedPage>1 then a3=a3 ..[[\n \n \n ]]AddClickArea(\"damage\",{id=\"DamagedPageUp\",mode=\"damage\",x1=750,x2=950,y1=290+(a4+1)*50,y2=290+50+(a4+1)*50})else DisableClickArea(\"DamagedPageUp\",\"damage\")end end end;if#brokenElements>0 then local a6=#brokenElements;if a6>DamagePageSize then a6=DamagePageSize end;if CurrentBrokenPage==math.ceil(#brokenElements/DamagePageSize)then a6=#brokenElements%DamagePageSize+12;if a6>12 then a6=a6-12 end end;a3=a3 ..[[]]a3=a3 ..[[]]if UseMyElementNames==true then a3=a3 ..[[Broken Name]]else a3=a3 ..[[Broken Type]]end;a3=a3 ..[[DMG]]a3=a3 ..[[T]]..ScrapTier..[[ SCRREPTIME]]AddClickArea(\"damage\",{id=\"SwitchScrapTier2\",mode=\"damage\",x1=1570,x2=1690,y1=315,y2=360})local g=0;for u=1+(CurrentBrokenPage-1)*DamagePageSize,a6+(CurrentBrokenPage-1)*DamagePageSize,1 do g=g+1;local a5=brokenElements[u]if UseMyElementNames==true then a3=a3 ..[[]]..string.format(\"%.30s\",a5.name)..[[]]else a3=a3 ..[[]]..string.format(\"%.30s\",a5.type)..[[]]end;a3=a3 ..[[]]..GenerateCommaValue(string.format(\"%.0f\",a5.missinghp),true)..[[]]..[[]]..getScraps(a5.missinghp,true)..[[]]..[[]]..getRepairTime(a5.missinghp,true)..[[]]..[[]]end;if#brokenElements>DamagePageSize then a3=a3 ..[[Page ]]..CurrentBrokenPage..\" of \"..math.ceil(#brokenElements/DamagePageSize)..[[]]if CurrentBrokenPage>1 then a3=a3 ..[[\n \n \n ]]AddClickArea(\"damage\",{id=\"BrokenPageUp\",mode=\"damage\",x1=1665,x2=1865,y1=290+(a6+1)*50,y2=290+50+(a6+1)*50})else DisableClickArea(\"BrokenPageUp\",\"damage\")end;if CurrentBrokenPage\n \n \n ]]AddClickArea(\"damage\",{id=\"BrokenPageDown\",mode=\"damage\",x1=980,x2=1180,y1=290+(a6+1)*50,y2=290+50+(a6+1)*50})else DisableClickArea(\"BrokenPageDown\",\"damage\")end end end;if#damagedElements>0 or#brokenElements>0 then local a7=math.floor(1878/#elementsIdList*#damagedElements)local a8=math.floor(1878/#elementsIdList*#brokenElements)local a9=1878-a7-a8+1;a3=a3 ..[[]]a3=a3 ..[[]]a3=a3 ..[[]]a3=a3 ..[[]]if#damagedElements>0 then a3=a3 ..[[]]..#damagedElements..[[]]end;if#healthyElements>0 then a3=a3 ..[[]]..#healthyElements..[[]]end;if#brokenElements>0 then a3=a3 ..[[]]..#brokenElements..[[]]end;a3=a3 ..[[]]a3=a3 ..[[]]..GenerateCommaValue(string.format(\"%.0f\",totalShipMaxHP-totalShipHP))..[[ HP damage in total ]]..getScraps(totalShipMaxHP-totalShipHP,true)..[[ T]]..ScrapTier..[[ scraps needed. ]]..getRepairTime(totalShipMaxHP-totalShipHP,true)..[[ projected repair time.]]else a3=a3 ..GetElementLogo(812,380,\"ch\",\"ch\",\"ch\")..[[]]..OkayCenterMessage..[[]]..[[]]..#healthyElements..[[ elements stand ]]..GenerateCommaValue(string.format(\"%.0f\",totalShipMaxHP))..[[ HP strong.]]end;forceDamageRedraw=false;return a3 end;function ActionStopengines()ToggleHUD()end;function ActionStrafeRight()if KeyCTRLPressed==true then if HUDShiftU<4000 then HUDShiftU=HUDShiftU+50;SaveToDatabank()RenderScreens()end else HudDeselectElement()end end;function ActionStrafeLeft()if KeyCTRLPressed==true then if HUDShiftU>=50 then HUDShiftU=HUDShiftU-50;SaveToDatabank()RenderScreens()end else ToggleHUD()end end;function ActionDown()if KeyCTRLPressed==true then if HUDShiftV<4000 then HUDShiftV=HUDShiftV+50;SaveToDatabank()RenderScreens()end else ChangeHudSelectedElement(1)end end;function ActionUp()if KeyCTRLPressed==true then if HUDShiftV>=50 then HUDShiftV=HUDShiftV-50;SaveToDatabank()RenderScreens()end else ChangeHudSelectedElement(-1)end end;function ActionOption1()ScrapTier=1;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption2()ScrapTier=2;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption3()ScrapTier=3;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption4()ScrapTier=4;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption8()HUDShiftU=0;HUDShiftV=0;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption9()SaveToDatabank()SwitchScreens(\"off\")unit.exit()end",
- "filter": {
- "args": [],
- "signature": "start()",
- "slotKey": "-1"
- },
- "key": "9"
- },
- {
- "code": "SaveToDatabank()\nSwitchScreens(\"off\")",
- "filter": {
- "args": [],
- "signature": "stop()",
- "slotKey": "-1"
- },
- "key": "10"
- },
- {
- "code": "OnTickData()\n",
- "filter": {
- "args": [
- {
- "value": "UpdateData"
- }
- ],
- "signature": "tick(timerId)",
- "slotKey": "-1"
- },
- "key": "11"
- },
- {
- "code": "ToggleHighlight()",
- "filter": {
- "args": [
- {
- "value": "UpdateHighlight"
- }
- ],
- "signature": "tick(timerId)",
- "slotKey": "-1"
- },
- "key": "12"
- },
- {
- "code": "--[[\n Damage Report 3.04\n A LUA script for Dual Universe\n\n Created By Dorian Gray\n Ingame: DorianGray\n Discord: Dorian Gray#2623\n\n You can find/update this script on GitHub. Explanations, installation and usage information as well as screenshots can be found there too.\n GitHub: https://github.com/DorianTheGrey/DU-DamageReport\n\n GNU Public License 3.0. Use whatever you want, be so kind to leave credit.\n \n Credits & thanks: \n Thanks to NovaQuark for creating the MMO of the century.\n Thanks to Jericho, Dmentia and Archaegeo for learning a lot from their fine scripts.\n Thanks to TheBlacklist for testing and wonderful suggestions.\n SVG patterns by Hero Patterns.\n DU atlas data from Jayle Break.\n \n]]\n\n--[[ 1. USER DEFINED VARIABLES ]]\n\nYourShipsName = \"Enter here\" --export Enter your ship name here if you want it displayed instead of the ship's ID. YOU NEED TO LEAVE THE QUOTATION MARKS.\n\nSkillRepairToolEfficiency = 2 --export Enter (0-5) your talent \"Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency\"\nSkillRepairToolOptimization = 0 --export Enter your talent \"Mining and Inventory -> Equipment Manager -> Repair Tool Optimization\"\n\n-- SkillAtmosphericFuelEfficiency = 0 --export Enter (0-5) your talent \"Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency\"\n-- SkillSpaceFuelEfficiency = 0 --export Enter (0-5) your talent \"Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency\"\n-- SkillRocketFuelEfficiency = 0 --export Enter (0-5) your talent \"Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency\"\n\nStatAtmosphericFuelTankHandling = 3 --export (0-5) Enter the LEVEL OF YOUR PLACED ATMOSPHERIC FUEL TANKS (from the builders talent \"Piloting -> Atmospheric Flight Technician -> Atmospheric Fuel-Tank Handling\")\nStatSpaceFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL SPACE TANKS (from the builders talent \"Piloting -> Atmospheric Engine Technician -> Space Fuel-Tank Handling\")\nStatRocketFuelTankHandling = 1 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL ROCKET TANKS (from the builders talent \"Piloting -> Rocket Scientist -> Rocket Booster Fuel Tank Handling\")\nStatContainerOptimization = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL TANKS \"from the builders talent Mining and Inventory -> Stock Control -> Container Optimization\"\nStatFuelTankOptimization = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL TANKS \"from the builders talent Mining and Inventory -> Stock Control -> Fuel Tank Optimization\"\n\nShowWelcomeMessage = true --export Do you want the welcome message on the start screen with your name?\nAddSummertimeHour = false --export: Is summertime currently enabled in your location? (Adds one hour.)\n\nUpdateDataInterval=1.0;HighlightBlinkingInterval=0.5;ColorPrimary=\"FF6700\"ColorSecondary=\"FFFFFF\"ColorTertiary=\"000000\"ColorHealthy=\"00FF00\"ColorWarning=\"FFFF00\"ColorCritical=\"FF0000\"ColorBackground=\"000000\"ColorBackgroundPattern=\"4F4F4F\"ColorFuelAtmospheric=\"004444\"ColorFuelSpace=\"444400\"ColorFuelRocket=\"440044\"VERSION=3.04;DebugMode=false;DebugRenderClickareas=true;DBData={}core=nil;db=nil;screens={}dscreens={}Warnings={}screenModes={[\"flight\"]={id=\"flight\"},[\"damage\"]={id=\"damage\"},[\"damageoutline\"]={id=\"damageoutline\"},[\"fuel\"]={id=\"fuel\"},[\"cargo\"]={id=\"cargo\"},[\"agg\"]={id=\"agg\"},[\"map\"]={id=\"map\"},[\"time\"]={id=\"time\",activetoggle=\"true\"},[\"settings1\"]={id=\"settings1\"},[\"startup\"]={id=\"startup\"}}backgroundModes={\"deathstar\",\"capsule\",\"rain\",\"signal\",\"hexagon\",\"diagonal\",\"diamond\",\"plus\",\"dots\"}BackgroundMode=\"deathstar\"BackgroundSelected=1;BackgroundModeOpacity=0.25;SaveVars={\"dscreens\",\"ColorPrimary\",\"ColorSecondary\",\"ColorTertiary\",\"ColorHealthy\",\"ColorWarning\",\"ColorCritical\",\"ColorBackground\",\"ColorBackgroundPattern\",\"ScrapTier\",\"HUDMode\",\"SimulationMode\",\"DMGOStretch\",\"HUDShiftU\",\"HUDShiftV\",\"colorIDIndex\",\"colorIDTable\",\"BackgroundMode\",\"BackgroundSelected\",\"BackgroundModeOpacity\"}HUDMode=false;HUDShiftU=0;HUDShiftV=0;hudSelectedIndex=0;hudStartIndex=1;hudArrowSticker={}highlightOn=false;highlightID=0;highlightX=0;highlightY=0;highlightZ=0;SimulationMode=false;OkayCenterMessage=\"All systems nominal.\"CurrentDamagedPage=1;CurrentBrokenPage=1;DamagePageSize=12;ScrapTier=1;totalScraps=0;ScrapTierRepairTimes={10,50,250,1250}coreWorldOffset=0;totalShipHP=0;formerTotalShipHP=-1;totalShipMaxHP=0;totalShipIntegrity=100;elementsId={}elementsIdList={}damagedElements={}brokenElements={}rE={}healthyElements={}typeElements={}ElementCounter=0;UseMyElementNames=true;dmgoElements={}DMGOMaxElements=250;DMGOStretch=false;ShipXmin=99999999;ShipXmax=-99999999;ShipYmin=99999999;ShipYmax=-99999999;ShipZmin=99999999;ShipZmax=-99999999;totalShipMass=0;formerTotalShipMass=-1;formerTime=-1;FuelAtmosphericTanks={}FuelSpaceTanks={}FuelRocketTanks={}FuelAtmosphericTotal=0;FuelSpaceTotal=0;FuelRocketTotal=0;FuelAtmosphericCurrent=0;FuelSpaceTotalCurrent=0;FuelRocketTotalCurrent=0;formerFuelAtmosphericTotal=-1;formerFuelSpaceTotal=-1;formerFuelRocketTotal=-1;hexTable={\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"A\",\"B\",\"C\",\"D\",\"E\",\"F\"}colorIDIndex=1;colorIDTable={[1]={id=\"ColorPrimary\",desc=\"Main HUD Color\",basec=\"FF6700\",newc=\"FF6700\"},[2]={id=\"ColorSecondary\",desc=\"Secondary HUD Color\",basec=\"FFFFFF\",newc=\"FFFFFF\"},[3]={id=\"ColorTertiary\",desc=\"Tertiary HUD Color\",basec=\"000000\",newc=\"000000\"},[4]={id=\"ColorHealthy\",desc=\"Color code for Healthy/Okay\",basec=\"00FF00\",newc=\"00FF00\"},[5]={id=\"ColorWarning\",desc=\"Color code for Damaged/Warning\",basec=\"FFFF00\",newc=\"FFFF00\"},[6]={id=\"ColorCritical\",desc=\"Color code for Broken/Critical\",basec=\"FF0000\",newc=\"FF0000\"},[7]={id=\"ColorBackground\",desc=\"Background Color\",basec=\"000000\",newc=\"000000\"},[8]={id=\"ColorBackgroundPattern\",desc=\"Background Pattern Color\",basec=\"4F4F4F\",newc=\"4F4F4F\"},[9]={id=\"ColorFuelAtmospheric\",desc=\"Color for Atmo Fuel/Elements\",basec=\"004444\",newc=\"004444\"},[10]={id=\"ColorFuelSpace\",desc=\"Color for Space Fuel/Elements\",basec=\"444400\",newc=\"444400\"},[11]={id=\"ColorFuelRocket\",desc=\"Color for Rocket Fuel/Elements\",basec=\"440044\",newc=\"440044\"}}function InitiateSlots()for a,b in pairs(unit)do if type(b)==\"table\"and type(b.export)==\"table\"and b.getElementClass then local c=b.getElementClass():lower()if c:find(\"coreunit\")then core=b;local d=core.getMaxHitPoints()if d>10000 then coreWorldOffset=128 elseif d>1000 then coreWorldOffset=64 elseif d>150 then coreWorldOffset=32 else coreWorldOffset=16 end elseif c=='databankunit'then db=b elseif c==\"screenunit\"then local e=\"startup\"screens[#screens+1]={element=b,id=b.getId(),mode=e,submode=\"\",ClickAreas={},refresh=true,active=false,fuelA=true,fuelS=true,fuelR=true,fuelIndex=1}end end end end;function LoadFromDatabank()if db==nil then return else for f,g in pairs(SaveVars)do if db.hasKey(g)then local h=json.decode(db.getStringValue(g))if h~=nil then if g==\"YourShipsName\"or g==\"AddSummertimeHour\"or g==\"UpdateDataInterval\"or g==\"HighlightBlinkingInterval\"or g==\"SkillRepairToolEfficiency\"or g==\"SkillRepairToolOptimization\"or g==\"SkillAtmosphericFuelEfficiency\"or g==\"SkillSpaceFuelEfficiency\"or g==\"SkillRocketFuelEfficiency\"or g==\"StatAtmosphericFuelTankHandling\"or g==\"StatSpaceFuelTankHandling\"or g==\"StatRocketFuelTankHandling\"then else _G[g]=h end end end end;for i,j in ipairs(screens)do for k,l in ipairs(dscreens)do if screens[i].id==dscreens[k].id then screens[i].mode=dscreens[k].mode;screens[i].submode=dscreens[k].submode;screens[i].active=dscreens[k].active;screens[i].refresh=true;screens[i].fuelA=dscreens[k].fuelA;screens[i].fuelS=dscreens[k].fuelS;screens[i].fuelR=dscreens[k].fuelR;screens[i].fuelIndex=dscreens[k].fuelIndex end end end end end;function SaveToDatabank()if db==nil then return else dscreens={}for i,m in ipairs(screens)do dscreens[i]={}dscreens[i].id=m.id;dscreens[i].mode=m.mode;dscreens[i].submode=m.submode;dscreens[i].active=m.active;dscreens[i].fuelA=m.fuelA;dscreens[i].fuelS=m.fuelS;dscreens[i].fuelR=m.fuelR;dscreens[i].fuelIndex=m.fuelIndex end;db.clear()for f,g in pairs(SaveVars)do db.setStringValue(g,json.encode(_G[g]))end end end;function InitiateScreens()if screens~=nil and#screens>0 then for i=1,#screens,1 do screens[i]=CreateClickAreasForScreen(screens[i])end end end;function UpdateTypeData()FuelAtmosphericTanks={}FuelSpaceTanks={}FuelRocketTanks={}FuelAtmosphericTotal=0;FuelAtmosphericCurrent=0;FuelSpaceTotal=0;FuelSpaceCurrent=0;FuelRocketCurrent=0;FuelRocketTotal=0;local n=4;local o=6;local p=0.8;if StatContainerOptimization>0 then n=n-0.05*StatContainerOptimization*n;o=o-0.05*StatContainerOptimization*o;p=p-0.05*StatContainerOptimization*p end;if StatFuelTankOptimization>0 then n=n-0.05*StatFuelTankOptimization*n;o=o-0.05*StatFuelTankOptimization*o;p=p-0.05*StatFuelTankOptimization*p end;for i,q in ipairs(typeElements)do local r=core.getElementNameById(q)or\"\"local s=core.getElementTypeById(q)or\"\"local t=core.getElementPositionById(q)or 0;local u=core.getElementHitPointsById(q)or 0;local v=core.getElementMaxHitPointsById(q)or 0;local w=core.getElementMassById(q)or 0;local x=\"\"local y=0;local z=0;local A=0;local B=0;if s==\"atmospheric fuel-tank\"then if v>10000 then x=\"L\"z=5480;y=12800 elseif v>1300 then x=\"M\"z=988.67;y=1600 elseif v>150 then x=\"S\"z=182.67;y=400 else x=\"XS\"z=35.03;y=100 end;if StatAtmosphericFuelTankHandling>0 then y=0.2*StatAtmosphericFuelTankHandling*y+y end;A=w-z;if A<=10 then A=0 end;B=string.format(\"%.0f\",A/n)cPercent=string.format(\"%.1f\",math.floor(100/y*tonumber(B)))table.insert(FuelAtmosphericTanks,{type=1,id=q,name=r,maxhp=v,hp=GetHPforElement(q),pos=t,size=x,mass=z,vol=y,cvol=B,percent=cPercent})if u>0 then FuelAtmosphericCurrent=FuelAtmosphericCurrent+B end;FuelAtmosphericTotal=FuelAtmosphericTotal+y elseif s==\"space fuel-tank\"then if v>10000 then x=\"L\"z=5480;y=12800 elseif v>1300 then x=\"M\"z=988.67;y=1600 else x=\"S\"z=182.67;y=400 end;if StatSpaceFuelTankHandling>0 then y=0.2*StatSpaceFuelTankHandling*y+y end;A=w-z;if A<=10 then A=0 end;B=string.format(\"%.0f\",A/o)cPercent=string.format(\"%.1f\",100/y*tonumber(B))table.insert(FuelSpaceTanks,{type=2,id=q,name=r,maxhp=v,hp=GetHPforElement(q),pos=t,size=x,mass=z,vol=y,cvol=B,percent=cPercent})if u>0 then FuelSpaceCurrent=FuelSpaceCurrent+B end;FuelSpaceTotal=FuelSpaceTotal+y elseif s==\"rocket fuel-tank\"then if v>65000 then x=\"L\"z=25740;y=50000 elseif v>6000 then x=\"M\"z=4720;y=6400 elseif v>700 then x=\"S\"z=886.72;y=800 else x=\"XS\"z=173.42;y=400 end;if StatRocketFuelTankHandling>0 then y=0.2*StatRocketFuelTankHandling*y+y end;A=w-z;if A<=10 then A=0 end;B=string.format(\"%.0f\",A/p)cPercent=string.format(\"%.1f\",100/y*tonumber(B))table.insert(FuelRocketTanks,{type=3,id=q,name=r,maxhp=v,hp=GetHPforElement(q),pos=t,size=x,mass=z,vol=y,cvol=B,percent=cPercent})if u>0 then FuelRocketCurrent=FuelRocketCurrent+B end;FuelRocketTotal=FuelRocketTotal+y end end;if FuelAtmosphericCurrent~=formerFuelAtmosphericCurrent then SetRefresh(\"fuel\")formerFuelAtmosphericCurrent=FuelAtmosphericCurrent end;if FuelSpaceCurrent~=formerFuelSpaceCurrent then SetRefresh(\"fuel\")formerFuelSpaceCurrent=FuelSpaceCurrent end;if FuelRocketCurrent~=formerFuelRocketCurrent then SetRefresh(\"fuel\")formerFuelRocketCurrent=FuelRocketCurrent end end;function UpdateDamageData(C)C=C or false;if SimulationActive==true then return end;local formerTotalShipHP=totalShipHP;totalShipHP=0;totalShipMaxHP=0;totalShipIntegrity=100;damagedElements={}brokenElements={}healthyElements={}ElementCounter=0;elementsIdList=core.getElementIdList()for i,q in pairs(elementsIdList)do ElementCounter=ElementCounter+1;local r=core.getElementNameById(q)local s=core.getElementTypeById(q)local t=core.getElementPositionById(q)local u=core.getElementHitPointsById(q)local v=core.getElementMaxHitPointsById(q)if SimulationMode==true then SimulationActive=true;local D=math.random(0,10)if D<2 and#brokenElements<30 then u=0 elseif D>=2 and D<4 and#damagedElements<30 then u=math.random(1,math.ceil(v))else u=v end end;totalShipHP=totalShipHP+u;totalShipMaxHP=totalShipMaxHP+v;if v-u>constants.epsilon then if u>0 then table.insert(damagedElements,{id=q,name=r,type=s,counter=ElementCounter,hp=u,maxhp=v,missinghp=v-u,percent=math.ceil(100/v*u),pos=t})else table.insert(brokenElements,{id=q,name=r,type=s,counter=ElementCounter,hp=u,maxhp=v,missinghp=v-u,percent=0,pos=t})end else table.insert(healthyElements,{id=q,name=r,type=s,counter=ElementCounter,hp=u,maxhp=v,pos=t})if q==highlightID then highlightID=0;highlightOn=false;HideHighlight()hudSelectedIndex=0 end end;if C==true then if s==\"atmospheric fuel-tank\"or s==\"space fuel-tank\"or s==\"rocket fuel-tank\"then table.insert(typeElements,q)end end end;SortDamageTables()rE={}if#brokenElements>0 then for f,j in ipairs(brokenElements)do table.insert(rE,{id=j.id,missinghp=j.missinghp,hp=j.hp,name=j.name,type=j.type,pos=j.pos})end end;if#damagedElements>0 then for f,j in ipairs(damagedElements)do table.insert(rE,{id=j.id,missinghp=j.missinghp,hp=j.hp,name=j.name,type=j.type,pos=j.pos})end end;if#rE>0 then table.sort(rE,function(E,F)return E.missinghp>F.missinghp end)end;totalShipIntegrity=string.format(\"%2.0f\",100/totalShipMaxHP*totalShipHP)if formerTotalShipHP~=totalShipHP then forceDamageRedraw=true;formerTotalShipHP=totalShipHP else forceDamageRedraw=false end end;function GetHPforElement(q)for i,j in ipairs(brokenElements)do if j.id==q then return 0 end end;for i,j in ipairs(damagedElements)do if j.id==q then return j.hp end end;for i,j in ipairs(healthyElements)do if j.id==q then return j.maxhp end end end;function UpdateClickArea(G,H,I)for i,m in ipairs(screens)do for J,j in pairs(screens[i].ClickAreas)do if j.id==G and j.mode==I then screens[i].ClickAreas[J]=H end end end end;function AddClickArea(I,H)for i,m in ipairs(screens)do if screens[i].mode==I then table.insert(screens[i].ClickAreas,H)end end end;function AddClickAreaForScreenID(K,H)for i,m in ipairs(screens)do if screens[i].id==K then table.insert(screens[i].ClickAreas,H)end end end;function DisableClickArea(G,I)UpdateClickArea(G,{id=G,mode=I,x1=-1,x2=-1,y1=-1,y2=-1})end;function SetRefresh(I,L)I=I or\"all\"L=L or\"all\"if screens~=nil and#screens>0 then for i=1,#screens,1 do if screens[i].mode==I or I==\"all\"then if screens[i].submode==L or L==\"all\"then screens[i].refresh=true end end end end end;function WipeClickAreasForScreen(m)m.ClickAreas={}return m end;function CreateBaseClickAreas(m)table.insert(m.ClickAreas,{mode=\"all\",id=\"ToggleHudMode\",x1=1537,x2=1728,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"damage\",x1=193,x2=384,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"damageoutline\",x1=385,x2=576,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"fuel\",x1=577,x2=768,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"time\",x1=0,x2=192,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"settings1\",x1=1729,x2=1920,y1=1015,y2=1075})return m end;function CreateClickAreasForScreen(m)if m==nil then return{}end;if m.mode==\"flight\"then elseif m.mode==\"damage\"then table.insert(m.ClickAreas,{mode=\"damage\",id=\"ToggleElementLabel\",x1=70,x2=425,y1=325,y2=355})table.insert(m.ClickAreas,{mode=\"damage\",id=\"ToggleElementLabel2\",x1=980,x2=1400,y1=325,y2=355})elseif m.mode==\"damageoutline\"then table.insert(m.ClickAreas,{mode=\"damageoutline\",id=\"DMGOChangeView\",param=\"top\",x1=60,x2=439,y1=150,y2=200})table.insert(m.ClickAreas,{mode=\"damageoutline\",id=\"DMGOChangeView\",param=\"side\",x1=440,x2=824,y1=150,y2=200})table.insert(m.ClickAreas,{mode=\"damageoutline\",id=\"DMGOChangeView\",param=\"front\",x1=825,x2=1215,y1=150,y2=200})table.insert(m.ClickAreas,{mode=\"damageoutline\",id=\"DMGOChangeStretch\",x1=1530,x2=1580,y1=150,y2=200})elseif m.mode==\"fuel\"then elseif m.mode==\"cargo\"then elseif m.mode==\"agg\"then elseif m.mode==\"map\"then elseif m.mode==\"time\"then elseif m.mode==\"settings1\"then table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ToggleBackground\",x1=75,x2=860,y1=170,y2=215})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"PreviousBackground\",x1=75,x2=460,y1=235,y2=285})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"NextBackground\",x1=480,x2=860,y1=235,y2=285})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"DecreaseOpacity\",x1=75,x2=460,y1=300,y2=350})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"IncreaseOpacity\",x1=480,x2=860,y1=300,y2=350})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ResetColors\",x1=75,x2=860,y1=370,y2=415})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"PreviousColorID\",x1=90,x2=140,y1=500,y2=550})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"NextColorID\",x1=795,x2=845,y1=500,y2=550})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"1\",x1=210,x2=290,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"2\",x1=300,x2=380,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"3\",x1=385,x2=465,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"4\",x1=470,x2=550,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"5\",x1=560,x2=640,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"6\",x1=645,x2=725,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"1\",x1=210,x2=290,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"2\",x1=300,x2=380,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"3\",x1=385,x2=465,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"4\",x1=470,x2=550,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"5\",x1=560,x2=640,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"6\",x1=645,x2=725,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ResetPosColor\",x1=160,x2=340,y1=885,y2=935})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ApplyPosColor\",x1=355,x2=780,y1=885,y2=935})elseif m.mode==\"startup\"then end;m=CreateBaseClickAreas(m)return m end;function CheckClick(M,N,O)M=M*1920;N=N*1120;O=O or\"\"HitPayload={}if screens~=nil and#screens>0 then for i=1,#screens,1 do if screens[i].active==true and screens[i].element.getMouseX()~=-1 and screens[i].element.getMouseY()~=-1 then if O==\"\"then for J,j in pairs(screens[i].ClickAreas)do if j~=nil and M>=j.x1 and M<=j.x2 and N>=j.y1 and N<=j.y2 then O=j.id;HitPayload=j;break end end end;if O==\"ButtonPress\"then if screens[i].mode==HitPayload.param then screens[i].mode=\"startup\"else screens[i].mode=HitPayload.param end;if screens[i].mode==\"damageoutline\"then if screens[i].submode==\"\"then screens[i].submode=\"top\"end end;screens[i].refresh=true;screens[i].ClickAreas={}SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"ToggleBackground\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundMode==\"\"then BackgroundSelected=1;BackgroundMode=backgroundModes[BackgroundSelected]else BackgroundSelected=1;BackgroundMode=\"\"end;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"PreviousBackground\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundMode==\"\"then BackgroundSelected=1;BackgroundMode=backgroundModes[BackgroundSelected]else if BackgroundSelected<=1 then BackgroundSelected=#backgroundModes else BackgroundSelected=BackgroundSelected-1 end;BackgroundMode=backgroundModes[BackgroundSelected]end;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"NextBackground\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundMode==\"\"then BackgroundSelected=1;BackgroundMode=backgroundModes[BackgroundSelected]else if BackgroundSelected>=#backgroundModes then BackgroundSelected=1 else BackgroundSelected=BackgroundSelected+1 end;BackgroundMode=backgroundModes[BackgroundSelected]end;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"DecreaseOpacity\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundModeOpacity>0.1 then BackgroundModeOpacity=BackgroundModeOpacity-0.05;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()end elseif O==\"IncreaseOpacity\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundModeOpacity<1.0 then BackgroundModeOpacity=BackgroundModeOpacity+0.05;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()end elseif O==\"ResetColors\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then db.clear()ColorPrimary=\"FF6700\"ColorSecondary=\"FFFFFF\"ColorTertiary=\"000000\"ColorHealthy=\"00FF00\"ColorWarning=\"FFFF00\"ColorCritical=\"FF0000\"ColorBackground=\"000000\"ColorBackgroundPattern=\"4f4f4f\"BackgroundMode=\"deathstar\"BackgroundSelected=1;BackgroundModeOpacity=0.25;colorIDTable={[1]={id=\"ColorPrimary\",desc=\"Main HUD Color\",basec=\"FF6700\",newc=\"FF6700\"},[2]={id=\"ColorSecondary\",desc=\"Secondary HUD Color\",basec=\"FFFFFF\",newc=\"FFFFFF\"},[3]={id=\"ColorTertiary\",desc=\"Tertiary HUD Color\",basec=\"000000\",newc=\"000000\"},[4]={id=\"ColorHealthy\",desc=\"Color code for Healthy/Okay\",basec=\"00FF00\",newc=\"00FF00\"},[5]={id=\"ColorWarning\",desc=\"Color code for Damaged/Warning\",basec=\"FFFF00\",newc=\"FFFF00\"},[6]={id=\"ColorCritical\",desc=\"Color code for Broken/Critical\",basec=\"FF0000\",newc=\"FF0000\"},[7]={id=\"ColorBackground\",desc=\"Background Color\",basec=\"000000\",newc=\"000000\"},[8]={id=\"ColorBackgroundPattern\",desc=\"Background Pattern Color\",basec=\"4F4F4F\",newc=\"4F4F4F\"},[9]={id=\"ColorFuelAtmospheric\",desc=\"Color for Atmo Fuel/Elements\",basec=\"004444\",newc=\"004444\"},[10]={id=\"ColorFuelSpace\",desc=\"Color for Space Fuel/Elements\",basec=\"444400\",newc=\"444400\"},[11]={id=\"ColorFuelRocket\",desc=\"Color for Rocket Fuel/Elements\",basec=\"440044\",newc=\"440044\"}}SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"PreviousColorID\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then colorIDIndex=colorIDIndex-1;if colorIDIndex<1 then colorIDIndex=#colorIDTable end;SaveToDatabank()SetRefresh(\"settings1\")RenderScreens(\"settings1\")elseif O==\"NextColorID\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then colorIDIndex=colorIDIndex+1;if colorIDIndex>#colorIDTable then colorIDIndex=1 end;SaveToDatabank()SetRefresh(\"settings1\")RenderScreens(\"settings1\")elseif O==\"ColorPosUp\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then local P=tonumber(string.sub(colorIDTable[colorIDIndex].newc,HitPayload.param,HitPayload.param),16)P=P+1;if P>15 then P=0 end;colorIDTable[colorIDIndex].newc=replace_char(HitPayload.param,colorIDTable[colorIDIndex].newc,hexTable[P+1])SaveToDatabank()SetRefresh(\"settings1\")RenderScreens(\"settings1\")elseif O==\"ColorPosDown\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then local P=tonumber(string.sub(colorIDTable[colorIDIndex].newc,HitPayload.param,HitPayload.param),16)P=P-1;if P<0 then P=15 end;colorIDTable[colorIDIndex].newc=replace_char(HitPayload.param,colorIDTable[colorIDIndex].newc,hexTable[P+1])SaveToDatabank()SetRefresh(\"settings1\")RenderScreens(\"settings1\")elseif O==\"ResetPosColor\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then colorIDTable[colorIDIndex].newc=colorIDTable[colorIDIndex].basec;_G[colorIDTable[colorIDIndex].id]=colorIDTable[colorIDIndex].basec;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"ApplyPosColor\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then _G[colorIDTable[colorIDIndex].id]=colorIDTable[colorIDIndex].newc;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"DamagedPageDown\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentDamagedPage=CurrentDamagedPage+1;if CurrentDamagedPage>math.ceil(#damagedElements/DamagePageSize)then CurrentDamagedPage=math.ceil(#damagedElements/DamagePageSize)end;HudDeselectElement()SaveToDatabank()SetRefresh(\"damage\")RenderScreens(\"damage\")elseif O==\"DamagedPageUp\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentDamagedPage=CurrentDamagedPage-1;if CurrentDamagedPage<1 then CurrentDamagedPage=1 end;HudDeselectElement()SaveToDatabank()SetRefresh(\"damage\")RenderScreens(\"damage\")elseif O==\"BrokenPageDown\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentBrokenPage=CurrentBrokenPage+1;if CurrentBrokenPage>math.ceil(#brokenElements/DamagePageSize)then CurrentBrokenPage=math.ceil(#brokenElements/DamagePageSize)end;HudDeselectElement()SaveToDatabank()SetRefresh(\"damage\")RenderScreens(\"damage\")elseif O==\"BrokenPageUp\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentBrokenPage=CurrentBrokenPage-1;if CurrentBrokenPage<1 then CurrentBrokenPage=1 end;HudDeselectElement()SaveToDatabank()SetRefresh(\"damage\")RenderScreens(\"damage\")elseif O==\"DMGOChangeView\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then screens[i].submode=HitPayload.param;UpdateViewDamageoutline(screens[i])SaveToDatabank()SetRefresh(\"damageoutline\",screens[i].submode)RenderScreens(\"damageoutline\",screens[i].submode)elseif O==\"DMGOChangeStretch\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if DMGOStretch==true then DMGOStretch=false else DMGOStretch=true end;UpdateViewDamageoutline(screens[i])SaveToDatabank()SetRefresh(\"damageoutline\")RenderScreens(\"damageoutline\")elseif O==\"ToggleDisplayAtmosphere\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if screens[i].fuelA==true then screens[i].fuelA=false else screens[i].fuelA=true end;screens[i].fuelIndex=1;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"ToggleDisplaySpace\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if screens[i].fuelS==true then screens[i].fuelS=false else screens[i].fuelS=true end;screens[i].fuelIndex=1;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"ToggleDisplayRocket\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if screens[i].fuelR==true then screens[i].fuelR=false else screens[i].fuelR=true end;screens[i].fuelIndex=1;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"DecreaseFuelIndex\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then screens[i].fuelIndex=screens[i].fuelIndex-1;if screens[i].fuelIndex<1 then screens[i].fuelIndex=1 end;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"IncreaseFuelIndex\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then screens[i].fuelIndex=screens[i].fuelIndex+1;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"ToggleHudMode\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if HUDMode==true then HUDMode=false;forceDamageRedraw=true;HudDeselectElement()SaveToDatabank()SetRefresh()RenderScreens()else HUDMode=true;forceDamageRedraw=true;HudDeselectElement()SaveToDatabank()SetRefresh()RenderScreens()end elseif O==\"ToggleSimulation\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentDamagedPage=1;CurrentBrokenPage=1;if SimulationMode==true then SimulationMode=false;SimulationActive=false;UpdateDamageData()UpdateTypeData()forceDamageRedraw=true;HudDeselectElement()SetRefresh(\"damage\")SetRefresh(\"damageoutline\")SetRefresh(\"settings1\")SetRefresh(\"fuel\")SaveToDatabank()RenderScreens()else SimulationMode=true;SimulationActive=false;UpdateDamageData()UpdateTypeData()forceDamageRedraw=true;HudDeselectElement()SetRefresh(\"damage\")SetRefresh(\"damageoutline\")SetRefresh(\"settings1\")SetRefresh(\"fuel\")SaveToDatabank()RenderScreens()end elseif(O==\"ToggleElementLabel\"or O==\"ToggleElementLabel2\")and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if UseMyElementNames==true then UseMyElementNames=false;SetRefresh(\"damage\")RenderScreens(\"damage\")else UseMyElementNames=true;SetRefresh(\"damage\")RenderScreens(\"damage\")end elseif(O==\"SwitchScrapTier\"or O==\"SwitchScrapTier2\")and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then ScrapTier=ScrapTier+1;if ScrapTier>4 then ScrapTier=1 end;SetRefresh(\"damage\")RenderScreens(\"damage\")end end end end end;function GetContentFlight()local Q=\"\"Q=Q..GetHeader(\"Flight Data Report\")..[[\n \n ]]return Q end;function GetContentDamage()local Q=\"\"if SimulationMode==true then Q=Q..GetHeader(\"Damage Report (Simulated damage)\")..[[]]else Q=Q..GetHeader(\"Damage Report\")..[[]]end;Q=Q..GetContentDamageScreen()return Q end;function GetContentDamageoutline(m)UpdateDataDamageoutline()UpdateViewDamageoutline(m)local Q=\"\"Q=Q..GetHeader(\"Damage Ship Outline Report\")..GetDamageoutlineShip()..[[]]if m.submode==\"top\"then Q=Q..[[\n \n Top View\n \n Side View\n \n Front View\n ]]elseif m.submode==\"side\"then Q=Q..[[\n \n Top View\n \n Side View\n \n Front View\n ]]elseif m.submode==\"front\"then Q=Q..[[\n \n Top View\n \n Side View\n \n Front View\n ]]else end;Q=Q..[[]]..#dmgoElements..[[ of ]]..ElementCounter..[[ shown]]Q=Q..[[]]if DMGOStretch==true then Q=Q..[[]]end;Q=Q..[[Stretch both axis]]return Q end;function GetContentFuel(m)if#FuelAtmosphericTanks<1 and#FuelSpaceTanks<1 and#FuelRocketTanks<1 then return\"\"end;local R=0;local Q=\"\"local S={}FuelDisplay={m.fuelA,m.fuelS,m.fuelR}if FuelDisplay[1]==true and#FuelAtmosphericTanks>0 then table.insert(S,\"Atmospheric\")R=R+1 end;if FuelDisplay[2]==true and#FuelSpaceTanks>0 then table.insert(S,\"Space\")R=R+1 end;if FuelDisplay[3]==true and#FuelRocketTanks>0 then table.insert(S,\"Rocket\")R=R+1 end;Q=Q..GetHeader(\"Fuel Report (\"..table.concat(S,\", \")..\")\")..[[\n ]]local T=150;local U=0;local V=0;if FuelDisplay[1]==true and#FuelAtmosphericTanks>0 then if R==1 then V=50 elseif R==2 then V=6 elseif R==3 then V=0 end;Q=Q..[[\n \n \n \n ]]Q=Q..[[]]..GenerateCommaValue(FuelAtmosphericCurrent,true)..[[ of ]]..GenerateCommaValue(FuelAtmosphericTotal,true)..[[ | Total Atmospheric Fuel in ]]..#FuelAtmosphericTanks..[[ tank]]..(#FuelAtmosphericTanks==1 and\"\"or\"s\")..[[ (]]..math.floor(100/FuelAtmosphericTotal*FuelAtmosphericCurrent)..[[%)]]U=U+1 end;if FuelDisplay[2]==true and#FuelSpaceTanks>0 then if R==1 then V=50 elseif R==2 then V=6 elseif R==3 then V=0 end;Q=Q..[[\n \n \n \n ]]Q=Q..[[]]..GenerateCommaValue(FuelSpaceCurrent,true)..[[ of ]]..GenerateCommaValue(FuelSpaceTotal,true)..[[ | Total Space Fuel in ]]..#FuelSpaceTanks..[[ tank]]..(#FuelSpaceTanks==1 and\"\"or\"s\")..[[ (]]..math.floor(100/FuelSpaceTotal*FuelSpaceCurrent)..[[%)]]U=U+1 end;if FuelDisplay[3]==true and#FuelRocketTanks>0 then if R==1 then V=50 elseif R==2 then V=6 elseif R==3 then V=0 end;Q=Q..[[\n \n \n \n ]]Q=Q..[[]]..GenerateCommaValue(FuelRocketCurrent,true)..[[ of ]]..GenerateCommaValue(FuelRocketTotal,true)..[[ | Total Rocket Fuel in ]]..#FuelRocketTanks..[[ tank]]..(#FuelRocketTanks==1 and\"\"or\"s\")..[[ (]]..math.floor(100/FuelRocketTotal*FuelRocketCurrent)..[[%)]]end;Q=Q..[[\n \n \n \n ]]local W={}if m.fuelIndex==nil or m.fuelIndex<1 then m.fuelIndex=1 end;if FuelDisplay[1]==true then for f,j in ipairs(FuelAtmosphericTanks)do table.insert(W,j)end end;if FuelDisplay[2]==true then for f,j in ipairs(FuelSpaceTanks)do table.insert(W,j)end end;if FuelDisplay[3]==true then for f,j in ipairs(FuelRocketTanks)do table.insert(W,j)end end;table.sort(W,function(E,F)return E.type\n \n \n ]]if Y.hp==0 then Q=Q..[[]]elseif Y.maxhp-Y.hp>constants.epsilon then Q=Q..[[]]else Q=Q..[[]]end;if Y.hp==0 then Q=Q..[[]]..Y.size..[[]]else Q=Q..[[]]..Y.size..[[]]end;if Y.hp==0 then Q=Q..[[Broken]]..[[0 of ]]..GenerateCommaValue(Y.vol)..[[]]elseif tonumber(Y.percent)<10 then Q=Q..[[]]..Y.percent..[[%]]..[[]]..GenerateCommaValue(Y.cvol)..[[ of ]]..GenerateCommaValue(Y.vol)..[[]]elseif tonumber(Y.percent)<30 then Q=Q..[[]]..Y.percent..[[%]]..[[]]..GenerateCommaValue(Y.cvol)..[[ of ]]..GenerateCommaValue(Y.vol)..[[]]else Q=Q..[[]]..Y.percent..[[%]]..[[]]..GenerateCommaValue(Y.cvol)..[[ of ]]..GenerateCommaValue(Y.vol)..[[]]end;Q=Q..[[]]..Y.name..[[]]Q=Q..[[]]end end;if#FuelAtmosphericTanks>0 then Q=Q..[[]]if FuelDisplay[1]==true then Q=Q..[[]]end;Q=Q..[[ATM]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"ToggleDisplayAtmosphere\",x1=50,x2=100,y1=270,y2=320})end;if#FuelSpaceTanks>0 then Q=Q..[[]]if FuelDisplay[2]==true then Q=Q..[[]]end;Q=Q..[[SPC]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"ToggleDisplaySpace\",x1=200,x2=250,y1=270,y2=320})end;if#FuelRocketTanks>0 then Q=Q..[[]]if FuelDisplay[3]==true then Q=Q..[[]]end;Q=Q..[[RKT]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"ToggleDisplayRocket\",x1=350,x2=400,y1=270,y2=320})end;if m.fuelIndex>1 then Q=Q..[[\n \n \n ]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"DecreaseFuelIndex\",x1=1470,x2=1670,y1=270,y2=320})end;if m.fuelIndex+X-1<#W then Q=Q..[[\n \n \n ]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"IncreaseFuelIndex\",x1=1680,x2=1880,y1=270,y2=320})end;if X>0 then Q=Q..[[]]..#W..[[ Tank]]..(#W==1 and\"\"or\"s\")..[[ (Showing ]]..m.fuelIndex..[[ to ]]..m.fuelIndex+X-1 ..[[)]]end;return Q end;function GetContentCargo()local Q=\"\"Q=Q..GetHeader(\"Cargo Report\")..[[\n \n ]]return Q end;function GetContentAGG()local Q=\"\"Q=Q..GetHeader(\"Anti-Grav Control\")..[[\n \n ]]return Q end;function GetContentMap()local Q=\"\"Q=Q..GetHeader(\"Map Overview\")..[[\n \n ]]return Q end;function GetContentTime()local Q=\"\"Q=Q..GetHeader(\"Time\")..epochTime()Q=Q..[[\n \n \n \n \n \n \n \n \n \n \n \n \n ]]return Q end;function GetContentSettings1()local Q=\"\"Q=Q..GetHeader(\"Settings\")..[[]]if BackgroundMode==\"\"then Q=Q..[[Activate background]]else Q=Q..[[Deactivate background (']]..BackgroundMode..[[', ]]..string.format(\"%.0f\",BackgroundModeOpacity*100)..[[%)]]end;Q=Q..[[\n \n Previous background\n \n Next background\n\n \n Decrease Opacity\n \n Increase Opacity\n ]]Q=Q..[[]]..[[Reset background and all colors]]Q=Q..[[]]..[[]]..[[]]..[[Select and change any of the ]]..#colorIDTable..[[ HUD colors]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..colorIDTable[colorIDIndex].desc..[[]]..[[]]..[[Current color]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[#]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,1,1)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,2,2)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,3,3)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,4,4)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,5,5)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,6,6)..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[New color]]..[[]]..[[Apply new color]]..[[]]..[[Reset]]..[[]]Q=Q..[[]]..[[]]..[[]]..[[Explanation / Hints]]..[[Coming soon.]]Q=Q..[[]]if SimulationMode==true then Q=Q..[[Simulating Damage to elements]]AddClickArea(\"settings1\",{id=\"ToggleSimulation\",mode=\"settings1\",x1=940,x2=1850,y1=919,y2=969})else Q=Q..[[Simulate Damage to elements]]AddClickArea(\"settings1\",{id=\"ToggleSimulation\",mode=\"settings1\",x1=940,x2=1850,y1=919,y2=969})end;return Q end;function GetContentStartup()local Q=\"\"Q=Q..GetElementLogo(812,380,\"f\",\"f\",\"f\")if YourShipsName==\"Enter here\"then Q=Q..[[Spaceship ID ]]..ShipID..[[]]else Q=Q..[[]]..YourShipsName..[[]]end;if ShowWelcomeMessage==true then Q=Q..[[Greetings, Commander ]]..PlayerName..[[.]]end;if#Warnings>0 then Q=Q..[[Warning: ]]..table.concat(Warnings,\" \")..[[]]end;Q=Q..[[Damage Report v]]..VERSION..[[, by Scion Interstellar, DorianGray - Discord: Dorian Gray#2623. Under GNU Public License 3.0.]]return Q end;function RenderScreen(m,a0)if a0==nil then PrintConsole(\"ERROR: contentToRender is nil.\")unit.exit()end;CreateClickAreasForScreen(m)local Q=\"\"Q=Q..[[\n \n \n ]]Q=Q..a0;if m.mode==\"startup\"then Q=Q..[[]]else Q=Q..[[]]end;Q=Q..[[\n \n ]]Q=Q..[[]]local a1=string.len(Q)m.element.setSVG(Q)end;function RenderScreens(a2,a3)a2=a2 or\"all\"a3=a3 or\"all\"if screens~=nil and#screens>0 then local a4=\"\"local a5=\"\"local a6=\"\"local a7=\"\"local a8=\"\"local a9=\"\"local aa=\"\"local ab=\"\"local ac=\"\"local ad=\"\"local ae=\"\"local af=\"\"for J,m in pairs(screens)do if m.refresh==true then local a0=\"\"if m.mode==\"flight\"and(a2==\"flight\"or a2==\"all\")then if a4==\"\"then a4=GetContentFlight()end;a0=a4 elseif m.mode==\"damage\"and(a2==\"damage\"or a2==\"all\")then if a5==\"\"then a5=GetContentDamage()end;a0=a5 elseif m.mode==\"damageoutline\"and(a2==\"damageoutline\"or a2==\"all\")then if m.submode==\"\"then m.submode=\"top\"screens[J].submode=\"top\"end;if m.submode==\"top\"and(a3==\"top\"or a3==\"all\")then if a6==\"\"then a6=GetContentDamageoutline(m)end;a0=a6 end;if m.submode==\"side\"and(a3==\"side\"or a3==\"all\")then if a7==\"\"then a7=GetContentDamageoutline(m)end;a0=a7 end;if m.submode==\"front\"and(a3==\"front\"or a3==\"all\")then if a8==\"\"then a8=GetContentDamageoutline(m)end;a0=a8 end elseif m.mode==\"fuel\"and(a2==\"fuel\"or a2==\"all\")then m=WipeClickAreasForScreen(screens[J])a0=GetContentFuel(m)elseif m.mode==\"cargo\"and(a2==\"cargo\"or a2==\"all\")then if aa==\"\"then aa=GetContentCargo()end;a0=aa elseif m.mode==\"agg\"and(a2==\"agg\"or a2==\"all\")then if ab==\"\"then ab=GetContentAGG()end;a0=ab elseif m.mode==\"map\"and(a2==\"map\"or a2==\"all\")then if ac==\"\"then ac=GetContentMap()end;a0=ac elseif m.mode==\"time\"and(a2==\"time\"or a2==\"all\")then if ad==\"\"then ad=GetContentTime()end;a0=ad elseif m.mode==\"settings1\"and(a2==\"settings1\"or a2==\"all\")then if ae==\"\"then ae=GetContentSettings1()end;a0=ae elseif m.mode==\"startup\"and(a2==\"startup\"or a2==\"all\")then if af==\"\"then af=GetContentStartup()end;a0=af else a0=\"Invalid screen mode. ('\"..m.mode..\"')\"end;if a0~=\"\"then RenderScreen(m,a0)else DrawCenteredText(\"ERROR: No contentToRender delivered for \"..m.mode)PrintConsole(\"ERROR: No contentToRender delivered for \"..m.mode)unit.exit()end;screens[J].refresh=false end end end;if HUDMode==true then system.setScreen(GetContentDamageHUDOutput())system.showScreen(1)else system.showScreen(0)end end;function OnTickData(C)if formerTime+605 or SkillRepairToolOptimization>5 or StatFuelTankOptimization>5 or StatContainerOptimization>5 or StatAtmosphericFuelTankHandling>5 or StatSpaceFuelTankHandling>5 or StatRocketFuelTankHandling>5 then PrintConsole(\"ERROR: Talents/stats can only range from 0 to 5. Please set correctly in LUA settings and reactivate script.\")unit.exit()end;if screens==nil or#screens==0 then HUDMode=true;PrintConsole(\"Warning: No screens connected. Entering HUD mode only.\")end;OnTickData(true)unit.setTimer('UpdateData',UpdateDataInterval)unit.setTimer('UpdateHighlight',HighlightBlinkingInterval)",
- "filter": {
- "args": [],
- "signature": "start()",
- "slotKey": "-1"
- },
- "key": "13"
- },
- {
- "code": "ActionUp()",
- "filter": {
- "args": [
- {
- "value": "up"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "14"
- },
- {
- "code": "ActionDown()",
- "filter": {
- "args": [
- {
- "value": "down"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "15"
- },
- {
- "code": "ActionStrafeLeft()",
- "filter": {
- "args": [
- {
- "value": "strafeleft"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "16"
- },
- {
- "code": "ActionStrafeRight()",
- "filter": {
- "args": [
- {
- "value": "straferight"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "17"
- },
- {
- "code": "KeyCTRLPressed = true",
- "filter": {
- "args": [
- {
- "value": "brake"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "18"
- },
- {
- "code": "KeyCTRLPressed = false",
- "filter": {
- "args": [
- {
- "value": "brake"
- }
- ],
- "signature": "actionStop(action)",
- "slotKey": "-2"
- },
- "key": "19"
- },
- {
- "code": "ActionOption1()",
- "filter": {
- "args": [
- {
- "value": "option1"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "20"
- },
- {
- "code": "ActionOption2()",
- "filter": {
- "args": [
- {
- "value": "option2"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "21"
- },
- {
- "code": "ActionOption3()",
- "filter": {
- "args": [
- {
- "value": "option3"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "22"
- },
- {
- "code": "ActionOption4()",
- "filter": {
- "args": [
- {
- "value": "option4"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "23"
- },
- {
- "code": "ActionOption9()",
- "filter": {
- "args": [
- {
- "value": "option9"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "24"
- },
- {
- "code": "ActionOption8()",
- "filter": {
- "args": [
- {
- "value": "option8"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "25"
- }
- ],
- "methods": [],
- "events": []
-}
\ No newline at end of file
diff --git a/versions/DamageReport_3_1.conf b/versions/DamageReport_3_1.conf
deleted file mode 100644
index 449a90b..0000000
--- a/versions/DamageReport_3_1.conf
+++ /dev/null
@@ -1,452 +0,0 @@
-{
- "slots": {
- "0": {
- "name": "slot1",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "1": {
- "name": "slot2",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "2": {
- "name": "slot3",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "3": {
- "name": "slot4",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "4": {
- "name": "slot5",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "5": {
- "name": "slot6",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "6": {
- "name": "slot7",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "7": {
- "name": "slot8",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "8": {
- "name": "slot9",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "9": {
- "name": "slot10",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-1": {
- "name": "unit",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-2": {
- "name": "system",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-3": {
- "name": "library",
- "type": {
- "events": [],
- "methods": []
- }
- }
- },
- "handlers": [
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "0"
- },
- "key": "0"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "2"
- },
- "key": "1"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "3"
- },
- "key": "2"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "4"
- },
- "key": "3"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "5"
- },
- "key": "4"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "6"
- },
- "key": "5"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "7"
- },
- "key": "6"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "8"
- },
- "key": "7"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "9"
- },
- "key": "8"
- },
- {
- "code": "function GenerateCommaValue(a,b,c)b=b or false;c=c or 1;local d=a;if b==true then if string.len(a)>=4 then d=string.format(\"%.\"..c..\"fk\",a/1000)else d=string.format(\"%.\"..c..\"f\",a)end else while true do d,k=string.gsub(d,\"^(-?%d+)(%d%d%d)\",'%1,%2')if k==0 then break end end end;return d end;function PrintConsole(e,f)f=f or false;if f then system.print(\"------------------------------------------------------------------------\")end;system.print(e)if f then system.print(\"------------------------------------------------------------------------\")end end;function DrawCenteredText(e)if screens~=nil and#screens>0 then for g=1,#screens,1 do screens[g].element.setCenteredText(e)end end end;function ClearConsole()for g=1,10,1 do PrintConsole()end end;function SwitchScreens(h)h=h or\"on\"if screens~=nil and#screens>0 then for g=1,#screens,1 do if h==\"on\"then screens[g].element.clear()screens[g].element.activate()screens[g].active=true else screens[g].element.clear()screens[g].element.deactivate()screens[g].active=false end end end end;function GetSecondsString(i)local i=tonumber(i)if i==nil or i<=0 then return\"-\"else days=string.format(\"%2.f\",math.floor(i/(3600*24)))hours=string.format(\"%2.f\",math.floor(i/3600-days*24))mins=string.format(\"%2.f\",math.floor(i/60-hours*60-days*24*60))secs=string.format(\"%2.f\",math.floor(i-hours*3600-days*24*60*60-mins*60))str=\"\"if tonumber(days)>0 then str=str..days..\"d \"end;if tonumber(hours)>0 then str=str..hours..\"h \"end;if tonumber(mins)>0 then str=str..mins..\"m \"end;if tonumber(secs)>0 then str=str..secs..\"s\"end;return str end end;function replace_char(j,str,l)return str:sub(1,j-1)..l..str:sub(j+1)end;function epochTime()function rZ(m)if string.len(m)<=1 then return\"0\"..m else return m end end;function dPoint(n)if not(n==math.floor(n))then return true else return false end end;function lYear(year)if not dPoint(year/4)then if dPoint(year/100)then return true else if not dPoint(year/400)then return true else return false end end else return false end end;local o=5;local p=3600;local q=86400;local r=31536000;local s=31622400;local t=2419200;local g=2505600;local u=2592000;local k=2678400;local w={4,6,9,11}local x={1,3,5,7,8,10,12}local y=0;local z=1506816000;local A=system.getTime()_G[\"formerTime\"]=A;if AddSummertimeHour==true then A=A+3600 end;now=math.floor(A+z)year=1970;secs=0;y=0;while secs+s]]..hour..\":\"..minute..[[]]..[[]]..year..\"/\"..month..\"/\"..day..[[]]end;function ToggleHUD()if HUDMode==true then HUDMode=false;forceDamageRedraw=true;hudSelectedIndex=0;highlightID=0;HideHighlight()SetRefresh()RenderScreens()else HUDMode=true;forceDamageRedraw=true;hudSelectedIndex=0;highlightID=0;HideHighlight()SetRefresh()RenderScreens()end end;function HudDeselectElement()hudSelectedIndex=0;hudStartIndex=1;highlightID=0;HideHighlight()if HUDMode==true then SetRefresh(\"damage\")SetRefresh(\"damageoutline\")RenderScreens()end end;function ChangeHudSelectedElement(B)if HUDMode==true and#rE>0 then hudSelectedIndex=hudSelectedIndex+B;if hudSelectedIndex<1 then hudSelectedIndex=1 elseif hudSelectedIndex>#rE then hudSelectedIndex=#rE end;if hudSelectedIndex>9 then hudStartIndex=hudSelectedIndex-9 end;if hudSelectedIndex~=0 then highlightID=rE[hudSelectedIndex].id;if highlightID~=nil and highlightID~=0 then HideHighlight()elementPosition=vec3(rE[hudSelectedIndex].pos)highlightX=elementPosition.x-coreWorldOffset;highlightY=elementPosition.y-coreWorldOffset;highlightZ=elementPosition.z-coreWorldOffset;highlightOn=true;ShowHighlight()end end;SetRefresh(\"damage\")SetRefresh(\"damageoutline\")RenderScreens()end end;function HideHighlight()if#hudArrowSticker>0 then for g in pairs(hudArrowSticker)do core.deleteSticker(hudArrowSticker[g])end;hudArrowSticker={}end end;function ShowHighlight()if highlightOn==true and highlightID>0 then table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX+2,highlightY,highlightZ,\"north\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX,highlightY-2,highlightZ,\"east\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX-2,highlightY,highlightZ,\"south\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX,highlightY+2,highlightZ,\"west\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX,highlightY,highlightZ-2,\"up\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX,highlightY,highlightZ+2,\"down\"))end end;function ToggleHighlight()if highlightOn==true then highlightOn=false;HideHighlight()else highlightOn=true;ShowHighlight()end end;function SortDamageTables()table.sort(damagedElements,function(m,n)return m.missinghp>n.missinghp end)table.sort(brokenElements,function(m,n)return m.maxhp>n.maxhp end)end;function getScraps(C,D)D=D or false;C=C-SkillRepairToolOptimization*0.05*C;local E=math.ceil(C/(10*5^(ScrapTier-1)))if D==true then return GenerateCommaValue(string.format(\"%.0f\",E),false)else return E end end;function getRepairTime(C,F)F=F or false;C=C-SkillRepairToolOptimization*0.05*C;local E=math.ceil(C/ScrapTierRepairTimes[ScrapTier])E=E-SkillRepairToolEfficiency*0.1*E;if F==true then return GetSecondsString(string.format(\"%.0f\",E))else return E end end;function UpdateDataDamageoutline()dmgoElements={}for g,G in ipairs(brokenElements)do if#dmgoElementsShipXmax then ShipXmax=H end;if I>ShipYmax then ShipYmax=I end;if J>ShipZmax then ShipZmax=J end;table.insert(dmgoElements,{id=G.id,type=\"b\",size=G.maxhp,x=H,y=I,z=J,xp=0,yp=0,zp=0,u=0,v=0})end end;if#dmgoElementsShipXmax then ShipXmax=H end;if I>ShipYmax then ShipYmax=I end;if J>ShipZmax then ShipZmax=J end;table.insert(dmgoElements,{id=G.id,type=\"d\",size=G.maxhp,x=H,y=I,z=J,xp=0,yp=0,zp=0,u=0,v=0})end end end;if#dmgoElementsShipXmax then ShipXmax=H end;if I>ShipYmax then ShipYmax=I end;if J>ShipZmax then ShipZmax=J end;table.insert(dmgoElements,{id=G.id,type=\"h\",size=G.maxhp,x=H,y=I,z=J,xp=0,yp=0,zp=0,u=0,v=0})end end end;ShipX=math.abs(ShipXmax-ShipXmin)ShipY=math.abs(ShipYmax-ShipYmin)ShipZ=math.abs(ShipZmax-ShipZmin)for g,G in ipairs(dmgoElements)do dmgoElements[g].xp=math.abs(100/(ShipXmax-ShipXmin)*(G.x-ShipXmin))dmgoElements[g].yp=math.abs(100/(ShipYmax-ShipYmin)*(G.y-ShipYmin))dmgoElements[g].zp=math.abs(100/(ShipZmax-ShipZmin)*(G.z-ShipZmin))end end;function UpdateViewDamageoutline(K)UFrame=40;VFrame=40;UStart=20+UFrame;VStart=180+VFrame;UDim=1880-2*UFrame;VDim=840-2*VFrame;if K.submode==\"top\"then if DMGOStretch==false then local L=UDim/(ShipYmax-ShipYmin)local M=VDim/(ShipXmax-ShipXmin)if L>=M then local N=L/M;local O=math.floor(UDim/N)UStart=UStart+(UDim-O)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100/N*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100*G.xp+VStart)end else local N=M/L;local P=math.floor(VDim/N)VStart=VStart+(VDim-P)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100/N*G.xp+VStart)end end else for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100*G.xp+VStart)end end elseif K.submode==\"front\"then if DMGOStretch==false then local L=UDim/(ShipXmax-ShipXmin)local M=VDim/(ShipZmax-ShipZmin)if L>=M then local N=L/M;local O=math.floor(UDim/N)UStart=UStart+(UDim-O)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100/N*G.xp+UStart)dmgoElements[g].v=math.floor(VDim/100*(100-G.zp)+VStart)end else local N=M/L;local P=math.floor(VDim/N)VStart=VStart+(VDim-P)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.xp+UStart)dmgoElements[g].v=math.floor(VDim/100/N*(100-G.zp)+VStart)end end else for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.xp+UStart)dmgoElements[g].v=math.floor(VDim/100*(100-G.zp)+VStart)end end elseif K.submode==\"side\"then if DMGOStretch==false then local L=UDim/(ShipYmax-ShipYmin)local M=VDim/(ShipXmax-ShipZmin)if L>=M then local N=L/M;local O=math.floor(UDim/N)UStart=UStart+(UDim-O)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100/N*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100*(100-G.zp)+VStart)end else local N=M/L;local P=math.floor(VDim/N)VStart=VStart+(VDim-P)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100/N*(100-G.zp)+VStart)end end else for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100*(100-G.zp)+VStart)end end else DrawCenteredText(\"ERROR: non-existing DMGO mode set.\")PrintConsole(\"ERROR: non-existing DMGO mode set.\")unit.exit()end end;function GetDamageoutlineShip()local e=\"\"for g,G in ipairs(dmgoElements)do local Q=\"\"local R=1;if G.type==\"h\"then Q=\"ch\"elseif G.type==\"d\"then Q=\"cw\"else Q=\"cc\"end;if G.id==highlightID then Q=\"f2\"end;if G.size>0 and G.size<1000 then R=5 elseif G.size>=1000 and G.size<2000 then R=8 elseif G.size>=2000 and G.size<5000 then R=12 elseif G.size>=5000 and G.size<10000 then R=15 elseif G.size>=10000 and G.size<20000 then R=20 elseif G.size>=20000 then R=30 end;e=e..[[]]if G.id==highlightID then e=e..[[]]e=e..[[]]end end;return e end;function GetContentClickareas(K)local e=\"\"if K~=nil and K.ClickAreas~=nil and#K.ClickAreas>0 then for g,S in ipairs(K.ClickAreas)do e=e..[[]]end end;return e end;function GetElement1(H,I,T,U)H=H or 0;I=I or 0;T=T or 600;U=U or 600;local e=\"\"e=e..[[\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ]]return e end;function GetElement2(H,I)H=H or 0;I=I or 0;local e=\"\"e=e..[[]]return e end;function GetElementLogo(H,I,V,W,X)H=H or 812;I=I or 380;V=V or\"f\"W=W or\"f2\"X=X or\"f3\"local e=\"\"e=e..[[\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ]]return e end;function GetHeader(Y)Y=Y or\"ERROR: UNDEFINED\"local e=\"\"e=e..[[\n ]]..Y..[[]]return e end;function GetContentBackground(Z,_)bgColor=ColorBackgroundPattern;local e=\"\"if Z==\"dots\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' viewBox='0 0 4 4'%3E%3Cpath fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' d='M1 3h1v1H1V3zm2-2h1v1H3V1z'%3E%3C/path%3E%3C/svg%3E\");]]elseif Z==\"rain\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='12' height='16' viewBox='0 0 12 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 .99C4 .445 4.444 0 5 0c.552 0 1 .45 1 .99v4.02C6 5.555 5.556 6 5 6c-.552 0-1-.45-1-.99V.99zm6 8c0-.546.444-.99 1-.99.552 0 1 .45 1 .99v4.02c0 .546-.444.99-1 .99-.552 0-1-.45-1-.99V8.99z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E\");]]elseif Z==\"plus\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E\");]]elseif Z==\"signal\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='84' height='48' viewBox='0 0 84 48' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h12v6H0V0zm28 8h12v6H28V8zm14-8h12v6H42V0zm14 0h12v6H56V0zm0 8h12v6H56V8zM42 8h12v6H42V8zm0 16h12v6H42v-6zm14-8h12v6H56v-6zm14 0h12v6H70v-6zm0-16h12v6H70V0zM28 32h12v6H28v-6zM14 16h12v6H14v-6zM0 24h12v6H0v-6zm0 8h12v6H0v-6zm14 0h12v6H14v-6zm14 8h12v6H28v-6zm-14 0h12v6H14v-6zm28 0h12v6H42v-6zm14-8h12v6H56v-6zm0-8h12v6H56v-6zm14 8h12v6H70v-6zm0 8h12v6H70v-6zM14 24h12v6H14v-6zm14-8h12v6H28v-6zM14 8h12v6H14V8zM0 8h12v6H0V8z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E\");]]elseif Z==\"deathstar\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='105' viewBox='0 0 80 105'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M20 10a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm15 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zM20 75a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zm30-65a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm0 65a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zM35 10a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zM5 45a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zm60 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10z' /%3E%3C/g%3E%3C/g%3E%3C/svg%3E\");]]elseif Z==\"diamond\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='32' viewBox='0 0 16 32'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath fill-rule='evenodd' d='M0 24h4v2H0v-2zm0 4h6v2H0v-2zm0-8h2v2H0v-2zM0 0h4v2H0V0zm0 4h2v2H0V4zm16 20h-6v2h6v-2zm0 4H8v2h8v-2zm0-8h-4v2h4v-2zm0-20h-6v2h6V0zm0 4h-4v2h4V4zm-2 12h2v2h-2v-2zm0-8h2v2h-2V8zM2 8h10v2H2V8zm0 8h10v2H2v-2zm-2-4h14v2H0v-2zm4-8h6v2H4V4zm0 16h6v2H4v-2zM6 0h2v2H6V0zm0 24h2v2H6v-2z'/%3E%3C/g%3E%3C/svg%3E\");]]elseif Z==\"hexagon\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='49' viewBox='0 0 28 49'%3E%3Cg fill-rule='evenodd'%3E%3Cg id='hexagons' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='nonzero'%3E%3Cpath d='M13.99 9.25l13 7.5v15l-13 7.5L1 31.75v-15l12.99-7.5zM3 17.9v12.7l10.99 6.34 11-6.35V17.9l-11-6.34L3 17.9zM0 15l12.98-7.5V0h-2v6.35L0 12.69v2.3zm0 18.5L12.98 41v8h-2v-6.85L0 35.81v-2.3zM15 0v7.5L27.99 15H28v-2.31h-.01L17 6.35V0h-2zm0 49v-8l12.99-7.5H28v2.31h-.01L17 42.15V49h-2z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E\");]]elseif Z==\"capsule\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='32' height='26' viewBox='0 0 32 26' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M14 0v3.994C14 7.864 10.858 11 7 11c-3.866 0-7-3.138-7-7.006V0h2v4.005C2 6.765 4.24 9 7 9c2.756 0 5-2.236 5-4.995V0h2zm0 26v-5.994C14 16.138 10.866 13 7 13c-3.858 0-7 3.137-7 7.006V26h2v-6.005C2 17.235 4.244 15 7 15c2.76 0 5 2.236 5 4.995V26h2zm2-18.994C16 3.136 19.142 0 23 0c3.866 0 7 3.138 7 7.006v9.988C30 20.864 26.858 24 23 24c-3.866 0-7-3.138-7-7.006V7.006zm2-.01C18 4.235 20.244 2 23 2c2.76 0 5 2.236 5 4.995v10.01C28 19.765 25.756 22 23 22c-2.76 0-5-2.236-5-4.995V6.995z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E\");]]elseif Z==\"diagonal\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='6' height='6' viewBox='0 0 6 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'%3E%3Cpath d='M5 0h1L0 6V5zM6 5v1H5z'/%3E%3C/g%3E%3C/svg%3E\");]]end;return e end;function GetContentDamageHUDOutput()local a0=300;local a1=165;if#damagedElements>0 or#brokenElements>0 then a1=510 end;local e=\"\"e=e..[[\n \n ]]e=e..[[]]..[[]]..[[]]..[[]]..(YourShipsName==\"Enter here\"and\"Ship ID \"..ShipID or YourShipsName)..[[]]..[[]]if#brokenElements>0 then e=e..[[]]elseif#damagedElements>0 then e=e..[[]]else e=e..[[]]end;if#damagedElements>0 or#brokenElements>0 then e=e..[[Total Damage]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",totalShipMaxHP-totalShipHP))..[[]]e=e..[[T]]..ScrapTier..[[ Scrap Needed]]..[[]]..getScraps(totalShipMaxHP-totalShipHP,true)..[[]]e=e..[[Repair Time]]..[[]]..getRepairTime(totalShipMaxHP-totalShipHP,true)..[[]]e=e..[[]]..[[]]..[[]]..#healthyElements..[[]]..[[]]..[[]]..#damagedElements..[[]]..[[]]..[[]]..#brokenElements..[[]]local u=0;for a2=hudStartIndex,hudStartIndex+9,1 do if rE[a2]~=nil then v=rE[a2]if v.hp>0 then e=e..[[]]..[[]]..string.format(\"%.30s\",v.name)..[[]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",v.missinghp))..[[]]if v.id==highlightID then e=e..[[]]..[[]]..string.format(\"%.30s\",v.name)..[[]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",v.missinghp))..[[]]end else e=e..[[]]..[[]]..string.format(\"%.30s\",v.name)..[[]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",v.missinghp))..[[]]if v.id==highlightID then highlightX=elementPosition.x-coreWorldOffset;highlightY=elementPosition.y-coreWorldOffset;highlightZ=elementPosition.z-coreWorldOffset;e=e..[[]]..[[]]..string.format(\"%.30s\",v.name)..[[]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",v.missinghp))..[[]]end end;u=u+1 end end;e=e..[[]]..[[]]..[[]]..[[]]..[[Up/down arrows to highlight]]..[[CTRL + arrows to move HUD]]..[[Left arrow to toggle HUD Mode]]..[[ALT+1-4 to set Scrap Tier]]..[[ALT+8 to reset HUD position]]..[[ALT+9 to shut script off]]..[[]]..[[]]else e=e..[[]]..OkayCenterMessage..[[]]..[[]]..#healthyElements..[[ elements / ]]..GenerateCommaValue(string.format(\"%.0f\",totalShipMaxHP))..[[ HP.]]..[[]]..[[]]..[[]]..[[]]..[[Left arrow to toggle HUD Mode]]..[[CTRL + arrows to move HUD]]..[[ALT+8 to reset HUD position]]..[[ALT+9 to shut script off]]..[[]]..[[]]end;e=e..[[]]return e end;function GetContentDamageScreen()local a3=\"\"if#damagedElements>0 then local a4=#damagedElements;if a4>DamagePageSize then a4=DamagePageSize end;if CurrentDamagedPage==math.ceil(#damagedElements/DamagePageSize)then a4=#damagedElements%DamagePageSize+12;if a4>12 then a4=a4-12 end end;a3=a3 ..[[]]a3=a3 ..[[]]if UseMyElementNames==true then a3=a3 ..[[Damaged Name]]else a3=a3 ..[[Damaged Type]]end;a3=a3 ..[[HLTHDMG]]a3=a3 ..[[T]]..ScrapTier..[[ SCRREPTIME]]AddClickArea(\"damage\",{id=\"SwitchScrapTier\",mode=\"damage\",x1=650,x2=775,y1=315,y2=360})local g=0;for u=1+(CurrentDamagedPage-1)*DamagePageSize,a4+(CurrentDamagedPage-1)*DamagePageSize,1 do g=g+1;local a5=damagedElements[u]if UseMyElementNames==true then a3=a3 ..[[]]..string.format(\"%.23s\",a5.name)..[[]]else a3=a3 ..[[]]..string.format(\"%.23s\",a5.type)..[[]]end;a3=a3 ..[[]]..a5.percent..[[%]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",a5.missinghp),true)..[[]]..[[]]..getScraps(a5.missinghp,true)..[[]]..[[]]..getRepairTime(a5.missinghp,true)..[[]]..[[]]end;if#damagedElements>DamagePageSize then a3=a3 ..[[Page ]]..CurrentDamagedPage..\" of \"..math.ceil(#damagedElements/DamagePageSize)..[[]]if CurrentDamagedPage\n \n \n ]]AddClickArea(\"damage\",{id=\"DamagedPageDown\",mode=\"damage\",x1=65,x2=260,y1=290+(a4+1)*50,y2=290+50+(a4+1)*50})else DisableClickArea(\"DamagedPageDown\",\"damage\")end;if CurrentDamagedPage>1 then a3=a3 ..[[\n \n \n ]]AddClickArea(\"damage\",{id=\"DamagedPageUp\",mode=\"damage\",x1=750,x2=950,y1=290+(a4+1)*50,y2=290+50+(a4+1)*50})else DisableClickArea(\"DamagedPageUp\",\"damage\")end end end;if#brokenElements>0 then local a6=#brokenElements;if a6>DamagePageSize then a6=DamagePageSize end;if CurrentBrokenPage==math.ceil(#brokenElements/DamagePageSize)then a6=#brokenElements%DamagePageSize+12;if a6>12 then a6=a6-12 end end;a3=a3 ..[[]]a3=a3 ..[[]]if UseMyElementNames==true then a3=a3 ..[[Broken Name]]else a3=a3 ..[[Broken Type]]end;a3=a3 ..[[DMG]]a3=a3 ..[[T]]..ScrapTier..[[ SCRREPTIME]]AddClickArea(\"damage\",{id=\"SwitchScrapTier2\",mode=\"damage\",x1=1570,x2=1690,y1=315,y2=360})local g=0;for u=1+(CurrentBrokenPage-1)*DamagePageSize,a6+(CurrentBrokenPage-1)*DamagePageSize,1 do g=g+1;local a5=brokenElements[u]if UseMyElementNames==true then a3=a3 ..[[]]..string.format(\"%.30s\",a5.name)..[[]]else a3=a3 ..[[]]..string.format(\"%.30s\",a5.type)..[[]]end;a3=a3 ..[[]]..GenerateCommaValue(string.format(\"%.0f\",a5.missinghp),true)..[[]]..[[]]..getScraps(a5.missinghp,true)..[[]]..[[]]..getRepairTime(a5.missinghp,true)..[[]]..[[]]end;if#brokenElements>DamagePageSize then a3=a3 ..[[Page ]]..CurrentBrokenPage..\" of \"..math.ceil(#brokenElements/DamagePageSize)..[[]]if CurrentBrokenPage>1 then a3=a3 ..[[\n \n \n ]]AddClickArea(\"damage\",{id=\"BrokenPageUp\",mode=\"damage\",x1=1665,x2=1865,y1=290+(a6+1)*50,y2=290+50+(a6+1)*50})else DisableClickArea(\"BrokenPageUp\",\"damage\")end;if CurrentBrokenPage\n \n \n ]]AddClickArea(\"damage\",{id=\"BrokenPageDown\",mode=\"damage\",x1=980,x2=1180,y1=290+(a6+1)*50,y2=290+50+(a6+1)*50})else DisableClickArea(\"BrokenPageDown\",\"damage\")end end end;if#damagedElements>0 or#brokenElements>0 then local a7=math.floor(1878/#elementsIdList*#damagedElements)local a8=math.floor(1878/#elementsIdList*#brokenElements)local a9=1878-a7-a8+1;a3=a3 ..[[]]a3=a3 ..[[]]a3=a3 ..[[]]a3=a3 ..[[]]if#damagedElements>0 then a3=a3 ..[[]]..#damagedElements..[[]]end;if#healthyElements>0 then a3=a3 ..[[]]..#healthyElements..[[]]end;if#brokenElements>0 then a3=a3 ..[[]]..#brokenElements..[[]]end;a3=a3 ..[[]]a3=a3 ..[[]]..GenerateCommaValue(string.format(\"%.0f\",totalShipMaxHP-totalShipHP))..[[ HP damage in total ]]..getScraps(totalShipMaxHP-totalShipHP,true)..[[ T]]..ScrapTier..[[ scraps needed. ]]..getRepairTime(totalShipMaxHP-totalShipHP,true)..[[ projected repair time.]]else a3=a3 ..GetElementLogo(812,380,\"ch\",\"ch\",\"ch\")..[[]]..OkayCenterMessage..[[]]..[[]]..#healthyElements..[[ elements stand ]]..GenerateCommaValue(string.format(\"%.0f\",totalShipMaxHP))..[[ HP strong.]]end;forceDamageRedraw=false;return a3 end;function ActionStopengines()ToggleHUD()end;function ActionStrafeRight()if KeyCTRLPressed==true then if HUDShiftU<4000 then HUDShiftU=HUDShiftU+50;SaveToDatabank()RenderScreens()end else HudDeselectElement()end end;function ActionStrafeLeft()if KeyCTRLPressed==true then if HUDShiftU>=50 then HUDShiftU=HUDShiftU-50;SaveToDatabank()RenderScreens()end else ToggleHUD()end end;function ActionDown()if KeyCTRLPressed==true then if HUDShiftV<4000 then HUDShiftV=HUDShiftV+50;SaveToDatabank()RenderScreens()end else ChangeHudSelectedElement(1)end end;function ActionUp()if KeyCTRLPressed==true then if HUDShiftV>=50 then HUDShiftV=HUDShiftV-50;SaveToDatabank()RenderScreens()end else ChangeHudSelectedElement(-1)end end;function ActionOption1()ScrapTier=1;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption2()ScrapTier=2;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption3()ScrapTier=3;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption4()ScrapTier=4;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption8()HUDShiftU=0;HUDShiftV=0;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption9()SaveToDatabank()SwitchScreens(\"off\")unit.exit()end",
- "filter": {
- "args": [],
- "signature": "start()",
- "slotKey": "-1"
- },
- "key": "9"
- },
- {
- "code": "SaveToDatabank()\nSwitchScreens(\"off\")",
- "filter": {
- "args": [],
- "signature": "stop()",
- "slotKey": "-1"
- },
- "key": "10"
- },
- {
- "code": "OnTickData()\n",
- "filter": {
- "args": [
- {
- "value": "UpdateData"
- }
- ],
- "signature": "tick(timerId)",
- "slotKey": "-1"
- },
- "key": "11"
- },
- {
- "code": "ToggleHighlight()",
- "filter": {
- "args": [
- {
- "value": "UpdateHighlight"
- }
- ],
- "signature": "tick(timerId)",
- "slotKey": "-1"
- },
- "key": "12"
- },
- {
- "code": "--[[\n Damage Report 3.1\n A LUA script for Dual Universe\n\n Created By Dorian Gray\n Ingame: DorianGray\n Discord: Dorian Gray#2623\n\n You can find/update this script on GitHub. Explanations, installation and usage information as well as screenshots can be found there too.\n GitHub: https://github.com/DorianTheGrey/DU-DamageReport\n\n GNU Public License 3.0. Use whatever you want, be so kind to leave credit.\n \n Credits & thanks: \n Thanks to NovaQuark for creating the MMO of the century.\n Thanks to Jericho, Dmentia and Archaegeo for learning a lot from their fine scripts.\n Thanks to TheBlacklist for testing and wonderful suggestions.\n SVG patterns by Hero Patterns.\n DU atlas data from Jayle Break.\n \n]]\n\n--[[ 1. USER DEFINED VARIABLES ]]\n\nYourShipsName = \"Enter here\" --export Enter your ship name here if you want it displayed instead of the ship's ID. YOU NEED TO LEAVE THE QUOTATION MARKS.\n\nSkillRepairToolEfficiency = 0 --export Enter (0-5) your talent \"Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency\"\nSkillRepairToolOptimization = 0 --export Enter your talent \"Mining and Inventory -> Equipment Manager -> Repair Tool Optimization\"\n\nStatAtmosphericFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED ATMOSPHERIC FUEL TANKS (from the builders talent \"Piloting -> Atmospheric Flight Technician -> Atmospheric Fuel-Tank Handling\")\nStatSpaceFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL SPACE TANKS (from the builders talent \"Piloting -> Atmospheric Engine Technician -> Space Fuel-Tank Handling\")\nStatRocketFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL ROCKET TANKS (from the builders talent \"Piloting -> Rocket Scientist -> Rocket Booster Fuel Tank Handling\")\nStatContainerOptimization = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL TANKS \"from the builders talent Mining and Inventory -> Stock Control -> Container Optimization\"\nStatFuelTankOptimization = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL TANKS \"from the builders talent Mining and Inventory -> Stock Control -> Fuel Tank Optimization\"\n\nShowWelcomeMessage = true --export Do you want the welcome message on the start screen with your name?\nAddSummertimeHour = false --export: Is summertime currently enabled in your location? (Adds one hour.)\n\nUpdateDataInterval=1.0;HighlightBlinkingInterval=0.5;ColorPrimary=\"FF6700\"ColorSecondary=\"FFFFFF\"ColorTertiary=\"000000\"ColorHealthy=\"00FF00\"ColorWarning=\"FFFF00\"ColorCritical=\"FF0000\"ColorBackground=\"000000\"ColorBackgroundPattern=\"4F4F4F\"ColorFuelAtmospheric=\"004444\"ColorFuelSpace=\"444400\"ColorFuelRocket=\"440044\"VERSION=3.1;DebugMode=false;DebugRenderClickareas=true;DBData={}core=nil;db=nil;screens={}dscreens={}Warnings={}screenModes={[\"flight\"]={id=\"flight\"},[\"damage\"]={id=\"damage\"},[\"damageoutline\"]={id=\"damageoutline\"},[\"fuel\"]={id=\"fuel\"},[\"cargo\"]={id=\"cargo\"},[\"agg\"]={id=\"agg\"},[\"map\"]={id=\"map\"},[\"time\"]={id=\"time\",activetoggle=\"true\"},[\"settings1\"]={id=\"settings1\"},[\"startup\"]={id=\"startup\"}}backgroundModes={\"deathstar\",\"capsule\",\"rain\",\"signal\",\"hexagon\",\"diagonal\",\"diamond\",\"plus\",\"dots\"}BackgroundMode=\"deathstar\"BackgroundSelected=1;BackgroundModeOpacity=0.25;SaveVars={\"dscreens\",\"ColorPrimary\",\"ColorSecondary\",\"ColorTertiary\",\"ColorHealthy\",\"ColorWarning\",\"ColorCritical\",\"ColorBackground\",\"ColorBackgroundPattern\",\"ScrapTier\",\"HUDMode\",\"SimulationMode\",\"DMGOStretch\",\"HUDShiftU\",\"HUDShiftV\",\"colorIDIndex\",\"colorIDTable\",\"BackgroundMode\",\"BackgroundSelected\",\"BackgroundModeOpacity\"}HUDMode=false;HUDShiftU=0;HUDShiftV=0;hudSelectedIndex=0;hudStartIndex=1;hudArrowSticker={}highlightOn=false;highlightID=0;highlightX=0;highlightY=0;highlightZ=0;SimulationMode=false;OkayCenterMessage=\"All systems nominal.\"CurrentDamagedPage=1;CurrentBrokenPage=1;DamagePageSize=12;ScrapTier=1;totalScraps=0;ScrapTierRepairTimes={10,50,250,1250}coreWorldOffset=0;totalShipHP=0;formerTotalShipHP=-1;totalShipMaxHP=0;totalShipIntegrity=100;elementsId={}elementsIdList={}damagedElements={}brokenElements={}rE={}healthyElements={}typeElements={}ElementCounter=0;UseMyElementNames=true;dmgoElements={}DMGOMaxElements=250;DMGOStretch=false;ShipXmin=99999999;ShipXmax=-99999999;ShipYmin=99999999;ShipYmax=-99999999;ShipZmin=99999999;ShipZmax=-99999999;totalShipMass=0;formerTotalShipMass=-1;formerTime=-1;FuelAtmosphericTanks={}FuelSpaceTanks={}FuelRocketTanks={}FuelAtmosphericTotal=0;FuelSpaceTotal=0;FuelRocketTotal=0;FuelAtmosphericCurrent=0;FuelSpaceTotalCurrent=0;FuelRocketTotalCurrent=0;formerFuelAtmosphericTotal=-1;formerFuelSpaceTotal=-1;formerFuelRocketTotal=-1;hexTable={\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"A\",\"B\",\"C\",\"D\",\"E\",\"F\"}colorIDIndex=1;colorIDTable={[1]={id=\"ColorPrimary\",desc=\"Main HUD Color\",basec=\"FF6700\",newc=\"FF6700\"},[2]={id=\"ColorSecondary\",desc=\"Secondary HUD Color\",basec=\"FFFFFF\",newc=\"FFFFFF\"},[3]={id=\"ColorTertiary\",desc=\"Tertiary HUD Color\",basec=\"000000\",newc=\"000000\"},[4]={id=\"ColorHealthy\",desc=\"Color code for Healthy/Okay\",basec=\"00FF00\",newc=\"00FF00\"},[5]={id=\"ColorWarning\",desc=\"Color code for Damaged/Warning\",basec=\"FFFF00\",newc=\"FFFF00\"},[6]={id=\"ColorCritical\",desc=\"Color code for Broken/Critical\",basec=\"FF0000\",newc=\"FF0000\"},[7]={id=\"ColorBackground\",desc=\"Background Color\",basec=\"000000\",newc=\"000000\"},[8]={id=\"ColorBackgroundPattern\",desc=\"Background Pattern Color\",basec=\"4F4F4F\",newc=\"4F4F4F\"},[9]={id=\"ColorFuelAtmospheric\",desc=\"Color for Atmo Fuel/Elements\",basec=\"004444\",newc=\"004444\"},[10]={id=\"ColorFuelSpace\",desc=\"Color for Space Fuel/Elements\",basec=\"444400\",newc=\"444400\"},[11]={id=\"ColorFuelRocket\",desc=\"Color for Rocket Fuel/Elements\",basec=\"440044\",newc=\"440044\"}}function InitiateSlots()for a,b in pairs(unit)do if type(b)==\"table\"and type(b.export)==\"table\"and b.getElementClass then local c=b.getElementClass():lower()if c:find(\"coreunit\")then core=b;local d=core.getMaxHitPoints()if d>10000 then coreWorldOffset=128 elseif d>1000 then coreWorldOffset=64 elseif d>150 then coreWorldOffset=32 else coreWorldOffset=16 end elseif c=='databankunit'then db=b elseif c==\"screenunit\"then local e=\"startup\"screens[#screens+1]={element=b,id=b.getId(),mode=e,submode=\"\",ClickAreas={},refresh=true,active=false,fuelA=true,fuelS=true,fuelR=true,fuelIndex=1}end end end end;function LoadFromDatabank()if db==nil then return else for f,g in pairs(SaveVars)do if db.hasKey(g)then local h=json.decode(db.getStringValue(g))if h~=nil then if g==\"YourShipsName\"or g==\"AddSummertimeHour\"or g==\"UpdateDataInterval\"or g==\"HighlightBlinkingInterval\"or g==\"SkillRepairToolEfficiency\"or g==\"SkillRepairToolOptimization\"or g==\"SkillAtmosphericFuelEfficiency\"or g==\"SkillSpaceFuelEfficiency\"or g==\"SkillRocketFuelEfficiency\"or g==\"StatAtmosphericFuelTankHandling\"or g==\"StatSpaceFuelTankHandling\"or g==\"StatRocketFuelTankHandling\"then else _G[g]=h end end end end;for i,j in ipairs(screens)do for k,l in ipairs(dscreens)do if screens[i].id==dscreens[k].id then screens[i].mode=dscreens[k].mode;screens[i].submode=dscreens[k].submode;screens[i].active=dscreens[k].active;screens[i].refresh=true;screens[i].fuelA=dscreens[k].fuelA;screens[i].fuelS=dscreens[k].fuelS;screens[i].fuelR=dscreens[k].fuelR;screens[i].fuelIndex=dscreens[k].fuelIndex end end end end end;function SaveToDatabank()if db==nil then return else dscreens={}for i,m in ipairs(screens)do dscreens[i]={}dscreens[i].id=m.id;dscreens[i].mode=m.mode;dscreens[i].submode=m.submode;dscreens[i].active=m.active;dscreens[i].fuelA=m.fuelA;dscreens[i].fuelS=m.fuelS;dscreens[i].fuelR=m.fuelR;dscreens[i].fuelIndex=m.fuelIndex end;db.clear()for f,g in pairs(SaveVars)do db.setStringValue(g,json.encode(_G[g]))end end end;function InitiateScreens()if screens~=nil and#screens>0 then for i=1,#screens,1 do screens[i]=CreateClickAreasForScreen(screens[i])end end end;function UpdateTypeData()FuelAtmosphericTanks={}FuelSpaceTanks={}FuelRocketTanks={}FuelAtmosphericTotal=0;FuelAtmosphericCurrent=0;FuelSpaceTotal=0;FuelSpaceCurrent=0;FuelRocketCurrent=0;FuelRocketTotal=0;local n=4;local o=6;local p=0.8;if StatContainerOptimization>0 then n=n-0.05*StatContainerOptimization*n;o=o-0.05*StatContainerOptimization*o;p=p-0.05*StatContainerOptimization*p end;if StatFuelTankOptimization>0 then n=n-0.05*StatFuelTankOptimization*n;o=o-0.05*StatFuelTankOptimization*o;p=p-0.05*StatFuelTankOptimization*p end;for i,q in ipairs(typeElements)do local r=core.getElementNameById(q)or\"\"local s=core.getElementTypeById(q)or\"\"local t=core.getElementPositionById(q)or 0;local u=core.getElementHitPointsById(q)or 0;local v=core.getElementMaxHitPointsById(q)or 0;local w=core.getElementMassById(q)or 0;local x=\"\"local y=0;local z=0;local A=0;local B=0;if s==\"atmospheric fuel-tank\"then if v>10000 then x=\"L\"z=5480;y=12800 elseif v>1300 then x=\"M\"z=988.67;y=1600 elseif v>150 then x=\"S\"z=182.67;y=400 else x=\"XS\"z=35.03;y=100 end;if StatAtmosphericFuelTankHandling>0 then y=0.2*StatAtmosphericFuelTankHandling*y+y end;A=w-z;if A<=10 then A=0 end;B=string.format(\"%.0f\",A/n)cPercent=string.format(\"%.1f\",math.floor(100/y*tonumber(B)))table.insert(FuelAtmosphericTanks,{type=1,id=q,name=r,maxhp=v,hp=GetHPforElement(q),pos=t,size=x,mass=z,vol=y,cvol=B,percent=cPercent})if u>0 then FuelAtmosphericCurrent=FuelAtmosphericCurrent+B end;FuelAtmosphericTotal=FuelAtmosphericTotal+y elseif s==\"space fuel-tank\"then if v>10000 then x=\"L\"z=5480;y=12800 elseif v>1300 then x=\"M\"z=988.67;y=1600 else x=\"S\"z=182.67;y=400 end;if StatSpaceFuelTankHandling>0 then y=0.2*StatSpaceFuelTankHandling*y+y end;A=w-z;if A<=10 then A=0 end;B=string.format(\"%.0f\",A/o)cPercent=string.format(\"%.1f\",100/y*tonumber(B))table.insert(FuelSpaceTanks,{type=2,id=q,name=r,maxhp=v,hp=GetHPforElement(q),pos=t,size=x,mass=z,vol=y,cvol=B,percent=cPercent})if u>0 then FuelSpaceCurrent=FuelSpaceCurrent+B end;FuelSpaceTotal=FuelSpaceTotal+y elseif s==\"rocket fuel-tank\"then if v>65000 then x=\"L\"z=25740;y=50000 elseif v>6000 then x=\"M\"z=4720;y=6400 elseif v>700 then x=\"S\"z=886.72;y=800 else x=\"XS\"z=173.42;y=400 end;if StatRocketFuelTankHandling>0 then y=0.2*StatRocketFuelTankHandling*y+y end;A=w-z;if A<=10 then A=0 end;B=string.format(\"%.0f\",A/p)cPercent=string.format(\"%.1f\",100/y*tonumber(B))table.insert(FuelRocketTanks,{type=3,id=q,name=r,maxhp=v,hp=GetHPforElement(q),pos=t,size=x,mass=z,vol=y,cvol=B,percent=cPercent})if u>0 then FuelRocketCurrent=FuelRocketCurrent+B end;FuelRocketTotal=FuelRocketTotal+y end end;if FuelAtmosphericCurrent~=formerFuelAtmosphericCurrent then SetRefresh(\"fuel\")formerFuelAtmosphericCurrent=FuelAtmosphericCurrent end;if FuelSpaceCurrent~=formerFuelSpaceCurrent then SetRefresh(\"fuel\")formerFuelSpaceCurrent=FuelSpaceCurrent end;if FuelRocketCurrent~=formerFuelRocketCurrent then SetRefresh(\"fuel\")formerFuelRocketCurrent=FuelRocketCurrent end end;function UpdateDamageData(C)C=C or false;if SimulationActive==true then return end;local formerTotalShipHP=totalShipHP;totalShipHP=0;totalShipMaxHP=0;totalShipIntegrity=100;damagedElements={}brokenElements={}healthyElements={}if C==true then typeElements={}end;ElementCounter=0;elementsIdList=core.getElementIdList()for i,q in pairs(elementsIdList)do ElementCounter=ElementCounter+1;local r=core.getElementNameById(q)local s=core.getElementTypeById(q)local t=core.getElementPositionById(q)local u=core.getElementHitPointsById(q)local v=core.getElementMaxHitPointsById(q)if SimulationMode==true then SimulationActive=true;local D=math.random(0,10)if D<2 and#brokenElements<30 then u=0 elseif D>=2 and D<4 and#damagedElements<30 then u=math.random(1,math.ceil(v))else u=v end end;totalShipHP=totalShipHP+u;totalShipMaxHP=totalShipMaxHP+v;if v-u>constants.epsilon then if u>0 then table.insert(damagedElements,{id=q,name=r,type=s,counter=ElementCounter,hp=u,maxhp=v,missinghp=v-u,percent=math.ceil(100/v*u),pos=t})else table.insert(brokenElements,{id=q,name=r,type=s,counter=ElementCounter,hp=u,maxhp=v,missinghp=v-u,percent=0,pos=t})end else table.insert(healthyElements,{id=q,name=r,type=s,counter=ElementCounter,hp=u,maxhp=v,pos=t})if q==highlightID then highlightID=0;highlightOn=false;HideHighlight()hudSelectedIndex=0 end end;if C==true then if s==\"atmospheric fuel-tank\"or s==\"space fuel-tank\"or s==\"rocket fuel-tank\"then table.insert(typeElements,q)end end end;SortDamageTables()rE={}if#brokenElements>0 then for f,j in ipairs(brokenElements)do table.insert(rE,{id=j.id,missinghp=j.missinghp,hp=j.hp,name=j.name,type=j.type,pos=j.pos})end end;if#damagedElements>0 then for f,j in ipairs(damagedElements)do table.insert(rE,{id=j.id,missinghp=j.missinghp,hp=j.hp,name=j.name,type=j.type,pos=j.pos})end end;if#rE>0 then table.sort(rE,function(E,F)return E.missinghp>F.missinghp end)end;totalShipIntegrity=string.format(\"%2.0f\",100/totalShipMaxHP*totalShipHP)if formerTotalShipHP~=totalShipHP then forceDamageRedraw=true;formerTotalShipHP=totalShipHP else forceDamageRedraw=false end end;function GetHPforElement(q)for i,j in ipairs(brokenElements)do if j.id==q then return 0 end end;for i,j in ipairs(damagedElements)do if j.id==q then return j.hp end end;for i,j in ipairs(healthyElements)do if j.id==q then return j.maxhp end end end;function UpdateClickArea(G,H,I)for i,m in ipairs(screens)do for J,j in pairs(screens[i].ClickAreas)do if j.id==G and j.mode==I then screens[i].ClickAreas[J]=H end end end end;function AddClickArea(I,H)for i,m in ipairs(screens)do if screens[i].mode==I then table.insert(screens[i].ClickAreas,H)end end end;function AddClickAreaForScreenID(K,H)for i,m in ipairs(screens)do if screens[i].id==K then table.insert(screens[i].ClickAreas,H)end end end;function DisableClickArea(G,I)UpdateClickArea(G,{id=G,mode=I,x1=-1,x2=-1,y1=-1,y2=-1})end;function SetRefresh(I,L)I=I or\"all\"L=L or\"all\"if screens~=nil and#screens>0 then for i=1,#screens,1 do if screens[i].mode==I or I==\"all\"then if screens[i].submode==L or L==\"all\"then screens[i].refresh=true end end end end end;function WipeClickAreasForScreen(m)m.ClickAreas={}return m end;function CreateBaseClickAreas(m)table.insert(m.ClickAreas,{mode=\"all\",id=\"ToggleHudMode\",x1=1537,x2=1728,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"damage\",x1=193,x2=384,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"damageoutline\",x1=385,x2=576,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"fuel\",x1=577,x2=768,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"time\",x1=0,x2=192,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"settings1\",x1=1729,x2=1920,y1=1015,y2=1075})return m end;function CreateClickAreasForScreen(m)if m==nil then return{}end;if m.mode==\"flight\"then elseif m.mode==\"damage\"then table.insert(m.ClickAreas,{mode=\"damage\",id=\"ToggleElementLabel\",x1=70,x2=425,y1=325,y2=355})table.insert(m.ClickAreas,{mode=\"damage\",id=\"ToggleElementLabel2\",x1=980,x2=1400,y1=325,y2=355})elseif m.mode==\"damageoutline\"then table.insert(m.ClickAreas,{mode=\"damageoutline\",id=\"DMGOChangeView\",param=\"top\",x1=60,x2=439,y1=150,y2=200})table.insert(m.ClickAreas,{mode=\"damageoutline\",id=\"DMGOChangeView\",param=\"side\",x1=440,x2=824,y1=150,y2=200})table.insert(m.ClickAreas,{mode=\"damageoutline\",id=\"DMGOChangeView\",param=\"front\",x1=825,x2=1215,y1=150,y2=200})table.insert(m.ClickAreas,{mode=\"damageoutline\",id=\"DMGOChangeStretch\",x1=1530,x2=1580,y1=150,y2=200})elseif m.mode==\"fuel\"then elseif m.mode==\"cargo\"then elseif m.mode==\"agg\"then elseif m.mode==\"map\"then elseif m.mode==\"time\"then elseif m.mode==\"settings1\"then table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ToggleBackground\",x1=75,x2=860,y1=170,y2=215})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"PreviousBackground\",x1=75,x2=460,y1=235,y2=285})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"NextBackground\",x1=480,x2=860,y1=235,y2=285})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"DecreaseOpacity\",x1=75,x2=460,y1=300,y2=350})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"IncreaseOpacity\",x1=480,x2=860,y1=300,y2=350})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ResetColors\",x1=75,x2=860,y1=370,y2=415})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"PreviousColorID\",x1=90,x2=140,y1=500,y2=550})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"NextColorID\",x1=795,x2=845,y1=500,y2=550})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"1\",x1=210,x2=290,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"2\",x1=300,x2=380,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"3\",x1=385,x2=465,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"4\",x1=470,x2=550,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"5\",x1=560,x2=640,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"6\",x1=645,x2=725,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"1\",x1=210,x2=290,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"2\",x1=300,x2=380,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"3\",x1=385,x2=465,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"4\",x1=470,x2=550,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"5\",x1=560,x2=640,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"6\",x1=645,x2=725,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ResetPosColor\",x1=160,x2=340,y1=885,y2=935})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ApplyPosColor\",x1=355,x2=780,y1=885,y2=935})elseif m.mode==\"startup\"then end;m=CreateBaseClickAreas(m)return m end;function CheckClick(M,N,O)M=M*1920;N=N*1120;O=O or\"\"HitPayload={}if screens~=nil and#screens>0 then for i=1,#screens,1 do if screens[i].active==true and screens[i].element.getMouseX()~=-1 and screens[i].element.getMouseY()~=-1 then if O==\"\"then for J,j in pairs(screens[i].ClickAreas)do if j~=nil and M>=j.x1 and M<=j.x2 and N>=j.y1 and N<=j.y2 then O=j.id;HitPayload=j;break end end end;if O==\"ButtonPress\"then if screens[i].mode==HitPayload.param then screens[i].mode=\"startup\"else screens[i].mode=HitPayload.param end;if screens[i].mode==\"damageoutline\"then if screens[i].submode==\"\"then screens[i].submode=\"top\"end end;screens[i].refresh=true;screens[i].ClickAreas={}SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"ToggleBackground\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundMode==\"\"then BackgroundSelected=1;BackgroundMode=backgroundModes[BackgroundSelected]else BackgroundSelected=1;BackgroundMode=\"\"end;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"PreviousBackground\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundMode==\"\"then BackgroundSelected=1;BackgroundMode=backgroundModes[BackgroundSelected]else if BackgroundSelected<=1 then BackgroundSelected=#backgroundModes else BackgroundSelected=BackgroundSelected-1 end;BackgroundMode=backgroundModes[BackgroundSelected]end;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"NextBackground\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundMode==\"\"then BackgroundSelected=1;BackgroundMode=backgroundModes[BackgroundSelected]else if BackgroundSelected>=#backgroundModes then BackgroundSelected=1 else BackgroundSelected=BackgroundSelected+1 end;BackgroundMode=backgroundModes[BackgroundSelected]end;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"DecreaseOpacity\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundModeOpacity>0.1 then BackgroundModeOpacity=BackgroundModeOpacity-0.05;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()end elseif O==\"IncreaseOpacity\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundModeOpacity<1.0 then BackgroundModeOpacity=BackgroundModeOpacity+0.05;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()end elseif O==\"ResetColors\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then db.clear()ColorPrimary=\"FF6700\"ColorSecondary=\"FFFFFF\"ColorTertiary=\"000000\"ColorHealthy=\"00FF00\"ColorWarning=\"FFFF00\"ColorCritical=\"FF0000\"ColorBackground=\"000000\"ColorBackgroundPattern=\"4f4f4f\"BackgroundMode=\"deathstar\"BackgroundSelected=1;BackgroundModeOpacity=0.25;colorIDTable={[1]={id=\"ColorPrimary\",desc=\"Main HUD Color\",basec=\"FF6700\",newc=\"FF6700\"},[2]={id=\"ColorSecondary\",desc=\"Secondary HUD Color\",basec=\"FFFFFF\",newc=\"FFFFFF\"},[3]={id=\"ColorTertiary\",desc=\"Tertiary HUD Color\",basec=\"000000\",newc=\"000000\"},[4]={id=\"ColorHealthy\",desc=\"Color code for Healthy/Okay\",basec=\"00FF00\",newc=\"00FF00\"},[5]={id=\"ColorWarning\",desc=\"Color code for Damaged/Warning\",basec=\"FFFF00\",newc=\"FFFF00\"},[6]={id=\"ColorCritical\",desc=\"Color code for Broken/Critical\",basec=\"FF0000\",newc=\"FF0000\"},[7]={id=\"ColorBackground\",desc=\"Background Color\",basec=\"000000\",newc=\"000000\"},[8]={id=\"ColorBackgroundPattern\",desc=\"Background Pattern Color\",basec=\"4F4F4F\",newc=\"4F4F4F\"},[9]={id=\"ColorFuelAtmospheric\",desc=\"Color for Atmo Fuel/Elements\",basec=\"004444\",newc=\"004444\"},[10]={id=\"ColorFuelSpace\",desc=\"Color for Space Fuel/Elements\",basec=\"444400\",newc=\"444400\"},[11]={id=\"ColorFuelRocket\",desc=\"Color for Rocket Fuel/Elements\",basec=\"440044\",newc=\"440044\"}}SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"PreviousColorID\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then colorIDIndex=colorIDIndex-1;if colorIDIndex<1 then colorIDIndex=#colorIDTable end;SaveToDatabank()SetRefresh(\"settings1\")RenderScreens(\"settings1\")elseif O==\"NextColorID\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then colorIDIndex=colorIDIndex+1;if colorIDIndex>#colorIDTable then colorIDIndex=1 end;SaveToDatabank()SetRefresh(\"settings1\")RenderScreens(\"settings1\")elseif O==\"ColorPosUp\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then local P=tonumber(string.sub(colorIDTable[colorIDIndex].newc,HitPayload.param,HitPayload.param),16)P=P+1;if P>15 then P=0 end;colorIDTable[colorIDIndex].newc=replace_char(HitPayload.param,colorIDTable[colorIDIndex].newc,hexTable[P+1])SaveToDatabank()SetRefresh(\"settings1\")RenderScreens(\"settings1\")elseif O==\"ColorPosDown\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then local P=tonumber(string.sub(colorIDTable[colorIDIndex].newc,HitPayload.param,HitPayload.param),16)P=P-1;if P<0 then P=15 end;colorIDTable[colorIDIndex].newc=replace_char(HitPayload.param,colorIDTable[colorIDIndex].newc,hexTable[P+1])SaveToDatabank()SetRefresh(\"settings1\")RenderScreens(\"settings1\")elseif O==\"ResetPosColor\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then colorIDTable[colorIDIndex].newc=colorIDTable[colorIDIndex].basec;_G[colorIDTable[colorIDIndex].id]=colorIDTable[colorIDIndex].basec;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"ApplyPosColor\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then _G[colorIDTable[colorIDIndex].id]=colorIDTable[colorIDIndex].newc;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"DamagedPageDown\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentDamagedPage=CurrentDamagedPage+1;if CurrentDamagedPage>math.ceil(#damagedElements/DamagePageSize)then CurrentDamagedPage=math.ceil(#damagedElements/DamagePageSize)end;HudDeselectElement()SaveToDatabank()SetRefresh(\"damage\")RenderScreens(\"damage\")elseif O==\"DamagedPageUp\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentDamagedPage=CurrentDamagedPage-1;if CurrentDamagedPage<1 then CurrentDamagedPage=1 end;HudDeselectElement()SaveToDatabank()SetRefresh(\"damage\")RenderScreens(\"damage\")elseif O==\"BrokenPageDown\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentBrokenPage=CurrentBrokenPage+1;if CurrentBrokenPage>math.ceil(#brokenElements/DamagePageSize)then CurrentBrokenPage=math.ceil(#brokenElements/DamagePageSize)end;HudDeselectElement()SaveToDatabank()SetRefresh(\"damage\")RenderScreens(\"damage\")elseif O==\"BrokenPageUp\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentBrokenPage=CurrentBrokenPage-1;if CurrentBrokenPage<1 then CurrentBrokenPage=1 end;HudDeselectElement()SaveToDatabank()SetRefresh(\"damage\")RenderScreens(\"damage\")elseif O==\"DMGOChangeView\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then screens[i].submode=HitPayload.param;UpdateViewDamageoutline(screens[i])SaveToDatabank()SetRefresh(\"damageoutline\",screens[i].submode)RenderScreens(\"damageoutline\",screens[i].submode)elseif O==\"DMGOChangeStretch\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if DMGOStretch==true then DMGOStretch=false else DMGOStretch=true end;UpdateViewDamageoutline(screens[i])SaveToDatabank()SetRefresh(\"damageoutline\")RenderScreens(\"damageoutline\")elseif O==\"ToggleDisplayAtmosphere\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if screens[i].fuelA==true then screens[i].fuelA=false else screens[i].fuelA=true end;screens[i].fuelIndex=1;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"ToggleDisplaySpace\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if screens[i].fuelS==true then screens[i].fuelS=false else screens[i].fuelS=true end;screens[i].fuelIndex=1;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"ToggleDisplayRocket\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if screens[i].fuelR==true then screens[i].fuelR=false else screens[i].fuelR=true end;screens[i].fuelIndex=1;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"DecreaseFuelIndex\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then screens[i].fuelIndex=screens[i].fuelIndex-1;if screens[i].fuelIndex<1 then screens[i].fuelIndex=1 end;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"IncreaseFuelIndex\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then screens[i].fuelIndex=screens[i].fuelIndex+1;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"ToggleHudMode\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if HUDMode==true then HUDMode=false;forceDamageRedraw=true;HudDeselectElement()SaveToDatabank()SetRefresh()RenderScreens()else HUDMode=true;forceDamageRedraw=true;HudDeselectElement()SaveToDatabank()SetRefresh()RenderScreens()end elseif O==\"ToggleSimulation\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentDamagedPage=1;CurrentBrokenPage=1;if SimulationMode==true then SimulationMode=false;SimulationActive=false;UpdateDamageData()UpdateTypeData()forceDamageRedraw=true;HudDeselectElement()SetRefresh(\"damage\")SetRefresh(\"damageoutline\")SetRefresh(\"settings1\")SetRefresh(\"fuel\")SaveToDatabank()RenderScreens()else SimulationMode=true;SimulationActive=false;UpdateDamageData()UpdateTypeData()forceDamageRedraw=true;HudDeselectElement()SetRefresh(\"damage\")SetRefresh(\"damageoutline\")SetRefresh(\"settings1\")SetRefresh(\"fuel\")SaveToDatabank()RenderScreens()end elseif(O==\"ToggleElementLabel\"or O==\"ToggleElementLabel2\")and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if UseMyElementNames==true then UseMyElementNames=false;SetRefresh(\"damage\")RenderScreens(\"damage\")else UseMyElementNames=true;SetRefresh(\"damage\")RenderScreens(\"damage\")end elseif(O==\"SwitchScrapTier\"or O==\"SwitchScrapTier2\")and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then ScrapTier=ScrapTier+1;if ScrapTier>4 then ScrapTier=1 end;SetRefresh(\"damage\")RenderScreens(\"damage\")end end end end end;function GetContentFlight()local Q=\"\"Q=Q..GetHeader(\"Flight Data Report\")..[[\n \n ]]return Q end;function GetContentDamage()local Q=\"\"if SimulationMode==true then Q=Q..GetHeader(\"Damage Report (Simulated damage)\")..[[]]else Q=Q..GetHeader(\"Damage Report\")..[[]]end;Q=Q..GetContentDamageScreen()return Q end;function GetContentDamageoutline(m)UpdateDataDamageoutline()UpdateViewDamageoutline(m)local Q=\"\"Q=Q..GetHeader(\"Damage Ship Outline Report\")..GetDamageoutlineShip()..[[]]if m.submode==\"top\"then Q=Q..[[\n \n Top View\n \n Side View\n \n Front View\n ]]elseif m.submode==\"side\"then Q=Q..[[\n \n Top View\n \n Side View\n \n Front View\n ]]elseif m.submode==\"front\"then Q=Q..[[\n \n Top View\n \n Side View\n \n Front View\n ]]else end;Q=Q..[[]]..#dmgoElements..[[ of ]]..ElementCounter..[[ shown]]Q=Q..[[]]if DMGOStretch==true then Q=Q..[[]]end;Q=Q..[[Stretch both axis]]return Q end;function GetContentFuel(m)if#FuelAtmosphericTanks<1 and#FuelSpaceTanks<1 and#FuelRocketTanks<1 then return\"\"end;local R=0;local Q=\"\"local S={}FuelDisplay={m.fuelA,m.fuelS,m.fuelR}if FuelDisplay[1]==true and#FuelAtmosphericTanks>0 then table.insert(S,\"Atmospheric\")R=R+1 end;if FuelDisplay[2]==true and#FuelSpaceTanks>0 then table.insert(S,\"Space\")R=R+1 end;if FuelDisplay[3]==true and#FuelRocketTanks>0 then table.insert(S,\"Rocket\")R=R+1 end;Q=Q..GetHeader(\"Fuel Report (\"..table.concat(S,\", \")..\")\")..[[\n ]]local T=150;local U=0;local V=0;if FuelDisplay[1]==true and#FuelAtmosphericTanks>0 then if R==1 then V=50 elseif R==2 then V=6 elseif R==3 then V=0 end;Q=Q..[[\n \n \n \n ]]Q=Q..[[]]..GenerateCommaValue(FuelAtmosphericCurrent,true)..[[ of ]]..GenerateCommaValue(FuelAtmosphericTotal,true)..[[ | Total Atmospheric Fuel in ]]..#FuelAtmosphericTanks..[[ tank]]..(#FuelAtmosphericTanks==1 and\"\"or\"s\")..[[ (]]..math.floor(100/FuelAtmosphericTotal*FuelAtmosphericCurrent)..[[%)]]U=U+1 end;if FuelDisplay[2]==true and#FuelSpaceTanks>0 then if R==1 then V=50 elseif R==2 then V=6 elseif R==3 then V=0 end;Q=Q..[[\n \n \n \n ]]Q=Q..[[]]..GenerateCommaValue(FuelSpaceCurrent,true)..[[ of ]]..GenerateCommaValue(FuelSpaceTotal,true)..[[ | Total Space Fuel in ]]..#FuelSpaceTanks..[[ tank]]..(#FuelSpaceTanks==1 and\"\"or\"s\")..[[ (]]..math.floor(100/FuelSpaceTotal*FuelSpaceCurrent)..[[%)]]U=U+1 end;if FuelDisplay[3]==true and#FuelRocketTanks>0 then if R==1 then V=50 elseif R==2 then V=6 elseif R==3 then V=0 end;Q=Q..[[\n \n \n \n ]]Q=Q..[[]]..GenerateCommaValue(FuelRocketCurrent,true)..[[ of ]]..GenerateCommaValue(FuelRocketTotal,true)..[[ | Total Rocket Fuel in ]]..#FuelRocketTanks..[[ tank]]..(#FuelRocketTanks==1 and\"\"or\"s\")..[[ (]]..math.floor(100/FuelRocketTotal*FuelRocketCurrent)..[[%)]]end;Q=Q..[[\n \n \n \n ]]local W={}if m.fuelIndex==nil or m.fuelIndex<1 then m.fuelIndex=1 end;if FuelDisplay[1]==true then for f,j in ipairs(FuelAtmosphericTanks)do table.insert(W,j)end end;if FuelDisplay[2]==true then for f,j in ipairs(FuelSpaceTanks)do table.insert(W,j)end end;if FuelDisplay[3]==true then for f,j in ipairs(FuelRocketTanks)do table.insert(W,j)end end;table.sort(W,function(E,F)return E.type\n \n \n ]]if Y.hp==0 then Q=Q..[[]]elseif Y.maxhp-Y.hp>constants.epsilon then Q=Q..[[]]else Q=Q..[[]]end;if Y.hp==0 then Q=Q..[[]]..Y.size..[[]]else Q=Q..[[]]..Y.size..[[]]end;if Y.hp==0 then Q=Q..[[Broken]]..[[0 of ]]..GenerateCommaValue(Y.vol)..[[]]elseif tonumber(Y.percent)<10 then Q=Q..[[]]..Y.percent..[[%]]..[[]]..GenerateCommaValue(Y.cvol)..[[ of ]]..GenerateCommaValue(Y.vol)..[[]]elseif tonumber(Y.percent)<30 then Q=Q..[[]]..Y.percent..[[%]]..[[]]..GenerateCommaValue(Y.cvol)..[[ of ]]..GenerateCommaValue(Y.vol)..[[]]else Q=Q..[[]]..Y.percent..[[%]]..[[]]..GenerateCommaValue(Y.cvol)..[[ of ]]..GenerateCommaValue(Y.vol)..[[]]end;Q=Q..[[]]..Y.name..[[]]Q=Q..[[]]end end;if#FuelAtmosphericTanks>0 then Q=Q..[[]]if FuelDisplay[1]==true then Q=Q..[[]]end;Q=Q..[[ATM]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"ToggleDisplayAtmosphere\",x1=50,x2=100,y1=270,y2=320})end;if#FuelSpaceTanks>0 then Q=Q..[[]]if FuelDisplay[2]==true then Q=Q..[[]]end;Q=Q..[[SPC]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"ToggleDisplaySpace\",x1=200,x2=250,y1=270,y2=320})end;if#FuelRocketTanks>0 then Q=Q..[[]]if FuelDisplay[3]==true then Q=Q..[[]]end;Q=Q..[[RKT]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"ToggleDisplayRocket\",x1=350,x2=400,y1=270,y2=320})end;if m.fuelIndex>1 then Q=Q..[[\n \n \n ]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"DecreaseFuelIndex\",x1=1470,x2=1670,y1=270,y2=320})end;if m.fuelIndex+X-1<#W then Q=Q..[[\n \n \n ]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"IncreaseFuelIndex\",x1=1680,x2=1880,y1=270,y2=320})end;if X>0 then Q=Q..[[]]..#W..[[ Tank]]..(#W==1 and\"\"or\"s\")..[[ (Showing ]]..m.fuelIndex..[[ to ]]..m.fuelIndex+X-1 ..[[)]]end;return Q end;function GetContentCargo()local Q=\"\"Q=Q..GetHeader(\"Cargo Report\")..[[\n \n ]]return Q end;function GetContentAGG()local Q=\"\"Q=Q..GetHeader(\"Anti-Grav Control\")..[[\n \n ]]return Q end;function GetContentMap()local Q=\"\"Q=Q..GetHeader(\"Map Overview\")..[[\n \n ]]return Q end;function GetContentTime()local Q=\"\"Q=Q..GetHeader(\"Time\")..epochTime()Q=Q..[[\n \n \n \n \n \n \n \n \n \n \n \n \n ]]return Q end;function GetContentSettings1()local Q=\"\"Q=Q..GetHeader(\"Settings\")..[[]]if BackgroundMode==\"\"then Q=Q..[[Activate background]]else Q=Q..[[Deactivate background (']]..BackgroundMode..[[', ]]..string.format(\"%.0f\",BackgroundModeOpacity*100)..[[%)]]end;Q=Q..[[\n \n Previous background\n \n Next background\n\n \n Decrease Opacity\n \n Increase Opacity\n ]]Q=Q..[[]]..[[Reset background and all colors]]Q=Q..[[]]..[[]]..[[]]..[[Select and change any of the ]]..#colorIDTable..[[ HUD colors]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..colorIDTable[colorIDIndex].desc..[[]]..[[]]..[[Current color]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[#]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,1,1)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,2,2)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,3,3)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,4,4)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,5,5)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,6,6)..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[New color]]..[[]]..[[Apply new color]]..[[]]..[[Reset]]..[[]]Q=Q..[[]]..[[]]..[[]]..[[Explanation / Hints]]..[[Coming soon.]]Q=Q..[[]]if SimulationMode==true then Q=Q..[[Simulating Damage to elements]]AddClickArea(\"settings1\",{id=\"ToggleSimulation\",mode=\"settings1\",x1=940,x2=1850,y1=919,y2=969})else Q=Q..[[Simulate Damage to elements]]AddClickArea(\"settings1\",{id=\"ToggleSimulation\",mode=\"settings1\",x1=940,x2=1850,y1=919,y2=969})end;return Q end;function GetContentStartup()local Q=\"\"Q=Q..GetElementLogo(812,380,\"f\",\"f\",\"f\")if YourShipsName==\"Enter here\"then Q=Q..[[Spaceship ID ]]..ShipID..[[]]else Q=Q..[[]]..YourShipsName..[[]]end;if ShowWelcomeMessage==true then Q=Q..[[Greetings, Commander ]]..PlayerName..[[.]]end;if#Warnings>0 then Q=Q..[[Warning: ]]..table.concat(Warnings,\" \")..[[]]end;Q=Q..[[Damage Report v]]..VERSION..[[, by Scion Interstellar, DorianGray - Discord: Dorian Gray#2623. Under GNU Public License 3.0.]]return Q end;function RenderScreen(m,a0)if a0==nil then PrintConsole(\"ERROR: contentToRender is nil.\")unit.exit()end;CreateClickAreasForScreen(m)local Q=\"\"Q=Q..[[\n \n \n ]]Q=Q..a0;if m.mode==\"startup\"then Q=Q..[[]]else Q=Q..[[]]end;Q=Q..[[\n \n ]]Q=Q..[[]]local a1=string.len(Q)m.element.setSVG(Q)end;function RenderScreens(a2,a3)a2=a2 or\"all\"a3=a3 or\"all\"if screens~=nil and#screens>0 then local a4=\"\"local a5=\"\"local a6=\"\"local a7=\"\"local a8=\"\"local a9=\"\"local aa=\"\"local ab=\"\"local ac=\"\"local ad=\"\"local ae=\"\"local af=\"\"for J,m in pairs(screens)do if m.refresh==true then local a0=\"\"if m.mode==\"flight\"and(a2==\"flight\"or a2==\"all\")then if a4==\"\"then a4=GetContentFlight()end;a0=a4 elseif m.mode==\"damage\"and(a2==\"damage\"or a2==\"all\")then if a5==\"\"then a5=GetContentDamage()end;a0=a5 elseif m.mode==\"damageoutline\"and(a2==\"damageoutline\"or a2==\"all\")then if m.submode==\"\"then m.submode=\"top\"screens[J].submode=\"top\"end;if m.submode==\"top\"and(a3==\"top\"or a3==\"all\")then if a6==\"\"then a6=GetContentDamageoutline(m)end;a0=a6 end;if m.submode==\"side\"and(a3==\"side\"or a3==\"all\")then if a7==\"\"then a7=GetContentDamageoutline(m)end;a0=a7 end;if m.submode==\"front\"and(a3==\"front\"or a3==\"all\")then if a8==\"\"then a8=GetContentDamageoutline(m)end;a0=a8 end elseif m.mode==\"fuel\"and(a2==\"fuel\"or a2==\"all\")then m=WipeClickAreasForScreen(screens[J])a0=GetContentFuel(m)elseif m.mode==\"cargo\"and(a2==\"cargo\"or a2==\"all\")then if aa==\"\"then aa=GetContentCargo()end;a0=aa elseif m.mode==\"agg\"and(a2==\"agg\"or a2==\"all\")then if ab==\"\"then ab=GetContentAGG()end;a0=ab elseif m.mode==\"map\"and(a2==\"map\"or a2==\"all\")then if ac==\"\"then ac=GetContentMap()end;a0=ac elseif m.mode==\"time\"and(a2==\"time\"or a2==\"all\")then if ad==\"\"then ad=GetContentTime()end;a0=ad elseif m.mode==\"settings1\"and(a2==\"settings1\"or a2==\"all\")then if ae==\"\"then ae=GetContentSettings1()end;a0=ae elseif m.mode==\"startup\"and(a2==\"startup\"or a2==\"all\")then if af==\"\"then af=GetContentStartup()end;a0=af else a0=\"Invalid screen mode. ('\"..m.mode..\"')\"end;if a0~=\"\"then RenderScreen(m,a0)else DrawCenteredText(\"ERROR: No contentToRender delivered for \"..m.mode)PrintConsole(\"ERROR: No contentToRender delivered for \"..m.mode)unit.exit()end;screens[J].refresh=false end end end;if HUDMode==true then system.setScreen(GetContentDamageHUDOutput())system.showScreen(1)else system.showScreen(0)end end;function OnTickData(C)if formerTime+605 or SkillRepairToolOptimization>5 or StatFuelTankOptimization>5 or StatContainerOptimization>5 or StatAtmosphericFuelTankHandling>5 or StatSpaceFuelTankHandling>5 or StatRocketFuelTankHandling>5 then PrintConsole(\"ERROR: Talents/stats can only range from 0 to 5. Please set correctly in LUA settings and reactivate script.\")unit.exit()end;if screens==nil or#screens==0 then HUDMode=true;PrintConsole(\"Warning: No screens connected. Entering HUD mode only.\")end;OnTickData(true)unit.setTimer('UpdateData',UpdateDataInterval)unit.setTimer('UpdateHighlight',HighlightBlinkingInterval)",
- "filter": {
- "args": [],
- "signature": "start()",
- "slotKey": "-1"
- },
- "key": "13"
- },
- {
- "code": "ActionUp()",
- "filter": {
- "args": [
- {
- "value": "up"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "14"
- },
- {
- "code": "ActionDown()",
- "filter": {
- "args": [
- {
- "value": "down"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "15"
- },
- {
- "code": "ActionStrafeLeft()",
- "filter": {
- "args": [
- {
- "value": "strafeleft"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "16"
- },
- {
- "code": "ActionStrafeRight()",
- "filter": {
- "args": [
- {
- "value": "straferight"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "17"
- },
- {
- "code": "KeyCTRLPressed = true",
- "filter": {
- "args": [
- {
- "value": "brake"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "18"
- },
- {
- "code": "KeyCTRLPressed = false",
- "filter": {
- "args": [
- {
- "value": "brake"
- }
- ],
- "signature": "actionStop(action)",
- "slotKey": "-2"
- },
- "key": "19"
- },
- {
- "code": "ActionOption1()",
- "filter": {
- "args": [
- {
- "value": "option1"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "20"
- },
- {
- "code": "ActionOption2()",
- "filter": {
- "args": [
- {
- "value": "option2"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "21"
- },
- {
- "code": "ActionOption3()",
- "filter": {
- "args": [
- {
- "value": "option3"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "22"
- },
- {
- "code": "ActionOption4()",
- "filter": {
- "args": [
- {
- "value": "option4"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "23"
- },
- {
- "code": "ActionOption9()",
- "filter": {
- "args": [
- {
- "value": "option9"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "24"
- },
- {
- "code": "ActionOption8()",
- "filter": {
- "args": [
- {
- "value": "option8"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "25"
- }
- ],
- "methods": [],
- "events": []
-}
\ No newline at end of file
diff --git a/versions/DamageReport_3_11.conf b/versions/DamageReport_3_11.conf
deleted file mode 100644
index 3dab058..0000000
--- a/versions/DamageReport_3_11.conf
+++ /dev/null
@@ -1,436 +0,0 @@
-{
- "slots": {
- "0": {
- "name": "slot1",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "1": {
- "name": "slot2",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "2": {
- "name": "slot3",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "3": {
- "name": "slot4",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "4": {
- "name": "slot5",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "5": {
- "name": "slot6",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "6": {
- "name": "slot7",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "7": {
- "name": "slot8",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "8": {
- "name": "slot9",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "9": {
- "name": "slot10",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-1": {
- "name": "unit",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-2": {
- "name": "system",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-3": {
- "name": "library",
- "type": {
- "events": [],
- "methods": []
- }
- }
- },
- "handlers": [
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "2"
- },
- "key": "0"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "3"
- },
- "key": "1"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "4"
- },
- "key": "2"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "5"
- },
- "key": "3"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "6"
- },
- "key": "4"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "7"
- },
- "key": "5"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "8"
- },
- "key": "6"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "9"
- },
- "key": "7"
- },
- {
- "code": "function GenerateCommaValue(a,b,c)b=b or false;c=c or 1;local d=a;if b==true then if string.len(a)>=4 then d=string.format(\"%.\"..c..\"fk\",a/1000)else d=string.format(\"%.\"..c..\"f\",a)end else while true do d,k=string.gsub(d,\"^(-?%d+)(%d%d%d)\",'%1,%2')if k==0 then break end end end;return d end;function PrintConsole(e,f)f=f or false;if f then system.print(\"------------------------------------------------------------------------\")end;system.print(e)if f then system.print(\"------------------------------------------------------------------------\")end end;function DrawCenteredText(e)if screens~=nil and#screens>0 then for g=1,#screens,1 do screens[g].element.setCenteredText(e)end end end;function ClearConsole()for g=1,10,1 do PrintConsole()end end;function SwitchScreens(h)h=h or\"on\"if screens~=nil and#screens>0 then for g=1,#screens,1 do if h==\"on\"then screens[g].element.clear()screens[g].element.activate()screens[g].active=true else screens[g].element.clear()screens[g].element.deactivate()screens[g].active=false end end end end;function GetSecondsString(i)local i=tonumber(i)if i==nil or i<=0 then return\"-\"else days=string.format(\"%2.f\",math.floor(i/(3600*24)))hours=string.format(\"%2.f\",math.floor(i/3600-days*24))mins=string.format(\"%2.f\",math.floor(i/60-hours*60-days*24*60))secs=string.format(\"%2.f\",math.floor(i-hours*3600-days*24*60*60-mins*60))str=\"\"if tonumber(days)>0 then str=str..days..\"d \"end;if tonumber(hours)>0 then str=str..hours..\"h \"end;if tonumber(mins)>0 then str=str..mins..\"m \"end;if tonumber(secs)>0 then str=str..secs..\"s\"end;return str end end;function replace_char(j,str,l)return str:sub(1,j-1)..l..str:sub(j+1)end;function epochTime()function rZ(m)if string.len(m)<=1 then return\"0\"..m else return m end end;function dPoint(n)if not(n==math.floor(n))then return true else return false end end;function lYear(year)if not dPoint(year/4)then if dPoint(year/100)then return true else if not dPoint(year/400)then return true else return false end end else return false end end;local o=5;local p=3600;local q=86400;local r=31536000;local s=31622400;local t=2419200;local g=2505600;local u=2592000;local k=2678400;local w={4,6,9,11}local x={1,3,5,7,8,10,12}local y=0;local z=1506816000;local A=system.getTime()_G[\"formerTime\"]=A;if AddSummertimeHour==true then A=A+3600 end;now=math.floor(A+z)year=1970;secs=0;y=0;while secs+s]]..hour..\":\"..minute..[[]]..[[]]..year..\"/\"..month..\"/\"..day..[[]]end;function ToggleHUD()if HUDMode==true then HUDMode=false;forceDamageRedraw=true;hudSelectedIndex=0;highlightID=0;HideHighlight()SetRefresh()RenderScreens()else HUDMode=true;forceDamageRedraw=true;hudSelectedIndex=0;highlightID=0;HideHighlight()SetRefresh()RenderScreens()end end;function HudDeselectElement()hudSelectedIndex=0;hudStartIndex=1;highlightID=0;HideHighlight()if HUDMode==true then SetRefresh(\"damage\")SetRefresh(\"damageoutline\")RenderScreens()end end;function ChangeHudSelectedElement(B)if HUDMode==true and#rE>0 then hudSelectedIndex=hudSelectedIndex+B;if hudSelectedIndex<1 then hudSelectedIndex=1 elseif hudSelectedIndex>#rE then hudSelectedIndex=#rE end;if hudSelectedIndex>9 then hudStartIndex=hudSelectedIndex-9 end;if hudSelectedIndex~=0 then highlightID=rE[hudSelectedIndex].id;if highlightID~=nil and highlightID~=0 then HideHighlight()elementPosition=vec3(rE[hudSelectedIndex].pos)highlightX=elementPosition.x-coreWorldOffset;highlightY=elementPosition.y-coreWorldOffset;highlightZ=elementPosition.z-coreWorldOffset;highlightOn=true;ShowHighlight()end end;SetRefresh(\"damage\")SetRefresh(\"damageoutline\")RenderScreens()end end;function HideHighlight()if#hudArrowSticker>0 then for g in pairs(hudArrowSticker)do core.deleteSticker(hudArrowSticker[g])end;hudArrowSticker={}end end;function ShowHighlight()if highlightOn==true and highlightID>0 then table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX+2,highlightY,highlightZ,\"north\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX,highlightY-2,highlightZ,\"east\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX-2,highlightY,highlightZ,\"south\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX,highlightY+2,highlightZ,\"west\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX,highlightY,highlightZ-2,\"up\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX,highlightY,highlightZ+2,\"down\"))end end;function ToggleHighlight()if highlightOn==true then highlightOn=false;HideHighlight()else highlightOn=true;ShowHighlight()end end;function SortDamageTables()table.sort(damagedElements,function(m,n)return m.missinghp>n.missinghp end)table.sort(brokenElements,function(m,n)return m.maxhp>n.maxhp end)end;function getScraps(C,D)D=D or false;C=C-SkillRepairToolOptimization*0.05*C;local E=math.ceil(C/(10*5^(ScrapTier-1)))if D==true then return GenerateCommaValue(string.format(\"%.0f\",E),false)else return E end end;function getRepairTime(C,F)F=F or false;C=C-SkillRepairToolOptimization*0.05*C;local E=math.ceil(C/ScrapTierRepairTimes[ScrapTier])E=E-SkillRepairToolEfficiency*0.1*E;if F==true then return GetSecondsString(string.format(\"%.0f\",E))else return E end end;function UpdateDataDamageoutline()dmgoElements={}for g,G in ipairs(brokenElements)do if#dmgoElementsShipXmax then ShipXmax=H end;if I>ShipYmax then ShipYmax=I end;if J>ShipZmax then ShipZmax=J end;table.insert(dmgoElements,{id=G.id,type=\"b\",size=G.maxhp,x=H,y=I,z=J,xp=0,yp=0,zp=0,u=0,v=0})end end;if#dmgoElementsShipXmax then ShipXmax=H end;if I>ShipYmax then ShipYmax=I end;if J>ShipZmax then ShipZmax=J end;table.insert(dmgoElements,{id=G.id,type=\"d\",size=G.maxhp,x=H,y=I,z=J,xp=0,yp=0,zp=0,u=0,v=0})end end end;if#dmgoElementsShipXmax then ShipXmax=H end;if I>ShipYmax then ShipYmax=I end;if J>ShipZmax then ShipZmax=J end;table.insert(dmgoElements,{id=G.id,type=\"h\",size=G.maxhp,x=H,y=I,z=J,xp=0,yp=0,zp=0,u=0,v=0})end end end;ShipX=math.abs(ShipXmax-ShipXmin)ShipY=math.abs(ShipYmax-ShipYmin)ShipZ=math.abs(ShipZmax-ShipZmin)for g,G in ipairs(dmgoElements)do dmgoElements[g].xp=math.abs(100/(ShipXmax-ShipXmin)*(G.x-ShipXmin))dmgoElements[g].yp=math.abs(100/(ShipYmax-ShipYmin)*(G.y-ShipYmin))dmgoElements[g].zp=math.abs(100/(ShipZmax-ShipZmin)*(G.z-ShipZmin))end end;function UpdateViewDamageoutline(K)UFrame=40;VFrame=40;UStart=20+UFrame;VStart=180+VFrame;UDim=1880-2*UFrame;VDim=840-2*VFrame;if K.submode==\"top\"then if DMGOStretch==false then local L=UDim/(ShipYmax-ShipYmin)local M=VDim/(ShipXmax-ShipXmin)if L>=M then local N=L/M;local O=math.floor(UDim/N)UStart=UStart+(UDim-O)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100/N*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100*G.xp+VStart)end else local N=M/L;local P=math.floor(VDim/N)VStart=VStart+(VDim-P)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100/N*G.xp+VStart)end end else for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100*G.xp+VStart)end end elseif K.submode==\"front\"then if DMGOStretch==false then local L=UDim/(ShipXmax-ShipXmin)local M=VDim/(ShipZmax-ShipZmin)if L>=M then local N=L/M;local O=math.floor(UDim/N)UStart=UStart+(UDim-O)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100/N*G.xp+UStart)dmgoElements[g].v=math.floor(VDim/100*(100-G.zp)+VStart)end else local N=M/L;local P=math.floor(VDim/N)VStart=VStart+(VDim-P)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.xp+UStart)dmgoElements[g].v=math.floor(VDim/100/N*(100-G.zp)+VStart)end end else for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.xp+UStart)dmgoElements[g].v=math.floor(VDim/100*(100-G.zp)+VStart)end end elseif K.submode==\"side\"then if DMGOStretch==false then local L=UDim/(ShipYmax-ShipYmin)local M=VDim/(ShipXmax-ShipZmin)if L>=M then local N=L/M;local O=math.floor(UDim/N)UStart=UStart+(UDim-O)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100/N*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100*(100-G.zp)+VStart)end else local N=M/L;local P=math.floor(VDim/N)VStart=VStart+(VDim-P)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100/N*(100-G.zp)+VStart)end end else for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100*(100-G.zp)+VStart)end end else DrawCenteredText(\"ERROR: non-existing DMGO mode set.\")PrintConsole(\"ERROR: non-existing DMGO mode set.\")unit.exit()end end;function GetDamageoutlineShip()local e=\"\"for g,G in ipairs(dmgoElements)do local Q=\"\"local R=1;if G.type==\"h\"then Q=\"ch\"elseif G.type==\"d\"then Q=\"cw\"else Q=\"cc\"end;if G.id==highlightID then Q=\"f2\"end;if G.size>0 and G.size<1000 then R=5 elseif G.size>=1000 and G.size<2000 then R=8 elseif G.size>=2000 and G.size<5000 then R=12 elseif G.size>=5000 and G.size<10000 then R=15 elseif G.size>=10000 and G.size<20000 then R=20 elseif G.size>=20000 then R=30 end;e=e..[[]]if G.id==highlightID then e=e..[[]]e=e..[[]]end end;return e end;function GetContentClickareas(K)local e=\"\"if K~=nil and K.ClickAreas~=nil and#K.ClickAreas>0 then for g,S in ipairs(K.ClickAreas)do e=e..[[]]end end;return e end;function GetElement1(H,I,T,U)H=H or 0;I=I or 0;T=T or 600;U=U or 600;local e=\"\"e=e..[[\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ]]return e end;function GetElement2(H,I)H=H or 0;I=I or 0;local e=\"\"e=e..[[]]return e end;function GetElementLogo(H,I,V,W,X)H=H or 812;I=I or 380;V=V or\"f\"W=W or\"f2\"X=X or\"f3\"local e=\"\"e=e..[[\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ]]return e end;function GetHeader(Y)Y=Y or\"ERROR: UNDEFINED\"local e=\"\"e=e..[[\n ]]..Y..[[]]return e end;function GetContentBackground(Z,_)bgColor=ColorBackgroundPattern;local e=\"\"if Z==\"dots\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' viewBox='0 0 4 4'%3E%3Cpath fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' d='M1 3h1v1H1V3zm2-2h1v1H3V1z'%3E%3C/path%3E%3C/svg%3E\");]]elseif Z==\"rain\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='12' height='16' viewBox='0 0 12 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 .99C4 .445 4.444 0 5 0c.552 0 1 .45 1 .99v4.02C6 5.555 5.556 6 5 6c-.552 0-1-.45-1-.99V.99zm6 8c0-.546.444-.99 1-.99.552 0 1 .45 1 .99v4.02c0 .546-.444.99-1 .99-.552 0-1-.45-1-.99V8.99z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E\");]]elseif Z==\"plus\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E\");]]elseif Z==\"signal\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='84' height='48' viewBox='0 0 84 48' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h12v6H0V0zm28 8h12v6H28V8zm14-8h12v6H42V0zm14 0h12v6H56V0zm0 8h12v6H56V8zM42 8h12v6H42V8zm0 16h12v6H42v-6zm14-8h12v6H56v-6zm14 0h12v6H70v-6zm0-16h12v6H70V0zM28 32h12v6H28v-6zM14 16h12v6H14v-6zM0 24h12v6H0v-6zm0 8h12v6H0v-6zm14 0h12v6H14v-6zm14 8h12v6H28v-6zm-14 0h12v6H14v-6zm28 0h12v6H42v-6zm14-8h12v6H56v-6zm0-8h12v6H56v-6zm14 8h12v6H70v-6zm0 8h12v6H70v-6zM14 24h12v6H14v-6zm14-8h12v6H28v-6zM14 8h12v6H14V8zM0 8h12v6H0V8z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E\");]]elseif Z==\"deathstar\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='105' viewBox='0 0 80 105'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M20 10a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm15 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zM20 75a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zm30-65a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm0 65a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zM35 10a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zM5 45a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zm60 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10z' /%3E%3C/g%3E%3C/g%3E%3C/svg%3E\");]]elseif Z==\"diamond\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='32' viewBox='0 0 16 32'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath fill-rule='evenodd' d='M0 24h4v2H0v-2zm0 4h6v2H0v-2zm0-8h2v2H0v-2zM0 0h4v2H0V0zm0 4h2v2H0V4zm16 20h-6v2h6v-2zm0 4H8v2h8v-2zm0-8h-4v2h4v-2zm0-20h-6v2h6V0zm0 4h-4v2h4V4zm-2 12h2v2h-2v-2zm0-8h2v2h-2V8zM2 8h10v2H2V8zm0 8h10v2H2v-2zm-2-4h14v2H0v-2zm4-8h6v2H4V4zm0 16h6v2H4v-2zM6 0h2v2H6V0zm0 24h2v2H6v-2z'/%3E%3C/g%3E%3C/svg%3E\");]]elseif Z==\"hexagon\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='49' viewBox='0 0 28 49'%3E%3Cg fill-rule='evenodd'%3E%3Cg id='hexagons' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='nonzero'%3E%3Cpath d='M13.99 9.25l13 7.5v15l-13 7.5L1 31.75v-15l12.99-7.5zM3 17.9v12.7l10.99 6.34 11-6.35V17.9l-11-6.34L3 17.9zM0 15l12.98-7.5V0h-2v6.35L0 12.69v2.3zm0 18.5L12.98 41v8h-2v-6.85L0 35.81v-2.3zM15 0v7.5L27.99 15H28v-2.31h-.01L17 6.35V0h-2zm0 49v-8l12.99-7.5H28v2.31h-.01L17 42.15V49h-2z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E\");]]elseif Z==\"capsule\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='32' height='26' viewBox='0 0 32 26' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M14 0v3.994C14 7.864 10.858 11 7 11c-3.866 0-7-3.138-7-7.006V0h2v4.005C2 6.765 4.24 9 7 9c2.756 0 5-2.236 5-4.995V0h2zm0 26v-5.994C14 16.138 10.866 13 7 13c-3.858 0-7 3.137-7 7.006V26h2v-6.005C2 17.235 4.244 15 7 15c2.76 0 5 2.236 5 4.995V26h2zm2-18.994C16 3.136 19.142 0 23 0c3.866 0 7 3.138 7 7.006v9.988C30 20.864 26.858 24 23 24c-3.866 0-7-3.138-7-7.006V7.006zm2-.01C18 4.235 20.244 2 23 2c2.76 0 5 2.236 5 4.995v10.01C28 19.765 25.756 22 23 22c-2.76 0-5-2.236-5-4.995V6.995z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E\");]]elseif Z==\"diagonal\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='6' height='6' viewBox='0 0 6 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'%3E%3Cpath d='M5 0h1L0 6V5zM6 5v1H5z'/%3E%3C/g%3E%3C/svg%3E\");]]end;return e end;function GetContentDamageHUDOutput()local a0=300;local a1=165;if#damagedElements>0 or#brokenElements>0 then a1=510 end;local e=\"\"e=e..[[\n \n ]]e=e..[[]]..[[]]..[[]]..[[]]..(YourShipsName==\"Enter here\"and\"Ship ID \"..ShipID or YourShipsName)..[[]]..[[]]if#brokenElements>0 then e=e..[[]]elseif#damagedElements>0 then e=e..[[]]else e=e..[[]]end;if#damagedElements>0 or#brokenElements>0 then e=e..[[Total Damage]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",totalShipMaxHP-totalShipHP))..[[]]e=e..[[T]]..ScrapTier..[[ Scrap Needed]]..[[]]..getScraps(totalShipMaxHP-totalShipHP,true)..[[]]e=e..[[Repair Time]]..[[]]..getRepairTime(totalShipMaxHP-totalShipHP,true)..[[]]e=e..[[]]..[[]]..[[]]..#healthyElements..[[]]..[[]]..[[]]..#damagedElements..[[]]..[[]]..[[]]..#brokenElements..[[]]local u=0;for a2=hudStartIndex,hudStartIndex+9,1 do if rE[a2]~=nil then v=rE[a2]if v.hp>0 then e=e..[[]]..[[]]..string.format(\"%.30s\",v.name)..[[]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",v.missinghp))..[[]]if v.id==highlightID then e=e..[[]]..[[]]..string.format(\"%.30s\",v.name)..[[]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",v.missinghp))..[[]]end else e=e..[[]]..[[]]..string.format(\"%.30s\",v.name)..[[]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",v.missinghp))..[[]]if v.id==highlightID then highlightX=elementPosition.x-coreWorldOffset;highlightY=elementPosition.y-coreWorldOffset;highlightZ=elementPosition.z-coreWorldOffset;e=e..[[]]..[[]]..string.format(\"%.30s\",v.name)..[[]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",v.missinghp))..[[]]end end;u=u+1 end end;e=e..[[]]..[[]]..[[]]..[[]]..[[Up/down arrows to highlight]]..[[CTRL + arrows to move HUD]]..[[Left arrow to toggle HUD Mode]]..[[ALT+1-4 to set Scrap Tier]]..[[ALT+8 to reset HUD position]]..[[ALT+9 to shut script off]]..[[]]..[[]]else e=e..[[]]..OkayCenterMessage..[[]]..[[]]..#healthyElements..[[ elements / ]]..GenerateCommaValue(string.format(\"%.0f\",totalShipMaxHP))..[[ HP.]]..[[]]..[[]]..[[]]..[[]]..[[Left arrow to toggle HUD Mode]]..[[CTRL + arrows to move HUD]]..[[ALT+8 to reset HUD position]]..[[ALT+9 to shut script off]]..[[]]..[[]]end;e=e..[[]]return e end;function GetContentDamageScreen()local a3=\"\"if#damagedElements>0 then local a4=#damagedElements;if a4>DamagePageSize then a4=DamagePageSize end;if CurrentDamagedPage==math.ceil(#damagedElements/DamagePageSize)then a4=#damagedElements%DamagePageSize+12;if a4>12 then a4=a4-12 end end;a3=a3 ..[[]]a3=a3 ..[[]]if UseMyElementNames==true then a3=a3 ..[[Damaged Name]]else a3=a3 ..[[Damaged Type]]end;a3=a3 ..[[HLTHDMG]]a3=a3 ..[[T]]..ScrapTier..[[ SCRREPTIME]]AddClickArea(\"damage\",{id=\"SwitchScrapTier\",mode=\"damage\",x1=650,x2=775,y1=315,y2=360})local g=0;for u=1+(CurrentDamagedPage-1)*DamagePageSize,a4+(CurrentDamagedPage-1)*DamagePageSize,1 do g=g+1;local a5=damagedElements[u]if UseMyElementNames==true then a3=a3 ..[[]]..string.format(\"%.23s\",a5.name)..[[]]else a3=a3 ..[[]]..string.format(\"%.23s\",a5.type)..[[]]end;a3=a3 ..[[]]..a5.percent..[[%]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",a5.missinghp),true)..[[]]..[[]]..getScraps(a5.missinghp,true)..[[]]..[[]]..getRepairTime(a5.missinghp,true)..[[]]..[[]]end;if#damagedElements>DamagePageSize then a3=a3 ..[[Page ]]..CurrentDamagedPage..\" of \"..math.ceil(#damagedElements/DamagePageSize)..[[]]if CurrentDamagedPage\n \n \n ]]AddClickArea(\"damage\",{id=\"DamagedPageDown\",mode=\"damage\",x1=65,x2=260,y1=290+(a4+1)*50,y2=290+50+(a4+1)*50})else DisableClickArea(\"DamagedPageDown\",\"damage\")end;if CurrentDamagedPage>1 then a3=a3 ..[[\n \n \n ]]AddClickArea(\"damage\",{id=\"DamagedPageUp\",mode=\"damage\",x1=750,x2=950,y1=290+(a4+1)*50,y2=290+50+(a4+1)*50})else DisableClickArea(\"DamagedPageUp\",\"damage\")end end end;if#brokenElements>0 then local a6=#brokenElements;if a6>DamagePageSize then a6=DamagePageSize end;if CurrentBrokenPage==math.ceil(#brokenElements/DamagePageSize)then a6=#brokenElements%DamagePageSize+12;if a6>12 then a6=a6-12 end end;a3=a3 ..[[]]a3=a3 ..[[]]if UseMyElementNames==true then a3=a3 ..[[Broken Name]]else a3=a3 ..[[Broken Type]]end;a3=a3 ..[[DMG]]a3=a3 ..[[T]]..ScrapTier..[[ SCRREPTIME]]AddClickArea(\"damage\",{id=\"SwitchScrapTier2\",mode=\"damage\",x1=1570,x2=1690,y1=315,y2=360})local g=0;for u=1+(CurrentBrokenPage-1)*DamagePageSize,a6+(CurrentBrokenPage-1)*DamagePageSize,1 do g=g+1;local a5=brokenElements[u]if UseMyElementNames==true then a3=a3 ..[[]]..string.format(\"%.30s\",a5.name)..[[]]else a3=a3 ..[[]]..string.format(\"%.30s\",a5.type)..[[]]end;a3=a3 ..[[]]..GenerateCommaValue(string.format(\"%.0f\",a5.missinghp),true)..[[]]..[[]]..getScraps(a5.missinghp,true)..[[]]..[[]]..getRepairTime(a5.missinghp,true)..[[]]..[[]]end;if#brokenElements>DamagePageSize then a3=a3 ..[[Page ]]..CurrentBrokenPage..\" of \"..math.ceil(#brokenElements/DamagePageSize)..[[]]if CurrentBrokenPage>1 then a3=a3 ..[[\n \n \n ]]AddClickArea(\"damage\",{id=\"BrokenPageUp\",mode=\"damage\",x1=1665,x2=1865,y1=290+(a6+1)*50,y2=290+50+(a6+1)*50})else DisableClickArea(\"BrokenPageUp\",\"damage\")end;if CurrentBrokenPage\n \n \n ]]AddClickArea(\"damage\",{id=\"BrokenPageDown\",mode=\"damage\",x1=980,x2=1180,y1=290+(a6+1)*50,y2=290+50+(a6+1)*50})else DisableClickArea(\"BrokenPageDown\",\"damage\")end end end;if#damagedElements>0 or#brokenElements>0 then local a7=math.floor(1878/#elementsIdList*#damagedElements)local a8=math.floor(1878/#elementsIdList*#brokenElements)local a9=1878-a7-a8+1;a3=a3 ..[[]]a3=a3 ..[[]]a3=a3 ..[[]]a3=a3 ..[[]]if#damagedElements>0 then a3=a3 ..[[]]..#damagedElements..[[]]end;if#healthyElements>0 then a3=a3 ..[[]]..#healthyElements..[[]]end;if#brokenElements>0 then a3=a3 ..[[]]..#brokenElements..[[]]end;a3=a3 ..[[]]a3=a3 ..[[]]..GenerateCommaValue(string.format(\"%.0f\",totalShipMaxHP-totalShipHP))..[[ HP damage in total ]]..getScraps(totalShipMaxHP-totalShipHP,true)..[[ T]]..ScrapTier..[[ scraps needed. ]]..getRepairTime(totalShipMaxHP-totalShipHP,true)..[[ projected repair time.]]else a3=a3 ..GetElementLogo(812,380,\"ch\",\"ch\",\"ch\")..[[]]..OkayCenterMessage..[[]]..[[]]..#healthyElements..[[ elements stand ]]..GenerateCommaValue(string.format(\"%.0f\",totalShipMaxHP))..[[ HP strong.]]end;forceDamageRedraw=false;return a3 end;function ActionStopengines()ToggleHUD()end;function ActionStrafeRight()if KeyCTRLPressed==true then if HUDShiftU<4000 then HUDShiftU=HUDShiftU+50;SaveToDatabank()RenderScreens()end else HudDeselectElement()end end;function ActionStrafeLeft()if KeyCTRLPressed==true then if HUDShiftU>=50 then HUDShiftU=HUDShiftU-50;SaveToDatabank()RenderScreens()end else ToggleHUD()end end;function ActionDown()if KeyCTRLPressed==true then if HUDShiftV<4000 then HUDShiftV=HUDShiftV+50;SaveToDatabank()RenderScreens()end else ChangeHudSelectedElement(1)end end;function ActionUp()if KeyCTRLPressed==true then if HUDShiftV>=50 then HUDShiftV=HUDShiftV-50;SaveToDatabank()RenderScreens()end else ChangeHudSelectedElement(-1)end end;function ActionOption1()ScrapTier=1;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption2()ScrapTier=2;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption3()ScrapTier=3;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption4()ScrapTier=4;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption8()HUDShiftU=0;HUDShiftV=0;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption9()SaveToDatabank()SwitchScreens(\"off\")unit.exit()end",
- "filter": {
- "args": [],
- "signature": "start()",
- "slotKey": "-1"
- },
- "key": "8"
- },
- {
- "code": "SaveToDatabank()\nSwitchScreens(\"off\")",
- "filter": {
- "args": [],
- "signature": "stop()",
- "slotKey": "-1"
- },
- "key": "9"
- },
- {
- "code": "OnTickData()\n",
- "filter": {
- "args": [
- {
- "value": "UpdateData"
- }
- ],
- "signature": "tick(timerId)",
- "slotKey": "-1"
- },
- "key": "10"
- },
- {
- "code": "ToggleHighlight()",
- "filter": {
- "args": [
- {
- "value": "UpdateHighlight"
- }
- ],
- "signature": "tick(timerId)",
- "slotKey": "-1"
- },
- "key": "11"
- },
- {
- "code": "--[[\n Damage Report 3.11\n A LUA script for Dual Universe\n\n Created By Dorian Gray\n Ingame: DorianGray\n Discord: Dorian Gray#2623\n\n You can find/update this script on GitHub. Explanations, installation and usage information as well as screenshots can be found there too.\n GitHub: https://github.com/DorianTheGrey/DU-DamageReport\n\n GNU Public License 3.0. Use whatever you want, be so kind to leave credit.\n \n Credits & thanks: \n Thanks to NovaQuark for creating the MMO of the century.\n Thanks to Jericho, Dmentia and Archaegeo for learning a lot from their fine scripts.\n Thanks to TheBlacklist for testing and wonderful suggestions.\n SVG patterns by Hero Patterns.\n DU atlas data from Jayle Break.\n \n]]\n\n--[[ 1. USER DEFINED VARIABLES ]]\n\nYourShipsName = \"Enter here\" --export Enter your ship name here if you want it displayed instead of the ship's ID. YOU NEED TO LEAVE THE QUOTATION MARKS.\n\nSkillRepairToolEfficiency = 0 --export Enter (0-5) your talent \"Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency\"\nSkillRepairToolOptimization = 0 --export Enter your talent \"Mining and Inventory -> Equipment Manager -> Repair Tool Optimization\"\n\nStatAtmosphericFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED ATMOSPHERIC FUEL TANKS (from the builders talent \"Piloting -> Atmospheric Flight Technician -> Atmospheric Fuel-Tank Handling\")\nStatSpaceFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL SPACE TANKS (from the builders talent \"Piloting -> Atmospheric Engine Technician -> Space Fuel-Tank Handling\")\nStatRocketFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL ROCKET TANKS (from the builders talent \"Piloting -> Rocket Scientist -> Rocket Booster Fuel Tank Handling\")\nStatContainerOptimization = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL TANKS \"from the builders talent Mining and Inventory -> Stock Control -> Container Optimization\"\nStatFuelTankOptimization = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL TANKS \"from the builders talent Mining and Inventory -> Stock Control -> Fuel Tank Optimization\"\n\nShowWelcomeMessage = true --export Do you want the welcome message on the start screen with your name?\nAddSummertimeHour = false --export: Is summertime currently enabled in your location? (Adds one hour.)\n\nUpdateDataInterval=1.0;HighlightBlinkingInterval=0.5;ColorPrimary=\"FF6700\"ColorSecondary=\"FFFFFF\"ColorTertiary=\"000000\"ColorHealthy=\"00FF00\"ColorWarning=\"FFFF00\"ColorCritical=\"FF0000\"ColorBackground=\"000000\"ColorBackgroundPattern=\"4F4F4F\"ColorFuelAtmospheric=\"004444\"ColorFuelSpace=\"444400\"ColorFuelRocket=\"440044\"VERSION=3.11;DebugMode=false;DebugRenderClickareas=true;DBData={}core=nil;db=nil;screens={}dscreens={}Warnings={}screenModes={[\"flight\"]={id=\"flight\"},[\"damage\"]={id=\"damage\"},[\"damageoutline\"]={id=\"damageoutline\"},[\"fuel\"]={id=\"fuel\"},[\"cargo\"]={id=\"cargo\"},[\"agg\"]={id=\"agg\"},[\"map\"]={id=\"map\"},[\"time\"]={id=\"time\",activetoggle=\"true\"},[\"settings1\"]={id=\"settings1\"},[\"startup\"]={id=\"startup\"}}backgroundModes={\"deathstar\",\"capsule\",\"rain\",\"signal\",\"hexagon\",\"diagonal\",\"diamond\",\"plus\",\"dots\"}BackgroundMode=\"deathstar\"BackgroundSelected=1;BackgroundModeOpacity=0.25;SaveVars={\"dscreens\",\"ColorPrimary\",\"ColorSecondary\",\"ColorTertiary\",\"ColorHealthy\",\"ColorWarning\",\"ColorCritical\",\"ColorBackground\",\"ColorBackgroundPattern\",\"ScrapTier\",\"HUDMode\",\"SimulationMode\",\"DMGOStretch\",\"HUDShiftU\",\"HUDShiftV\",\"colorIDIndex\",\"colorIDTable\",\"BackgroundMode\",\"BackgroundSelected\",\"BackgroundModeOpacity\"}HUDMode=false;HUDShiftU=0;HUDShiftV=0;hudSelectedIndex=0;hudStartIndex=1;hudArrowSticker={}highlightOn=false;highlightID=0;highlightX=0;highlightY=0;highlightZ=0;SimulationMode=false;OkayCenterMessage=\"All systems nominal.\"CurrentDamagedPage=1;CurrentBrokenPage=1;DamagePageSize=12;ScrapTier=1;totalScraps=0;ScrapTierRepairTimes={10,50,250,1250}coreWorldOffset=0;totalShipHP=0;formerTotalShipHP=-1;totalShipMaxHP=0;totalShipIntegrity=100;elementsId={}elementsIdList={}damagedElements={}brokenElements={}rE={}healthyElements={}typeElements={}ElementCounter=0;UseMyElementNames=true;dmgoElements={}DMGOMaxElements=250;DMGOStretch=false;ShipXmin=99999999;ShipXmax=-99999999;ShipYmin=99999999;ShipYmax=-99999999;ShipZmin=99999999;ShipZmax=-99999999;totalShipMass=0;formerTotalShipMass=-1;formerTime=-1;FuelAtmosphericTanks={}FuelSpaceTanks={}FuelRocketTanks={}FuelAtmosphericTotal=0;FuelSpaceTotal=0;FuelRocketTotal=0;FuelAtmosphericCurrent=0;FuelSpaceTotalCurrent=0;FuelRocketTotalCurrent=0;formerFuelAtmosphericTotal=-1;formerFuelSpaceTotal=-1;formerFuelRocketTotal=-1;hexTable={\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"A\",\"B\",\"C\",\"D\",\"E\",\"F\"}colorIDIndex=1;colorIDTable={[1]={id=\"ColorPrimary\",desc=\"Main HUD Color\",basec=\"FF6700\",newc=\"FF6700\"},[2]={id=\"ColorSecondary\",desc=\"Secondary HUD Color\",basec=\"FFFFFF\",newc=\"FFFFFF\"},[3]={id=\"ColorTertiary\",desc=\"Tertiary HUD Color\",basec=\"000000\",newc=\"000000\"},[4]={id=\"ColorHealthy\",desc=\"Color code for Healthy/Okay\",basec=\"00FF00\",newc=\"00FF00\"},[5]={id=\"ColorWarning\",desc=\"Color code for Damaged/Warning\",basec=\"FFFF00\",newc=\"FFFF00\"},[6]={id=\"ColorCritical\",desc=\"Color code for Broken/Critical\",basec=\"FF0000\",newc=\"FF0000\"},[7]={id=\"ColorBackground\",desc=\"Background Color\",basec=\"000000\",newc=\"000000\"},[8]={id=\"ColorBackgroundPattern\",desc=\"Background Pattern Color\",basec=\"4F4F4F\",newc=\"4F4F4F\"},[9]={id=\"ColorFuelAtmospheric\",desc=\"Color for Atmo Fuel/Elements\",basec=\"004444\",newc=\"004444\"},[10]={id=\"ColorFuelSpace\",desc=\"Color for Space Fuel/Elements\",basec=\"444400\",newc=\"444400\"},[11]={id=\"ColorFuelRocket\",desc=\"Color for Rocket Fuel/Elements\",basec=\"440044\",newc=\"440044\"}}function InitiateSlots()for a,b in pairs(unit)do if type(b)==\"table\"and type(b.export)==\"table\"and b.getElementClass then local c=b.getElementClass():lower()if c:find(\"coreunit\")then core=b;local d=core.getMaxHitPoints()if d>10000 then coreWorldOffset=128 elseif d>1000 then coreWorldOffset=64 elseif d>150 then coreWorldOffset=32 else coreWorldOffset=16 end elseif c=='databankunit'then db=b elseif c==\"screenunit\"then local e=\"startup\"screens[#screens+1]={element=b,id=b.getId(),mode=e,submode=\"\",ClickAreas={},refresh=true,active=false,fuelA=true,fuelS=true,fuelR=true,fuelIndex=1}end end end end;function LoadFromDatabank()if db==nil then return else for f,g in pairs(SaveVars)do if db.hasKey(g)then local h=json.decode(db.getStringValue(g))if h~=nil then if g==\"YourShipsName\"or g==\"AddSummertimeHour\"or g==\"UpdateDataInterval\"or g==\"HighlightBlinkingInterval\"or g==\"SkillRepairToolEfficiency\"or g==\"SkillRepairToolOptimization\"or g==\"SkillAtmosphericFuelEfficiency\"or g==\"SkillSpaceFuelEfficiency\"or g==\"SkillRocketFuelEfficiency\"or g==\"StatAtmosphericFuelTankHandling\"or g==\"StatSpaceFuelTankHandling\"or g==\"StatRocketFuelTankHandling\"then else _G[g]=h end end end end;for i,j in ipairs(screens)do for k,l in ipairs(dscreens)do if screens[i].id==dscreens[k].id then screens[i].mode=dscreens[k].mode;screens[i].submode=dscreens[k].submode;screens[i].active=dscreens[k].active;screens[i].refresh=true;screens[i].fuelA=dscreens[k].fuelA;screens[i].fuelS=dscreens[k].fuelS;screens[i].fuelR=dscreens[k].fuelR;screens[i].fuelIndex=dscreens[k].fuelIndex end end end end end;function SaveToDatabank()if db==nil then return else dscreens={}for i,m in ipairs(screens)do dscreens[i]={}dscreens[i].id=m.id;dscreens[i].mode=m.mode;dscreens[i].submode=m.submode;dscreens[i].active=m.active;dscreens[i].fuelA=m.fuelA;dscreens[i].fuelS=m.fuelS;dscreens[i].fuelR=m.fuelR;dscreens[i].fuelIndex=m.fuelIndex end;db.clear()for f,g in pairs(SaveVars)do db.setStringValue(g,json.encode(_G[g]))end end end;function InitiateScreens()if screens~=nil and#screens>0 then for i=1,#screens,1 do screens[i]=CreateClickAreasForScreen(screens[i])end end end;function UpdateTypeData()FuelAtmosphericTanks={}FuelSpaceTanks={}FuelRocketTanks={}FuelAtmosphericTotal=0;FuelAtmosphericCurrent=0;FuelSpaceTotal=0;FuelSpaceCurrent=0;FuelRocketCurrent=0;FuelRocketTotal=0;local n=4;local o=6;local p=0.8;if StatContainerOptimization>0 then n=n-0.05*StatContainerOptimization*n;o=o-0.05*StatContainerOptimization*o;p=p-0.05*StatContainerOptimization*p end;if StatFuelTankOptimization>0 then n=n-0.05*StatFuelTankOptimization*n;o=o-0.05*StatFuelTankOptimization*o;p=p-0.05*StatFuelTankOptimization*p end;for i,q in ipairs(typeElements)do local r=core.getElementNameById(q)or\"\"local s=core.getElementTypeById(q)or\"\"local t=core.getElementPositionById(q)or 0;local u=core.getElementHitPointsById(q)or 0;local v=core.getElementMaxHitPointsById(q)or 0;local w=core.getElementMassById(q)or 0;local x=\"\"local y=0;local z=0;local A=0;local B=0;if s==\"atmospheric fuel-tank\"then if v>10000 then x=\"L\"z=5480;y=12800 elseif v>1300 then x=\"M\"z=988.67;y=1600 elseif v>150 then x=\"S\"z=182.67;y=400 else x=\"XS\"z=35.03;y=100 end;if StatAtmosphericFuelTankHandling>0 then y=0.2*StatAtmosphericFuelTankHandling*y+y end;A=w-z;if A<=10 then A=0 end;B=string.format(\"%.0f\",A/n)cPercent=string.format(\"%.1f\",math.floor(100/y*tonumber(B)))table.insert(FuelAtmosphericTanks,{type=1,id=q,name=r,maxhp=v,hp=GetHPforElement(q),pos=t,size=x,mass=z,vol=y,cvol=B,percent=cPercent})if u>0 then FuelAtmosphericCurrent=FuelAtmosphericCurrent+B end;FuelAtmosphericTotal=FuelAtmosphericTotal+y elseif s==\"space fuel-tank\"then if v>10000 then x=\"L\"z=5480;y=12800 elseif v>1300 then x=\"M\"z=988.67;y=1600 else x=\"S\"z=182.67;y=400 end;if StatSpaceFuelTankHandling>0 then y=0.2*StatSpaceFuelTankHandling*y+y end;A=w-z;if A<=10 then A=0 end;B=string.format(\"%.0f\",A/o)cPercent=string.format(\"%.1f\",100/y*tonumber(B))table.insert(FuelSpaceTanks,{type=2,id=q,name=r,maxhp=v,hp=GetHPforElement(q),pos=t,size=x,mass=z,vol=y,cvol=B,percent=cPercent})if u>0 then FuelSpaceCurrent=FuelSpaceCurrent+B end;FuelSpaceTotal=FuelSpaceTotal+y elseif s==\"rocket fuel-tank\"then if v>65000 then x=\"L\"z=25740;y=50000 elseif v>6000 then x=\"M\"z=4720;y=6400 elseif v>700 then x=\"S\"z=886.72;y=800 else x=\"XS\"z=173.42;y=400 end;if StatRocketFuelTankHandling>0 then y=0.2*StatRocketFuelTankHandling*y+y end;A=w-z;if A<=10 then A=0 end;B=string.format(\"%.0f\",A/p)cPercent=string.format(\"%.1f\",100/y*tonumber(B))table.insert(FuelRocketTanks,{type=3,id=q,name=r,maxhp=v,hp=GetHPforElement(q),pos=t,size=x,mass=z,vol=y,cvol=B,percent=cPercent})if u>0 then FuelRocketCurrent=FuelRocketCurrent+B end;FuelRocketTotal=FuelRocketTotal+y end end;if FuelAtmosphericCurrent~=formerFuelAtmosphericCurrent then SetRefresh(\"fuel\")formerFuelAtmosphericCurrent=FuelAtmosphericCurrent end;if FuelSpaceCurrent~=formerFuelSpaceCurrent then SetRefresh(\"fuel\")formerFuelSpaceCurrent=FuelSpaceCurrent end;if FuelRocketCurrent~=formerFuelRocketCurrent then SetRefresh(\"fuel\")formerFuelRocketCurrent=FuelRocketCurrent end end;function UpdateDamageData(C)C=C or false;if SimulationActive==true then return end;local formerTotalShipHP=totalShipHP;totalShipHP=0;totalShipMaxHP=0;totalShipIntegrity=100;damagedElements={}brokenElements={}healthyElements={}if C==true then typeElements={}end;ElementCounter=0;elementsIdList=core.getElementIdList()for i,q in pairs(elementsIdList)do ElementCounter=ElementCounter+1;local r=core.getElementNameById(q)local s=core.getElementTypeById(q)local t=core.getElementPositionById(q)local u=core.getElementHitPointsById(q)local v=core.getElementMaxHitPointsById(q)if SimulationMode==true then SimulationActive=true;local D=math.random(0,10)if D<2 and#brokenElements<30 then u=0 elseif D>=2 and D<4 and#damagedElements<30 then u=math.random(1,math.ceil(v))else u=v end end;totalShipHP=totalShipHP+u;totalShipMaxHP=totalShipMaxHP+v;if v-u>constants.epsilon then if u>0 then table.insert(damagedElements,{id=q,name=r,type=s,counter=ElementCounter,hp=u,maxhp=v,missinghp=v-u,percent=math.ceil(100/v*u),pos=t})else table.insert(brokenElements,{id=q,name=r,type=s,counter=ElementCounter,hp=u,maxhp=v,missinghp=v-u,percent=0,pos=t})end else table.insert(healthyElements,{id=q,name=r,type=s,counter=ElementCounter,hp=u,maxhp=v,pos=t})if q==highlightID then highlightID=0;highlightOn=false;HideHighlight()hudSelectedIndex=0 end end;if C==true then if s==\"atmospheric fuel-tank\"or s==\"space fuel-tank\"or s==\"rocket fuel-tank\"then table.insert(typeElements,q)end end end;SortDamageTables()rE={}if#brokenElements>0 then for f,j in ipairs(brokenElements)do table.insert(rE,{id=j.id,missinghp=j.missinghp,hp=j.hp,name=j.name,type=j.type,pos=j.pos})end end;if#damagedElements>0 then for f,j in ipairs(damagedElements)do table.insert(rE,{id=j.id,missinghp=j.missinghp,hp=j.hp,name=j.name,type=j.type,pos=j.pos})end end;if#rE>0 then table.sort(rE,function(E,F)return E.missinghp>F.missinghp end)end;totalShipIntegrity=string.format(\"%2.0f\",100/totalShipMaxHP*totalShipHP)if formerTotalShipHP~=totalShipHP then forceDamageRedraw=true;formerTotalShipHP=totalShipHP else forceDamageRedraw=false end end;function GetHPforElement(q)for i,j in ipairs(brokenElements)do if j.id==q then return 0 end end;for i,j in ipairs(damagedElements)do if j.id==q then return j.hp end end;for i,j in ipairs(healthyElements)do if j.id==q then return j.maxhp end end end;function UpdateClickArea(G,H,I)for i,m in ipairs(screens)do for J,j in pairs(screens[i].ClickAreas)do if j.id==G and j.mode==I then screens[i].ClickAreas[J]=H end end end end;function AddClickArea(I,H)for i,m in ipairs(screens)do if screens[i].mode==I then table.insert(screens[i].ClickAreas,H)end end end;function AddClickAreaForScreenID(K,H)for i,m in ipairs(screens)do if screens[i].id==K then table.insert(screens[i].ClickAreas,H)end end end;function DisableClickArea(G,I)UpdateClickArea(G,{id=G,mode=I,x1=-1,x2=-1,y1=-1,y2=-1})end;function SetRefresh(I,L)I=I or\"all\"L=L or\"all\"if screens~=nil and#screens>0 then for i=1,#screens,1 do if screens[i].mode==I or I==\"all\"then if screens[i].submode==L or L==\"all\"then screens[i].refresh=true end end end end end;function WipeClickAreasForScreen(m)m.ClickAreas={}return m end;function CreateBaseClickAreas(m)table.insert(m.ClickAreas,{mode=\"all\",id=\"ToggleHudMode\",x1=1537,x2=1728,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"damage\",x1=193,x2=384,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"damageoutline\",x1=385,x2=576,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"fuel\",x1=577,x2=768,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"time\",x1=0,x2=192,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"settings1\",x1=1729,x2=1920,y1=1015,y2=1075})return m end;function CreateClickAreasForScreen(m)if m==nil then return{}end;if m.mode==\"flight\"then elseif m.mode==\"damage\"then table.insert(m.ClickAreas,{mode=\"damage\",id=\"ToggleElementLabel\",x1=70,x2=425,y1=325,y2=355})table.insert(m.ClickAreas,{mode=\"damage\",id=\"ToggleElementLabel2\",x1=980,x2=1400,y1=325,y2=355})elseif m.mode==\"damageoutline\"then table.insert(m.ClickAreas,{mode=\"damageoutline\",id=\"DMGOChangeView\",param=\"top\",x1=60,x2=439,y1=150,y2=200})table.insert(m.ClickAreas,{mode=\"damageoutline\",id=\"DMGOChangeView\",param=\"side\",x1=440,x2=824,y1=150,y2=200})table.insert(m.ClickAreas,{mode=\"damageoutline\",id=\"DMGOChangeView\",param=\"front\",x1=825,x2=1215,y1=150,y2=200})table.insert(m.ClickAreas,{mode=\"damageoutline\",id=\"DMGOChangeStretch\",x1=1530,x2=1580,y1=150,y2=200})elseif m.mode==\"fuel\"then elseif m.mode==\"cargo\"then elseif m.mode==\"agg\"then elseif m.mode==\"map\"then elseif m.mode==\"time\"then elseif m.mode==\"settings1\"then table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ToggleBackground\",x1=75,x2=860,y1=170,y2=215})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"PreviousBackground\",x1=75,x2=460,y1=235,y2=285})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"NextBackground\",x1=480,x2=860,y1=235,y2=285})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"DecreaseOpacity\",x1=75,x2=460,y1=300,y2=350})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"IncreaseOpacity\",x1=480,x2=860,y1=300,y2=350})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ResetColors\",x1=75,x2=860,y1=370,y2=415})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"PreviousColorID\",x1=90,x2=140,y1=500,y2=550})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"NextColorID\",x1=795,x2=845,y1=500,y2=550})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"1\",x1=210,x2=290,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"2\",x1=300,x2=380,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"3\",x1=385,x2=465,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"4\",x1=470,x2=550,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"5\",x1=560,x2=640,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"6\",x1=645,x2=725,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"1\",x1=210,x2=290,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"2\",x1=300,x2=380,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"3\",x1=385,x2=465,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"4\",x1=470,x2=550,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"5\",x1=560,x2=640,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"6\",x1=645,x2=725,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ResetPosColor\",x1=160,x2=340,y1=885,y2=935})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ApplyPosColor\",x1=355,x2=780,y1=885,y2=935})elseif m.mode==\"startup\"then end;m=CreateBaseClickAreas(m)return m end;function CheckClick(M,N,O)M=M*1920;N=N*1120;O=O or\"\"HitPayload={}if screens~=nil and#screens>0 then for i=1,#screens,1 do if screens[i].active==true and screens[i].element.getMouseX()~=-1 and screens[i].element.getMouseY()~=-1 then if O==\"\"then for J,j in pairs(screens[i].ClickAreas)do if j~=nil and M>=j.x1 and M<=j.x2 and N>=j.y1 and N<=j.y2 then O=j.id;HitPayload=j;break end end end;if O==\"ButtonPress\"then if screens[i].mode==HitPayload.param then screens[i].mode=\"startup\"else screens[i].mode=HitPayload.param end;if screens[i].mode==\"damageoutline\"then if screens[i].submode==\"\"then screens[i].submode=\"top\"end end;screens[i].refresh=true;screens[i].ClickAreas={}SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"ToggleBackground\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundMode==\"\"then BackgroundSelected=1;BackgroundMode=backgroundModes[BackgroundSelected]else BackgroundSelected=1;BackgroundMode=\"\"end;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"PreviousBackground\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundMode==\"\"then BackgroundSelected=1;BackgroundMode=backgroundModes[BackgroundSelected]else if BackgroundSelected<=1 then BackgroundSelected=#backgroundModes else BackgroundSelected=BackgroundSelected-1 end;BackgroundMode=backgroundModes[BackgroundSelected]end;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"NextBackground\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundMode==\"\"then BackgroundSelected=1;BackgroundMode=backgroundModes[BackgroundSelected]else if BackgroundSelected>=#backgroundModes then BackgroundSelected=1 else BackgroundSelected=BackgroundSelected+1 end;BackgroundMode=backgroundModes[BackgroundSelected]end;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"DecreaseOpacity\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundModeOpacity>0.1 then BackgroundModeOpacity=BackgroundModeOpacity-0.05;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()end elseif O==\"IncreaseOpacity\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundModeOpacity<1.0 then BackgroundModeOpacity=BackgroundModeOpacity+0.05;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()end elseif O==\"ResetColors\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then db.clear()ColorPrimary=\"FF6700\"ColorSecondary=\"FFFFFF\"ColorTertiary=\"000000\"ColorHealthy=\"00FF00\"ColorWarning=\"FFFF00\"ColorCritical=\"FF0000\"ColorBackground=\"000000\"ColorBackgroundPattern=\"4f4f4f\"ColorFuelAtmospheric=\"004444\"ColorFuelSpace=\"444400\"ColorFuelRocket=\"440044\"BackgroundMode=\"deathstar\"BackgroundSelected=1;BackgroundModeOpacity=0.25;colorIDTable={[1]={id=\"ColorPrimary\",desc=\"Main HUD Color\",basec=\"FF6700\",newc=\"FF6700\"},[2]={id=\"ColorSecondary\",desc=\"Secondary HUD Color\",basec=\"FFFFFF\",newc=\"FFFFFF\"},[3]={id=\"ColorTertiary\",desc=\"Tertiary HUD Color\",basec=\"000000\",newc=\"000000\"},[4]={id=\"ColorHealthy\",desc=\"Color code for Healthy/Okay\",basec=\"00FF00\",newc=\"00FF00\"},[5]={id=\"ColorWarning\",desc=\"Color code for Damaged/Warning\",basec=\"FFFF00\",newc=\"FFFF00\"},[6]={id=\"ColorCritical\",desc=\"Color code for Broken/Critical\",basec=\"FF0000\",newc=\"FF0000\"},[7]={id=\"ColorBackground\",desc=\"Background Color\",basec=\"000000\",newc=\"000000\"},[8]={id=\"ColorBackgroundPattern\",desc=\"Background Pattern Color\",basec=\"4F4F4F\",newc=\"4F4F4F\"},[9]={id=\"ColorFuelAtmospheric\",desc=\"Color for Atmo Fuel/Elements\",basec=\"004444\",newc=\"004444\"},[10]={id=\"ColorFuelSpace\",desc=\"Color for Space Fuel/Elements\",basec=\"444400\",newc=\"444400\"},[11]={id=\"ColorFuelRocket\",desc=\"Color for Rocket Fuel/Elements\",basec=\"440044\",newc=\"440044\"}}SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"PreviousColorID\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then colorIDIndex=colorIDIndex-1;if colorIDIndex<1 then colorIDIndex=#colorIDTable end;SaveToDatabank()SetRefresh(\"settings1\")RenderScreens(\"settings1\")elseif O==\"NextColorID\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then colorIDIndex=colorIDIndex+1;if colorIDIndex>#colorIDTable then colorIDIndex=1 end;SaveToDatabank()SetRefresh(\"settings1\")RenderScreens(\"settings1\")elseif O==\"ColorPosUp\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then local P=tonumber(string.sub(colorIDTable[colorIDIndex].newc,HitPayload.param,HitPayload.param),16)P=P+1;if P>15 then P=0 end;colorIDTable[colorIDIndex].newc=replace_char(HitPayload.param,colorIDTable[colorIDIndex].newc,hexTable[P+1])SaveToDatabank()SetRefresh(\"settings1\")RenderScreens(\"settings1\")elseif O==\"ColorPosDown\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then local P=tonumber(string.sub(colorIDTable[colorIDIndex].newc,HitPayload.param,HitPayload.param),16)P=P-1;if P<0 then P=15 end;colorIDTable[colorIDIndex].newc=replace_char(HitPayload.param,colorIDTable[colorIDIndex].newc,hexTable[P+1])SaveToDatabank()SetRefresh(\"settings1\")RenderScreens(\"settings1\")elseif O==\"ResetPosColor\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then colorIDTable[colorIDIndex].newc=colorIDTable[colorIDIndex].basec;_G[colorIDTable[colorIDIndex].id]=colorIDTable[colorIDIndex].basec;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"ApplyPosColor\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then _G[colorIDTable[colorIDIndex].id]=colorIDTable[colorIDIndex].newc;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"DamagedPageDown\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentDamagedPage=CurrentDamagedPage+1;if CurrentDamagedPage>math.ceil(#damagedElements/DamagePageSize)then CurrentDamagedPage=math.ceil(#damagedElements/DamagePageSize)end;HudDeselectElement()SaveToDatabank()SetRefresh(\"damage\")RenderScreens(\"damage\")elseif O==\"DamagedPageUp\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentDamagedPage=CurrentDamagedPage-1;if CurrentDamagedPage<1 then CurrentDamagedPage=1 end;HudDeselectElement()SaveToDatabank()SetRefresh(\"damage\")RenderScreens(\"damage\")elseif O==\"BrokenPageDown\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentBrokenPage=CurrentBrokenPage+1;if CurrentBrokenPage>math.ceil(#brokenElements/DamagePageSize)then CurrentBrokenPage=math.ceil(#brokenElements/DamagePageSize)end;HudDeselectElement()SaveToDatabank()SetRefresh(\"damage\")RenderScreens(\"damage\")elseif O==\"BrokenPageUp\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentBrokenPage=CurrentBrokenPage-1;if CurrentBrokenPage<1 then CurrentBrokenPage=1 end;HudDeselectElement()SaveToDatabank()SetRefresh(\"damage\")RenderScreens(\"damage\")elseif O==\"DMGOChangeView\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then screens[i].submode=HitPayload.param;UpdateViewDamageoutline(screens[i])SaveToDatabank()SetRefresh(\"damageoutline\",screens[i].submode)RenderScreens(\"damageoutline\",screens[i].submode)elseif O==\"DMGOChangeStretch\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if DMGOStretch==true then DMGOStretch=false else DMGOStretch=true end;UpdateViewDamageoutline(screens[i])SaveToDatabank()SetRefresh(\"damageoutline\")RenderScreens(\"damageoutline\")elseif O==\"ToggleDisplayAtmosphere\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if screens[i].fuelA==true then screens[i].fuelA=false else screens[i].fuelA=true end;screens[i].fuelIndex=1;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"ToggleDisplaySpace\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if screens[i].fuelS==true then screens[i].fuelS=false else screens[i].fuelS=true end;screens[i].fuelIndex=1;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"ToggleDisplayRocket\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if screens[i].fuelR==true then screens[i].fuelR=false else screens[i].fuelR=true end;screens[i].fuelIndex=1;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"DecreaseFuelIndex\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then screens[i].fuelIndex=screens[i].fuelIndex-1;if screens[i].fuelIndex<1 then screens[i].fuelIndex=1 end;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"IncreaseFuelIndex\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then screens[i].fuelIndex=screens[i].fuelIndex+1;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"ToggleHudMode\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if HUDMode==true then HUDMode=false;forceDamageRedraw=true;HudDeselectElement()SaveToDatabank()SetRefresh()RenderScreens()else HUDMode=true;forceDamageRedraw=true;HudDeselectElement()SaveToDatabank()SetRefresh()RenderScreens()end elseif O==\"ToggleSimulation\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentDamagedPage=1;CurrentBrokenPage=1;if SimulationMode==true then SimulationMode=false;SimulationActive=false;UpdateDamageData()UpdateTypeData()forceDamageRedraw=true;HudDeselectElement()SetRefresh(\"damage\")SetRefresh(\"damageoutline\")SetRefresh(\"settings1\")SetRefresh(\"fuel\")SaveToDatabank()RenderScreens()else SimulationMode=true;SimulationActive=false;UpdateDamageData()UpdateTypeData()forceDamageRedraw=true;HudDeselectElement()SetRefresh(\"damage\")SetRefresh(\"damageoutline\")SetRefresh(\"settings1\")SetRefresh(\"fuel\")SaveToDatabank()RenderScreens()end elseif(O==\"ToggleElementLabel\"or O==\"ToggleElementLabel2\")and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if UseMyElementNames==true then UseMyElementNames=false;SetRefresh(\"damage\")RenderScreens(\"damage\")else UseMyElementNames=true;SetRefresh(\"damage\")RenderScreens(\"damage\")end elseif(O==\"SwitchScrapTier\"or O==\"SwitchScrapTier2\")and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then ScrapTier=ScrapTier+1;if ScrapTier>4 then ScrapTier=1 end;SetRefresh(\"damage\")RenderScreens(\"damage\")end end end end end;function GetContentFlight()local Q=\"\"Q=Q..GetHeader(\"Flight Data Report\")..[[\n \n ]]return Q end;function GetContentDamage()local Q=\"\"if SimulationMode==true then Q=Q..GetHeader(\"Damage Report (Simulated damage)\")..[[]]else Q=Q..GetHeader(\"Damage Report\")..[[]]end;Q=Q..GetContentDamageScreen()return Q end;function GetContentDamageoutline(m)UpdateDataDamageoutline()UpdateViewDamageoutline(m)local Q=\"\"Q=Q..GetHeader(\"Damage Ship Outline Report\")..GetDamageoutlineShip()..[[]]if m.submode==\"top\"then Q=Q..[[\n \n Top View\n \n Side View\n \n Front View\n ]]elseif m.submode==\"side\"then Q=Q..[[\n \n Top View\n \n Side View\n \n Front View\n ]]elseif m.submode==\"front\"then Q=Q..[[\n \n Top View\n \n Side View\n \n Front View\n ]]else end;Q=Q..[[]]..#dmgoElements..[[ of ]]..ElementCounter..[[ shown]]Q=Q..[[]]if DMGOStretch==true then Q=Q..[[]]end;Q=Q..[[Stretch both axis]]return Q end;function GetContentFuel(m)if#FuelAtmosphericTanks<1 and#FuelSpaceTanks<1 and#FuelRocketTanks<1 then return\"\"end;local R=0;local Q=\"\"local S={}FuelDisplay={m.fuelA,m.fuelS,m.fuelR}if FuelDisplay[1]==true and#FuelAtmosphericTanks>0 then table.insert(S,\"Atmospheric\")R=R+1 end;if FuelDisplay[2]==true and#FuelSpaceTanks>0 then table.insert(S,\"Space\")R=R+1 end;if FuelDisplay[3]==true and#FuelRocketTanks>0 then table.insert(S,\"Rocket\")R=R+1 end;Q=Q..GetHeader(\"Fuel Report (\"..table.concat(S,\", \")..\")\")..[[\n ]]local T=150;local U=0;local V=0;if FuelDisplay[1]==true and#FuelAtmosphericTanks>0 then if R==1 then V=50 elseif R==2 then V=6 elseif R==3 then V=0 end;Q=Q..[[\n \n \n \n ]]Q=Q..[[]]..GenerateCommaValue(FuelAtmosphericCurrent,true)..[[ of ]]..GenerateCommaValue(FuelAtmosphericTotal,true)..[[ | Total Atmospheric Fuel in ]]..#FuelAtmosphericTanks..[[ tank]]..(#FuelAtmosphericTanks==1 and\"\"or\"s\")..[[ (]]..math.floor(100/FuelAtmosphericTotal*FuelAtmosphericCurrent)..[[%)]]U=U+1 end;if FuelDisplay[2]==true and#FuelSpaceTanks>0 then if R==1 then V=50 elseif R==2 then V=6 elseif R==3 then V=0 end;Q=Q..[[\n \n \n \n ]]Q=Q..[[]]..GenerateCommaValue(FuelSpaceCurrent,true)..[[ of ]]..GenerateCommaValue(FuelSpaceTotal,true)..[[ | Total Space Fuel in ]]..#FuelSpaceTanks..[[ tank]]..(#FuelSpaceTanks==1 and\"\"or\"s\")..[[ (]]..math.floor(100/FuelSpaceTotal*FuelSpaceCurrent)..[[%)]]U=U+1 end;if FuelDisplay[3]==true and#FuelRocketTanks>0 then if R==1 then V=50 elseif R==2 then V=6 elseif R==3 then V=0 end;Q=Q..[[\n \n \n \n ]]Q=Q..[[]]..GenerateCommaValue(FuelRocketCurrent,true)..[[ of ]]..GenerateCommaValue(FuelRocketTotal,true)..[[ | Total Rocket Fuel in ]]..#FuelRocketTanks..[[ tank]]..(#FuelRocketTanks==1 and\"\"or\"s\")..[[ (]]..math.floor(100/FuelRocketTotal*FuelRocketCurrent)..[[%)]]end;Q=Q..[[\n \n \n \n ]]local W={}if m.fuelIndex==nil or m.fuelIndex<1 then m.fuelIndex=1 end;if FuelDisplay[1]==true then for f,j in ipairs(FuelAtmosphericTanks)do table.insert(W,j)end end;if FuelDisplay[2]==true then for f,j in ipairs(FuelSpaceTanks)do table.insert(W,j)end end;if FuelDisplay[3]==true then for f,j in ipairs(FuelRocketTanks)do table.insert(W,j)end end;table.sort(W,function(E,F)return E.type\n \n \n ]]if Y.hp==0 then Q=Q..[[]]elseif Y.maxhp-Y.hp>constants.epsilon then Q=Q..[[]]else Q=Q..[[]]end;if Y.hp==0 then Q=Q..[[]]..Y.size..[[]]else Q=Q..[[]]..Y.size..[[]]end;if Y.hp==0 then Q=Q..[[Broken]]..[[0 of ]]..GenerateCommaValue(Y.vol)..[[]]elseif tonumber(Y.percent)<10 then Q=Q..[[]]..Y.percent..[[%]]..[[]]..GenerateCommaValue(Y.cvol)..[[ of ]]..GenerateCommaValue(Y.vol)..[[]]elseif tonumber(Y.percent)<30 then Q=Q..[[]]..Y.percent..[[%]]..[[]]..GenerateCommaValue(Y.cvol)..[[ of ]]..GenerateCommaValue(Y.vol)..[[]]else Q=Q..[[]]..Y.percent..[[%]]..[[]]..GenerateCommaValue(Y.cvol)..[[ of ]]..GenerateCommaValue(Y.vol)..[[]]end;Q=Q..[[]]..Y.name..[[]]Q=Q..[[]]end end;if#FuelAtmosphericTanks>0 then Q=Q..[[]]if FuelDisplay[1]==true then Q=Q..[[]]end;Q=Q..[[ATM]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"ToggleDisplayAtmosphere\",x1=50,x2=100,y1=270,y2=320})end;if#FuelSpaceTanks>0 then Q=Q..[[]]if FuelDisplay[2]==true then Q=Q..[[]]end;Q=Q..[[SPC]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"ToggleDisplaySpace\",x1=200,x2=250,y1=270,y2=320})end;if#FuelRocketTanks>0 then Q=Q..[[]]if FuelDisplay[3]==true then Q=Q..[[]]end;Q=Q..[[RKT]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"ToggleDisplayRocket\",x1=350,x2=400,y1=270,y2=320})end;if m.fuelIndex>1 then Q=Q..[[\n \n \n ]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"DecreaseFuelIndex\",x1=1470,x2=1670,y1=270,y2=320})end;if m.fuelIndex+X-1<#W then Q=Q..[[\n \n \n ]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"IncreaseFuelIndex\",x1=1680,x2=1880,y1=270,y2=320})end;if X>0 then Q=Q..[[]]..#W..[[ Tank]]..(#W==1 and\"\"or\"s\")..[[ (Showing ]]..m.fuelIndex..[[ to ]]..m.fuelIndex+X-1 ..[[)]]end;return Q end;function GetContentCargo()local Q=\"\"Q=Q..GetHeader(\"Cargo Report\")..[[\n \n ]]return Q end;function GetContentAGG()local Q=\"\"Q=Q..GetHeader(\"Anti-Grav Control\")..[[\n \n ]]return Q end;function GetContentMap()local Q=\"\"Q=Q..GetHeader(\"Map Overview\")..[[\n \n ]]return Q end;function GetContentTime()local Q=\"\"Q=Q..GetHeader(\"Time\")..epochTime()Q=Q..[[\n \n \n \n \n \n \n \n \n \n \n \n \n ]]return Q end;function GetContentSettings1()local Q=\"\"Q=Q..GetHeader(\"Settings\")..[[]]if BackgroundMode==\"\"then Q=Q..[[Activate background]]else Q=Q..[[Deactivate background (']]..BackgroundMode..[[', ]]..string.format(\"%.0f\",BackgroundModeOpacity*100)..[[%)]]end;Q=Q..[[\n \n Previous background\n \n Next background\n\n \n Decrease Opacity\n \n Increase Opacity\n ]]Q=Q..[[]]..[[Reset background and all colors]]Q=Q..[[]]..[[]]..[[]]..[[Select and change any of the ]]..#colorIDTable..[[ HUD colors]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..colorIDTable[colorIDIndex].desc..[[]]..[[]]..[[Current color]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[#]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,1,1)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,2,2)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,3,3)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,4,4)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,5,5)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,6,6)..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[New color]]..[[]]..[[Apply new color]]..[[]]..[[Reset]]..[[]]Q=Q..[[]]..[[]]..[[]]..[[Explanation / Hints]]..[[Coming soon.]]Q=Q..[[]]if SimulationMode==true then Q=Q..[[Simulating Damage to elements]]AddClickArea(\"settings1\",{id=\"ToggleSimulation\",mode=\"settings1\",x1=940,x2=1850,y1=919,y2=969})else Q=Q..[[Simulate Damage to elements]]AddClickArea(\"settings1\",{id=\"ToggleSimulation\",mode=\"settings1\",x1=940,x2=1850,y1=919,y2=969})end;return Q end;function GetContentStartup()local Q=\"\"Q=Q..GetElementLogo(812,380,\"f\",\"f\",\"f\")if YourShipsName==\"Enter here\"then Q=Q..[[Spaceship ID ]]..ShipID..[[]]else Q=Q..[[]]..YourShipsName..[[]]end;if ShowWelcomeMessage==true then Q=Q..[[Greetings, Commander ]]..PlayerName..[[.]]end;if#Warnings>0 then Q=Q..[[Warning: ]]..table.concat(Warnings,\" \")..[[]]end;Q=Q..[[Damage Report v]]..VERSION..[[, by Scion Interstellar, DorianGray - Discord: Dorian Gray#2623. Under GNU Public License 3.0.]]return Q end;function RenderScreen(m,a0)if a0==nil then PrintConsole(\"ERROR: contentToRender is nil.\")unit.exit()end;CreateClickAreasForScreen(m)local Q=\"\"Q=Q..[[\n \n \n ]]Q=Q..a0;if m.mode==\"startup\"then Q=Q..[[]]else Q=Q..[[]]end;Q=Q..[[\n \n ]]Q=Q..[[]]local a1=string.len(Q)m.element.setSVG(Q)end;function RenderScreens(a2,a3)a2=a2 or\"all\"a3=a3 or\"all\"if screens~=nil and#screens>0 then local a4=\"\"local a5=\"\"local a6=\"\"local a7=\"\"local a8=\"\"local a9=\"\"local aa=\"\"local ab=\"\"local ac=\"\"local ad=\"\"local ae=\"\"local af=\"\"for J,m in pairs(screens)do if m.refresh==true then local a0=\"\"if m.mode==\"flight\"and(a2==\"flight\"or a2==\"all\")then if a4==\"\"then a4=GetContentFlight()end;a0=a4 elseif m.mode==\"damage\"and(a2==\"damage\"or a2==\"all\")then if a5==\"\"then a5=GetContentDamage()end;a0=a5 elseif m.mode==\"damageoutline\"and(a2==\"damageoutline\"or a2==\"all\")then if m.submode==\"\"then m.submode=\"top\"screens[J].submode=\"top\"end;if m.submode==\"top\"and(a3==\"top\"or a3==\"all\")then if a6==\"\"then a6=GetContentDamageoutline(m)end;a0=a6 end;if m.submode==\"side\"and(a3==\"side\"or a3==\"all\")then if a7==\"\"then a7=GetContentDamageoutline(m)end;a0=a7 end;if m.submode==\"front\"and(a3==\"front\"or a3==\"all\")then if a8==\"\"then a8=GetContentDamageoutline(m)end;a0=a8 end elseif m.mode==\"fuel\"and(a2==\"fuel\"or a2==\"all\")then m=WipeClickAreasForScreen(screens[J])a0=GetContentFuel(m)elseif m.mode==\"cargo\"and(a2==\"cargo\"or a2==\"all\")then if aa==\"\"then aa=GetContentCargo()end;a0=aa elseif m.mode==\"agg\"and(a2==\"agg\"or a2==\"all\")then if ab==\"\"then ab=GetContentAGG()end;a0=ab elseif m.mode==\"map\"and(a2==\"map\"or a2==\"all\")then if ac==\"\"then ac=GetContentMap()end;a0=ac elseif m.mode==\"time\"and(a2==\"time\"or a2==\"all\")then if ad==\"\"then ad=GetContentTime()end;a0=ad elseif m.mode==\"settings1\"and(a2==\"settings1\"or a2==\"all\")then if ae==\"\"then ae=GetContentSettings1()end;a0=ae elseif m.mode==\"startup\"and(a2==\"startup\"or a2==\"all\")then if af==\"\"then af=GetContentStartup()end;a0=af else a0=\"Invalid screen mode. ('\"..m.mode..\"')\"end;if a0~=\"\"then RenderScreen(m,a0)else DrawCenteredText(\"ERROR: No contentToRender delivered for \"..m.mode)PrintConsole(\"ERROR: No contentToRender delivered for \"..m.mode)unit.exit()end;screens[J].refresh=false end end end;if HUDMode==true then system.setScreen(GetContentDamageHUDOutput())system.showScreen(1)else system.showScreen(0)end end;function OnTickData(C)if formerTime+605 or SkillRepairToolOptimization>5 or StatFuelTankOptimization>5 or StatContainerOptimization>5 or StatAtmosphericFuelTankHandling>5 or StatSpaceFuelTankHandling>5 or StatRocketFuelTankHandling>5 then PrintConsole(\"ERROR: Talents/stats can only range from 0 to 5. Please set correctly in LUA settings and reactivate script.\")unit.exit()end;if screens==nil or#screens==0 then HUDMode=true;PrintConsole(\"Warning: No screens connected. Entering HUD mode only.\")end;OnTickData(true)unit.setTimer('UpdateData',UpdateDataInterval)unit.setTimer('UpdateHighlight',HighlightBlinkingInterval)",
- "filter": {
- "args": [],
- "signature": "start()",
- "slotKey": "-1"
- },
- "key": "12"
- },
- {
- "code": "ActionUp()",
- "filter": {
- "args": [
- {
- "value": "up"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "13"
- },
- {
- "code": "ActionDown()",
- "filter": {
- "args": [
- {
- "value": "down"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "14"
- },
- {
- "code": "ActionStrafeLeft()",
- "filter": {
- "args": [
- {
- "value": "strafeleft"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "15"
- },
- {
- "code": "ActionStrafeRight()",
- "filter": {
- "args": [
- {
- "value": "straferight"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "16"
- },
- {
- "code": "KeyCTRLPressed = true",
- "filter": {
- "args": [
- {
- "value": "brake"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "17"
- },
- {
- "code": "KeyCTRLPressed = false",
- "filter": {
- "args": [
- {
- "value": "brake"
- }
- ],
- "signature": "actionStop(action)",
- "slotKey": "-2"
- },
- "key": "18"
- },
- {
- "code": "ActionOption1()",
- "filter": {
- "args": [
- {
- "value": "option1"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "19"
- },
- {
- "code": "ActionOption2()",
- "filter": {
- "args": [
- {
- "value": "option2"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "20"
- },
- {
- "code": "ActionOption3()",
- "filter": {
- "args": [
- {
- "value": "option3"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "21"
- },
- {
- "code": "ActionOption4()",
- "filter": {
- "args": [
- {
- "value": "option4"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "22"
- },
- {
- "code": "ActionOption9()",
- "filter": {
- "args": [
- {
- "value": "option9"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "23"
- },
- {
- "code": "ActionOption8()",
- "filter": {
- "args": [
- {
- "value": "option8"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "24"
- }
- ],
- "methods": [],
- "events": []
-}
\ No newline at end of file
diff --git a/versions/DamageReport_3_12.conf b/versions/DamageReport_3_12.conf
deleted file mode 100644
index 4992e3f..0000000
--- a/versions/DamageReport_3_12.conf
+++ /dev/null
@@ -1,436 +0,0 @@
-{
- "slots": {
- "0": {
- "name": "slot1",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "1": {
- "name": "slot2",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "2": {
- "name": "slot3",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "3": {
- "name": "slot4",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "4": {
- "name": "slot5",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "5": {
- "name": "slot6",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "6": {
- "name": "slot7",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "7": {
- "name": "slot8",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "8": {
- "name": "slot9",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "9": {
- "name": "slot10",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-1": {
- "name": "unit",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-2": {
- "name": "system",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-3": {
- "name": "library",
- "type": {
- "events": [],
- "methods": []
- }
- }
- },
- "handlers": [
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "2"
- },
- "key": "0"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "3"
- },
- "key": "1"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "4"
- },
- "key": "2"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "5"
- },
- "key": "3"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "6"
- },
- "key": "4"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "7"
- },
- "key": "5"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "8"
- },
- "key": "6"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "9"
- },
- "key": "7"
- },
- {
- "code": "function GenerateCommaValue(a,b,c)b=b or false;c=c or 1;local d=a;if b==true then if string.len(a)>=4 then d=string.format(\"%.\"..c..\"fk\",a/1000)else d=string.format(\"%.\"..c..\"f\",a)end else while true do d,k=string.gsub(d,\"^(-?%d+)(%d%d%d)\",'%1,%2')if k==0 then break end end end;return d end;function PrintConsole(e,f)f=f or false;if f then system.print(\"------------------------------------------------------------------------\")end;system.print(e)if f then system.print(\"------------------------------------------------------------------------\")end end;function DrawCenteredText(e)if screens~=nil and#screens>0 then for g=1,#screens,1 do screens[g].element.setCenteredText(e)end end end;function ClearConsole()for g=1,10,1 do PrintConsole()end end;function SwitchScreens(h)h=h or\"on\"if screens~=nil and#screens>0 then for g=1,#screens,1 do if h==\"on\"then screens[g].element.clear()screens[g].element.activate()screens[g].active=true else screens[g].element.clear()screens[g].element.deactivate()screens[g].active=false end end end end;function GetSecondsString(i)local i=tonumber(i)if i==nil or i<=0 then return\"-\"else days=string.format(\"%2.f\",math.floor(i/(3600*24)))hours=string.format(\"%2.f\",math.floor(i/3600-days*24))mins=string.format(\"%2.f\",math.floor(i/60-hours*60-days*24*60))secs=string.format(\"%2.f\",math.floor(i-hours*3600-days*24*60*60-mins*60))str=\"\"if tonumber(days)>0 then str=str..days..\"d \"end;if tonumber(hours)>0 then str=str..hours..\"h \"end;if tonumber(mins)>0 then str=str..mins..\"m \"end;if tonumber(secs)>0 then str=str..secs..\"s\"end;return str end end;function replace_char(j,str,l)return str:sub(1,j-1)..l..str:sub(j+1)end;function epochTime()function rZ(m)if string.len(m)<=1 then return\"0\"..m else return m end end;function dPoint(n)if not(n==math.floor(n))then return true else return false end end;function lYear(year)if not dPoint(year/4)then if dPoint(year/100)then return true else if not dPoint(year/400)then return true else return false end end else return false end end;local o=5;local p=3600;local q=86400;local r=31536000;local s=31622400;local t=2419200;local g=2505600;local u=2592000;local k=2678400;local w={4,6,9,11}local x={1,3,5,7,8,10,12}local y=0;local z=1506816000;local A=system.getTime()_G[\"formerTime\"]=A;if AddSummertimeHour==true then A=A+3600 end;now=math.floor(A+z)year=1970;secs=0;y=0;while secs+s]]..hour..\":\"..minute..[[]]..[[]]..year..\"/\"..month..\"/\"..day..[[]]end;function ToggleHUD()if HUDMode==true then HUDMode=false;forceDamageRedraw=true;hudSelectedIndex=0;highlightID=0;HideHighlight()SetRefresh()RenderScreens()else HUDMode=true;forceDamageRedraw=true;hudSelectedIndex=0;highlightID=0;HideHighlight()SetRefresh()RenderScreens()end end;function HudDeselectElement()hudSelectedIndex=0;hudStartIndex=1;highlightID=0;HideHighlight()if HUDMode==true then SetRefresh(\"damage\")SetRefresh(\"damageoutline\")RenderScreens()end end;function ChangeHudSelectedElement(B)if HUDMode==true and#rE>0 then hudSelectedIndex=hudSelectedIndex+B;if hudSelectedIndex<1 then hudSelectedIndex=1 elseif hudSelectedIndex>#rE then hudSelectedIndex=#rE end;if hudSelectedIndex>9 then hudStartIndex=hudSelectedIndex-9 end;if hudSelectedIndex~=0 then highlightID=rE[hudSelectedIndex].id;if highlightID~=nil and highlightID~=0 then HideHighlight()elementPosition=vec3(rE[hudSelectedIndex].pos)highlightX=elementPosition.x-coreWorldOffset;highlightY=elementPosition.y-coreWorldOffset;highlightZ=elementPosition.z-coreWorldOffset;highlightOn=true;ShowHighlight()end end;SetRefresh(\"damage\")SetRefresh(\"damageoutline\")RenderScreens()end end;function HideHighlight()if#hudArrowSticker>0 then for g in pairs(hudArrowSticker)do core.deleteSticker(hudArrowSticker[g])end;hudArrowSticker={}end end;function ShowHighlight()if highlightOn==true and highlightID>0 then table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX+2,highlightY,highlightZ,\"north\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX,highlightY-2,highlightZ,\"east\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX-2,highlightY,highlightZ,\"south\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX,highlightY+2,highlightZ,\"west\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX,highlightY,highlightZ-2,\"up\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX,highlightY,highlightZ+2,\"down\"))end end;function ToggleHighlight()if highlightOn==true then highlightOn=false;HideHighlight()else highlightOn=true;ShowHighlight()end end;function SortDamageTables()table.sort(damagedElements,function(m,n)return m.missinghp>n.missinghp end)table.sort(brokenElements,function(m,n)return m.maxhp>n.maxhp end)end;function getScraps(C,D)D=D or false;C=C-SkillRepairToolOptimization*0.05*C;local E=math.ceil(C/(10*5^(ScrapTier-1)))if D==true then return GenerateCommaValue(string.format(\"%.0f\",E),false)else return E end end;function getRepairTime(C,F)F=F or false;C=C-SkillRepairToolOptimization*0.05*C;local E=math.ceil(C/ScrapTierRepairTimes[ScrapTier])E=E-SkillRepairToolEfficiency*0.1*E;if F==true then return GetSecondsString(string.format(\"%.0f\",E))else return E end end;function UpdateDataDamageoutline()dmgoElements={}for g,G in ipairs(brokenElements)do if#dmgoElementsShipXmax then ShipXmax=H end;if I>ShipYmax then ShipYmax=I end;if J>ShipZmax then ShipZmax=J end;table.insert(dmgoElements,{id=G.id,type=\"b\",size=G.maxhp,x=H,y=I,z=J,xp=0,yp=0,zp=0,u=0,v=0})end end;if#dmgoElementsShipXmax then ShipXmax=H end;if I>ShipYmax then ShipYmax=I end;if J>ShipZmax then ShipZmax=J end;table.insert(dmgoElements,{id=G.id,type=\"d\",size=G.maxhp,x=H,y=I,z=J,xp=0,yp=0,zp=0,u=0,v=0})end end end;if#dmgoElementsShipXmax then ShipXmax=H end;if I>ShipYmax then ShipYmax=I end;if J>ShipZmax then ShipZmax=J end;table.insert(dmgoElements,{id=G.id,type=\"h\",size=G.maxhp,x=H,y=I,z=J,xp=0,yp=0,zp=0,u=0,v=0})end end end;ShipX=math.abs(ShipXmax-ShipXmin)ShipY=math.abs(ShipYmax-ShipYmin)ShipZ=math.abs(ShipZmax-ShipZmin)for g,G in ipairs(dmgoElements)do dmgoElements[g].xp=math.abs(100/(ShipXmax-ShipXmin)*(G.x-ShipXmin))dmgoElements[g].yp=math.abs(100/(ShipYmax-ShipYmin)*(G.y-ShipYmin))dmgoElements[g].zp=math.abs(100/(ShipZmax-ShipZmin)*(G.z-ShipZmin))end end;function UpdateViewDamageoutline(K)UFrame=40;VFrame=40;UStart=20+UFrame;VStart=180+VFrame;UDim=1880-2*UFrame;VDim=840-2*VFrame;if K.submode==\"top\"then if DMGOStretch==false then local L=UDim/(ShipYmax-ShipYmin)local M=VDim/(ShipXmax-ShipXmin)if L>=M then local N=L/M;local O=math.floor(UDim/N)UStart=UStart+(UDim-O)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100/N*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100*G.xp+VStart)end else local N=M/L;local P=math.floor(VDim/N)VStart=VStart+(VDim-P)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100/N*G.xp+VStart)end end else for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100*G.xp+VStart)end end elseif K.submode==\"front\"then if DMGOStretch==false then local L=UDim/(ShipXmax-ShipXmin)local M=VDim/(ShipZmax-ShipZmin)if L>=M then local N=L/M;local O=math.floor(UDim/N)UStart=UStart+(UDim-O)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100/N*G.xp+UStart)dmgoElements[g].v=math.floor(VDim/100*(100-G.zp)+VStart)end else local N=M/L;local P=math.floor(VDim/N)VStart=VStart+(VDim-P)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.xp+UStart)dmgoElements[g].v=math.floor(VDim/100/N*(100-G.zp)+VStart)end end else for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.xp+UStart)dmgoElements[g].v=math.floor(VDim/100*(100-G.zp)+VStart)end end elseif K.submode==\"side\"then if DMGOStretch==false then local L=UDim/(ShipYmax-ShipYmin)local M=VDim/(ShipXmax-ShipZmin)if L>=M then local N=L/M;local O=math.floor(UDim/N)UStart=UStart+(UDim-O)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100/N*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100*(100-G.zp)+VStart)end else local N=M/L;local P=math.floor(VDim/N)VStart=VStart+(VDim-P)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100/N*(100-G.zp)+VStart)end end else for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100*(100-G.zp)+VStart)end end else DrawCenteredText(\"ERROR: non-existing DMGO mode set.\")PrintConsole(\"ERROR: non-existing DMGO mode set.\")unit.exit()end end;function GetDamageoutlineShip()local e=\"\"for g,G in ipairs(dmgoElements)do local Q=\"\"local R=1;if G.type==\"h\"then Q=\"ch\"elseif G.type==\"d\"then Q=\"cw\"else Q=\"cc\"end;if G.id==highlightID then Q=\"f2\"end;if G.size>0 and G.size<1000 then R=5 elseif G.size>=1000 and G.size<2000 then R=8 elseif G.size>=2000 and G.size<5000 then R=12 elseif G.size>=5000 and G.size<10000 then R=15 elseif G.size>=10000 and G.size<20000 then R=20 elseif G.size>=20000 then R=30 end;e=e..[[]]if G.id==highlightID then e=e..[[]]e=e..[[]]end end;return e end;function GetContentClickareas(K)local e=\"\"if K~=nil and K.ClickAreas~=nil and#K.ClickAreas>0 then for g,S in ipairs(K.ClickAreas)do e=e..[[]]end end;return e end;function GetElement1(H,I,T,U)H=H or 0;I=I or 0;T=T or 600;U=U or 600;local e=\"\"e=e..[[\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ]]return e end;function GetElement2(H,I)H=H or 0;I=I or 0;local e=\"\"e=e..[[]]return e end;function GetElementLogo(H,I,V,W,X)H=H or 812;I=I or 380;V=V or\"f\"W=W or\"f2\"X=X or\"f3\"local e=\"\"e=e..[[\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ]]return e end;function GetHeader(Y)Y=Y or\"ERROR: UNDEFINED\"local e=\"\"e=e..[[\n ]]..Y..[[]]return e end;function GetContentBackground(Z,_)bgColor=ColorBackgroundPattern;local e=\"\"if Z==\"dots\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' viewBox='0 0 4 4'%3E%3Cpath fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' d='M1 3h1v1H1V3zm2-2h1v1H3V1z'%3E%3C/path%3E%3C/svg%3E\");]]elseif Z==\"rain\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='12' height='16' viewBox='0 0 12 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 .99C4 .445 4.444 0 5 0c.552 0 1 .45 1 .99v4.02C6 5.555 5.556 6 5 6c-.552 0-1-.45-1-.99V.99zm6 8c0-.546.444-.99 1-.99.552 0 1 .45 1 .99v4.02c0 .546-.444.99-1 .99-.552 0-1-.45-1-.99V8.99z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E\");]]elseif Z==\"plus\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E\");]]elseif Z==\"signal\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='84' height='48' viewBox='0 0 84 48' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h12v6H0V0zm28 8h12v6H28V8zm14-8h12v6H42V0zm14 0h12v6H56V0zm0 8h12v6H56V8zM42 8h12v6H42V8zm0 16h12v6H42v-6zm14-8h12v6H56v-6zm14 0h12v6H70v-6zm0-16h12v6H70V0zM28 32h12v6H28v-6zM14 16h12v6H14v-6zM0 24h12v6H0v-6zm0 8h12v6H0v-6zm14 0h12v6H14v-6zm14 8h12v6H28v-6zm-14 0h12v6H14v-6zm28 0h12v6H42v-6zm14-8h12v6H56v-6zm0-8h12v6H56v-6zm14 8h12v6H70v-6zm0 8h12v6H70v-6zM14 24h12v6H14v-6zm14-8h12v6H28v-6zM14 8h12v6H14V8zM0 8h12v6H0V8z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E\");]]elseif Z==\"deathstar\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='105' viewBox='0 0 80 105'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M20 10a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm15 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zM20 75a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zm30-65a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm0 65a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zM35 10a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zM5 45a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zm60 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10z' /%3E%3C/g%3E%3C/g%3E%3C/svg%3E\");]]elseif Z==\"diamond\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='32' viewBox='0 0 16 32'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath fill-rule='evenodd' d='M0 24h4v2H0v-2zm0 4h6v2H0v-2zm0-8h2v2H0v-2zM0 0h4v2H0V0zm0 4h2v2H0V4zm16 20h-6v2h6v-2zm0 4H8v2h8v-2zm0-8h-4v2h4v-2zm0-20h-6v2h6V0zm0 4h-4v2h4V4zm-2 12h2v2h-2v-2zm0-8h2v2h-2V8zM2 8h10v2H2V8zm0 8h10v2H2v-2zm-2-4h14v2H0v-2zm4-8h6v2H4V4zm0 16h6v2H4v-2zM6 0h2v2H6V0zm0 24h2v2H6v-2z'/%3E%3C/g%3E%3C/svg%3E\");]]elseif Z==\"hexagon\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='49' viewBox='0 0 28 49'%3E%3Cg fill-rule='evenodd'%3E%3Cg id='hexagons' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='nonzero'%3E%3Cpath d='M13.99 9.25l13 7.5v15l-13 7.5L1 31.75v-15l12.99-7.5zM3 17.9v12.7l10.99 6.34 11-6.35V17.9l-11-6.34L3 17.9zM0 15l12.98-7.5V0h-2v6.35L0 12.69v2.3zm0 18.5L12.98 41v8h-2v-6.85L0 35.81v-2.3zM15 0v7.5L27.99 15H28v-2.31h-.01L17 6.35V0h-2zm0 49v-8l12.99-7.5H28v2.31h-.01L17 42.15V49h-2z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E\");]]elseif Z==\"capsule\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='32' height='26' viewBox='0 0 32 26' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M14 0v3.994C14 7.864 10.858 11 7 11c-3.866 0-7-3.138-7-7.006V0h2v4.005C2 6.765 4.24 9 7 9c2.756 0 5-2.236 5-4.995V0h2zm0 26v-5.994C14 16.138 10.866 13 7 13c-3.858 0-7 3.137-7 7.006V26h2v-6.005C2 17.235 4.244 15 7 15c2.76 0 5 2.236 5 4.995V26h2zm2-18.994C16 3.136 19.142 0 23 0c3.866 0 7 3.138 7 7.006v9.988C30 20.864 26.858 24 23 24c-3.866 0-7-3.138-7-7.006V7.006zm2-.01C18 4.235 20.244 2 23 2c2.76 0 5 2.236 5 4.995v10.01C28 19.765 25.756 22 23 22c-2.76 0-5-2.236-5-4.995V6.995z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E\");]]elseif Z==\"diagonal\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='6' height='6' viewBox='0 0 6 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'%3E%3Cpath d='M5 0h1L0 6V5zM6 5v1H5z'/%3E%3C/g%3E%3C/svg%3E\");]]end;return e end;function GetContentDamageHUDOutput()local a0=300;local a1=165;if#damagedElements>0 or#brokenElements>0 then a1=510 end;local e=\"\"e=e..[[\n \n ]]e=e..[[]]..[[]]..[[]]..[[]]..(YourShipsName==\"Enter here\"and\"Ship ID \"..ShipID or YourShipsName)..[[]]..[[]]if#brokenElements>0 then e=e..[[]]elseif#damagedElements>0 then e=e..[[]]else e=e..[[]]end;if#damagedElements>0 or#brokenElements>0 then e=e..[[Total Damage]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",totalShipMaxHP-totalShipHP))..[[]]e=e..[[T]]..ScrapTier..[[ Scrap Needed]]..[[]]..getScraps(totalShipMaxHP-totalShipHP,true)..[[]]e=e..[[Repair Time]]..[[]]..getRepairTime(totalShipMaxHP-totalShipHP,true)..[[]]e=e..[[]]..[[]]..[[]]..#healthyElements..[[]]..[[]]..[[]]..#damagedElements..[[]]..[[]]..[[]]..#brokenElements..[[]]local u=0;for a2=hudStartIndex,hudStartIndex+9,1 do if rE[a2]~=nil then v=rE[a2]if v.hp>0 then e=e..[[]]..[[]]..string.format(\"%.30s\",v.name)..[[]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",v.missinghp))..[[]]if v.id==highlightID then e=e..[[]]..[[]]..string.format(\"%.30s\",v.name)..[[]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",v.missinghp))..[[]]end else e=e..[[]]..[[]]..string.format(\"%.30s\",v.name)..[[]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",v.missinghp))..[[]]if v.id==highlightID then highlightX=elementPosition.x-coreWorldOffset;highlightY=elementPosition.y-coreWorldOffset;highlightZ=elementPosition.z-coreWorldOffset;e=e..[[]]..[[]]..string.format(\"%.30s\",v.name)..[[]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",v.missinghp))..[[]]end end;u=u+1 end end;if DisallowKeyPresses==true then e=e..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[Keypresses disabled.]]..[[Change in LUA parameters]]..[[by unchecking DisallowKeyPresses.]]..[[]]..[[]]..[[]]else e=e..[[]]..[[]]..[[]]..[[]]..[[Up/down arrows to highlight]]..[[CTRL + arrows to move HUD]]..[[Left arrow to toggle HUD Mode]]..[[ALT+1-4 to set Scrap Tier]]..[[ALT+8 to reset HUD position]]..[[ALT+9 to shut script off]]..[[]]..[[]]end else if DisallowKeyPresses==true then e=e..[[]]..OkayCenterMessage..[[]]..[[]]..#healthyElements..[[ elements / ]]..GenerateCommaValue(string.format(\"%.0f\",totalShipMaxHP))..[[ HP.]]..[[]]..[[]]..[[]]..[[]]..[[Keypresses disabled.]]..[[Change in LUA parameters]]..[[by unchecking DisallowKeyPresses.]]..[[]]..[[]]..[[]]else e=e..[[]]..OkayCenterMessage..[[]]..[[]]..#healthyElements..[[ elements / ]]..GenerateCommaValue(string.format(\"%.0f\",totalShipMaxHP))..[[ HP.]]..[[]]..[[]]..[[]]..[[]]..[[Left arrow to toggle HUD Mode]]..[[CTRL + arrows to move HUD]]..[[ALT+8 to reset HUD position]]..[[ALT+9 to shut script off]]..[[]]..[[]]end end;e=e..[[]]return e end;function GetContentDamageScreen()local a3=\"\"if#damagedElements>0 then local a4=#damagedElements;if a4>DamagePageSize then a4=DamagePageSize end;if CurrentDamagedPage==math.ceil(#damagedElements/DamagePageSize)then a4=#damagedElements%DamagePageSize+12;if a4>12 then a4=a4-12 end end;a3=a3 ..[[]]a3=a3 ..[[]]if UseMyElementNames==true then a3=a3 ..[[Damaged Name]]else a3=a3 ..[[Damaged Type]]end;a3=a3 ..[[HLTHDMG]]a3=a3 ..[[T]]..ScrapTier..[[ SCRREPTIME]]AddClickArea(\"damage\",{id=\"SwitchScrapTier\",mode=\"damage\",x1=650,x2=775,y1=315,y2=360})local g=0;for u=1+(CurrentDamagedPage-1)*DamagePageSize,a4+(CurrentDamagedPage-1)*DamagePageSize,1 do g=g+1;local a5=damagedElements[u]if UseMyElementNames==true then a3=a3 ..[[]]..string.format(\"%.23s\",a5.name)..[[]]else a3=a3 ..[[]]..string.format(\"%.23s\",a5.type)..[[]]end;a3=a3 ..[[]]..a5.percent..[[%]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",a5.missinghp),true)..[[]]..[[]]..getScraps(a5.missinghp,true)..[[]]..[[]]..getRepairTime(a5.missinghp,true)..[[]]..[[]]end;if#damagedElements>DamagePageSize then a3=a3 ..[[Page ]]..CurrentDamagedPage..\" of \"..math.ceil(#damagedElements/DamagePageSize)..[[]]if CurrentDamagedPage\n \n \n ]]AddClickArea(\"damage\",{id=\"DamagedPageDown\",mode=\"damage\",x1=65,x2=260,y1=290+(a4+1)*50,y2=290+50+(a4+1)*50})else DisableClickArea(\"DamagedPageDown\",\"damage\")end;if CurrentDamagedPage>1 then a3=a3 ..[[\n \n \n ]]AddClickArea(\"damage\",{id=\"DamagedPageUp\",mode=\"damage\",x1=750,x2=950,y1=290+(a4+1)*50,y2=290+50+(a4+1)*50})else DisableClickArea(\"DamagedPageUp\",\"damage\")end end end;if#brokenElements>0 then local a6=#brokenElements;if a6>DamagePageSize then a6=DamagePageSize end;if CurrentBrokenPage==math.ceil(#brokenElements/DamagePageSize)then a6=#brokenElements%DamagePageSize+12;if a6>12 then a6=a6-12 end end;a3=a3 ..[[]]a3=a3 ..[[]]if UseMyElementNames==true then a3=a3 ..[[Broken Name]]else a3=a3 ..[[Broken Type]]end;a3=a3 ..[[DMG]]a3=a3 ..[[T]]..ScrapTier..[[ SCRREPTIME]]AddClickArea(\"damage\",{id=\"SwitchScrapTier2\",mode=\"damage\",x1=1570,x2=1690,y1=315,y2=360})local g=0;for u=1+(CurrentBrokenPage-1)*DamagePageSize,a6+(CurrentBrokenPage-1)*DamagePageSize,1 do g=g+1;local a5=brokenElements[u]if UseMyElementNames==true then a3=a3 ..[[]]..string.format(\"%.30s\",a5.name)..[[]]else a3=a3 ..[[]]..string.format(\"%.30s\",a5.type)..[[]]end;a3=a3 ..[[]]..GenerateCommaValue(string.format(\"%.0f\",a5.missinghp),true)..[[]]..[[]]..getScraps(a5.missinghp,true)..[[]]..[[]]..getRepairTime(a5.missinghp,true)..[[]]..[[]]end;if#brokenElements>DamagePageSize then a3=a3 ..[[Page ]]..CurrentBrokenPage..\" of \"..math.ceil(#brokenElements/DamagePageSize)..[[]]if CurrentBrokenPage>1 then a3=a3 ..[[\n \n \n ]]AddClickArea(\"damage\",{id=\"BrokenPageUp\",mode=\"damage\",x1=1665,x2=1865,y1=290+(a6+1)*50,y2=290+50+(a6+1)*50})else DisableClickArea(\"BrokenPageUp\",\"damage\")end;if CurrentBrokenPage\n \n \n ]]AddClickArea(\"damage\",{id=\"BrokenPageDown\",mode=\"damage\",x1=980,x2=1180,y1=290+(a6+1)*50,y2=290+50+(a6+1)*50})else DisableClickArea(\"BrokenPageDown\",\"damage\")end end end;if#damagedElements>0 or#brokenElements>0 then local a7=math.floor(1878/#elementsIdList*#damagedElements)local a8=math.floor(1878/#elementsIdList*#brokenElements)local a9=1878-a7-a8+1;a3=a3 ..[[]]a3=a3 ..[[]]a3=a3 ..[[]]a3=a3 ..[[]]if#damagedElements>0 then a3=a3 ..[[]]..#damagedElements..[[]]end;if#healthyElements>0 then a3=a3 ..[[]]..#healthyElements..[[]]end;if#brokenElements>0 then a3=a3 ..[[]]..#brokenElements..[[]]end;a3=a3 ..[[]]a3=a3 ..[[]]..GenerateCommaValue(string.format(\"%.0f\",totalShipMaxHP-totalShipHP))..[[ HP damage in total ]]..getScraps(totalShipMaxHP-totalShipHP,true)..[[ T]]..ScrapTier..[[ scraps needed. ]]..getRepairTime(totalShipMaxHP-totalShipHP,true)..[[ projected repair time.]]else a3=a3 ..GetElementLogo(812,380,\"ch\",\"ch\",\"ch\")..[[]]..OkayCenterMessage..[[]]..[[]]..#healthyElements..[[ elements stand ]]..GenerateCommaValue(string.format(\"%.0f\",totalShipMaxHP))..[[ HP strong.]]end;forceDamageRedraw=false;return a3 end;function ActionStopengines()if DisallowKeyPresses==true then return end;ToggleHUD()end;function ActionStrafeRight()if DisallowKeyPresses==true then return end;if KeyCTRLPressed==true then if HUDShiftU<4000 then HUDShiftU=HUDShiftU+50;SaveToDatabank()RenderScreens()end else HudDeselectElement()end end;function ActionStrafeLeft()if DisallowKeyPresses==true then return end;if KeyCTRLPressed==true then if HUDShiftU>=50 then HUDShiftU=HUDShiftU-50;SaveToDatabank()RenderScreens()end else ToggleHUD()end end;function ActionDown()if DisallowKeyPresses==true then return end;if KeyCTRLPressed==true then if HUDShiftV<4000 then HUDShiftV=HUDShiftV+50;SaveToDatabank()RenderScreens()end else ChangeHudSelectedElement(1)end end;function ActionUp()if DisallowKeyPresses==true then return end;if KeyCTRLPressed==true then if HUDShiftV>=50 then HUDShiftV=HUDShiftV-50;SaveToDatabank()RenderScreens()end else ChangeHudSelectedElement(-1)end end;function ActionOption1()if DisallowKeyPresses==true then return end;ScrapTier=1;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption2()if DisallowKeyPresses==true then return end;ScrapTier=2;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption3()if DisallowKeyPresses==true then return end;ScrapTier=3;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption4()if DisallowKeyPresses==true then return end;ScrapTier=4;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption8()if DisallowKeyPresses==true then return end;HUDShiftU=0;HUDShiftV=0;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption9()if DisallowKeyPresses==true then return end;SaveToDatabank()SwitchScreens(\"off\")unit.exit()end",
- "filter": {
- "args": [],
- "signature": "start()",
- "slotKey": "-1"
- },
- "key": "8"
- },
- {
- "code": "SaveToDatabank()\nSwitchScreens(\"off\")",
- "filter": {
- "args": [],
- "signature": "stop()",
- "slotKey": "-1"
- },
- "key": "9"
- },
- {
- "code": "OnTickData()\n",
- "filter": {
- "args": [
- {
- "value": "UpdateData"
- }
- ],
- "signature": "tick(timerId)",
- "slotKey": "-1"
- },
- "key": "10"
- },
- {
- "code": "ToggleHighlight()",
- "filter": {
- "args": [
- {
- "value": "UpdateHighlight"
- }
- ],
- "signature": "tick(timerId)",
- "slotKey": "-1"
- },
- "key": "11"
- },
- {
- "code": "--[[\n Damage Report 3.12\n A LUA script for Dual Universe\n\n Created By Dorian Gray\n Ingame: DorianGray\n Discord: Dorian Gray#2623\n\n You can find/update this script on GitHub. Explanations, installation and usage information as well as screenshots can be found there too.\n GitHub: https://github.com/DorianTheGrey/DU-DamageReport\n\n GNU Public License 3.0. Use whatever you want, be so kind to leave credit.\n \n Credits & thanks: \n Thanks to NovaQuark for creating the MMO of the century.\n Thanks to Jericho, Dmentia and Archaegeo for learning a lot from their fine scripts.\n Thanks to TheBlacklist for testing and wonderful suggestions.\n SVG patterns by Hero Patterns.\n DU atlas data from Jayle Break.\n \n]]\n\n--[[ 1. USER DEFINED VARIABLES ]]\n\nYourShipsName = \"Enter here\" --export Enter your ship name here if you want it displayed instead of the ship's ID. YOU NEED TO LEAVE THE QUOTATION MARKS.\n\nSkillRepairToolEfficiency = 0 --export Enter (0-5) your talent \"Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency\"\nSkillRepairToolOptimization = 0 --export Enter your talent \"Mining and Inventory -> Equipment Manager -> Repair Tool Optimization\"\n\nStatAtmosphericFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED ATMOSPHERIC FUEL TANKS (from the builders talent \"Piloting -> Atmospheric Flight Technician -> Atmospheric Fuel-Tank Handling\")\nStatSpaceFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL SPACE TANKS (from the builders talent \"Piloting -> Atmospheric Engine Technician -> Space Fuel-Tank Handling\")\nStatRocketFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL ROCKET TANKS (from the builders talent \"Piloting -> Rocket Scientist -> Rocket Booster Fuel Tank Handling\")\nStatContainerOptimization = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL TANKS \"from the builders talent Mining and Inventory -> Stock Control -> Container Optimization\"\nStatFuelTankOptimization = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL TANKS \"from the builders talent Mining and Inventory -> Stock Control -> Fuel Tank Optimization\"\n\nShowWelcomeMessage = true --export Do you want the welcome message on the start screen with your name?\nDisallowKeyPresses = false --export Need your keys for other scripts/huds and want to prevent Damage Report keypresses to be processed? Then check this. (Usability of the HUD mode will be small.)\nAddSummertimeHour = false --export: Is summertime currently enabled in your location? (Adds one hour.)\n\nUpdateDataInterval=1.0;HighlightBlinkingInterval=0.5;ColorPrimary=\"FF6700\"ColorSecondary=\"FFFFFF\"ColorTertiary=\"000000\"ColorHealthy=\"00FF00\"ColorWarning=\"FFFF00\"ColorCritical=\"FF0000\"ColorBackground=\"000000\"ColorBackgroundPattern=\"4F4F4F\"ColorFuelAtmospheric=\"004444\"ColorFuelSpace=\"444400\"ColorFuelRocket=\"440044\"VERSION=3.12;DebugMode=false;DebugRenderClickareas=true;DBData={}core=nil;db=nil;screens={}dscreens={}Warnings={}screenModes={[\"flight\"]={id=\"flight\"},[\"damage\"]={id=\"damage\"},[\"damageoutline\"]={id=\"damageoutline\"},[\"fuel\"]={id=\"fuel\"},[\"cargo\"]={id=\"cargo\"},[\"agg\"]={id=\"agg\"},[\"map\"]={id=\"map\"},[\"time\"]={id=\"time\",activetoggle=\"true\"},[\"settings1\"]={id=\"settings1\"},[\"startup\"]={id=\"startup\"}}backgroundModes={\"deathstar\",\"capsule\",\"rain\",\"signal\",\"hexagon\",\"diagonal\",\"diamond\",\"plus\",\"dots\"}BackgroundMode=\"deathstar\"BackgroundSelected=1;BackgroundModeOpacity=0.25;SaveVars={\"dscreens\",\"ColorPrimary\",\"ColorSecondary\",\"ColorTertiary\",\"ColorHealthy\",\"ColorWarning\",\"ColorCritical\",\"ColorBackground\",\"ColorBackgroundPattern\",\"ScrapTier\",\"HUDMode\",\"SimulationMode\",\"DMGOStretch\",\"HUDShiftU\",\"HUDShiftV\",\"colorIDIndex\",\"colorIDTable\",\"BackgroundMode\",\"BackgroundSelected\",\"BackgroundModeOpacity\"}HUDMode=false;HUDShiftU=0;HUDShiftV=0;hudSelectedIndex=0;hudStartIndex=1;hudArrowSticker={}highlightOn=false;highlightID=0;highlightX=0;highlightY=0;highlightZ=0;SimulationMode=false;OkayCenterMessage=\"All systems nominal.\"CurrentDamagedPage=1;CurrentBrokenPage=1;DamagePageSize=12;ScrapTier=1;totalScraps=0;ScrapTierRepairTimes={10,50,250,1250}coreWorldOffset=0;totalShipHP=0;formerTotalShipHP=-1;totalShipMaxHP=0;totalShipIntegrity=100;elementsId={}elementsIdList={}damagedElements={}brokenElements={}rE={}healthyElements={}typeElements={}ElementCounter=0;UseMyElementNames=true;dmgoElements={}DMGOMaxElements=250;DMGOStretch=false;ShipXmin=99999999;ShipXmax=-99999999;ShipYmin=99999999;ShipYmax=-99999999;ShipZmin=99999999;ShipZmax=-99999999;totalShipMass=0;formerTotalShipMass=-1;formerTime=-1;FuelAtmosphericTanks={}FuelSpaceTanks={}FuelRocketTanks={}FuelAtmosphericTotal=0;FuelSpaceTotal=0;FuelRocketTotal=0;FuelAtmosphericCurrent=0;FuelSpaceTotalCurrent=0;FuelRocketTotalCurrent=0;formerFuelAtmosphericTotal=-1;formerFuelSpaceTotal=-1;formerFuelRocketTotal=-1;hexTable={\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"A\",\"B\",\"C\",\"D\",\"E\",\"F\"}colorIDIndex=1;colorIDTable={[1]={id=\"ColorPrimary\",desc=\"Main HUD Color\",basec=\"FF6700\",newc=\"FF6700\"},[2]={id=\"ColorSecondary\",desc=\"Secondary HUD Color\",basec=\"FFFFFF\",newc=\"FFFFFF\"},[3]={id=\"ColorTertiary\",desc=\"Tertiary HUD Color\",basec=\"000000\",newc=\"000000\"},[4]={id=\"ColorHealthy\",desc=\"Color code for Healthy/Okay\",basec=\"00FF00\",newc=\"00FF00\"},[5]={id=\"ColorWarning\",desc=\"Color code for Damaged/Warning\",basec=\"FFFF00\",newc=\"FFFF00\"},[6]={id=\"ColorCritical\",desc=\"Color code for Broken/Critical\",basec=\"FF0000\",newc=\"FF0000\"},[7]={id=\"ColorBackground\",desc=\"Background Color\",basec=\"000000\",newc=\"000000\"},[8]={id=\"ColorBackgroundPattern\",desc=\"Background Pattern Color\",basec=\"4F4F4F\",newc=\"4F4F4F\"},[9]={id=\"ColorFuelAtmospheric\",desc=\"Color for Atmo Fuel/Elements\",basec=\"004444\",newc=\"004444\"},[10]={id=\"ColorFuelSpace\",desc=\"Color for Space Fuel/Elements\",basec=\"444400\",newc=\"444400\"},[11]={id=\"ColorFuelRocket\",desc=\"Color for Rocket Fuel/Elements\",basec=\"440044\",newc=\"440044\"}}function InitiateSlots()for a,b in pairs(unit)do if type(b)==\"table\"and type(b.export)==\"table\"and b.getElementClass then local c=b.getElementClass():lower()if c:find(\"coreunit\")then core=b;local d=core.getMaxHitPoints()if d>10000 then coreWorldOffset=128 elseif d>1000 then coreWorldOffset=64 elseif d>150 then coreWorldOffset=32 else coreWorldOffset=16 end elseif c=='databankunit'then db=b elseif c==\"screenunit\"then local e=\"startup\"screens[#screens+1]={element=b,id=b.getId(),mode=e,submode=\"\",ClickAreas={},refresh=true,active=false,fuelA=true,fuelS=true,fuelR=true,fuelIndex=1}end end end end;function LoadFromDatabank()if db==nil then return else for f,g in pairs(SaveVars)do if db.hasKey(g)then local h=json.decode(db.getStringValue(g))if h~=nil then if g==\"YourShipsName\"or g==\"AddSummertimeHour\"or g==\"UpdateDataInterval\"or g==\"HighlightBlinkingInterval\"or g==\"SkillRepairToolEfficiency\"or g==\"SkillRepairToolOptimization\"or g==\"SkillAtmosphericFuelEfficiency\"or g==\"SkillSpaceFuelEfficiency\"or g==\"SkillRocketFuelEfficiency\"or g==\"StatAtmosphericFuelTankHandling\"or g==\"StatSpaceFuelTankHandling\"or g==\"StatRocketFuelTankHandling\"then else _G[g]=h end end end end;for i,j in ipairs(screens)do for k,l in ipairs(dscreens)do if screens[i].id==dscreens[k].id then screens[i].mode=dscreens[k].mode;screens[i].submode=dscreens[k].submode;screens[i].active=dscreens[k].active;screens[i].refresh=true;screens[i].fuelA=dscreens[k].fuelA;screens[i].fuelS=dscreens[k].fuelS;screens[i].fuelR=dscreens[k].fuelR;screens[i].fuelIndex=dscreens[k].fuelIndex end end end end end;function SaveToDatabank()if db==nil then return else dscreens={}for i,m in ipairs(screens)do dscreens[i]={}dscreens[i].id=m.id;dscreens[i].mode=m.mode;dscreens[i].submode=m.submode;dscreens[i].active=m.active;dscreens[i].fuelA=m.fuelA;dscreens[i].fuelS=m.fuelS;dscreens[i].fuelR=m.fuelR;dscreens[i].fuelIndex=m.fuelIndex end;db.clear()for f,g in pairs(SaveVars)do db.setStringValue(g,json.encode(_G[g]))end end end;function InitiateScreens()if screens~=nil and#screens>0 then for i=1,#screens,1 do screens[i]=CreateClickAreasForScreen(screens[i])end end end;function UpdateTypeData()FuelAtmosphericTanks={}FuelSpaceTanks={}FuelRocketTanks={}FuelAtmosphericTotal=0;FuelAtmosphericCurrent=0;FuelSpaceTotal=0;FuelSpaceCurrent=0;FuelRocketCurrent=0;FuelRocketTotal=0;local n=4;local o=6;local p=0.8;if StatContainerOptimization>0 then n=n-0.05*StatContainerOptimization*n;o=o-0.05*StatContainerOptimization*o;p=p-0.05*StatContainerOptimization*p end;if StatFuelTankOptimization>0 then n=n-0.05*StatFuelTankOptimization*n;o=o-0.05*StatFuelTankOptimization*o;p=p-0.05*StatFuelTankOptimization*p end;for i,q in ipairs(typeElements)do local r=core.getElementNameById(q)or\"\"local s=core.getElementTypeById(q)or\"\"local t=core.getElementPositionById(q)or 0;local u=core.getElementHitPointsById(q)or 0;local v=core.getElementMaxHitPointsById(q)or 0;local w=core.getElementMassById(q)or 0;local x=\"\"local y=0;local z=0;local A=0;local B=0;if s==\"atmospheric fuel-tank\"then if v>10000 then x=\"L\"z=5480;y=12800 elseif v>1300 then x=\"M\"z=988.67;y=1600 elseif v>150 then x=\"S\"z=182.67;y=400 else x=\"XS\"z=35.03;y=100 end;if StatAtmosphericFuelTankHandling>0 then y=0.2*StatAtmosphericFuelTankHandling*y+y end;A=w-z;if A<=10 then A=0 end;B=string.format(\"%.0f\",A/n)cPercent=string.format(\"%.1f\",math.floor(100/y*tonumber(B)))table.insert(FuelAtmosphericTanks,{type=1,id=q,name=r,maxhp=v,hp=GetHPforElement(q),pos=t,size=x,mass=z,vol=y,cvol=B,percent=cPercent})if u>0 then FuelAtmosphericCurrent=FuelAtmosphericCurrent+B end;FuelAtmosphericTotal=FuelAtmosphericTotal+y elseif s==\"space fuel-tank\"then if v>10000 then x=\"L\"z=5480;y=12800 elseif v>1300 then x=\"M\"z=988.67;y=1600 else x=\"S\"z=182.67;y=400 end;if StatSpaceFuelTankHandling>0 then y=0.2*StatSpaceFuelTankHandling*y+y end;A=w-z;if A<=10 then A=0 end;B=string.format(\"%.0f\",A/o)cPercent=string.format(\"%.1f\",100/y*tonumber(B))table.insert(FuelSpaceTanks,{type=2,id=q,name=r,maxhp=v,hp=GetHPforElement(q),pos=t,size=x,mass=z,vol=y,cvol=B,percent=cPercent})if u>0 then FuelSpaceCurrent=FuelSpaceCurrent+B end;FuelSpaceTotal=FuelSpaceTotal+y elseif s==\"rocket fuel-tank\"then if v>65000 then x=\"L\"z=25740;y=50000 elseif v>6000 then x=\"M\"z=4720;y=6400 elseif v>700 then x=\"S\"z=886.72;y=800 else x=\"XS\"z=173.42;y=400 end;if StatRocketFuelTankHandling>0 then y=0.2*StatRocketFuelTankHandling*y+y end;A=w-z;if A<=10 then A=0 end;B=string.format(\"%.0f\",A/p)cPercent=string.format(\"%.1f\",100/y*tonumber(B))table.insert(FuelRocketTanks,{type=3,id=q,name=r,maxhp=v,hp=GetHPforElement(q),pos=t,size=x,mass=z,vol=y,cvol=B,percent=cPercent})if u>0 then FuelRocketCurrent=FuelRocketCurrent+B end;FuelRocketTotal=FuelRocketTotal+y end end;if FuelAtmosphericCurrent~=formerFuelAtmosphericCurrent then SetRefresh(\"fuel\")formerFuelAtmosphericCurrent=FuelAtmosphericCurrent end;if FuelSpaceCurrent~=formerFuelSpaceCurrent then SetRefresh(\"fuel\")formerFuelSpaceCurrent=FuelSpaceCurrent end;if FuelRocketCurrent~=formerFuelRocketCurrent then SetRefresh(\"fuel\")formerFuelRocketCurrent=FuelRocketCurrent end end;function UpdateDamageData(C)C=C or false;if SimulationActive==true then return end;local formerTotalShipHP=totalShipHP;totalShipHP=0;totalShipMaxHP=0;totalShipIntegrity=100;damagedElements={}brokenElements={}healthyElements={}if C==true then typeElements={}end;ElementCounter=0;elementsIdList=core.getElementIdList()for i,q in pairs(elementsIdList)do ElementCounter=ElementCounter+1;local r=core.getElementNameById(q)local s=core.getElementTypeById(q)local t=core.getElementPositionById(q)local u=core.getElementHitPointsById(q)local v=core.getElementMaxHitPointsById(q)if SimulationMode==true then SimulationActive=true;local D=math.random(0,10)if D<2 and#brokenElements<30 then u=0 elseif D>=2 and D<4 and#damagedElements<30 then u=math.random(1,math.ceil(v))else u=v end end;totalShipHP=totalShipHP+u;totalShipMaxHP=totalShipMaxHP+v;if v-u>constants.epsilon then if u>0 then table.insert(damagedElements,{id=q,name=r,type=s,counter=ElementCounter,hp=u,maxhp=v,missinghp=v-u,percent=math.ceil(100/v*u),pos=t})else table.insert(brokenElements,{id=q,name=r,type=s,counter=ElementCounter,hp=u,maxhp=v,missinghp=v-u,percent=0,pos=t})end else table.insert(healthyElements,{id=q,name=r,type=s,counter=ElementCounter,hp=u,maxhp=v,pos=t})if q==highlightID then highlightID=0;highlightOn=false;HideHighlight()hudSelectedIndex=0 end end;if C==true then if s==\"atmospheric fuel-tank\"or s==\"space fuel-tank\"or s==\"rocket fuel-tank\"then table.insert(typeElements,q)end end end;SortDamageTables()rE={}if#brokenElements>0 then for f,j in ipairs(brokenElements)do table.insert(rE,{id=j.id,missinghp=j.missinghp,hp=j.hp,name=j.name,type=j.type,pos=j.pos})end end;if#damagedElements>0 then for f,j in ipairs(damagedElements)do table.insert(rE,{id=j.id,missinghp=j.missinghp,hp=j.hp,name=j.name,type=j.type,pos=j.pos})end end;if#rE>0 then table.sort(rE,function(E,F)return E.missinghp>F.missinghp end)end;totalShipIntegrity=string.format(\"%2.0f\",100/totalShipMaxHP*totalShipHP)if formerTotalShipHP~=totalShipHP then forceDamageRedraw=true;formerTotalShipHP=totalShipHP else forceDamageRedraw=false end end;function GetHPforElement(q)for i,j in ipairs(brokenElements)do if j.id==q then return 0 end end;for i,j in ipairs(damagedElements)do if j.id==q then return j.hp end end;for i,j in ipairs(healthyElements)do if j.id==q then return j.maxhp end end end;function UpdateClickArea(G,H,I)for i,m in ipairs(screens)do for J,j in pairs(screens[i].ClickAreas)do if j.id==G and j.mode==I then screens[i].ClickAreas[J]=H end end end end;function AddClickArea(I,H)for i,m in ipairs(screens)do if screens[i].mode==I then table.insert(screens[i].ClickAreas,H)end end end;function AddClickAreaForScreenID(K,H)for i,m in ipairs(screens)do if screens[i].id==K then table.insert(screens[i].ClickAreas,H)end end end;function DisableClickArea(G,I)UpdateClickArea(G,{id=G,mode=I,x1=-1,x2=-1,y1=-1,y2=-1})end;function SetRefresh(I,L)I=I or\"all\"L=L or\"all\"if screens~=nil and#screens>0 then for i=1,#screens,1 do if screens[i].mode==I or I==\"all\"then if screens[i].submode==L or L==\"all\"then screens[i].refresh=true end end end end end;function WipeClickAreasForScreen(m)m.ClickAreas={}return m end;function CreateBaseClickAreas(m)table.insert(m.ClickAreas,{mode=\"all\",id=\"ToggleHudMode\",x1=1537,x2=1728,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"damage\",x1=193,x2=384,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"damageoutline\",x1=385,x2=576,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"fuel\",x1=577,x2=768,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"time\",x1=0,x2=192,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"settings1\",x1=1729,x2=1920,y1=1015,y2=1075})return m end;function CreateClickAreasForScreen(m)if m==nil then return{}end;if m.mode==\"flight\"then elseif m.mode==\"damage\"then table.insert(m.ClickAreas,{mode=\"damage\",id=\"ToggleElementLabel\",x1=70,x2=425,y1=325,y2=355})table.insert(m.ClickAreas,{mode=\"damage\",id=\"ToggleElementLabel2\",x1=980,x2=1400,y1=325,y2=355})elseif m.mode==\"damageoutline\"then table.insert(m.ClickAreas,{mode=\"damageoutline\",id=\"DMGOChangeView\",param=\"top\",x1=60,x2=439,y1=150,y2=200})table.insert(m.ClickAreas,{mode=\"damageoutline\",id=\"DMGOChangeView\",param=\"side\",x1=440,x2=824,y1=150,y2=200})table.insert(m.ClickAreas,{mode=\"damageoutline\",id=\"DMGOChangeView\",param=\"front\",x1=825,x2=1215,y1=150,y2=200})table.insert(m.ClickAreas,{mode=\"damageoutline\",id=\"DMGOChangeStretch\",x1=1530,x2=1580,y1=150,y2=200})elseif m.mode==\"fuel\"then elseif m.mode==\"cargo\"then elseif m.mode==\"agg\"then elseif m.mode==\"map\"then elseif m.mode==\"time\"then elseif m.mode==\"settings1\"then table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ToggleBackground\",x1=75,x2=860,y1=170,y2=215})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"PreviousBackground\",x1=75,x2=460,y1=235,y2=285})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"NextBackground\",x1=480,x2=860,y1=235,y2=285})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"DecreaseOpacity\",x1=75,x2=460,y1=300,y2=350})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"IncreaseOpacity\",x1=480,x2=860,y1=300,y2=350})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ResetColors\",x1=75,x2=860,y1=370,y2=415})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"PreviousColorID\",x1=90,x2=140,y1=500,y2=550})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"NextColorID\",x1=795,x2=845,y1=500,y2=550})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"1\",x1=210,x2=290,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"2\",x1=300,x2=380,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"3\",x1=385,x2=465,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"4\",x1=470,x2=550,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"5\",x1=560,x2=640,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"6\",x1=645,x2=725,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"1\",x1=210,x2=290,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"2\",x1=300,x2=380,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"3\",x1=385,x2=465,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"4\",x1=470,x2=550,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"5\",x1=560,x2=640,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"6\",x1=645,x2=725,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ResetPosColor\",x1=160,x2=340,y1=885,y2=935})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ApplyPosColor\",x1=355,x2=780,y1=885,y2=935})elseif m.mode==\"startup\"then end;m=CreateBaseClickAreas(m)return m end;function CheckClick(M,N,O)M=M*1920;N=N*1120;O=O or\"\"HitPayload={}if screens~=nil and#screens>0 then for i=1,#screens,1 do if screens[i].active==true and screens[i].element.getMouseX()~=-1 and screens[i].element.getMouseY()~=-1 then if O==\"\"then for J,j in pairs(screens[i].ClickAreas)do if j~=nil and M>=j.x1 and M<=j.x2 and N>=j.y1 and N<=j.y2 then O=j.id;HitPayload=j;break end end end;if O==\"ButtonPress\"then if screens[i].mode==HitPayload.param then screens[i].mode=\"startup\"else screens[i].mode=HitPayload.param end;if screens[i].mode==\"damageoutline\"then if screens[i].submode==\"\"then screens[i].submode=\"top\"end end;screens[i].refresh=true;screens[i].ClickAreas={}SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"ToggleBackground\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundMode==\"\"then BackgroundSelected=1;BackgroundMode=backgroundModes[BackgroundSelected]else BackgroundSelected=1;BackgroundMode=\"\"end;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"PreviousBackground\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundMode==\"\"then BackgroundSelected=1;BackgroundMode=backgroundModes[BackgroundSelected]else if BackgroundSelected<=1 then BackgroundSelected=#backgroundModes else BackgroundSelected=BackgroundSelected-1 end;BackgroundMode=backgroundModes[BackgroundSelected]end;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"NextBackground\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundMode==\"\"then BackgroundSelected=1;BackgroundMode=backgroundModes[BackgroundSelected]else if BackgroundSelected>=#backgroundModes then BackgroundSelected=1 else BackgroundSelected=BackgroundSelected+1 end;BackgroundMode=backgroundModes[BackgroundSelected]end;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"DecreaseOpacity\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundModeOpacity>0.1 then BackgroundModeOpacity=BackgroundModeOpacity-0.05;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()end elseif O==\"IncreaseOpacity\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundModeOpacity<1.0 then BackgroundModeOpacity=BackgroundModeOpacity+0.05;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()end elseif O==\"ResetColors\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then db.clear()ColorPrimary=\"FF6700\"ColorSecondary=\"FFFFFF\"ColorTertiary=\"000000\"ColorHealthy=\"00FF00\"ColorWarning=\"FFFF00\"ColorCritical=\"FF0000\"ColorBackground=\"000000\"ColorBackgroundPattern=\"4f4f4f\"ColorFuelAtmospheric=\"004444\"ColorFuelSpace=\"444400\"ColorFuelRocket=\"440044\"BackgroundMode=\"deathstar\"BackgroundSelected=1;BackgroundModeOpacity=0.25;colorIDTable={[1]={id=\"ColorPrimary\",desc=\"Main HUD Color\",basec=\"FF6700\",newc=\"FF6700\"},[2]={id=\"ColorSecondary\",desc=\"Secondary HUD Color\",basec=\"FFFFFF\",newc=\"FFFFFF\"},[3]={id=\"ColorTertiary\",desc=\"Tertiary HUD Color\",basec=\"000000\",newc=\"000000\"},[4]={id=\"ColorHealthy\",desc=\"Color code for Healthy/Okay\",basec=\"00FF00\",newc=\"00FF00\"},[5]={id=\"ColorWarning\",desc=\"Color code for Damaged/Warning\",basec=\"FFFF00\",newc=\"FFFF00\"},[6]={id=\"ColorCritical\",desc=\"Color code for Broken/Critical\",basec=\"FF0000\",newc=\"FF0000\"},[7]={id=\"ColorBackground\",desc=\"Background Color\",basec=\"000000\",newc=\"000000\"},[8]={id=\"ColorBackgroundPattern\",desc=\"Background Pattern Color\",basec=\"4F4F4F\",newc=\"4F4F4F\"},[9]={id=\"ColorFuelAtmospheric\",desc=\"Color for Atmo Fuel/Elements\",basec=\"004444\",newc=\"004444\"},[10]={id=\"ColorFuelSpace\",desc=\"Color for Space Fuel/Elements\",basec=\"444400\",newc=\"444400\"},[11]={id=\"ColorFuelRocket\",desc=\"Color for Rocket Fuel/Elements\",basec=\"440044\",newc=\"440044\"}}SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"PreviousColorID\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then colorIDIndex=colorIDIndex-1;if colorIDIndex<1 then colorIDIndex=#colorIDTable end;SaveToDatabank()SetRefresh(\"settings1\")RenderScreens(\"settings1\")elseif O==\"NextColorID\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then colorIDIndex=colorIDIndex+1;if colorIDIndex>#colorIDTable then colorIDIndex=1 end;SaveToDatabank()SetRefresh(\"settings1\")RenderScreens(\"settings1\")elseif O==\"ColorPosUp\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then local P=tonumber(string.sub(colorIDTable[colorIDIndex].newc,HitPayload.param,HitPayload.param),16)P=P+1;if P>15 then P=0 end;colorIDTable[colorIDIndex].newc=replace_char(HitPayload.param,colorIDTable[colorIDIndex].newc,hexTable[P+1])SaveToDatabank()SetRefresh(\"settings1\")RenderScreens(\"settings1\")elseif O==\"ColorPosDown\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then local P=tonumber(string.sub(colorIDTable[colorIDIndex].newc,HitPayload.param,HitPayload.param),16)P=P-1;if P<0 then P=15 end;colorIDTable[colorIDIndex].newc=replace_char(HitPayload.param,colorIDTable[colorIDIndex].newc,hexTable[P+1])SaveToDatabank()SetRefresh(\"settings1\")RenderScreens(\"settings1\")elseif O==\"ResetPosColor\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then colorIDTable[colorIDIndex].newc=colorIDTable[colorIDIndex].basec;_G[colorIDTable[colorIDIndex].id]=colorIDTable[colorIDIndex].basec;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"ApplyPosColor\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then _G[colorIDTable[colorIDIndex].id]=colorIDTable[colorIDIndex].newc;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"DamagedPageDown\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentDamagedPage=CurrentDamagedPage+1;if CurrentDamagedPage>math.ceil(#damagedElements/DamagePageSize)then CurrentDamagedPage=math.ceil(#damagedElements/DamagePageSize)end;HudDeselectElement()SaveToDatabank()SetRefresh(\"damage\")RenderScreens(\"damage\")elseif O==\"DamagedPageUp\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentDamagedPage=CurrentDamagedPage-1;if CurrentDamagedPage<1 then CurrentDamagedPage=1 end;HudDeselectElement()SaveToDatabank()SetRefresh(\"damage\")RenderScreens(\"damage\")elseif O==\"BrokenPageDown\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentBrokenPage=CurrentBrokenPage+1;if CurrentBrokenPage>math.ceil(#brokenElements/DamagePageSize)then CurrentBrokenPage=math.ceil(#brokenElements/DamagePageSize)end;HudDeselectElement()SaveToDatabank()SetRefresh(\"damage\")RenderScreens(\"damage\")elseif O==\"BrokenPageUp\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentBrokenPage=CurrentBrokenPage-1;if CurrentBrokenPage<1 then CurrentBrokenPage=1 end;HudDeselectElement()SaveToDatabank()SetRefresh(\"damage\")RenderScreens(\"damage\")elseif O==\"DMGOChangeView\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then screens[i].submode=HitPayload.param;UpdateViewDamageoutline(screens[i])SaveToDatabank()SetRefresh(\"damageoutline\",screens[i].submode)RenderScreens(\"damageoutline\",screens[i].submode)elseif O==\"DMGOChangeStretch\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if DMGOStretch==true then DMGOStretch=false else DMGOStretch=true end;UpdateViewDamageoutline(screens[i])SaveToDatabank()SetRefresh(\"damageoutline\")RenderScreens(\"damageoutline\")elseif O==\"ToggleDisplayAtmosphere\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if screens[i].fuelA==true then screens[i].fuelA=false else screens[i].fuelA=true end;screens[i].fuelIndex=1;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"ToggleDisplaySpace\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if screens[i].fuelS==true then screens[i].fuelS=false else screens[i].fuelS=true end;screens[i].fuelIndex=1;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"ToggleDisplayRocket\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if screens[i].fuelR==true then screens[i].fuelR=false else screens[i].fuelR=true end;screens[i].fuelIndex=1;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"DecreaseFuelIndex\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then screens[i].fuelIndex=screens[i].fuelIndex-1;if screens[i].fuelIndex<1 then screens[i].fuelIndex=1 end;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"IncreaseFuelIndex\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then screens[i].fuelIndex=screens[i].fuelIndex+1;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"ToggleHudMode\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if HUDMode==true then HUDMode=false;forceDamageRedraw=true;HudDeselectElement()SaveToDatabank()SetRefresh()RenderScreens()else HUDMode=true;forceDamageRedraw=true;HudDeselectElement()SaveToDatabank()SetRefresh()RenderScreens()end elseif O==\"ToggleSimulation\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentDamagedPage=1;CurrentBrokenPage=1;if SimulationMode==true then SimulationMode=false;SimulationActive=false;UpdateDamageData()UpdateTypeData()forceDamageRedraw=true;HudDeselectElement()SetRefresh(\"damage\")SetRefresh(\"damageoutline\")SetRefresh(\"settings1\")SetRefresh(\"fuel\")SaveToDatabank()RenderScreens()else SimulationMode=true;SimulationActive=false;UpdateDamageData()UpdateTypeData()forceDamageRedraw=true;HudDeselectElement()SetRefresh(\"damage\")SetRefresh(\"damageoutline\")SetRefresh(\"settings1\")SetRefresh(\"fuel\")SaveToDatabank()RenderScreens()end elseif(O==\"ToggleElementLabel\"or O==\"ToggleElementLabel2\")and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if UseMyElementNames==true then UseMyElementNames=false;SetRefresh(\"damage\")RenderScreens(\"damage\")else UseMyElementNames=true;SetRefresh(\"damage\")RenderScreens(\"damage\")end elseif(O==\"SwitchScrapTier\"or O==\"SwitchScrapTier2\")and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then ScrapTier=ScrapTier+1;if ScrapTier>4 then ScrapTier=1 end;SetRefresh(\"damage\")RenderScreens(\"damage\")end end end end end;function GetContentFlight()local Q=\"\"Q=Q..GetHeader(\"Flight Data Report\")..[[\n \n ]]return Q end;function GetContentDamage()local Q=\"\"if SimulationMode==true then Q=Q..GetHeader(\"Damage Report (Simulated damage)\")..[[]]else Q=Q..GetHeader(\"Damage Report\")..[[]]end;Q=Q..GetContentDamageScreen()return Q end;function GetContentDamageoutline(m)UpdateDataDamageoutline()UpdateViewDamageoutline(m)local Q=\"\"Q=Q..GetHeader(\"Damage Ship Outline Report\")..GetDamageoutlineShip()..[[]]if m.submode==\"top\"then Q=Q..[[\n \n Top View\n \n Side View\n \n Front View\n ]]elseif m.submode==\"side\"then Q=Q..[[\n \n Top View\n \n Side View\n \n Front View\n ]]elseif m.submode==\"front\"then Q=Q..[[\n \n Top View\n \n Side View\n \n Front View\n ]]else end;Q=Q..[[]]..#dmgoElements..[[ of ]]..ElementCounter..[[ shown]]Q=Q..[[]]if DMGOStretch==true then Q=Q..[[]]end;Q=Q..[[Stretch both axis]]return Q end;function GetContentFuel(m)if#FuelAtmosphericTanks<1 and#FuelSpaceTanks<1 and#FuelRocketTanks<1 then return\"\"end;local R=0;local Q=\"\"local S={}FuelDisplay={m.fuelA,m.fuelS,m.fuelR}if FuelDisplay[1]==true and#FuelAtmosphericTanks>0 then table.insert(S,\"Atmospheric\")R=R+1 end;if FuelDisplay[2]==true and#FuelSpaceTanks>0 then table.insert(S,\"Space\")R=R+1 end;if FuelDisplay[3]==true and#FuelRocketTanks>0 then table.insert(S,\"Rocket\")R=R+1 end;Q=Q..GetHeader(\"Fuel Report (\"..table.concat(S,\", \")..\")\")..[[\n ]]local T=150;local U=0;local V=0;if FuelDisplay[1]==true and#FuelAtmosphericTanks>0 then if R==1 then V=50 elseif R==2 then V=6 elseif R==3 then V=0 end;Q=Q..[[\n \n \n \n ]]Q=Q..[[]]..GenerateCommaValue(FuelAtmosphericCurrent,true)..[[ of ]]..GenerateCommaValue(FuelAtmosphericTotal,true)..[[ | Total Atmospheric Fuel in ]]..#FuelAtmosphericTanks..[[ tank]]..(#FuelAtmosphericTanks==1 and\"\"or\"s\")..[[ (]]..math.floor(100/FuelAtmosphericTotal*FuelAtmosphericCurrent)..[[%)]]U=U+1 end;if FuelDisplay[2]==true and#FuelSpaceTanks>0 then if R==1 then V=50 elseif R==2 then V=6 elseif R==3 then V=0 end;Q=Q..[[\n \n \n \n ]]Q=Q..[[]]..GenerateCommaValue(FuelSpaceCurrent,true)..[[ of ]]..GenerateCommaValue(FuelSpaceTotal,true)..[[ | Total Space Fuel in ]]..#FuelSpaceTanks..[[ tank]]..(#FuelSpaceTanks==1 and\"\"or\"s\")..[[ (]]..math.floor(100/FuelSpaceTotal*FuelSpaceCurrent)..[[%)]]U=U+1 end;if FuelDisplay[3]==true and#FuelRocketTanks>0 then if R==1 then V=50 elseif R==2 then V=6 elseif R==3 then V=0 end;Q=Q..[[\n \n \n \n ]]Q=Q..[[]]..GenerateCommaValue(FuelRocketCurrent,true)..[[ of ]]..GenerateCommaValue(FuelRocketTotal,true)..[[ | Total Rocket Fuel in ]]..#FuelRocketTanks..[[ tank]]..(#FuelRocketTanks==1 and\"\"or\"s\")..[[ (]]..math.floor(100/FuelRocketTotal*FuelRocketCurrent)..[[%)]]end;Q=Q..[[\n \n \n \n ]]local W={}if m.fuelIndex==nil or m.fuelIndex<1 then m.fuelIndex=1 end;if FuelDisplay[1]==true then for f,j in ipairs(FuelAtmosphericTanks)do table.insert(W,j)end end;if FuelDisplay[2]==true then for f,j in ipairs(FuelSpaceTanks)do table.insert(W,j)end end;if FuelDisplay[3]==true then for f,j in ipairs(FuelRocketTanks)do table.insert(W,j)end end;table.sort(W,function(E,F)return E.type\n \n \n ]]if Y.hp==0 then Q=Q..[[]]elseif Y.maxhp-Y.hp>constants.epsilon then Q=Q..[[]]else Q=Q..[[]]end;if Y.hp==0 then Q=Q..[[]]..Y.size..[[]]else Q=Q..[[]]..Y.size..[[]]end;if Y.hp==0 then Q=Q..[[Broken]]..[[0 of ]]..GenerateCommaValue(Y.vol)..[[]]elseif tonumber(Y.percent)<10 then Q=Q..[[]]..Y.percent..[[%]]..[[]]..GenerateCommaValue(Y.cvol)..[[ of ]]..GenerateCommaValue(Y.vol)..[[]]elseif tonumber(Y.percent)<30 then Q=Q..[[]]..Y.percent..[[%]]..[[]]..GenerateCommaValue(Y.cvol)..[[ of ]]..GenerateCommaValue(Y.vol)..[[]]else Q=Q..[[]]..Y.percent..[[%]]..[[]]..GenerateCommaValue(Y.cvol)..[[ of ]]..GenerateCommaValue(Y.vol)..[[]]end;Q=Q..[[]]..Y.name..[[]]Q=Q..[[]]end end;if#FuelAtmosphericTanks>0 then Q=Q..[[]]if FuelDisplay[1]==true then Q=Q..[[]]end;Q=Q..[[ATM]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"ToggleDisplayAtmosphere\",x1=50,x2=100,y1=270,y2=320})end;if#FuelSpaceTanks>0 then Q=Q..[[]]if FuelDisplay[2]==true then Q=Q..[[]]end;Q=Q..[[SPC]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"ToggleDisplaySpace\",x1=200,x2=250,y1=270,y2=320})end;if#FuelRocketTanks>0 then Q=Q..[[]]if FuelDisplay[3]==true then Q=Q..[[]]end;Q=Q..[[RKT]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"ToggleDisplayRocket\",x1=350,x2=400,y1=270,y2=320})end;if m.fuelIndex>1 then Q=Q..[[\n \n \n ]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"DecreaseFuelIndex\",x1=1470,x2=1670,y1=270,y2=320})end;if m.fuelIndex+X-1<#W then Q=Q..[[\n \n \n ]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"IncreaseFuelIndex\",x1=1680,x2=1880,y1=270,y2=320})end;if X>0 then Q=Q..[[]]..#W..[[ Tank]]..(#W==1 and\"\"or\"s\")..[[ (Showing ]]..m.fuelIndex..[[ to ]]..m.fuelIndex+X-1 ..[[)]]end;return Q end;function GetContentCargo()local Q=\"\"Q=Q..GetHeader(\"Cargo Report\")..[[\n \n ]]return Q end;function GetContentAGG()local Q=\"\"Q=Q..GetHeader(\"Anti-Grav Control\")..[[\n \n ]]return Q end;function GetContentMap()local Q=\"\"Q=Q..GetHeader(\"Map Overview\")..[[\n \n ]]return Q end;function GetContentTime()local Q=\"\"Q=Q..GetHeader(\"Time\")..epochTime()Q=Q..[[\n \n \n \n \n \n \n \n \n \n \n \n \n ]]return Q end;function GetContentSettings1()local Q=\"\"Q=Q..GetHeader(\"Settings\")..[[]]if BackgroundMode==\"\"then Q=Q..[[Activate background]]else Q=Q..[[Deactivate background (']]..BackgroundMode..[[', ]]..string.format(\"%.0f\",BackgroundModeOpacity*100)..[[%)]]end;Q=Q..[[\n \n Previous background\n \n Next background\n\n \n Decrease Opacity\n \n Increase Opacity\n ]]Q=Q..[[]]..[[Reset background and all colors]]Q=Q..[[]]..[[]]..[[]]..[[Select and change any of the ]]..#colorIDTable..[[ HUD colors]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..colorIDTable[colorIDIndex].desc..[[]]..[[]]..[[Current color]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[#]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,1,1)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,2,2)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,3,3)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,4,4)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,5,5)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,6,6)..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[New color]]..[[]]..[[Apply new color]]..[[]]..[[Reset]]..[[]]Q=Q..[[]]..[[]]..[[]]..[[Explanation / Hints]]..[[Coming soon.]]Q=Q..[[]]if SimulationMode==true then Q=Q..[[Simulating Damage to elements]]AddClickArea(\"settings1\",{id=\"ToggleSimulation\",mode=\"settings1\",x1=940,x2=1850,y1=919,y2=969})else Q=Q..[[Simulate Damage to elements]]AddClickArea(\"settings1\",{id=\"ToggleSimulation\",mode=\"settings1\",x1=940,x2=1850,y1=919,y2=969})end;return Q end;function GetContentStartup()local Q=\"\"Q=Q..GetElementLogo(812,380,\"f\",\"f\",\"f\")if YourShipsName==\"Enter here\"then Q=Q..[[Spaceship ID ]]..ShipID..[[]]else Q=Q..[[]]..YourShipsName..[[]]end;if ShowWelcomeMessage==true then Q=Q..[[Greetings, Commander ]]..PlayerName..[[.]]end;if#Warnings>0 then Q=Q..[[Warning: ]]..table.concat(Warnings,\" \")..[[]]end;Q=Q..[[Damage Report v]]..VERSION..[[, by Scion Interstellar, DorianGray - Discord: Dorian Gray#2623. Under GNU Public License 3.0.]]return Q end;function RenderScreen(m,a0)if a0==nil then PrintConsole(\"ERROR: contentToRender is nil.\")unit.exit()end;CreateClickAreasForScreen(m)local Q=\"\"Q=Q..[[\n \n \n ]]Q=Q..a0;if m.mode==\"startup\"then Q=Q..[[]]else Q=Q..[[]]end;Q=Q..[[\n \n ]]Q=Q..[[]]local a1=string.len(Q)m.element.setSVG(Q)end;function RenderScreens(a2,a3)a2=a2 or\"all\"a3=a3 or\"all\"if screens~=nil and#screens>0 then local a4=\"\"local a5=\"\"local a6=\"\"local a7=\"\"local a8=\"\"local a9=\"\"local aa=\"\"local ab=\"\"local ac=\"\"local ad=\"\"local ae=\"\"local af=\"\"for J,m in pairs(screens)do if m.refresh==true then local a0=\"\"if m.mode==\"flight\"and(a2==\"flight\"or a2==\"all\")then if a4==\"\"then a4=GetContentFlight()end;a0=a4 elseif m.mode==\"damage\"and(a2==\"damage\"or a2==\"all\")then if a5==\"\"then a5=GetContentDamage()end;a0=a5 elseif m.mode==\"damageoutline\"and(a2==\"damageoutline\"or a2==\"all\")then if m.submode==\"\"then m.submode=\"top\"screens[J].submode=\"top\"end;if m.submode==\"top\"and(a3==\"top\"or a3==\"all\")then if a6==\"\"then a6=GetContentDamageoutline(m)end;a0=a6 end;if m.submode==\"side\"and(a3==\"side\"or a3==\"all\")then if a7==\"\"then a7=GetContentDamageoutline(m)end;a0=a7 end;if m.submode==\"front\"and(a3==\"front\"or a3==\"all\")then if a8==\"\"then a8=GetContentDamageoutline(m)end;a0=a8 end elseif m.mode==\"fuel\"and(a2==\"fuel\"or a2==\"all\")then m=WipeClickAreasForScreen(screens[J])a0=GetContentFuel(m)elseif m.mode==\"cargo\"and(a2==\"cargo\"or a2==\"all\")then if aa==\"\"then aa=GetContentCargo()end;a0=aa elseif m.mode==\"agg\"and(a2==\"agg\"or a2==\"all\")then if ab==\"\"then ab=GetContentAGG()end;a0=ab elseif m.mode==\"map\"and(a2==\"map\"or a2==\"all\")then if ac==\"\"then ac=GetContentMap()end;a0=ac elseif m.mode==\"time\"and(a2==\"time\"or a2==\"all\")then if ad==\"\"then ad=GetContentTime()end;a0=ad elseif m.mode==\"settings1\"and(a2==\"settings1\"or a2==\"all\")then if ae==\"\"then ae=GetContentSettings1()end;a0=ae elseif m.mode==\"startup\"and(a2==\"startup\"or a2==\"all\")then if af==\"\"then af=GetContentStartup()end;a0=af else a0=\"Invalid screen mode. ('\"..m.mode..\"')\"end;if a0~=\"\"then RenderScreen(m,a0)else DrawCenteredText(\"ERROR: No contentToRender delivered for \"..m.mode)PrintConsole(\"ERROR: No contentToRender delivered for \"..m.mode)unit.exit()end;screens[J].refresh=false end end end;if HUDMode==true then system.setScreen(GetContentDamageHUDOutput())system.showScreen(1)else system.showScreen(0)end end;function OnTickData(C)if formerTime+605 or SkillRepairToolOptimization>5 or StatFuelTankOptimization>5 or StatContainerOptimization>5 or StatAtmosphericFuelTankHandling>5 or StatSpaceFuelTankHandling>5 or StatRocketFuelTankHandling>5 then PrintConsole(\"ERROR: Talents/stats can only range from 0 to 5. Please set correctly in LUA settings and reactivate script.\")unit.exit()end;if screens==nil or#screens==0 then HUDMode=true;PrintConsole(\"Warning: No screens connected. Entering HUD mode only.\")end;OnTickData(true)unit.setTimer('UpdateData',UpdateDataInterval)unit.setTimer('UpdateHighlight',HighlightBlinkingInterval)",
- "filter": {
- "args": [],
- "signature": "start()",
- "slotKey": "-1"
- },
- "key": "12"
- },
- {
- "code": "ActionUp()",
- "filter": {
- "args": [
- {
- "value": "up"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "13"
- },
- {
- "code": "ActionDown()",
- "filter": {
- "args": [
- {
- "value": "down"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "14"
- },
- {
- "code": "ActionStrafeLeft()",
- "filter": {
- "args": [
- {
- "value": "strafeleft"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "15"
- },
- {
- "code": "ActionStrafeRight()",
- "filter": {
- "args": [
- {
- "value": "straferight"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "16"
- },
- {
- "code": "KeyCTRLPressed = true",
- "filter": {
- "args": [
- {
- "value": "brake"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "17"
- },
- {
- "code": "KeyCTRLPressed = false",
- "filter": {
- "args": [
- {
- "value": "brake"
- }
- ],
- "signature": "actionStop(action)",
- "slotKey": "-2"
- },
- "key": "18"
- },
- {
- "code": "ActionOption1()",
- "filter": {
- "args": [
- {
- "value": "option1"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "19"
- },
- {
- "code": "ActionOption2()",
- "filter": {
- "args": [
- {
- "value": "option2"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "20"
- },
- {
- "code": "ActionOption3()",
- "filter": {
- "args": [
- {
- "value": "option3"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "21"
- },
- {
- "code": "ActionOption4()",
- "filter": {
- "args": [
- {
- "value": "option4"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "22"
- },
- {
- "code": "ActionOption9()",
- "filter": {
- "args": [
- {
- "value": "option9"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "23"
- },
- {
- "code": "ActionOption8()",
- "filter": {
- "args": [
- {
- "value": "option8"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "24"
- }
- ],
- "methods": [],
- "events": []
-}
\ No newline at end of file
diff --git a/versions/DamageReport_3_13.conf b/versions/DamageReport_3_13.conf
deleted file mode 100644
index a338c3e..0000000
--- a/versions/DamageReport_3_13.conf
+++ /dev/null
@@ -1,436 +0,0 @@
-{
- "slots": {
- "0": {
- "name": "slot1",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "1": {
- "name": "slot2",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "2": {
- "name": "slot3",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "3": {
- "name": "slot4",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "4": {
- "name": "slot5",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "5": {
- "name": "slot6",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "6": {
- "name": "slot7",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "7": {
- "name": "slot8",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "8": {
- "name": "slot9",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "9": {
- "name": "slot10",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-1": {
- "name": "unit",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-2": {
- "name": "system",
- "type": {
- "events": [],
- "methods": []
- }
- },
- "-3": {
- "name": "library",
- "type": {
- "events": [],
- "methods": []
- }
- }
- },
- "handlers": [
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "2"
- },
- "key": "0"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "3"
- },
- "key": "1"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "4"
- },
- "key": "2"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "5"
- },
- "key": "3"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "6"
- },
- "key": "4"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "7"
- },
- "key": "5"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "8"
- },
- "key": "6"
- },
- {
- "code": "CheckClick(x, y)",
- "filter": {
- "args": [
- {
- "variable": "*"
- },
- {
- "variable": "*"
- }
- ],
- "signature": "mouseDown(x,y)",
- "slotKey": "9"
- },
- "key": "7"
- },
- {
- "code": "function GenerateCommaValue(a,b,c)b=b or false;c=c or 1;local d=a;if b==true then if string.len(a)>=4 then d=string.format(\"%.\"..c..\"fk\",a/1000)else d=string.format(\"%.\"..c..\"f\",a)end else while true do d,k=string.gsub(d,\"^(-?%d+)(%d%d%d)\",'%1,%2')if k==0 then break end end end;return d end;function PrintConsole(e,f)f=f or false;if f then system.print(\"------------------------------------------------------------------------\")end;system.print(e)if f then system.print(\"------------------------------------------------------------------------\")end end;function DrawCenteredText(e)if screens~=nil and#screens>0 then for g=1,#screens,1 do screens[g].element.setCenteredText(e)end end end;function ClearConsole()for g=1,10,1 do PrintConsole()end end;function SwitchScreens(h)h=h or\"on\"if screens~=nil and#screens>0 then for g=1,#screens,1 do if h==\"on\"then screens[g].element.clear()screens[g].element.activate()screens[g].active=true else screens[g].element.clear()screens[g].element.deactivate()screens[g].active=false end end end end;function GetSecondsString(i)local i=tonumber(i)if i==nil or i<=0 then return\"-\"else days=string.format(\"%2.f\",math.floor(i/(3600*24)))hours=string.format(\"%2.f\",math.floor(i/3600-days*24))mins=string.format(\"%2.f\",math.floor(i/60-hours*60-days*24*60))secs=string.format(\"%2.f\",math.floor(i-hours*3600-days*24*60*60-mins*60))str=\"\"if tonumber(days)>0 then str=str..days..\"d \"end;if tonumber(hours)>0 then str=str..hours..\"h \"end;if tonumber(mins)>0 then str=str..mins..\"m \"end;if tonumber(secs)>0 then str=str..secs..\"s\"end;return str end end;function replace_char(j,str,l)return str:sub(1,j-1)..l..str:sub(j+1)end;function epochTime()function rZ(m)if string.len(m)<=1 then return\"0\"..m else return m end end;function dPoint(n)if not(n==math.floor(n))then return true else return false end end;function lYear(year)if not dPoint(year/4)then if dPoint(year/100)then return true else if not dPoint(year/400)then return true else return false end end else return false end end;local o=5;local p=3600;local q=86400;local r=31536000;local s=31622400;local t=2419200;local g=2505600;local u=2592000;local k=2678400;local w={4,6,9,11}local x={1,3,5,7,8,10,12}local y=0;local z=1506816000;local A=system.getTime()_G[\"formerTime\"]=A;if AddSummertimeHour==true then A=A+3600 end;now=math.floor(A+z)year=1970;secs=0;y=0;while secs+s]]..hour..\":\"..minute..[[]]..[[]]..year..\"/\"..month..\"/\"..day..[[]]end;function ToggleHUD()if HUDMode==true then HUDMode=false;forceDamageRedraw=true;hudSelectedIndex=0;highlightID=0;HideHighlight()SetRefresh()RenderScreens()else HUDMode=true;forceDamageRedraw=true;hudSelectedIndex=0;highlightID=0;HideHighlight()SetRefresh()RenderScreens()end end;function HudDeselectElement()hudSelectedIndex=0;hudStartIndex=1;highlightID=0;HideHighlight()if HUDMode==true then SetRefresh(\"damage\")SetRefresh(\"damageoutline\")RenderScreens()end end;function ChangeHudSelectedElement(B)if HUDMode==true and#rE>0 then hudSelectedIndex=hudSelectedIndex+B;if hudSelectedIndex<1 then hudSelectedIndex=1 elseif hudSelectedIndex>#rE then hudSelectedIndex=#rE end;if hudSelectedIndex>9 then hudStartIndex=hudSelectedIndex-9 end;if hudSelectedIndex~=0 then highlightID=rE[hudSelectedIndex].id;if highlightID~=nil and highlightID~=0 then HideHighlight()elementPosition=vec3(rE[hudSelectedIndex].pos)highlightX=elementPosition.x-coreWorldOffset;highlightY=elementPosition.y-coreWorldOffset;highlightZ=elementPosition.z-coreWorldOffset;highlightOn=true;ShowHighlight()end end;SetRefresh(\"damage\")SetRefresh(\"damageoutline\")RenderScreens()end end;function HideHighlight()if#hudArrowSticker>0 then for g in pairs(hudArrowSticker)do core.deleteSticker(hudArrowSticker[g])end;hudArrowSticker={}end end;function ShowHighlight()if highlightOn==true and highlightID>0 then table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX+2,highlightY,highlightZ,\"north\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX,highlightY-2,highlightZ,\"east\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX-2,highlightY,highlightZ,\"south\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX,highlightY+2,highlightZ,\"west\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX,highlightY,highlightZ-2,\"up\"))table.insert(hudArrowSticker,core.spawnArrowSticker(highlightX,highlightY,highlightZ+2,\"down\"))end end;function ToggleHighlight()if highlightOn==true then highlightOn=false;HideHighlight()else highlightOn=true;ShowHighlight()end end;function SortDamageTables()table.sort(damagedElements,function(m,n)return m.missinghp>n.missinghp end)table.sort(brokenElements,function(m,n)return m.maxhp>n.maxhp end)end;function getScraps(C,D)D=D or false;C=C-SkillRepairToolOptimization*0.05*C;local E=math.ceil(C/(10*5^(ScrapTier-1)))if D==true then return GenerateCommaValue(string.format(\"%.0f\",E),false)else return E end end;function getRepairTime(C,F)F=F or false;C=C-SkillRepairToolOptimization*0.05*C;local E=math.ceil(C/ScrapTierRepairTimes[ScrapTier])E=E-SkillRepairToolEfficiency*0.1*E;if F==true then return GetSecondsString(string.format(\"%.0f\",E))else return E end end;function UpdateDataDamageoutline()dmgoElements={}for g,G in ipairs(brokenElements)do if#dmgoElementsShipXmax then ShipXmax=H end;if I>ShipYmax then ShipYmax=I end;if J>ShipZmax then ShipZmax=J end;table.insert(dmgoElements,{id=G.id,type=\"b\",size=G.maxhp,x=H,y=I,z=J,xp=0,yp=0,zp=0,u=0,v=0})end end;if#dmgoElementsShipXmax then ShipXmax=H end;if I>ShipYmax then ShipYmax=I end;if J>ShipZmax then ShipZmax=J end;table.insert(dmgoElements,{id=G.id,type=\"d\",size=G.maxhp,x=H,y=I,z=J,xp=0,yp=0,zp=0,u=0,v=0})end end end;if#dmgoElementsShipXmax then ShipXmax=H end;if I>ShipYmax then ShipYmax=I end;if J>ShipZmax then ShipZmax=J end;table.insert(dmgoElements,{id=G.id,type=\"h\",size=G.maxhp,x=H,y=I,z=J,xp=0,yp=0,zp=0,u=0,v=0})end end end;ShipX=math.abs(ShipXmax-ShipXmin)ShipY=math.abs(ShipYmax-ShipYmin)ShipZ=math.abs(ShipZmax-ShipZmin)for g,G in ipairs(dmgoElements)do dmgoElements[g].xp=math.abs(100/(ShipXmax-ShipXmin)*(G.x-ShipXmin))dmgoElements[g].yp=math.abs(100/(ShipYmax-ShipYmin)*(G.y-ShipYmin))dmgoElements[g].zp=math.abs(100/(ShipZmax-ShipZmin)*(G.z-ShipZmin))end end;function UpdateViewDamageoutline(K)UFrame=40;VFrame=40;UStart=20+UFrame;VStart=180+VFrame;UDim=1880-2*UFrame;VDim=840-2*VFrame;if K.submode==\"top\"then if DMGOStretch==false then local L=UDim/(ShipYmax-ShipYmin)local M=VDim/(ShipXmax-ShipXmin)if L>=M then local N=L/M;local O=math.floor(UDim/N)UStart=UStart+(UDim-O)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100/N*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100*G.xp+VStart)end else local N=M/L;local P=math.floor(VDim/N)VStart=VStart+(VDim-P)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100/N*G.xp+VStart)end end else for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100*G.xp+VStart)end end elseif K.submode==\"front\"then if DMGOStretch==false then local L=UDim/(ShipXmax-ShipXmin)local M=VDim/(ShipZmax-ShipZmin)if L>=M then local N=L/M;local O=math.floor(UDim/N)UStart=UStart+(UDim-O)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100/N*G.xp+UStart)dmgoElements[g].v=math.floor(VDim/100*(100-G.zp)+VStart)end else local N=M/L;local P=math.floor(VDim/N)VStart=VStart+(VDim-P)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.xp+UStart)dmgoElements[g].v=math.floor(VDim/100/N*(100-G.zp)+VStart)end end else for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.xp+UStart)dmgoElements[g].v=math.floor(VDim/100*(100-G.zp)+VStart)end end elseif K.submode==\"side\"then if DMGOStretch==false then local L=UDim/(ShipYmax-ShipYmin)local M=VDim/(ShipXmax-ShipZmin)if L>=M then local N=L/M;local O=math.floor(UDim/N)UStart=UStart+(UDim-O)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100/N*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100*(100-G.zp)+VStart)end else local N=M/L;local P=math.floor(VDim/N)VStart=VStart+(VDim-P)/2;for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100/N*(100-G.zp)+VStart)end end else for g,G in ipairs(dmgoElements)do dmgoElements[g].u=math.floor(UDim/100*G.yp+UStart)dmgoElements[g].v=math.floor(VDim/100*(100-G.zp)+VStart)end end else DrawCenteredText(\"ERROR: non-existing DMGO mode set.\")PrintConsole(\"ERROR: non-existing DMGO mode set.\")unit.exit()end end;function GetDamageoutlineShip()local e=\"\"for g,G in ipairs(dmgoElements)do local Q=\"\"local R=1;if G.type==\"h\"then Q=\"ch\"elseif G.type==\"d\"then Q=\"cw\"else Q=\"cc\"end;if G.id==highlightID then Q=\"f2\"end;if G.size>0 and G.size<1000 then R=5 elseif G.size>=1000 and G.size<2000 then R=8 elseif G.size>=2000 and G.size<5000 then R=12 elseif G.size>=5000 and G.size<10000 then R=15 elseif G.size>=10000 and G.size<20000 then R=20 elseif G.size>=20000 then R=30 end;e=e..[[]]if G.id==highlightID then e=e..[[]]e=e..[[]]end end;return e end;function GetContentClickareas(K)local e=\"\"if K~=nil and K.ClickAreas~=nil and#K.ClickAreas>0 then for g,S in ipairs(K.ClickAreas)do e=e..[[]]end end;return e end;function GetElement1(H,I,T,U)H=H or 0;I=I or 0;T=T or 600;U=U or 600;local e=\"\"e=e..[[\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ]]return e end;function GetElement2(H,I)H=H or 0;I=I or 0;local e=\"\"e=e..[[]]return e end;function GetElementLogo(H,I,V,W,X)H=H or 812;I=I or 380;V=V or\"f\"W=W or\"f2\"X=X or\"f3\"local e=\"\"e=e..[[\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ]]return e end;function GetHeader(Y)Y=Y or\"ERROR: UNDEFINED\"local e=\"\"e=e..[[\n ]]..Y..[[]]return e end;function GetContentBackground(Z,_)bgColor=ColorBackgroundPattern;local e=\"\"if Z==\"dots\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' viewBox='0 0 4 4'%3E%3Cpath fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' d='M1 3h1v1H1V3zm2-2h1v1H3V1z'%3E%3C/path%3E%3C/svg%3E\");]]elseif Z==\"rain\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='12' height='16' viewBox='0 0 12 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 .99C4 .445 4.444 0 5 0c.552 0 1 .45 1 .99v4.02C6 5.555 5.556 6 5 6c-.552 0-1-.45-1-.99V.99zm6 8c0-.546.444-.99 1-.99.552 0 1 .45 1 .99v4.02c0 .546-.444.99-1 .99-.552 0-1-.45-1-.99V8.99z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E\");]]elseif Z==\"plus\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E\");]]elseif Z==\"signal\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='84' height='48' viewBox='0 0 84 48' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h12v6H0V0zm28 8h12v6H28V8zm14-8h12v6H42V0zm14 0h12v6H56V0zm0 8h12v6H56V8zM42 8h12v6H42V8zm0 16h12v6H42v-6zm14-8h12v6H56v-6zm14 0h12v6H70v-6zm0-16h12v6H70V0zM28 32h12v6H28v-6zM14 16h12v6H14v-6zM0 24h12v6H0v-6zm0 8h12v6H0v-6zm14 0h12v6H14v-6zm14 8h12v6H28v-6zm-14 0h12v6H14v-6zm28 0h12v6H42v-6zm14-8h12v6H56v-6zm0-8h12v6H56v-6zm14 8h12v6H70v-6zm0 8h12v6H70v-6zM14 24h12v6H14v-6zm14-8h12v6H28v-6zM14 8h12v6H14V8zM0 8h12v6H0V8z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E\");]]elseif Z==\"deathstar\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='105' viewBox='0 0 80 105'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath d='M20 10a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm15 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zM20 75a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zm30-65a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V10zm0 65a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V75zM35 10a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zM5 45a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10zm60 35a5 5 0 0 1 10 0v50a5 5 0 0 1-10 0V45zm0-35a5 5 0 0 1 10 0v20a5 5 0 0 1-10 0V10z' /%3E%3C/g%3E%3C/g%3E%3C/svg%3E\");]]elseif Z==\"diamond\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='32' viewBox='0 0 16 32'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[['%3E%3Cpath fill-rule='evenodd' d='M0 24h4v2H0v-2zm0 4h6v2H0v-2zm0-8h2v2H0v-2zM0 0h4v2H0V0zm0 4h2v2H0V4zm16 20h-6v2h6v-2zm0 4H8v2h8v-2zm0-8h-4v2h4v-2zm0-20h-6v2h6V0zm0 4h-4v2h4V4zm-2 12h2v2h-2v-2zm0-8h2v2h-2V8zM2 8h10v2H2V8zm0 8h10v2H2v-2zm-2-4h14v2H0v-2zm4-8h6v2H4V4zm0 16h6v2H4v-2zM6 0h2v2H6V0zm0 24h2v2H6v-2z'/%3E%3C/g%3E%3C/svg%3E\");]]elseif Z==\"hexagon\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='49' viewBox='0 0 28 49'%3E%3Cg fill-rule='evenodd'%3E%3Cg id='hexagons' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='nonzero'%3E%3Cpath d='M13.99 9.25l13 7.5v15l-13 7.5L1 31.75v-15l12.99-7.5zM3 17.9v12.7l10.99 6.34 11-6.35V17.9l-11-6.34L3 17.9zM0 15l12.98-7.5V0h-2v6.35L0 12.69v2.3zm0 18.5L12.98 41v8h-2v-6.85L0 35.81v-2.3zM15 0v7.5L27.99 15H28v-2.31h-.01L17 6.35V0h-2zm0 49v-8l12.99-7.5H28v2.31h-.01L17 42.15V49h-2z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E\");]]elseif Z==\"capsule\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='32' height='26' viewBox='0 0 32 26' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M14 0v3.994C14 7.864 10.858 11 7 11c-3.866 0-7-3.138-7-7.006V0h2v4.005C2 6.765 4.24 9 7 9c2.756 0 5-2.236 5-4.995V0h2zm0 26v-5.994C14 16.138 10.866 13 7 13c-3.858 0-7 3.137-7 7.006V26h2v-6.005C2 17.235 4.244 15 7 15c2.76 0 5 2.236 5 4.995V26h2zm2-18.994C16 3.136 19.142 0 23 0c3.866 0 7 3.138 7 7.006v9.988C30 20.864 26.858 24 23 24c-3.866 0-7-3.138-7-7.006V7.006zm2-.01C18 4.235 20.244 2 23 2c2.76 0 5 2.236 5 4.995v10.01C28 19.765 25.756 22 23 22c-2.76 0-5-2.236-5-4.995V6.995z' fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'/%3E%3C/svg%3E\");]]elseif Z==\"diagonal\"then e=[[background-image: url(\"data:image/svg+xml,%3Csvg width='6' height='6' viewBox='0 0 6 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23]]..bgColor..[[' fill-opacity=']]..BackgroundModeOpacity..[[' fill-rule='evenodd'%3E%3Cpath d='M5 0h1L0 6V5zM6 5v1H5z'/%3E%3C/g%3E%3C/svg%3E\");]]end;return e end;function GetContentDamageHUDOutput()local a0=300;local a1=165;if#damagedElements>0 or#brokenElements>0 then a1=510 end;local e=\"\"e=e..[[\n \n ]]e=e..[[]]..[[]]..[[]]..[[]]..(YourShipsName==\"Enter here\"and\"Ship ID \"..ShipID or YourShipsName)..[[]]..[[]]if#brokenElements>0 then e=e..[[]]elseif#damagedElements>0 then e=e..[[]]else e=e..[[]]end;if#damagedElements>0 or#brokenElements>0 then e=e..[[Total Damage]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",totalShipMaxHP-totalShipHP))..[[]]e=e..[[T]]..ScrapTier..[[ Scrap Needed]]..[[]]..getScraps(totalShipMaxHP-totalShipHP,true)..[[]]e=e..[[Repair Time]]..[[]]..getRepairTime(totalShipMaxHP-totalShipHP,true)..[[]]e=e..[[]]..[[]]..[[]]..#healthyElements..[[]]..[[]]..[[]]..#damagedElements..[[]]..[[]]..[[]]..#brokenElements..[[]]local u=0;for a2=hudStartIndex,hudStartIndex+9,1 do if rE[a2]~=nil then v=rE[a2]if v.hp>0 then e=e..[[]]..[[]]..string.format(\"%.30s\",v.name)..[[]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",v.missinghp))..[[]]if v.id==highlightID then e=e..[[]]..[[]]..string.format(\"%.30s\",v.name)..[[]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",v.missinghp))..[[]]end else e=e..[[]]..[[]]..string.format(\"%.30s\",v.name)..[[]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",v.missinghp))..[[]]if v.id==highlightID then highlightX=elementPosition.x-coreWorldOffset;highlightY=elementPosition.y-coreWorldOffset;highlightZ=elementPosition.z-coreWorldOffset;e=e..[[]]..[[]]..string.format(\"%.30s\",v.name)..[[]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",v.missinghp))..[[]]end end;u=u+1 end end;if DisallowKeyPresses==true then e=e..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[Keypresses disabled.]]..[[Change in LUA parameters]]..[[by unchecking DisallowKeyPresses.]]..[[]]..[[]]..[[]]else e=e..[[]]..[[]]..[[]]..[[]]..[[Up/down arrows to highlight]]..[[CTRL + arrows to move HUD]]..[[Left arrow to toggle HUD Mode]]..[[ALT+1-4 to set Scrap Tier]]..[[ALT+8 to reset HUD position]]..[[ALT+9 to shut script off]]..[[]]..[[]]end else if DisallowKeyPresses==true then e=e..[[]]..OkayCenterMessage..[[]]..[[]]..#healthyElements..[[ elements / ]]..GenerateCommaValue(string.format(\"%.0f\",totalShipMaxHP))..[[ HP.]]..[[]]..[[]]..[[]]..[[]]..[[Keypresses disabled.]]..[[Change in LUA parameters]]..[[by unchecking DisallowKeyPresses.]]..[[]]..[[]]..[[]]else e=e..[[]]..OkayCenterMessage..[[]]..[[]]..#healthyElements..[[ elements / ]]..GenerateCommaValue(string.format(\"%.0f\",totalShipMaxHP))..[[ HP.]]..[[]]..[[]]..[[]]..[[]]..[[Left arrow to toggle HUD Mode]]..[[CTRL + arrows to move HUD]]..[[ALT+8 to reset HUD position]]..[[ALT+9 to shut script off]]..[[]]..[[]]end end;e=e..[[]]return e end;function GetContentDamageScreen()local a3=\"\"if#damagedElements>0 then local a4=#damagedElements;if a4>DamagePageSize then a4=DamagePageSize end;if CurrentDamagedPage==math.ceil(#damagedElements/DamagePageSize)then a4=#damagedElements%DamagePageSize+12;if a4>12 then a4=a4-12 end end;a3=a3 ..[[]]a3=a3 ..[[]]if UseMyElementNames==true then a3=a3 ..[[Damaged Name]]else a3=a3 ..[[Damaged Type]]end;a3=a3 ..[[HLTHDMG]]a3=a3 ..[[T]]..ScrapTier..[[ SCRREPTIME]]AddClickArea(\"damage\",{id=\"SwitchScrapTier\",mode=\"damage\",x1=650,x2=775,y1=315,y2=360})local g=0;for u=1+(CurrentDamagedPage-1)*DamagePageSize,a4+(CurrentDamagedPage-1)*DamagePageSize,1 do g=g+1;local a5=damagedElements[u]if UseMyElementNames==true then a3=a3 ..[[]]..string.format(\"%.23s\",a5.name)..[[]]else a3=a3 ..[[]]..string.format(\"%.23s\",a5.type)..[[]]end;a3=a3 ..[[]]..a5.percent..[[%]]..[[]]..GenerateCommaValue(string.format(\"%.0f\",a5.missinghp),true)..[[]]..[[]]..getScraps(a5.missinghp,true)..[[]]..[[]]..getRepairTime(a5.missinghp,true)..[[]]..[[]]end;if#damagedElements>DamagePageSize then a3=a3 ..[[Page ]]..CurrentDamagedPage..\" of \"..math.ceil(#damagedElements/DamagePageSize)..[[]]if CurrentDamagedPage\n \n \n ]]AddClickArea(\"damage\",{id=\"DamagedPageDown\",mode=\"damage\",x1=65,x2=260,y1=290+(a4+1)*50,y2=290+50+(a4+1)*50})else DisableClickArea(\"DamagedPageDown\",\"damage\")end;if CurrentDamagedPage>1 then a3=a3 ..[[\n \n \n ]]AddClickArea(\"damage\",{id=\"DamagedPageUp\",mode=\"damage\",x1=750,x2=950,y1=290+(a4+1)*50,y2=290+50+(a4+1)*50})else DisableClickArea(\"DamagedPageUp\",\"damage\")end end end;if#brokenElements>0 then local a6=#brokenElements;if a6>DamagePageSize then a6=DamagePageSize end;if CurrentBrokenPage==math.ceil(#brokenElements/DamagePageSize)then a6=#brokenElements%DamagePageSize+12;if a6>12 then a6=a6-12 end end;a3=a3 ..[[]]a3=a3 ..[[]]if UseMyElementNames==true then a3=a3 ..[[Broken Name]]else a3=a3 ..[[Broken Type]]end;a3=a3 ..[[DMG]]a3=a3 ..[[T]]..ScrapTier..[[ SCRREPTIME]]AddClickArea(\"damage\",{id=\"SwitchScrapTier2\",mode=\"damage\",x1=1570,x2=1690,y1=315,y2=360})local g=0;for u=1+(CurrentBrokenPage-1)*DamagePageSize,a6+(CurrentBrokenPage-1)*DamagePageSize,1 do g=g+1;local a5=brokenElements[u]if UseMyElementNames==true then a3=a3 ..[[]]..string.format(\"%.30s\",a5.name)..[[]]else a3=a3 ..[[]]..string.format(\"%.30s\",a5.type)..[[]]end;a3=a3 ..[[]]..GenerateCommaValue(string.format(\"%.0f\",a5.missinghp),true)..[[]]..[[]]..getScraps(a5.missinghp,true)..[[]]..[[]]..getRepairTime(a5.missinghp,true)..[[]]..[[]]end;if#brokenElements>DamagePageSize then a3=a3 ..[[Page ]]..CurrentBrokenPage..\" of \"..math.ceil(#brokenElements/DamagePageSize)..[[]]if CurrentBrokenPage>1 then a3=a3 ..[[\n \n \n ]]AddClickArea(\"damage\",{id=\"BrokenPageUp\",mode=\"damage\",x1=1665,x2=1865,y1=290+(a6+1)*50,y2=290+50+(a6+1)*50})else DisableClickArea(\"BrokenPageUp\",\"damage\")end;if CurrentBrokenPage\n \n \n ]]AddClickArea(\"damage\",{id=\"BrokenPageDown\",mode=\"damage\",x1=980,x2=1180,y1=290+(a6+1)*50,y2=290+50+(a6+1)*50})else DisableClickArea(\"BrokenPageDown\",\"damage\")end end end;if#damagedElements>0 or#brokenElements>0 then local a7=math.floor(1878/#elementsIdList*#damagedElements)local a8=math.floor(1878/#elementsIdList*#brokenElements)local a9=1878-a7-a8+1;a3=a3 ..[[]]a3=a3 ..[[]]a3=a3 ..[[]]a3=a3 ..[[]]if#damagedElements>0 then a3=a3 ..[[]]..#damagedElements..[[]]end;if#healthyElements>0 then a3=a3 ..[[]]..#healthyElements..[[]]end;if#brokenElements>0 then a3=a3 ..[[]]..#brokenElements..[[]]end;a3=a3 ..[[]]a3=a3 ..[[]]..GenerateCommaValue(string.format(\"%.0f\",totalShipMaxHP-totalShipHP))..[[ HP damage in total ]]..getScraps(totalShipMaxHP-totalShipHP,true)..[[ T]]..ScrapTier..[[ scraps needed. ]]..getRepairTime(totalShipMaxHP-totalShipHP,true)..[[ projected repair time.]]else a3=a3 ..GetElementLogo(812,380,\"ch\",\"ch\",\"ch\")..[[]]..OkayCenterMessage..[[]]..[[]]..#healthyElements..[[ elements stand ]]..GenerateCommaValue(string.format(\"%.0f\",totalShipMaxHP))..[[ HP strong.]]end;forceDamageRedraw=false;return a3 end;function ActionStopengines()if DisallowKeyPresses==true then return end;ToggleHUD()end;function ActionStrafeRight()if DisallowKeyPresses==true then return end;if KeyCTRLPressed==true then if HUDShiftU<4000 then HUDShiftU=HUDShiftU+50;SaveToDatabank()RenderScreens()end else HudDeselectElement()end end;function ActionStrafeLeft()if DisallowKeyPresses==true then return end;if KeyCTRLPressed==true then if HUDShiftU>=50 then HUDShiftU=HUDShiftU-50;SaveToDatabank()RenderScreens()end else ToggleHUD()end end;function ActionDown()if DisallowKeyPresses==true then return end;if KeyCTRLPressed==true then if HUDShiftV<4000 then HUDShiftV=HUDShiftV+50;SaveToDatabank()RenderScreens()end else ChangeHudSelectedElement(1)end end;function ActionUp()if DisallowKeyPresses==true then return end;if KeyCTRLPressed==true then if HUDShiftV>=50 then HUDShiftV=HUDShiftV-50;SaveToDatabank()RenderScreens()end else ChangeHudSelectedElement(-1)end end;function ActionOption1()if DisallowKeyPresses==true then return end;ScrapTier=1;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption2()if DisallowKeyPresses==true then return end;ScrapTier=2;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption3()if DisallowKeyPresses==true then return end;ScrapTier=3;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption4()if DisallowKeyPresses==true then return end;ScrapTier=4;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption8()if DisallowKeyPresses==true then return end;HUDShiftU=0;HUDShiftV=0;SetRefresh(\"damage\")RenderScreens(\"damage\")end;function ActionOption9()if DisallowKeyPresses==true then return end;SaveToDatabank()SwitchScreens(\"off\")unit.exit()end",
- "filter": {
- "args": [],
- "signature": "start()",
- "slotKey": "-1"
- },
- "key": "8"
- },
- {
- "code": "SaveToDatabank()\nSwitchScreens(\"off\")",
- "filter": {
- "args": [],
- "signature": "stop()",
- "slotKey": "-1"
- },
- "key": "9"
- },
- {
- "code": "OnTickData()\n",
- "filter": {
- "args": [
- {
- "value": "UpdateData"
- }
- ],
- "signature": "tick(timerId)",
- "slotKey": "-1"
- },
- "key": "10"
- },
- {
- "code": "ToggleHighlight()",
- "filter": {
- "args": [
- {
- "value": "UpdateHighlight"
- }
- ],
- "signature": "tick(timerId)",
- "slotKey": "-1"
- },
- "key": "11"
- },
- {
- "code": "--[[\n Damage Report 3.13\n A LUA script for Dual Universe\n\n Created By Dorian Gray\n Ingame: DorianGray\n Discord: Dorian Gray#2623\n\n You can find/update this script on GitHub. Explanations, installation and usage information as well as screenshots can be found there too.\n GitHub: https://github.com/DorianTheGrey/DU-DamageReport\n\n GNU Public License 3.0. Use whatever you want, be so kind to leave credit.\n \n Credits & thanks: \n Thanks to NovaQuark for creating the MMO of the century.\n Thanks to Jericho, Dmentia and Archaegeo for learning a lot from their fine scripts.\n Thanks to TheBlacklist for testing and wonderful suggestions.\n SVG patterns by Hero Patterns.\n DU atlas data from Jayle Break.\n \n]]\n\n--[[ 1. USER DEFINED VARIABLES ]]\n\nYourShipsName = \"Enter here\" --export Enter your ship name here if you want it displayed instead of the ship's ID. YOU NEED TO LEAVE THE QUOTATION MARKS.\n\nSkillRepairToolEfficiency = 0 --export Enter (0-5) your talent \"Mining and Inventory -> Equipment Manager -> Repair Tool Efficiency\"\nSkillRepairToolOptimization = 0 --export Enter your talent \"Mining and Inventory -> Equipment Manager -> Repair Tool Optimization\"\n\nStatAtmosphericFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED ATMOSPHERIC FUEL TANKS (from the builders talent \"Piloting -> Atmospheric Flight Technician -> Atmospheric Fuel-Tank Handling\")\nStatSpaceFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL SPACE TANKS (from the builders talent \"Piloting -> Atmospheric Engine Technician -> Space Fuel-Tank Handling\")\nStatRocketFuelTankHandling = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL ROCKET TANKS (from the builders talent \"Piloting -> Rocket Scientist -> Rocket Booster Fuel Tank Handling\")\nStatContainerOptimization = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL TANKS \"from the builders talent Mining and Inventory -> Stock Control -> Container Optimization\"\nStatFuelTankOptimization = 0 --export (0-5) Enter the LEVEL OF YOUR PLACED FUEL TANKS \"from the builders talent Mining and Inventory -> Stock Control -> Fuel Tank Optimization\"\n\nShowWelcomeMessage = true --export Do you want the welcome message on the start screen with your name?\nDisallowKeyPresses = false --export Need your keys for other scripts/huds and want to prevent Damage Report keypresses to be processed? Then check this. (Usability of the HUD mode will be small.)\nAddSummertimeHour = false --export: Is summertime currently enabled in your location? (Adds one hour.)\n\nUpdateDataInterval=1.0;HighlightBlinkingInterval=0.5;ColorPrimary=\"FF6700\"ColorSecondary=\"FFFFFF\"ColorTertiary=\"000000\"ColorHealthy=\"00FF00\"ColorWarning=\"FFFF00\"ColorCritical=\"FF0000\"ColorBackground=\"000000\"ColorBackgroundPattern=\"4F4F4F\"ColorFuelAtmospheric=\"004444\"ColorFuelSpace=\"444400\"ColorFuelRocket=\"440044\"VERSION=3.13;DebugMode=false;DebugRenderClickareas=true;DBData={}core=nil;db=nil;screens={}dscreens={}Warnings={}screenModes={[\"flight\"]={id=\"flight\"},[\"damage\"]={id=\"damage\"},[\"damageoutline\"]={id=\"damageoutline\"},[\"fuel\"]={id=\"fuel\"},[\"cargo\"]={id=\"cargo\"},[\"agg\"]={id=\"agg\"},[\"map\"]={id=\"map\"},[\"time\"]={id=\"time\",activetoggle=\"true\"},[\"settings1\"]={id=\"settings1\"},[\"startup\"]={id=\"startup\"}}backgroundModes={\"deathstar\",\"capsule\",\"rain\",\"signal\",\"hexagon\",\"diagonal\",\"diamond\",\"plus\",\"dots\"}BackgroundMode=\"deathstar\"BackgroundSelected=1;BackgroundModeOpacity=0.25;SaveVars={\"dscreens\",\"ColorPrimary\",\"ColorSecondary\",\"ColorTertiary\",\"ColorHealthy\",\"ColorWarning\",\"ColorCritical\",\"ColorBackground\",\"ColorBackgroundPattern\",\"ColorFuelAtmospheric\",\"ColorFuelSpace\",\"ColorFuelRocket\",\"ScrapTier\",\"HUDMode\",\"SimulationMode\",\"DMGOStretch\",\"HUDShiftU\",\"HUDShiftV\",\"colorIDIndex\",\"colorIDTable\",\"BackgroundMode\",\"BackgroundSelected\",\"BackgroundModeOpacity\"}HUDMode=false;HUDShiftU=0;HUDShiftV=0;hudSelectedIndex=0;hudStartIndex=1;hudArrowSticker={}highlightOn=false;highlightID=0;highlightX=0;highlightY=0;highlightZ=0;SimulationMode=false;OkayCenterMessage=\"All systems nominal.\"CurrentDamagedPage=1;CurrentBrokenPage=1;DamagePageSize=12;ScrapTier=1;totalScraps=0;ScrapTierRepairTimes={10,50,250,1250}coreWorldOffset=0;totalShipHP=0;formerTotalShipHP=-1;totalShipMaxHP=0;totalShipIntegrity=100;elementsId={}elementsIdList={}damagedElements={}brokenElements={}rE={}healthyElements={}typeElements={}ElementCounter=0;UseMyElementNames=true;dmgoElements={}DMGOMaxElements=250;DMGOStretch=false;ShipXmin=99999999;ShipXmax=-99999999;ShipYmin=99999999;ShipYmax=-99999999;ShipZmin=99999999;ShipZmax=-99999999;totalShipMass=0;formerTotalShipMass=-1;formerTime=-1;FuelAtmosphericTanks={}FuelSpaceTanks={}FuelRocketTanks={}FuelAtmosphericTotal=0;FuelSpaceTotal=0;FuelRocketTotal=0;FuelAtmosphericCurrent=0;FuelSpaceTotalCurrent=0;FuelRocketTotalCurrent=0;formerFuelAtmosphericTotal=-1;formerFuelSpaceTotal=-1;formerFuelRocketTotal=-1;hexTable={\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"A\",\"B\",\"C\",\"D\",\"E\",\"F\"}colorIDIndex=1;colorIDTable={[1]={id=\"ColorPrimary\",desc=\"Main HUD Color\",basec=\"FF6700\",newc=\"FF6700\"},[2]={id=\"ColorSecondary\",desc=\"Secondary HUD Color\",basec=\"FFFFFF\",newc=\"FFFFFF\"},[3]={id=\"ColorTertiary\",desc=\"Tertiary HUD Color\",basec=\"000000\",newc=\"000000\"},[4]={id=\"ColorHealthy\",desc=\"Color code for Healthy/Okay\",basec=\"00FF00\",newc=\"00FF00\"},[5]={id=\"ColorWarning\",desc=\"Color code for Damaged/Warning\",basec=\"FFFF00\",newc=\"FFFF00\"},[6]={id=\"ColorCritical\",desc=\"Color code for Broken/Critical\",basec=\"FF0000\",newc=\"FF0000\"},[7]={id=\"ColorBackground\",desc=\"Background Color\",basec=\"000000\",newc=\"000000\"},[8]={id=\"ColorBackgroundPattern\",desc=\"Background Pattern Color\",basec=\"4F4F4F\",newc=\"4F4F4F\"},[9]={id=\"ColorFuelAtmospheric\",desc=\"Color for Atmo Fuel/Elements\",basec=\"004444\",newc=\"004444\"},[10]={id=\"ColorFuelSpace\",desc=\"Color for Space Fuel/Elements\",basec=\"444400\",newc=\"444400\"},[11]={id=\"ColorFuelRocket\",desc=\"Color for Rocket Fuel/Elements\",basec=\"440044\",newc=\"440044\"}}function InitiateSlots()for a,b in pairs(unit)do if type(b)==\"table\"and type(b.export)==\"table\"and b.getElementClass then local c=b.getElementClass():lower()if c:find(\"coreunit\")then core=b;local d=core.getMaxHitPoints()if d>10000 then coreWorldOffset=128 elseif d>1000 then coreWorldOffset=64 elseif d>150 then coreWorldOffset=32 else coreWorldOffset=16 end elseif c=='databankunit'then db=b elseif c==\"screenunit\"then local e=\"startup\"screens[#screens+1]={element=b,id=b.getId(),mode=e,submode=\"\",ClickAreas={},refresh=true,active=false,fuelA=true,fuelS=true,fuelR=true,fuelIndex=1}end end end end;function LoadFromDatabank()if db==nil then return else for f,g in pairs(SaveVars)do if db.hasKey(g)then local h=json.decode(db.getStringValue(g))if h~=nil then if g==\"YourShipsName\"or g==\"AddSummertimeHour\"or g==\"UpdateDataInterval\"or g==\"HighlightBlinkingInterval\"or g==\"SkillRepairToolEfficiency\"or g==\"SkillRepairToolOptimization\"or g==\"SkillAtmosphericFuelEfficiency\"or g==\"SkillSpaceFuelEfficiency\"or g==\"SkillRocketFuelEfficiency\"or g==\"StatAtmosphericFuelTankHandling\"or g==\"StatSpaceFuelTankHandling\"or g==\"StatRocketFuelTankHandling\"then else _G[g]=h end end end end;for i,j in ipairs(screens)do for k,l in ipairs(dscreens)do if screens[i].id==dscreens[k].id then screens[i].mode=dscreens[k].mode;screens[i].submode=dscreens[k].submode;screens[i].active=dscreens[k].active;screens[i].refresh=true;screens[i].fuelA=dscreens[k].fuelA;screens[i].fuelS=dscreens[k].fuelS;screens[i].fuelR=dscreens[k].fuelR;screens[i].fuelIndex=dscreens[k].fuelIndex end end end end end;function SaveToDatabank()if db==nil then return else dscreens={}for i,m in ipairs(screens)do dscreens[i]={}dscreens[i].id=m.id;dscreens[i].mode=m.mode;dscreens[i].submode=m.submode;dscreens[i].active=m.active;dscreens[i].fuelA=m.fuelA;dscreens[i].fuelS=m.fuelS;dscreens[i].fuelR=m.fuelR;dscreens[i].fuelIndex=m.fuelIndex end;db.clear()for f,g in pairs(SaveVars)do db.setStringValue(g,json.encode(_G[g]))end end end;function InitiateScreens()if screens~=nil and#screens>0 then for i=1,#screens,1 do screens[i]=CreateClickAreasForScreen(screens[i])end end end;function UpdateTypeData()FuelAtmosphericTanks={}FuelSpaceTanks={}FuelRocketTanks={}FuelAtmosphericTotal=0;FuelAtmosphericCurrent=0;FuelSpaceTotal=0;FuelSpaceCurrent=0;FuelRocketCurrent=0;FuelRocketTotal=0;local n=4;local o=6;local p=0.8;if StatContainerOptimization>0 then n=n-0.05*StatContainerOptimization*n;o=o-0.05*StatContainerOptimization*o;p=p-0.05*StatContainerOptimization*p end;if StatFuelTankOptimization>0 then n=n-0.05*StatFuelTankOptimization*n;o=o-0.05*StatFuelTankOptimization*o;p=p-0.05*StatFuelTankOptimization*p end;for i,q in ipairs(typeElements)do local r=core.getElementNameById(q)or\"\"local s=core.getElementTypeById(q)or\"\"local t=core.getElementPositionById(q)or 0;local u=core.getElementHitPointsById(q)or 0;local v=core.getElementMaxHitPointsById(q)or 0;local w=core.getElementMassById(q)or 0;local x=\"\"local y=0;local z=0;local A=0;local B=0;if s==\"atmospheric fuel-tank\"then if v>10000 then x=\"L\"z=5480;y=12800 elseif v>1300 then x=\"M\"z=988.67;y=1600 elseif v>150 then x=\"S\"z=182.67;y=400 else x=\"XS\"z=35.03;y=100 end;if StatAtmosphericFuelTankHandling>0 then y=0.2*StatAtmosphericFuelTankHandling*y+y end;A=w-z;if A<=10 then A=0 end;B=string.format(\"%.0f\",A/n)cPercent=string.format(\"%.1f\",math.floor(100/y*tonumber(B)))table.insert(FuelAtmosphericTanks,{type=1,id=q,name=r,maxhp=v,hp=GetHPforElement(q),pos=t,size=x,mass=z,vol=y,cvol=B,percent=cPercent})if u>0 then FuelAtmosphericCurrent=FuelAtmosphericCurrent+B end;FuelAtmosphericTotal=FuelAtmosphericTotal+y elseif s==\"space fuel-tank\"then if v>10000 then x=\"L\"z=5480;y=12800 elseif v>1300 then x=\"M\"z=988.67;y=1600 else x=\"S\"z=182.67;y=400 end;if StatSpaceFuelTankHandling>0 then y=0.2*StatSpaceFuelTankHandling*y+y end;A=w-z;if A<=10 then A=0 end;B=string.format(\"%.0f\",A/o)cPercent=string.format(\"%.1f\",100/y*tonumber(B))table.insert(FuelSpaceTanks,{type=2,id=q,name=r,maxhp=v,hp=GetHPforElement(q),pos=t,size=x,mass=z,vol=y,cvol=B,percent=cPercent})if u>0 then FuelSpaceCurrent=FuelSpaceCurrent+B end;FuelSpaceTotal=FuelSpaceTotal+y elseif s==\"rocket fuel-tank\"then if v>65000 then x=\"L\"z=25740;y=50000 elseif v>6000 then x=\"M\"z=4720;y=6400 elseif v>700 then x=\"S\"z=886.72;y=800 else x=\"XS\"z=173.42;y=400 end;if StatRocketFuelTankHandling>0 then y=0.2*StatRocketFuelTankHandling*y+y end;A=w-z;if A<=10 then A=0 end;B=string.format(\"%.0f\",A/p)cPercent=string.format(\"%.1f\",100/y*tonumber(B))table.insert(FuelRocketTanks,{type=3,id=q,name=r,maxhp=v,hp=GetHPforElement(q),pos=t,size=x,mass=z,vol=y,cvol=B,percent=cPercent})if u>0 then FuelRocketCurrent=FuelRocketCurrent+B end;FuelRocketTotal=FuelRocketTotal+y end end;if FuelAtmosphericCurrent~=formerFuelAtmosphericCurrent then SetRefresh(\"fuel\")formerFuelAtmosphericCurrent=FuelAtmosphericCurrent end;if FuelSpaceCurrent~=formerFuelSpaceCurrent then SetRefresh(\"fuel\")formerFuelSpaceCurrent=FuelSpaceCurrent end;if FuelRocketCurrent~=formerFuelRocketCurrent then SetRefresh(\"fuel\")formerFuelRocketCurrent=FuelRocketCurrent end end;function UpdateDamageData(C)C=C or false;if SimulationActive==true then return end;local formerTotalShipHP=totalShipHP;totalShipHP=0;totalShipMaxHP=0;totalShipIntegrity=100;damagedElements={}brokenElements={}healthyElements={}if C==true then typeElements={}end;ElementCounter=0;elementsIdList=core.getElementIdList()for i,q in pairs(elementsIdList)do ElementCounter=ElementCounter+1;local r=core.getElementNameById(q)local s=core.getElementTypeById(q)local t=core.getElementPositionById(q)local u=core.getElementHitPointsById(q)local v=core.getElementMaxHitPointsById(q)if SimulationMode==true then SimulationActive=true;local D=math.random(0,10)if D<2 and#brokenElements<30 then u=0 elseif D>=2 and D<4 and#damagedElements<30 then u=math.random(1,math.ceil(v))else u=v end end;totalShipHP=totalShipHP+u;totalShipMaxHP=totalShipMaxHP+v;if v-u>constants.epsilon then if u>0 then table.insert(damagedElements,{id=q,name=r,type=s,counter=ElementCounter,hp=u,maxhp=v,missinghp=v-u,percent=math.ceil(100/v*u),pos=t})else table.insert(brokenElements,{id=q,name=r,type=s,counter=ElementCounter,hp=u,maxhp=v,missinghp=v-u,percent=0,pos=t})end else table.insert(healthyElements,{id=q,name=r,type=s,counter=ElementCounter,hp=u,maxhp=v,pos=t})if q==highlightID then highlightID=0;highlightOn=false;HideHighlight()hudSelectedIndex=0 end end;if C==true then if s==\"atmospheric fuel-tank\"or s==\"space fuel-tank\"or s==\"rocket fuel-tank\"then table.insert(typeElements,q)end end end;SortDamageTables()rE={}if#brokenElements>0 then for f,j in ipairs(brokenElements)do table.insert(rE,{id=j.id,missinghp=j.missinghp,hp=j.hp,name=j.name,type=j.type,pos=j.pos})end end;if#damagedElements>0 then for f,j in ipairs(damagedElements)do table.insert(rE,{id=j.id,missinghp=j.missinghp,hp=j.hp,name=j.name,type=j.type,pos=j.pos})end end;if#rE>0 then table.sort(rE,function(E,F)return E.missinghp>F.missinghp end)end;totalShipIntegrity=string.format(\"%2.0f\",100/totalShipMaxHP*totalShipHP)if formerTotalShipHP~=totalShipHP then forceDamageRedraw=true;formerTotalShipHP=totalShipHP else forceDamageRedraw=false end end;function GetHPforElement(q)for i,j in ipairs(brokenElements)do if j.id==q then return 0 end end;for i,j in ipairs(damagedElements)do if j.id==q then return j.hp end end;for i,j in ipairs(healthyElements)do if j.id==q then return j.maxhp end end end;function UpdateClickArea(G,H,I)for i,m in ipairs(screens)do for J,j in pairs(screens[i].ClickAreas)do if j.id==G and j.mode==I then screens[i].ClickAreas[J]=H end end end end;function AddClickArea(I,H)for i,m in ipairs(screens)do if screens[i].mode==I then table.insert(screens[i].ClickAreas,H)end end end;function AddClickAreaForScreenID(K,H)for i,m in ipairs(screens)do if screens[i].id==K then table.insert(screens[i].ClickAreas,H)end end end;function DisableClickArea(G,I)UpdateClickArea(G,{id=G,mode=I,x1=-1,x2=-1,y1=-1,y2=-1})end;function SetRefresh(I,L)I=I or\"all\"L=L or\"all\"if screens~=nil and#screens>0 then for i=1,#screens,1 do if screens[i].mode==I or I==\"all\"then if screens[i].submode==L or L==\"all\"then screens[i].refresh=true end end end end end;function WipeClickAreasForScreen(m)m.ClickAreas={}return m end;function CreateBaseClickAreas(m)table.insert(m.ClickAreas,{mode=\"all\",id=\"ToggleHudMode\",x1=1537,x2=1728,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"damage\",x1=193,x2=384,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"damageoutline\",x1=385,x2=576,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"fuel\",x1=577,x2=768,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"time\",x1=0,x2=192,y1=1015,y2=1075})table.insert(m.ClickAreas,{mode=\"all\",id=\"ButtonPress\",param=\"settings1\",x1=1729,x2=1920,y1=1015,y2=1075})return m end;function CreateClickAreasForScreen(m)if m==nil then return{}end;if m.mode==\"flight\"then elseif m.mode==\"damage\"then table.insert(m.ClickAreas,{mode=\"damage\",id=\"ToggleElementLabel\",x1=70,x2=425,y1=325,y2=355})table.insert(m.ClickAreas,{mode=\"damage\",id=\"ToggleElementLabel2\",x1=980,x2=1400,y1=325,y2=355})elseif m.mode==\"damageoutline\"then table.insert(m.ClickAreas,{mode=\"damageoutline\",id=\"DMGOChangeView\",param=\"top\",x1=60,x2=439,y1=150,y2=200})table.insert(m.ClickAreas,{mode=\"damageoutline\",id=\"DMGOChangeView\",param=\"side\",x1=440,x2=824,y1=150,y2=200})table.insert(m.ClickAreas,{mode=\"damageoutline\",id=\"DMGOChangeView\",param=\"front\",x1=825,x2=1215,y1=150,y2=200})table.insert(m.ClickAreas,{mode=\"damageoutline\",id=\"DMGOChangeStretch\",x1=1530,x2=1580,y1=150,y2=200})elseif m.mode==\"fuel\"then elseif m.mode==\"cargo\"then elseif m.mode==\"agg\"then elseif m.mode==\"map\"then elseif m.mode==\"time\"then elseif m.mode==\"settings1\"then table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ToggleBackground\",x1=75,x2=860,y1=170,y2=215})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"PreviousBackground\",x1=75,x2=460,y1=235,y2=285})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"NextBackground\",x1=480,x2=860,y1=235,y2=285})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"DecreaseOpacity\",x1=75,x2=460,y1=300,y2=350})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"IncreaseOpacity\",x1=480,x2=860,y1=300,y2=350})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ResetColors\",x1=75,x2=860,y1=370,y2=415})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"PreviousColorID\",x1=90,x2=140,y1=500,y2=550})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"NextColorID\",x1=795,x2=845,y1=500,y2=550})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"1\",x1=210,x2=290,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"2\",x1=300,x2=380,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"3\",x1=385,x2=465,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"4\",x1=470,x2=550,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"5\",x1=560,x2=640,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosUp\",param=\"6\",x1=645,x2=725,y1=655,y2=700})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"1\",x1=210,x2=290,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"2\",x1=300,x2=380,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"3\",x1=385,x2=465,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"4\",x1=470,x2=550,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"5\",x1=560,x2=640,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ColorPosDown\",param=\"6\",x1=645,x2=725,y1=740,y2=780})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ResetPosColor\",x1=160,x2=340,y1=885,y2=935})table.insert(m.ClickAreas,{mode=\"settings1\",id=\"ApplyPosColor\",x1=355,x2=780,y1=885,y2=935})elseif m.mode==\"startup\"then end;m=CreateBaseClickAreas(m)return m end;function CheckClick(M,N,O)M=M*1920;N=N*1120;O=O or\"\"HitPayload={}if screens~=nil and#screens>0 then for i=1,#screens,1 do if screens[i].active==true and screens[i].element.getMouseX()~=-1 and screens[i].element.getMouseY()~=-1 then if O==\"\"then for J,j in pairs(screens[i].ClickAreas)do if j~=nil and M>=j.x1 and M<=j.x2 and N>=j.y1 and N<=j.y2 then O=j.id;HitPayload=j;break end end end;if O==\"ButtonPress\"then if screens[i].mode==HitPayload.param then screens[i].mode=\"startup\"else screens[i].mode=HitPayload.param end;if screens[i].mode==\"damageoutline\"then if screens[i].submode==\"\"then screens[i].submode=\"top\"end end;screens[i].refresh=true;screens[i].ClickAreas={}SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"ToggleBackground\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundMode==\"\"then BackgroundSelected=1;BackgroundMode=backgroundModes[BackgroundSelected]else BackgroundSelected=1;BackgroundMode=\"\"end;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"PreviousBackground\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundMode==\"\"then BackgroundSelected=1;BackgroundMode=backgroundModes[BackgroundSelected]else if BackgroundSelected<=1 then BackgroundSelected=#backgroundModes else BackgroundSelected=BackgroundSelected-1 end;BackgroundMode=backgroundModes[BackgroundSelected]end;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"NextBackground\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundMode==\"\"then BackgroundSelected=1;BackgroundMode=backgroundModes[BackgroundSelected]else if BackgroundSelected>=#backgroundModes then BackgroundSelected=1 else BackgroundSelected=BackgroundSelected+1 end;BackgroundMode=backgroundModes[BackgroundSelected]end;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"DecreaseOpacity\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundModeOpacity>0.1 then BackgroundModeOpacity=BackgroundModeOpacity-0.05;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()end elseif O==\"IncreaseOpacity\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if BackgroundModeOpacity<1.0 then BackgroundModeOpacity=BackgroundModeOpacity+0.05;for J,m in pairs(screens)do screens[J].refresh=true end;SaveToDatabank()SetRefresh()RenderScreens()end elseif O==\"ResetColors\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then db.clear()ColorPrimary=\"FF6700\"ColorSecondary=\"FFFFFF\"ColorTertiary=\"000000\"ColorHealthy=\"00FF00\"ColorWarning=\"FFFF00\"ColorCritical=\"FF0000\"ColorBackground=\"000000\"ColorBackgroundPattern=\"4f4f4f\"ColorFuelAtmospheric=\"004444\"ColorFuelSpace=\"444400\"ColorFuelRocket=\"440044\"BackgroundMode=\"deathstar\"BackgroundSelected=1;BackgroundModeOpacity=0.25;colorIDTable={[1]={id=\"ColorPrimary\",desc=\"Main HUD Color\",basec=\"FF6700\",newc=\"FF6700\"},[2]={id=\"ColorSecondary\",desc=\"Secondary HUD Color\",basec=\"FFFFFF\",newc=\"FFFFFF\"},[3]={id=\"ColorTertiary\",desc=\"Tertiary HUD Color\",basec=\"000000\",newc=\"000000\"},[4]={id=\"ColorHealthy\",desc=\"Color code for Healthy/Okay\",basec=\"00FF00\",newc=\"00FF00\"},[5]={id=\"ColorWarning\",desc=\"Color code for Damaged/Warning\",basec=\"FFFF00\",newc=\"FFFF00\"},[6]={id=\"ColorCritical\",desc=\"Color code for Broken/Critical\",basec=\"FF0000\",newc=\"FF0000\"},[7]={id=\"ColorBackground\",desc=\"Background Color\",basec=\"000000\",newc=\"000000\"},[8]={id=\"ColorBackgroundPattern\",desc=\"Background Pattern Color\",basec=\"4F4F4F\",newc=\"4F4F4F\"},[9]={id=\"ColorFuelAtmospheric\",desc=\"Color for Atmo Fuel/Elements\",basec=\"004444\",newc=\"004444\"},[10]={id=\"ColorFuelSpace\",desc=\"Color for Space Fuel/Elements\",basec=\"444400\",newc=\"444400\"},[11]={id=\"ColorFuelRocket\",desc=\"Color for Rocket Fuel/Elements\",basec=\"440044\",newc=\"440044\"}}SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"PreviousColorID\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then colorIDIndex=colorIDIndex-1;if colorIDIndex<1 then colorIDIndex=#colorIDTable end;SaveToDatabank()SetRefresh(\"settings1\")RenderScreens(\"settings1\")elseif O==\"NextColorID\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then colorIDIndex=colorIDIndex+1;if colorIDIndex>#colorIDTable then colorIDIndex=1 end;SaveToDatabank()SetRefresh(\"settings1\")RenderScreens(\"settings1\")elseif O==\"ColorPosUp\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then local P=tonumber(string.sub(colorIDTable[colorIDIndex].newc,HitPayload.param,HitPayload.param),16)P=P+1;if P>15 then P=0 end;colorIDTable[colorIDIndex].newc=replace_char(HitPayload.param,colorIDTable[colorIDIndex].newc,hexTable[P+1])SaveToDatabank()SetRefresh(\"settings1\")RenderScreens(\"settings1\")elseif O==\"ColorPosDown\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then local P=tonumber(string.sub(colorIDTable[colorIDIndex].newc,HitPayload.param,HitPayload.param),16)P=P-1;if P<0 then P=15 end;colorIDTable[colorIDIndex].newc=replace_char(HitPayload.param,colorIDTable[colorIDIndex].newc,hexTable[P+1])SaveToDatabank()SetRefresh(\"settings1\")RenderScreens(\"settings1\")elseif O==\"ResetPosColor\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then colorIDTable[colorIDIndex].newc=colorIDTable[colorIDIndex].basec;_G[colorIDTable[colorIDIndex].id]=colorIDTable[colorIDIndex].basec;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"ApplyPosColor\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then _G[colorIDTable[colorIDIndex].id]=colorIDTable[colorIDIndex].newc;SaveToDatabank()SetRefresh()RenderScreens()elseif O==\"DamagedPageDown\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentDamagedPage=CurrentDamagedPage+1;if CurrentDamagedPage>math.ceil(#damagedElements/DamagePageSize)then CurrentDamagedPage=math.ceil(#damagedElements/DamagePageSize)end;HudDeselectElement()SaveToDatabank()SetRefresh(\"damage\")RenderScreens(\"damage\")elseif O==\"DamagedPageUp\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentDamagedPage=CurrentDamagedPage-1;if CurrentDamagedPage<1 then CurrentDamagedPage=1 end;HudDeselectElement()SaveToDatabank()SetRefresh(\"damage\")RenderScreens(\"damage\")elseif O==\"BrokenPageDown\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentBrokenPage=CurrentBrokenPage+1;if CurrentBrokenPage>math.ceil(#brokenElements/DamagePageSize)then CurrentBrokenPage=math.ceil(#brokenElements/DamagePageSize)end;HudDeselectElement()SaveToDatabank()SetRefresh(\"damage\")RenderScreens(\"damage\")elseif O==\"BrokenPageUp\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentBrokenPage=CurrentBrokenPage-1;if CurrentBrokenPage<1 then CurrentBrokenPage=1 end;HudDeselectElement()SaveToDatabank()SetRefresh(\"damage\")RenderScreens(\"damage\")elseif O==\"DMGOChangeView\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then screens[i].submode=HitPayload.param;UpdateViewDamageoutline(screens[i])SaveToDatabank()SetRefresh(\"damageoutline\",screens[i].submode)RenderScreens(\"damageoutline\",screens[i].submode)elseif O==\"DMGOChangeStretch\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if DMGOStretch==true then DMGOStretch=false else DMGOStretch=true end;UpdateViewDamageoutline(screens[i])SaveToDatabank()SetRefresh(\"damageoutline\")RenderScreens(\"damageoutline\")elseif O==\"ToggleDisplayAtmosphere\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if screens[i].fuelA==true then screens[i].fuelA=false else screens[i].fuelA=true end;screens[i].fuelIndex=1;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"ToggleDisplaySpace\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if screens[i].fuelS==true then screens[i].fuelS=false else screens[i].fuelS=true end;screens[i].fuelIndex=1;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"ToggleDisplayRocket\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if screens[i].fuelR==true then screens[i].fuelR=false else screens[i].fuelR=true end;screens[i].fuelIndex=1;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"DecreaseFuelIndex\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then screens[i].fuelIndex=screens[i].fuelIndex-1;if screens[i].fuelIndex<1 then screens[i].fuelIndex=1 end;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"IncreaseFuelIndex\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then screens[i].fuelIndex=screens[i].fuelIndex+1;SaveToDatabank()SetRefresh(\"fuel\")RenderScreens(\"fuel\")elseif O==\"ToggleHudMode\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if HUDMode==true then HUDMode=false;forceDamageRedraw=true;HudDeselectElement()SaveToDatabank()SetRefresh()RenderScreens()else HUDMode=true;forceDamageRedraw=true;HudDeselectElement()SaveToDatabank()SetRefresh()RenderScreens()end elseif O==\"ToggleSimulation\"and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then CurrentDamagedPage=1;CurrentBrokenPage=1;if SimulationMode==true then SimulationMode=false;SimulationActive=false;UpdateDamageData()UpdateTypeData()forceDamageRedraw=true;HudDeselectElement()SetRefresh(\"damage\")SetRefresh(\"damageoutline\")SetRefresh(\"settings1\")SetRefresh(\"fuel\")SaveToDatabank()RenderScreens()else SimulationMode=true;SimulationActive=false;UpdateDamageData()UpdateTypeData()forceDamageRedraw=true;HudDeselectElement()SetRefresh(\"damage\")SetRefresh(\"damageoutline\")SetRefresh(\"settings1\")SetRefresh(\"fuel\")SaveToDatabank()RenderScreens()end elseif(O==\"ToggleElementLabel\"or O==\"ToggleElementLabel2\")and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then if UseMyElementNames==true then UseMyElementNames=false;SetRefresh(\"damage\")RenderScreens(\"damage\")else UseMyElementNames=true;SetRefresh(\"damage\")RenderScreens(\"damage\")end elseif(O==\"SwitchScrapTier\"or O==\"SwitchScrapTier2\")and(HitPayload.mode==screens[i].mode or HitPayload.mode==\"all\")then ScrapTier=ScrapTier+1;if ScrapTier>4 then ScrapTier=1 end;SetRefresh(\"damage\")RenderScreens(\"damage\")end end end end end;function GetContentFlight()local Q=\"\"Q=Q..GetHeader(\"Flight Data Report\")..[[\n \n ]]return Q end;function GetContentDamage()local Q=\"\"if SimulationMode==true then Q=Q..GetHeader(\"Damage Report (Simulated damage)\")..[[]]else Q=Q..GetHeader(\"Damage Report\")..[[]]end;Q=Q..GetContentDamageScreen()return Q end;function GetContentDamageoutline(m)UpdateDataDamageoutline()UpdateViewDamageoutline(m)local Q=\"\"Q=Q..GetHeader(\"Damage Ship Outline Report\")..GetDamageoutlineShip()..[[]]if m.submode==\"top\"then Q=Q..[[\n \n Top View\n \n Side View\n \n Front View\n ]]elseif m.submode==\"side\"then Q=Q..[[\n \n Top View\n \n Side View\n \n Front View\n ]]elseif m.submode==\"front\"then Q=Q..[[\n \n Top View\n \n Side View\n \n Front View\n ]]else end;Q=Q..[[]]..#dmgoElements..[[ of ]]..ElementCounter..[[ shown]]Q=Q..[[]]if DMGOStretch==true then Q=Q..[[]]end;Q=Q..[[Stretch both axis]]return Q end;function GetContentFuel(m)if#FuelAtmosphericTanks<1 and#FuelSpaceTanks<1 and#FuelRocketTanks<1 then return\"\"end;local R=0;local Q=\"\"local S={}FuelDisplay={m.fuelA,m.fuelS,m.fuelR}if FuelDisplay[1]==true and#FuelAtmosphericTanks>0 then table.insert(S,\"Atmospheric\")R=R+1 end;if FuelDisplay[2]==true and#FuelSpaceTanks>0 then table.insert(S,\"Space\")R=R+1 end;if FuelDisplay[3]==true and#FuelRocketTanks>0 then table.insert(S,\"Rocket\")R=R+1 end;Q=Q..GetHeader(\"Fuel Report (\"..table.concat(S,\", \")..\")\")..[[\n ]]local T=150;local U=0;local V=0;if FuelDisplay[1]==true and#FuelAtmosphericTanks>0 then if R==1 then V=50 elseif R==2 then V=6 elseif R==3 then V=0 end;Q=Q..[[\n \n \n \n ]]Q=Q..[[]]..GenerateCommaValue(FuelAtmosphericCurrent,true)..[[ of ]]..GenerateCommaValue(FuelAtmosphericTotal,true)..[[ | Total Atmospheric Fuel in ]]..#FuelAtmosphericTanks..[[ tank]]..(#FuelAtmosphericTanks==1 and\"\"or\"s\")..[[ (]]..math.floor(100/FuelAtmosphericTotal*FuelAtmosphericCurrent)..[[%)]]U=U+1 end;if FuelDisplay[2]==true and#FuelSpaceTanks>0 then if R==1 then V=50 elseif R==2 then V=6 elseif R==3 then V=0 end;Q=Q..[[\n \n \n \n ]]Q=Q..[[]]..GenerateCommaValue(FuelSpaceCurrent,true)..[[ of ]]..GenerateCommaValue(FuelSpaceTotal,true)..[[ | Total Space Fuel in ]]..#FuelSpaceTanks..[[ tank]]..(#FuelSpaceTanks==1 and\"\"or\"s\")..[[ (]]..math.floor(100/FuelSpaceTotal*FuelSpaceCurrent)..[[%)]]U=U+1 end;if FuelDisplay[3]==true and#FuelRocketTanks>0 then if R==1 then V=50 elseif R==2 then V=6 elseif R==3 then V=0 end;Q=Q..[[\n \n \n \n ]]Q=Q..[[]]..GenerateCommaValue(FuelRocketCurrent,true)..[[ of ]]..GenerateCommaValue(FuelRocketTotal,true)..[[ | Total Rocket Fuel in ]]..#FuelRocketTanks..[[ tank]]..(#FuelRocketTanks==1 and\"\"or\"s\")..[[ (]]..math.floor(100/FuelRocketTotal*FuelRocketCurrent)..[[%)]]end;Q=Q..[[\n \n \n \n ]]local W={}if m.fuelIndex==nil or m.fuelIndex<1 then m.fuelIndex=1 end;if FuelDisplay[1]==true then for f,j in ipairs(FuelAtmosphericTanks)do table.insert(W,j)end end;if FuelDisplay[2]==true then for f,j in ipairs(FuelSpaceTanks)do table.insert(W,j)end end;if FuelDisplay[3]==true then for f,j in ipairs(FuelRocketTanks)do table.insert(W,j)end end;table.sort(W,function(E,F)return E.type\n \n \n ]]if Y.hp==0 then Q=Q..[[]]elseif Y.maxhp-Y.hp>constants.epsilon then Q=Q..[[]]else Q=Q..[[]]end;if Y.hp==0 then Q=Q..[[]]..Y.size..[[]]else Q=Q..[[]]..Y.size..[[]]end;if Y.hp==0 then Q=Q..[[Broken]]..[[0 of ]]..GenerateCommaValue(Y.vol)..[[]]elseif tonumber(Y.percent)<10 then Q=Q..[[]]..Y.percent..[[%]]..[[]]..GenerateCommaValue(Y.cvol)..[[ of ]]..GenerateCommaValue(Y.vol)..[[]]elseif tonumber(Y.percent)<30 then Q=Q..[[]]..Y.percent..[[%]]..[[]]..GenerateCommaValue(Y.cvol)..[[ of ]]..GenerateCommaValue(Y.vol)..[[]]else Q=Q..[[]]..Y.percent..[[%]]..[[]]..GenerateCommaValue(Y.cvol)..[[ of ]]..GenerateCommaValue(Y.vol)..[[]]end;Q=Q..[[]]..Y.name..[[]]Q=Q..[[]]end end;if#FuelAtmosphericTanks>0 then Q=Q..[[]]if FuelDisplay[1]==true then Q=Q..[[]]end;Q=Q..[[ATM]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"ToggleDisplayAtmosphere\",x1=50,x2=100,y1=270,y2=320})end;if#FuelSpaceTanks>0 then Q=Q..[[]]if FuelDisplay[2]==true then Q=Q..[[]]end;Q=Q..[[SPC]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"ToggleDisplaySpace\",x1=200,x2=250,y1=270,y2=320})end;if#FuelRocketTanks>0 then Q=Q..[[]]if FuelDisplay[3]==true then Q=Q..[[]]end;Q=Q..[[RKT]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"ToggleDisplayRocket\",x1=350,x2=400,y1=270,y2=320})end;if m.fuelIndex>1 then Q=Q..[[\n \n \n ]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"DecreaseFuelIndex\",x1=1470,x2=1670,y1=270,y2=320})end;if m.fuelIndex+X-1<#W then Q=Q..[[\n \n \n ]]AddClickAreaForScreenID(m.id,{mode=\"fuel\",id=\"IncreaseFuelIndex\",x1=1680,x2=1880,y1=270,y2=320})end;if X>0 then Q=Q..[[]]..#W..[[ Tank]]..(#W==1 and\"\"or\"s\")..[[ (Showing ]]..m.fuelIndex..[[ to ]]..m.fuelIndex+X-1 ..[[)]]end;return Q end;function GetContentCargo()local Q=\"\"Q=Q..GetHeader(\"Cargo Report\")..[[\n \n ]]return Q end;function GetContentAGG()local Q=\"\"Q=Q..GetHeader(\"Anti-Grav Control\")..[[\n \n ]]return Q end;function GetContentMap()local Q=\"\"Q=Q..GetHeader(\"Map Overview\")..[[\n \n ]]return Q end;function GetContentTime()local Q=\"\"Q=Q..GetHeader(\"Time\")..epochTime()Q=Q..[[\n \n \n \n \n \n \n \n \n \n \n \n \n ]]return Q end;function GetContentSettings1()local Q=\"\"Q=Q..GetHeader(\"Settings\")..[[]]if BackgroundMode==\"\"then Q=Q..[[Activate background]]else Q=Q..[[Deactivate background (']]..BackgroundMode..[[', ]]..string.format(\"%.0f\",BackgroundModeOpacity*100)..[[%)]]end;Q=Q..[[\n \n Previous background\n \n Next background\n\n \n Decrease Opacity\n \n Increase Opacity\n ]]Q=Q..[[]]..[[Reset background and all colors]]Q=Q..[[]]..[[]]..[[]]..[[Select and change any of the ]]..#colorIDTable..[[ HUD colors]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..colorIDTable[colorIDIndex].desc..[[]]..[[]]..[[Current color]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[#]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,1,1)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,2,2)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,3,3)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,4,4)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,5,5)..[[]]..[[]]..[[]]..string.sub(colorIDTable[colorIDIndex].newc,6,6)..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[]]..[[New color]]..[[]]..[[Apply new color]]..[[]]..[[Reset]]..[[]]Q=Q..[[]]..[[]]..[[]]..[[Explanation / Hints]]..[[Coming soon.]]Q=Q..[[]]if SimulationMode==true then Q=Q..[[Simulating Damage to elements]]AddClickArea(\"settings1\",{id=\"ToggleSimulation\",mode=\"settings1\",x1=940,x2=1850,y1=919,y2=969})else Q=Q..[[Simulate Damage to elements]]AddClickArea(\"settings1\",{id=\"ToggleSimulation\",mode=\"settings1\",x1=940,x2=1850,y1=919,y2=969})end;return Q end;function GetContentStartup()local Q=\"\"Q=Q..GetElementLogo(812,380,\"f\",\"f\",\"f\")if YourShipsName==\"Enter here\"then Q=Q..[[Spaceship ID ]]..ShipID..[[]]else Q=Q..[[]]..YourShipsName..[[]]end;if ShowWelcomeMessage==true then Q=Q..[[Greetings, Commander ]]..PlayerName..[[.]]end;if#Warnings>0 then Q=Q..[[Warning: ]]..table.concat(Warnings,\" \")..[[]]end;Q=Q..[[Damage Report v]]..VERSION..[[, by Scion Interstellar, DorianGray - Discord: Dorian Gray#2623. Under GNU Public License 3.0.]]return Q end;function RenderScreen(m,a0)if a0==nil then PrintConsole(\"ERROR: contentToRender is nil.\")unit.exit()end;CreateClickAreasForScreen(m)local Q=\"\"Q=Q..[[\n \n \n ]]Q=Q..a0;if m.mode==\"startup\"then Q=Q..[[]]else Q=Q..[[]]end;Q=Q..[[\n \n ]]Q=Q..[[]]local a1=string.len(Q)m.element.setSVG(Q)end;function RenderScreens(a2,a3)a2=a2 or\"all\"a3=a3 or\"all\"if screens~=nil and#screens>0 then local a4=\"\"local a5=\"\"local a6=\"\"local a7=\"\"local a8=\"\"local a9=\"\"local aa=\"\"local ab=\"\"local ac=\"\"local ad=\"\"local ae=\"\"local af=\"\"for J,m in pairs(screens)do if m.refresh==true then local a0=\"\"if m.mode==\"flight\"and(a2==\"flight\"or a2==\"all\")then if a4==\"\"then a4=GetContentFlight()end;a0=a4 elseif m.mode==\"damage\"and(a2==\"damage\"or a2==\"all\")then if a5==\"\"then a5=GetContentDamage()end;a0=a5 elseif m.mode==\"damageoutline\"and(a2==\"damageoutline\"or a2==\"all\")then if m.submode==\"\"then m.submode=\"top\"screens[J].submode=\"top\"end;if m.submode==\"top\"and(a3==\"top\"or a3==\"all\")then if a6==\"\"then a6=GetContentDamageoutline(m)end;a0=a6 end;if m.submode==\"side\"and(a3==\"side\"or a3==\"all\")then if a7==\"\"then a7=GetContentDamageoutline(m)end;a0=a7 end;if m.submode==\"front\"and(a3==\"front\"or a3==\"all\")then if a8==\"\"then a8=GetContentDamageoutline(m)end;a0=a8 end elseif m.mode==\"fuel\"and(a2==\"fuel\"or a2==\"all\")then m=WipeClickAreasForScreen(screens[J])a0=GetContentFuel(m)elseif m.mode==\"cargo\"and(a2==\"cargo\"or a2==\"all\")then if aa==\"\"then aa=GetContentCargo()end;a0=aa elseif m.mode==\"agg\"and(a2==\"agg\"or a2==\"all\")then if ab==\"\"then ab=GetContentAGG()end;a0=ab elseif m.mode==\"map\"and(a2==\"map\"or a2==\"all\")then if ac==\"\"then ac=GetContentMap()end;a0=ac elseif m.mode==\"time\"and(a2==\"time\"or a2==\"all\")then if ad==\"\"then ad=GetContentTime()end;a0=ad elseif m.mode==\"settings1\"and(a2==\"settings1\"or a2==\"all\")then if ae==\"\"then ae=GetContentSettings1()end;a0=ae elseif m.mode==\"startup\"and(a2==\"startup\"or a2==\"all\")then if af==\"\"then af=GetContentStartup()end;a0=af else a0=\"Invalid screen mode. ('\"..m.mode..\"')\"end;if a0~=\"\"then RenderScreen(m,a0)else DrawCenteredText(\"ERROR: No contentToRender delivered for \"..m.mode)PrintConsole(\"ERROR: No contentToRender delivered for \"..m.mode)unit.exit()end;screens[J].refresh=false end end end;if HUDMode==true then system.setScreen(GetContentDamageHUDOutput())system.showScreen(1)else system.showScreen(0)end end;function OnTickData(C)if formerTime+605 or SkillRepairToolOptimization>5 or StatFuelTankOptimization>5 or StatContainerOptimization>5 or StatAtmosphericFuelTankHandling>5 or StatSpaceFuelTankHandling>5 or StatRocketFuelTankHandling>5 then PrintConsole(\"ERROR: Talents/stats can only range from 0 to 5. Please set correctly in LUA settings and reactivate script.\")unit.exit()end;if screens==nil or#screens==0 then HUDMode=true;PrintConsole(\"Warning: No screens connected. Entering HUD mode only.\")end;OnTickData(true)unit.setTimer('UpdateData',UpdateDataInterval)unit.setTimer('UpdateHighlight',HighlightBlinkingInterval)",
- "filter": {
- "args": [],
- "signature": "start()",
- "slotKey": "-1"
- },
- "key": "12"
- },
- {
- "code": "ActionUp()",
- "filter": {
- "args": [
- {
- "value": "up"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "13"
- },
- {
- "code": "ActionDown()",
- "filter": {
- "args": [
- {
- "value": "down"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "14"
- },
- {
- "code": "ActionStrafeLeft()",
- "filter": {
- "args": [
- {
- "value": "strafeleft"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "15"
- },
- {
- "code": "ActionStrafeRight()",
- "filter": {
- "args": [
- {
- "value": "straferight"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "16"
- },
- {
- "code": "KeyCTRLPressed = true",
- "filter": {
- "args": [
- {
- "value": "brake"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "17"
- },
- {
- "code": "KeyCTRLPressed = false",
- "filter": {
- "args": [
- {
- "value": "brake"
- }
- ],
- "signature": "actionStop(action)",
- "slotKey": "-2"
- },
- "key": "18"
- },
- {
- "code": "ActionOption1()",
- "filter": {
- "args": [
- {
- "value": "option1"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "19"
- },
- {
- "code": "ActionOption2()",
- "filter": {
- "args": [
- {
- "value": "option2"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "20"
- },
- {
- "code": "ActionOption3()",
- "filter": {
- "args": [
- {
- "value": "option3"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "21"
- },
- {
- "code": "ActionOption4()",
- "filter": {
- "args": [
- {
- "value": "option4"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "22"
- },
- {
- "code": "ActionOption9()",
- "filter": {
- "args": [
- {
- "value": "option9"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "23"
- },
- {
- "code": "ActionOption8()",
- "filter": {
- "args": [
- {
- "value": "option8"
- }
- ],
- "signature": "actionStart(action)",
- "slotKey": "-2"
- },
- "key": "24"
- }
- ],
- "methods": [],
- "events": []
-}
\ No newline at end of file