From bb159e36bdbd8dd12f4ecd789d3277734f94b849 Mon Sep 17 00:00:00 2001 From: JNS Date: Mon, 9 Nov 2020 00:41:51 +0100 Subject: [PATCH] Added user defined background color --- DamageReport_2_33.json | 339 ++++++++++++++++++ .../DamageReport_2_32.json | 0 2 files changed, 339 insertions(+) create mode 100644 DamageReport_2_33.json rename DamageReport_2_32.json => versions/DamageReport_2_32.json (100%) diff --git a/DamageReport_2_33.json b/DamageReport_2_33.json new file mode 100644 index 0000000..a3e77dc --- /dev/null +++ b/DamageReport_2_33.json @@ -0,0 +1,339 @@ +{ + "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/DamageReport_2_32.json b/versions/DamageReport_2_32.json similarity index 100% rename from DamageReport_2_32.json rename to versions/DamageReport_2_32.json