From aa1a2ee431c7a314cabac5ef5029c07a51c38e7d Mon Sep 17 00:00:00 2001 From: JNS Date: Wed, 28 Oct 2020 02:06:15 +0100 Subject: [PATCH] Update DamageReport_1_52.json --- DamageReport_1_52.json | 275 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 274 insertions(+), 1 deletion(-) diff --git a/DamageReport_1_52.json b/DamageReport_1_52.json index 7e6a394..621a86e 100644 --- a/DamageReport_1_52.json +++ b/DamageReport_1_52.json @@ -1 +1,274 @@ -{"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.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 +{ + "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