diff --git a/DamageReport_3_2.conf b/DamageReport_3_2.conf new file mode 100644 index 0000000..1341042 --- /dev/null +++ b/DamageReport_3_2.conf @@ -0,0 +1 @@ +{"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":"--[[\n Damage Report 3.2\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 Bayouking1 and kalazzerx for managing their forks of this script during my long absence to support the community. :)\n Thanks to Bayouking1 for fixing rocket fuel calculations.\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\nfunction GenerateCommaValue(a, b, c)\n b = b or false;\n c = c or 1;\n local d = a;\n if b == true then\n if string.len(a) >= 4 then\n d = string.format(\"%.\" .. c .. \"fk\", a / 1000)\n else\n d = string.format(\"%.\" .. c .. \"f\", a)\n end\n else\n while true do\n d, k = string.gsub(d, \"^(-?%d+)(%d%d%d)\", '%1,%2')\n if k == 0 then break end\n end\n end\n return d\nend\nfunction PrintConsole(e, f)\n f = f or false;\n if f then\n system.print(\n \"------------------------------------------------------------------------\")\n end\n system.print(e)\n if f then\n system.print(\n \"------------------------------------------------------------------------\")\n end\nend\nfunction DrawCenteredText(e)\n if screens ~= nil and #screens > 0 then\n for g = 1, #screens, 1 do screens[g].element.setCenteredText(e) end\n end\nend\nfunction ClearConsole() for g = 1, 10, 1 do PrintConsole() end end\nfunction SwitchScreens(h)\n h = h or \"on\"\n if screens ~= nil and #screens > 0 then\n for g = 1, #screens, 1 do\n if h == \"on\" then\n screens[g].element.clear()\n screens[g].element.activate()\n screens[g].active = true\n else\n screens[g].element.clear()\n screens[g].element.deactivate()\n screens[g].active = false\n end\n end\n end\nend\nfunction GetSecondsString(i)\n local i = tonumber(i)\n if i == nil or i <= 0 then\n return \"-\"\n else\n days = string.format(\"%2.f\", math.floor(i / (3600 * 24)))\n hours = string.format(\"%2.f\", math.floor(i / 3600 - days * 24))\n mins = string.format(\"%2.f\",\n math.floor(i / 60 - hours * 60 - days * 24 * 60))\n secs = string.format(\"%2.f\", math.floor(\n i - hours * 3600 - days * 24 * 60 * 60 - mins *\n 60))\n str = \"\"\n if tonumber(days) > 0 then str = str .. days .. \"d \" end\n if tonumber(hours) > 0 then str = str .. hours .. \"h \" end\n if tonumber(mins) > 0 then str = str .. mins .. \"m \" end\n if tonumber(secs) > 0 then str = str .. secs .. \"s\" end\n return str\n end\nend\nfunction replace_char(j, str, l) return str:sub(1, j - 1) .. l .. str:sub(j + 1) end\nfunction epochTime()\n function rZ(m)\n if string.len(m) <= 1 then\n return \"0\" .. m\n else\n return m\n end\n end\n function dPoint(n)\n if not (n == math.floor(n)) then\n return true\n else\n return false\n end\n end\n function lYear(year)\n if not dPoint(year / 4) then\n if dPoint(year / 100) then\n return true\n else\n if not dPoint(year / 400) then\n return true\n else\n return false\n end\n end\n else\n return false\n end\n end\n local o = 5;\n local p = 3600;\n local q = 86400;\n local r = 31536000;\n local s = 31622400;\n local t = 2419200;\n local g = 2505600;\n local u = 2592000;\n local k = 2678400;\n local w = {4, 6, 9, 11}\n local x = {1, 3, 5, 7, 8, 10, 12}\n local y = 0;\n local z = 1506816000;\n local A = system.getTime()\n _G[\"formerTime\"] = A;\n if AddSummertimeHour == true then A = A + 3600 end\n now = math.floor(A + z)\n year = 1970;\n secs = 0;\n y = 0;\n while secs + s < now or secs + r < now do\n if lYear(year + 1) then\n if secs + s < now then\n secs = secs + s;\n year = year + 1;\n y = y + 366\n end\n else\n if secs + r < now then\n secs = secs + r;\n year = year + 1;\n y = y + 365\n end\n end\n end\n secondsRemaining = now - secs;\n monthSecs = 0;\n yearlYear = lYear(year)\n month = 1;\n while monthSecs + t < secondsRemaining or monthSecs + u < secondsRemaining or\n monthSecs + k < secondsRemaining do\n if month == 1 then\n if monthSecs + k < secondsRemaining then\n month = 2;\n monthSecs = monthSecs + k;\n y = y + 31\n else\n break\n end\n end\n if month == 2 then\n if not yearlYear then\n if monthSecs + t < secondsRemaining then\n month = 3;\n monthSecs = monthSecs + t;\n y = y + 28\n else\n break\n end\n else\n if monthSecs + g < secondsRemaining then\n month = 3;\n monthSecs = monthSecs + g;\n y = y + 29\n else\n break\n end\n end\n end\n if month == 3 then\n if monthSecs + k < secondsRemaining then\n month = 4;\n monthSecs = monthSecs + k;\n y = y + 31\n else\n break\n end\n end\n if month == 4 then\n if monthSecs + u < secondsRemaining then\n month = 5;\n monthSecs = monthSecs + u;\n y = y + 30\n else\n break\n end\n end\n if month == 5 then\n if monthSecs + k < secondsRemaining then\n month = 6;\n monthSecs = monthSecs + k;\n y = y + 31\n else\n break\n end\n end\n if month == 6 then\n if monthSecs + u < secondsRemaining then\n month = 7;\n monthSecs = monthSecs + u;\n y = y + 30\n else\n break\n end\n end\n if month == 7 then\n if monthSecs + k < secondsRemaining then\n month = 8;\n monthSecs = monthSecs + k;\n y = y + 31\n else\n break\n end\n end\n if month == 8 then\n if monthSecs + k < secondsRemaining then\n month = 9;\n monthSecs = monthSecs + k;\n y = y + 31\n else\n break\n end\n end\n if month == 9 then\n if monthSecs + u < secondsRemaining then\n month = 10;\n monthSecs = monthSecs + u;\n y = y + 30\n else\n break\n end\n end\n if month == 10 then\n if monthSecs + k < secondsRemaining then\n month = 11;\n monthSecs = monthSecs + k;\n y = y + 31\n else\n break\n end\n end\n if month == 11 then\n if monthSecs + u < secondsRemaining then\n month = 12;\n monthSecs = monthSecs + u;\n y = y + 30\n else\n break\n end\n end\n end\n day = 1;\n daySecs = 0;\n daySecsRemaining = secondsRemaining - monthSecs;\n while daySecs + q < daySecsRemaining do\n day = day + 1;\n daySecs = daySecs + q;\n y = y + 1\n end\n hour = 0;\n hourSecs = 0;\n hourSecsRemaining = daySecsRemaining - daySecs;\n while hourSecs + p < hourSecsRemaining do\n hour = hour + 1;\n hourSecs = hourSecs + p\n end\n minute = 0;\n minuteSecs = 0;\n minuteSecsRemaining = hourSecsRemaining - hourSecs;\n while minuteSecs + 60 < minuteSecsRemaining do\n minute = minute + 1;\n minuteSecs = minuteSecs + 60\n end\n second = math.floor(now % 60)\n year = rZ(year)\n month = rZ(month)\n day = rZ(day)\n hour = rZ(hour)\n minute = rZ(minute)\n second = rZ(second)\n return [[]] .. hour .. \":\" .. minute ..\n [[]] .. [[]] .. year ..\n \"/\" .. month .. \"/\" .. day .. [[]]\nend\nfunction ToggleHUD()\n if HUDMode == true then\n HUDMode = false;\n forceDamageRedraw = true;\n hudSelectedIndex = 0;\n highlightID = 0;\n HideHighlight()\n SetRefresh()\n RenderScreens()\n else\n HUDMode = true;\n forceDamageRedraw = true;\n hudSelectedIndex = 0;\n highlightID = 0;\n HideHighlight()\n SetRefresh()\n RenderScreens()\n end\nend\nfunction HudDeselectElement()\n hudSelectedIndex = 0;\n hudStartIndex = 1;\n highlightID = 0;\n HideHighlight()\n if HUDMode == true then\n SetRefresh(\"damage\")\n SetRefresh(\"damageoutline\")\n RenderScreens()\n end\nend\nfunction ChangeHudSelectedElement(B)\n if HUDMode == true and #rE > 0 then\n hudSelectedIndex = hudSelectedIndex + B;\n if hudSelectedIndex < 1 then\n hudSelectedIndex = 1\n elseif hudSelectedIndex > #rE then\n hudSelectedIndex = #rE\n end\n if hudSelectedIndex > 9 then hudStartIndex = hudSelectedIndex - 9 end\n if hudSelectedIndex ~= 0 then\n highlightID = rE[hudSelectedIndex].id;\n if highlightID ~= nil and highlightID ~= 0 then\n HideHighlight()\n elementPosition = vec3(rE[hudSelectedIndex].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 SetRefresh(\"damage\")\n SetRefresh(\"damageoutline\")\n RenderScreens()\n end\nend\nfunction HideHighlight()\n if #hudArrowSticker > 0 then\n for g in pairs(hudArrowSticker) do\n core.deleteSticker(hudArrowSticker[g])\n end\n hudArrowSticker = {}\n end\nend\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\nfunction ToggleHighlight()\n if highlightOn == true then\n highlightOn = false;\n HideHighlight()\n else\n highlightOn = true;\n ShowHighlight()\n end\nend\nfunction SortDamageTables()\n table.sort(damagedElements,\n function(m, n) return m.missinghp > n.missinghp end)\n table.sort(brokenElements, function(m, n) return m.maxhp > n.maxhp end)\nend\nfunction getScraps(C, D)\n D = D or false;\n C = C - SkillRepairToolOptimization * 0.05 * C;\n local E = math.ceil(C / (10 * 5 ^ (ScrapTier - 1)))\n if D == true then\n return GenerateCommaValue(string.format(\"%.0f\", E), false)\n else\n return E\n end\nend\nfunction getRepairTime(C, F)\n F = F or false;\n C = C - SkillRepairToolOptimization * 0.05 * C;\n local E = math.ceil(C / ScrapTierRepairTimes[ScrapTier])\n E = E - SkillRepairToolEfficiency * 0.1 * E;\n if F == true then\n return GetSecondsString(string.format(\"%.0f\", E))\n else\n return E\n end\nend\nfunction UpdateDataDamageoutline()\n dmgoElements = {}\n for g, G in ipairs(brokenElements) do\n if #dmgoElements < DMGOMaxElements then\n local elementPosition = vec3(G.pos)\n local H = elementPosition.x - coreWorldOffset;\n local I = elementPosition.y - coreWorldOffset;\n local J = elementPosition.z - coreWorldOffset;\n if H < ShipXmin then ShipXmin = H end\n if I < ShipYmin then ShipYmin = I end\n if J < ShipZmin then ShipZmin = J end\n if H > ShipXmax then ShipXmax = H end\n if I > ShipYmax then ShipYmax = I end\n if J > ShipZmax then ShipZmax = J end\n table.insert(dmgoElements, {\n id = G.id,\n type = \"b\",\n size = G.maxhp,\n x = H,\n y = I,\n z = J,\n xp = 0,\n yp = 0,\n zp = 0,\n u = 0,\n v = 0\n })\n end\n end\n if #dmgoElements < DMGOMaxElements then\n for g, G in ipairs(damagedElements) do\n if #dmgoElements < DMGOMaxElements then\n local elementPosition = vec3(G.pos)\n local H = elementPosition.x - coreWorldOffset;\n local I = elementPosition.y - coreWorldOffset;\n local J = elementPosition.z - coreWorldOffset;\n if H < ShipXmin then ShipXmin = H end\n if I < ShipYmin then ShipYmin = I end\n if J < ShipZmin then ShipZmin = J end\n if H > ShipXmax then ShipXmax = H end\n if I > ShipYmax then ShipYmax = I end\n if J > ShipZmax then ShipZmax = J end\n table.insert(dmgoElements, {\n id = G.id,\n type = \"d\",\n size = G.maxhp,\n x = H,\n y = I,\n z = J,\n xp = 0,\n yp = 0,\n zp = 0,\n u = 0,\n v = 0\n })\n end\n end\n end\n if #dmgoElements < DMGOMaxElements then\n for g, G in ipairs(healthyElements) do\n if #dmgoElements < DMGOMaxElements then\n local elementPosition = vec3(G.pos)\n local H = elementPosition.x - coreWorldOffset;\n local I = elementPosition.y - coreWorldOffset;\n local J = elementPosition.z - coreWorldOffset;\n if H < ShipXmin then ShipXmin = H end\n if I < ShipYmin then ShipYmin = I end\n if J < ShipZmin then ShipZmin = J end\n if H > ShipXmax then ShipXmax = H end\n if I > ShipYmax then ShipYmax = I end\n if J > ShipZmax then ShipZmax = J end\n table.insert(dmgoElements, {\n id = G.id,\n type = \"h\",\n size = G.maxhp,\n x = H,\n y = I,\n z = J,\n xp = 0,\n yp = 0,\n zp = 0,\n u = 0,\n v = 0\n })\n end\n end\n end\n ShipX = math.abs(ShipXmax - ShipXmin)\n ShipY = math.abs(ShipYmax - ShipYmin)\n ShipZ = math.abs(ShipZmax - ShipZmin)\n for g, G in ipairs(dmgoElements) do\n dmgoElements[g].xp = math.abs(100 / (ShipXmax - ShipXmin) *\n (G.x - ShipXmin))\n dmgoElements[g].yp = math.abs(100 / (ShipYmax - ShipYmin) *\n (G.y - ShipYmin))\n dmgoElements[g].zp = math.abs(100 / (ShipZmax - ShipZmin) *\n (G.z - ShipZmin))\n end\nend\nfunction UpdateViewDamageoutline(K)\n UFrame = 40;\n VFrame = 40;\n UStart = 20 + UFrame;\n VStart = 180 + VFrame;\n UDim = 1880 - 2 * UFrame;\n VDim = 840 - 2 * VFrame;\n if K.submode == \"top\" then\n if DMGOStretch == false then\n local L = UDim / (ShipYmax - ShipYmin)\n local M = VDim / (ShipXmax - ShipXmin)\n if L >= M then\n local N = L / M;\n local O = math.floor(UDim / N)\n UStart = UStart + (UDim - O) / 2;\n for g, G in ipairs(dmgoElements) do\n dmgoElements[g].u = math.floor(\n UDim / 100 / N * G.yp + UStart)\n dmgoElements[g].v = math.floor(VDim / 100 * G.xp + VStart)\n end\n else\n local N = M / L;\n local P = math.floor(VDim / N)\n VStart = VStart + (VDim - P) / 2;\n for g, G in ipairs(dmgoElements) do\n dmgoElements[g].u = math.floor(UDim / 100 * G.yp + UStart)\n dmgoElements[g].v = math.floor(\n VDim / 100 / N * G.xp + VStart)\n end\n end\n else\n for g, G in ipairs(dmgoElements) do\n dmgoElements[g].u = math.floor(UDim / 100 * G.yp + UStart)\n dmgoElements[g].v = math.floor(VDim / 100 * G.xp + VStart)\n end\n end\n elseif K.submode == \"front\" then\n if DMGOStretch == false then\n local L = UDim / (ShipXmax - ShipXmin)\n local M = VDim / (ShipZmax - ShipZmin)\n if L >= M then\n local N = L / M;\n local O = math.floor(UDim / N)\n UStart = UStart + (UDim - O) / 2;\n for g, G in ipairs(dmgoElements) do\n dmgoElements[g].u = math.floor(\n UDim / 100 / N * G.xp + UStart)\n dmgoElements[g].v = math.floor(\n VDim / 100 * (100 - G.zp) + VStart)\n end\n else\n local N = M / L;\n local P = math.floor(VDim / N)\n VStart = VStart + (VDim - P) / 2;\n for g, G in ipairs(dmgoElements) do\n dmgoElements[g].u = math.floor(UDim / 100 * G.xp + UStart)\n dmgoElements[g].v = math.floor(\n VDim / 100 / N * (100 - G.zp) +\n VStart)\n end\n end\n else\n for g, G in ipairs(dmgoElements) do\n dmgoElements[g].u = math.floor(UDim / 100 * G.xp + UStart)\n dmgoElements[g].v = math.floor(\n VDim / 100 * (100 - G.zp) + VStart)\n end\n end\n elseif K.submode == \"side\" then\n if DMGOStretch == false then\n local L = UDim / (ShipYmax - ShipYmin)\n local M = VDim / (ShipXmax - ShipZmin)\n if L >= M then\n local N = L / M;\n local O = math.floor(UDim / N)\n UStart = UStart + (UDim - O) / 2;\n for g, G in ipairs(dmgoElements) do\n dmgoElements[g].u = math.floor(\n UDim / 100 / N * G.yp + UStart)\n dmgoElements[g].v = math.floor(\n VDim / 100 * (100 - G.zp) + VStart)\n end\n else\n local N = M / L;\n local P = math.floor(VDim / N)\n VStart = VStart + (VDim - P) / 2;\n for g, G in ipairs(dmgoElements) do\n dmgoElements[g].u = math.floor(UDim / 100 * G.yp + UStart)\n dmgoElements[g].v = math.floor(\n VDim / 100 / N * (100 - G.zp) +\n VStart)\n end\n end\n else\n for g, G in ipairs(dmgoElements) do\n dmgoElements[g].u = math.floor(UDim / 100 * G.yp + UStart)\n dmgoElements[g].v = math.floor(\n VDim / 100 * (100 - G.zp) + VStart)\n end\n end\n else\n DrawCenteredText(\"ERROR: non-existing DMGO mode set.\")\n PrintConsole(\"ERROR: non-existing DMGO mode set.\")\n unit.exit()\n end\nend\nfunction GetDamageoutlineShip()\n local e = \"\"\n for g, G in ipairs(dmgoElements) do\n local Q = \"\"\n local R = 1;\n if G.type == \"h\" then\n Q = \"ch\"\n elseif G.type == \"d\" then\n Q = \"cw\"\n else\n Q = \"cc\"\n end\n if G.id == highlightID then Q = \"f2\" end\n if G.size > 0 and G.size < 1000 then\n R = 5\n elseif G.size >= 1000 and G.size < 2000 then\n R = 8\n elseif G.size >= 2000 and G.size < 5000 then\n R = 12\n elseif G.size >= 5000 and G.size < 10000 then\n R = 15\n elseif G.size >= 10000 and G.size < 20000 then\n R = 20\n elseif G.size >= 20000 then\n R = 30\n end\n e = e .. [[]]\n if G.id == highlightID then\n e =\n e .. [[]]\n e =\n e .. [[]]\n end\n end\n return e\nend\nfunction GetContentClickareas(K)\n local e = \"\"\n if K ~= nil and K.ClickAreas ~= nil and #K.ClickAreas > 0 then\n for g, S in ipairs(K.ClickAreas) do\n e =\n e .. [[]]\n end\n end\n return e\nend\nfunction GetElement1(H, I, T, U)\n H = H or 0;\n I = I or 0;\n T = T or 600;\n U = U or 600;\n local e = \"\"\n e = e .. [[\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ]]\n return e\nend\nfunction GetElement2(H, I)\n H = H or 0;\n I = I or 0;\n local e = \"\"\n e = e .. [[]]\n return e\nend\nfunction GetElementLogo(H, I, V, W, X)\n H = H or 812;\n I = I or 380;\n V = V or \"f\"\n W = W or \"f2\"\n X = X or \"f3\"\n local e = \"\"\n 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 ]]\n return e\nend\nfunction GetHeader(Y)\n Y = Y or \"ERROR: UNDEFINED\"\n local e = \"\"\n e = e ..\n [[\n ]] .. Y .. [[]]\n return e\nend\nfunction GetContentBackground(Z, _)\n bgColor = ColorBackgroundPattern;\n local e = \"\"\n if Z == \"dots\" then\n e =\n [[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]] ..\n bgColor .. [[' fill-opacity=']] .. BackgroundModeOpacity ..\n [[' d='M1 3h1v1H1V3zm2-2h1v1H3V1z'%3E%3C/path%3E%3C/svg%3E\");]]\n elseif Z == \"rain\" then\n e =\n [[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]] ..\n bgColor .. [[' fill-opacity=']] .. BackgroundModeOpacity ..\n [[' fill-rule='evenodd'/%3E%3C/svg%3E\");]]\n elseif Z == \"plus\" then\n e =\n [[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]] ..\n bgColor .. [[' fill-opacity=']] .. BackgroundModeOpacity ..\n [['%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\");]]\n elseif Z == \"signal\" then\n e =\n [[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]] ..\n bgColor .. [[' fill-opacity=']] .. BackgroundModeOpacity ..\n [[' fill-rule='evenodd'/%3E%3C/svg%3E\");]]\n elseif Z == \"deathstar\" then\n e =\n [[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]] ..\n bgColor .. [[' fill-opacity=']] .. BackgroundModeOpacity ..\n [['%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\");]]\n elseif Z == \"diamond\" then\n e =\n [[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]] ..\n bgColor .. [[' fill-opacity=']] .. BackgroundModeOpacity ..\n [['%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\");]]\n elseif Z == \"hexagon\" then\n e =\n [[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]] ..\n bgColor .. [[' fill-opacity=']] .. BackgroundModeOpacity ..\n [[' 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\");]]\n elseif Z == \"capsule\" then\n e =\n [[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]] ..\n bgColor .. [[' fill-opacity=']] .. BackgroundModeOpacity ..\n [[' fill-rule='evenodd'/%3E%3C/svg%3E\");]]\n elseif Z == \"diagonal\" then\n e =\n [[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]] ..\n bgColor .. [[' fill-opacity=']] .. BackgroundModeOpacity ..\n [[' fill-rule='evenodd'%3E%3Cpath d='M5 0h1L0 6V5zM6 5v1H5z'/%3E%3C/g%3E%3C/svg%3E\");]]\n end\n return e\nend\nfunction GetContentDamageHUDOutput()\n local a0 = 300;\n local a1 = 165;\n if #damagedElements > 0 or #brokenElements > 0 then a1 = 510 end\n local e = \"\"\n e =\n e .. [[\n \n ]]\n e = e .. [[]] ..\n [[]] ..\n [[]] ..\n [[]] ..\n (YourShipsName == \"Enter here\" and \"Ship ID \" .. ShipID or\n YourShipsName) .. [[]] ..\n [[]]\n if #brokenElements > 0 then\n e = e ..\n [[]]\n elseif #damagedElements > 0 then\n e = e ..\n [[]]\n else\n e = e ..\n [[]]\n end\n if #damagedElements > 0 or #brokenElements > 0 then\n e = e .. [[Total Damage]] ..\n [[]] ..\n GenerateCommaValue(string.format(\"%.0f\",\n totalShipMaxHP - totalShipHP)) ..\n [[]]\n e = e .. [[T]] .. ScrapTier ..\n [[ Scrap Needed]] ..\n [[]] ..\n getScraps(totalShipMaxHP - totalShipHP, true) .. [[]]\n e = e .. [[Repair Time]] ..\n [[]] ..\n getRepairTime(totalShipMaxHP - totalShipHP, true) .. [[]]\n e = e ..\n [[]] ..\n [[]] ..\n [[]] .. #healthyElements ..\n [[]] .. [[]] ..\n [[]] .. #damagedElements ..\n [[]] .. [[]] ..\n [[]] .. #brokenElements ..\n [[]]\n local u = 0;\n for a2 = hudStartIndex, hudStartIndex + 9, 1 do\n if rE[a2] ~= nil then\n v = rE[a2]\n if v.hp > 0 then\n e = e .. [[]] .. [[]] ..\n string.format(\"%.30s\", v.name) .. [[]] ..\n [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", v.missinghp)) ..\n [[]]\n if v.id == highlightID then\n e = e .. [[]] .. [[]] ..\n string.format(\"%.30s\", v.name) .. [[]] ..\n [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", v.missinghp)) ..\n [[]]\n end\n else\n e = e .. [[]] ..\n [[]] ..\n string.format(\"%.30s\", v.name) .. [[]] ..\n [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", v.missinghp)) ..\n [[]]\n if v.id == highlightID then\n highlightX = elementPosition.x - coreWorldOffset;\n highlightY = elementPosition.y - coreWorldOffset;\n highlightZ = elementPosition.z - coreWorldOffset;\n e = e .. [[]] ..\n [[]] ..\n string.format(\"%.30s\", v.name) .. [[]] ..\n [[]] ..\n GenerateCommaValue(\n string.format(\"%.0f\", v.missinghp)) ..\n [[]]\n end\n end\n u = u + 1\n end\n end\n if DisallowKeyPresses == true then\n e = e .. [[]] ..\n [[]] ..\n [[]] ..\n [[]] ..\n [[]] ..\n [[]] ..\n [[Keypresses disabled.]] ..\n [[Change in LUA parameters]] ..\n [[by unchecking DisallowKeyPresses.]] ..\n [[]] .. [[]] ..\n [[]]\n else\n e = e .. [[]] ..\n [[]] ..\n [[]] ..\n [[]] ..\n [[Up/down arrows to highlight]] ..\n [[CTRL + arrows to move HUD]] ..\n [[Left arrow to toggle HUD Mode]] ..\n [[ALT+1-4 to set Scrap Tier]] ..\n [[ALT+8 to reset HUD position]] ..\n [[ALT+9 to shut script off]] ..\n [[]] .. [[]]\n end\n else\n if DisallowKeyPresses == true then\n e = e .. [[]] .. OkayCenterMessage .. [[]] ..\n [[]] .. #healthyElements ..\n [[ elements / ]] ..\n GenerateCommaValue(string.format(\"%.0f\", totalShipMaxHP)) ..\n [[ HP.]] .. [[]] ..\n [[]] ..\n [[]] ..\n [[]] ..\n [[Keypresses disabled.]] ..\n [[Change in LUA parameters]] ..\n [[by unchecking DisallowKeyPresses.]] ..\n [[]] .. [[]] ..\n [[]]\n else\n e = e .. [[]] .. OkayCenterMessage .. [[]] ..\n [[]] .. #healthyElements ..\n [[ elements / ]] ..\n GenerateCommaValue(string.format(\"%.0f\", totalShipMaxHP)) ..\n [[ HP.]] .. [[]] ..\n [[]] ..\n [[]] ..\n [[]] ..\n [[Left arrow to toggle HUD Mode]] ..\n [[CTRL + arrows to move HUD]] ..\n [[ALT+8 to reset HUD position]] ..\n [[ALT+9 to shut script off]] ..\n [[]] .. [[]]\n end\n end\n e = e .. [[]]\n return e\nend\nfunction GetContentDamageScreen()\n local a3 = \"\"\n if #damagedElements > 0 then\n local a4 = #damagedElements;\n if a4 > DamagePageSize then a4 = DamagePageSize end\n if CurrentDamagedPage == math.ceil(#damagedElements / DamagePageSize) then\n a4 = #damagedElements % DamagePageSize + 12;\n if a4 > 12 then a4 = a4 - 12 end\n end\n a3 =\n a3 .. [[]]\n a3 = a3 ..\n [[]]\n if UseMyElementNames == true then\n a3 = a3 ..\n [[Damaged Name]]\n else\n a3 = a3 ..\n [[Damaged Type]]\n end\n a3 = a3 ..\n [[HLTHDMG]]\n a3 = a3 .. [[T]] .. ScrapTier ..\n [[ SCRREPTIME]]\n AddClickArea(\"damage\", {\n id = \"SwitchScrapTier\",\n mode = \"damage\",\n x1 = 650,\n x2 = 775,\n y1 = 315,\n y2 = 360\n })\n local g = 0;\n for u = 1 + (CurrentDamagedPage - 1) * DamagePageSize, a4 +\n (CurrentDamagedPage - 1) * DamagePageSize, 1 do\n g = g + 1;\n local a5 = damagedElements[u]\n if UseMyElementNames == true then\n a3 = a3 .. [[]] ..\n string.format(\"%.23s\", a5.name) .. [[]]\n else\n a3 = a3 .. [[]] ..\n string.format(\"%.23s\", a5.type) .. [[]]\n end\n a3 = a3 .. [[]] .. a5.percent .. [[%]] ..\n [[]] ..\n GenerateCommaValue(string.format(\"%.0f\", a5.missinghp),\n true) .. [[]] ..\n [[]] .. getScraps(a5.missinghp, true) ..\n [[]] .. [[]] .. getRepairTime(a5.missinghp, true) ..\n [[]] .. [[]]\n end\n if #damagedElements > DamagePageSize then\n a3 = a3 .. [[Page ]] .. CurrentDamagedPage .. \" of \" ..\n math.ceil(#damagedElements / DamagePageSize) .. [[]]\n if CurrentDamagedPage < math.ceil(#damagedElements / DamagePageSize) then\n a3 = a3 .. [[\n \n \n ]]\n AddClickArea(\"damage\", {\n id = \"DamagedPageDown\",\n mode = \"damage\",\n x1 = 65,\n x2 = 260,\n y1 = 290 + (a4 + 1) * 50,\n y2 = 290 + 50 + (a4 + 1) * 50\n })\n else\n DisableClickArea(\"DamagedPageDown\", \"damage\")\n end\n if CurrentDamagedPage > 1 then\n a3 = a3 .. [[\n \n \n ]]\n AddClickArea(\"damage\", {\n id = \"DamagedPageUp\",\n mode = \"damage\",\n x1 = 750,\n x2 = 950,\n y1 = 290 + (a4 + 1) * 50,\n y2 = 290 + 50 + (a4 + 1) * 50\n })\n else\n DisableClickArea(\"DamagedPageUp\", \"damage\")\n end\n end\n end\n if #brokenElements > 0 then\n local a6 = #brokenElements;\n if a6 > DamagePageSize then a6 = DamagePageSize end\n if CurrentBrokenPage == math.ceil(#brokenElements / DamagePageSize) then\n a6 = #brokenElements % DamagePageSize + 12;\n if a6 > 12 then a6 = a6 - 12 end\n end\n a3 =\n a3 .. [[]]\n a3 = a3 ..\n [[]]\n if UseMyElementNames == true then\n a3 = a3 ..\n [[Broken Name]]\n else\n a3 = a3 ..\n [[Broken Type]]\n end\n a3 = a3 .. [[DMG]]\n a3 = a3 .. [[T]] .. ScrapTier ..\n [[ SCRREPTIME]]\n AddClickArea(\"damage\", {\n id = \"SwitchScrapTier2\",\n mode = \"damage\",\n x1 = 1570,\n x2 = 1690,\n y1 = 315,\n y2 = 360\n })\n local g = 0;\n for u = 1 + (CurrentBrokenPage - 1) * DamagePageSize, a6 +\n (CurrentBrokenPage - 1) * DamagePageSize, 1 do\n g = g + 1;\n local a5 = brokenElements[u]\n if UseMyElementNames == true then\n a3 = a3 .. [[]] ..\n string.format(\"%.30s\", a5.name) .. [[]]\n else\n a3 = a3 .. [[]] ..\n string.format(\"%.30s\", a5.type) .. [[]]\n end\n a3 = a3 .. [[]] ..\n GenerateCommaValue(string.format(\"%.0f\", a5.missinghp),\n true) .. [[]] ..\n [[]] .. getScraps(a5.missinghp, true) ..\n [[]] .. [[]] .. getRepairTime(a5.missinghp, true) ..\n [[]] .. [[]]\n end\n if #brokenElements > DamagePageSize then\n a3 =\n a3 .. [[Page ]] .. CurrentBrokenPage .. \" of \" ..\n math.ceil(#brokenElements / DamagePageSize) .. [[]]\n if CurrentBrokenPage > 1 then\n a3 = a3 .. [[\n \n \n ]]\n AddClickArea(\"damage\", {\n id = \"BrokenPageUp\",\n mode = \"damage\",\n x1 = 1665,\n x2 = 1865,\n y1 = 290 + (a6 + 1) * 50,\n y2 = 290 + 50 + (a6 + 1) * 50\n })\n else\n DisableClickArea(\"BrokenPageUp\", \"damage\")\n end\n if CurrentBrokenPage < math.ceil(#brokenElements / DamagePageSize) then\n a3 = a3 .. [[\n \n \n ]]\n AddClickArea(\"damage\", {\n id = \"BrokenPageDown\",\n mode = \"damage\",\n x1 = 980,\n x2 = 1180,\n y1 = 290 + (a6 + 1) * 50,\n y2 = 290 + 50 + (a6 + 1) * 50\n })\n else\n DisableClickArea(\"BrokenPageDown\", \"damage\")\n end\n end\n end\n if #damagedElements > 0 or #brokenElements > 0 then\n local a7 = math.floor(1878 / #elementsIdList * #damagedElements)\n local a8 = math.floor(1878 / #elementsIdList * #brokenElements)\n local a9 = 1878 - a7 - a8 + 1;\n a3 = a3 ..\n [[]]\n a3 = a3 .. [[]]\n a3 = a3 .. [[]]\n a3 = a3 .. [[]]\n if #damagedElements > 0 then\n a3 = a3 .. [[]] .. #damagedElements .. [[]]\n end\n if #healthyElements > 0 then\n a3 = a3 .. [[]] .. #healthyElements .. [[]]\n end\n if #brokenElements > 0 then\n a3 = a3 .. [[]] .. #brokenElements .. [[]]\n end\n a3 = a3 ..\n [[]]\n a3 = a3 .. [[]] ..\n GenerateCommaValue(string.format(\"%.0f\",\n totalShipMaxHP - totalShipHP)) ..\n [[ HP damage in total ]] ..\n getScraps(totalShipMaxHP - totalShipHP, true) .. [[ T]] ..\n ScrapTier .. [[ scraps needed. ]] ..\n getRepairTime(totalShipMaxHP - totalShipHP, true) ..\n [[ projected repair time.]]\n else\n a3 = a3 .. GetElementLogo(812, 380, \"ch\", \"ch\", \"ch\") ..\n [[]] .. OkayCenterMessage .. [[]] ..\n [[]] .. #healthyElements .. [[ elements stand ]] ..\n GenerateCommaValue(string.format(\"%.0f\", totalShipMaxHP)) ..\n [[ HP strong.]]\n end\n forceDamageRedraw = false;\n return a3\nend\nfunction ActionStopengines()\n if DisallowKeyPresses == true then return end\n ToggleHUD()\nend\nfunction ActionStrafeRight()\n if DisallowKeyPresses == true then return end\n if KeyCTRLPressed == true then\n if HUDShiftU < 4000 then\n HUDShiftU = HUDShiftU + 50;\n SaveToDatabank()\n RenderScreens()\n end\n else\n HudDeselectElement()\n end\nend\nfunction ActionStrafeLeft()\n if DisallowKeyPresses == true then return end\n if KeyCTRLPressed == true then\n if HUDShiftU >= 50 then\n HUDShiftU = HUDShiftU - 50;\n SaveToDatabank()\n RenderScreens()\n end\n else\n ToggleHUD()\n end\nend\nfunction ActionDown()\n if DisallowKeyPresses == true then return end\n if KeyCTRLPressed == true then\n if HUDShiftV < 4000 then\n HUDShiftV = HUDShiftV + 50;\n SaveToDatabank()\n RenderScreens()\n end\n else\n ChangeHudSelectedElement(1)\n end\nend\nfunction ActionUp()\n if DisallowKeyPresses == true then return end\n if KeyCTRLPressed == true then\n if HUDShiftV >= 50 then\n HUDShiftV = HUDShiftV - 50;\n SaveToDatabank()\n RenderScreens()\n end\n else\n ChangeHudSelectedElement(-1)\n end\nend\nfunction ActionOption1()\n if DisallowKeyPresses == true then return end\n ScrapTier = 1;\n SetRefresh(\"damage\")\n RenderScreens(\"damage\")\nend\nfunction ActionOption2()\n if DisallowKeyPresses == true then return end\n ScrapTier = 2;\n SetRefresh(\"damage\")\n RenderScreens(\"damage\")\nend\nfunction ActionOption3()\n if DisallowKeyPresses == true then return end\n ScrapTier = 3;\n SetRefresh(\"damage\")\n RenderScreens(\"damage\")\nend\nfunction ActionOption4()\n if DisallowKeyPresses == true then return end\n ScrapTier = 4;\n SetRefresh(\"damage\")\n RenderScreens(\"damage\")\nend\nfunction ActionOption8()\n if DisallowKeyPresses == true then return end\n HUDShiftU = 0;\n HUDShiftV = 0;\n SetRefresh(\"damage\")\n RenderScreens(\"damage\")\nend\nfunction ActionOption9()\n if DisallowKeyPresses == true then return end\n SaveToDatabank()\n SwitchScreens(\"off\")\n unit.exit()\nend\n","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.2\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 Bayouking1 and kalazzerx for managing their forks of this script during my long absence to support the community. :)\n Thanks to Bayouking1 for fixing rocket fuel calculations.\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 ]] 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.\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 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;\nHighlightBlinkingInterval = 0.5;\nColorPrimary = \"FF6700\"\nColorSecondary = \"FFFFFF\"\nColorTertiary = \"000000\"\nColorHealthy = \"00FF00\"\nColorWarning = \"FFFF00\"\nColorCritical = \"FF0000\"\nColorBackground = \"000000\"\nColorBackgroundPattern = \"4F4F4F\"\nColorFuelAtmospheric = \"004444\"\nColorFuelSpace = \"444400\"\nColorFuelRocket = \"440044\"\nVERSION = 3.2;\nDebugMode = false;\nDebugRenderClickareas = true;\nDBData = {}\ncore = nil;\ndb = nil;\nscreens = {}\ndscreens = {}\nWarnings = {}\nscreenModes = {\n [\"flight\"] = {id = \"flight\"},\n [\"damage\"] = {id = \"damage\"},\n [\"damageoutline\"] = {id = \"damageoutline\"},\n [\"fuel\"] = {id = \"fuel\"},\n [\"cargo\"] = {id = \"cargo\"},\n [\"agg\"] = {id = \"agg\"},\n [\"map\"] = {id = \"map\"},\n [\"time\"] = {id = \"time\", activetoggle = \"true\"},\n [\"settings1\"] = {id = \"settings1\"},\n [\"startup\"] = {id = \"startup\"}\n}\nbackgroundModes = {\n \"deathstar\", \"capsule\", \"rain\", \"signal\", \"hexagon\", \"diagonal\", \"diamond\",\n \"plus\", \"dots\"\n}\nBackgroundMode = \"deathstar\"\nBackgroundSelected = 1;\nBackgroundModeOpacity = 0.25;\nSaveVars = {\n \"dscreens\", \"ColorPrimary\", \"ColorSecondary\", \"ColorTertiary\",\n \"ColorHealthy\", \"ColorWarning\", \"ColorCritical\", \"ColorBackground\",\n \"ColorBackgroundPattern\", \"ColorFuelAtmospheric\", \"ColorFuelSpace\",\n \"ColorFuelRocket\", \"ScrapTier\", \"HUDMode\", \"SimulationMode\", \"DMGOStretch\",\n \"HUDShiftU\", \"HUDShiftV\", \"colorIDIndex\", \"colorIDTable\", \"BackgroundMode\",\n \"BackgroundSelected\", \"BackgroundModeOpacity\"\n}\nHUDMode = false;\nHUDShiftU = 0;\nHUDShiftV = 0;\nhudSelectedIndex = 0;\nhudStartIndex = 1;\nhudArrowSticker = {}\nhighlightOn = false;\nhighlightID = 0;\nhighlightX = 0;\nhighlightY = 0;\nhighlightZ = 0;\nSimulationMode = false;\nOkayCenterMessage = \"All systems nominal.\"\nCurrentDamagedPage = 1;\nCurrentBrokenPage = 1;\nDamagePageSize = 12;\nScrapTier = 1;\ntotalScraps = 0;\nScrapTierRepairTimes = {10, 50, 250, 1250}\ncoreWorldOffset = 0;\ntotalShipHP = 0;\nformerTotalShipHP = -1;\ntotalShipMaxHP = 0;\ntotalShipIntegrity = 100;\nelementsId = {}\nelementsIdList = {}\ndamagedElements = {}\nbrokenElements = {}\nrE = {}\nhealthyElements = {}\ntypeElements = {}\nElementCounter = 0;\nUseMyElementNames = true;\ndmgoElements = {}\nDMGOMaxElements = 250;\nDMGOStretch = false;\nShipXmin = 99999999;\nShipXmax = -99999999;\nShipYmin = 99999999;\nShipYmax = -99999999;\nShipZmin = 99999999;\nShipZmax = -99999999;\ntotalShipMass = 0;\nformerTotalShipMass = -1;\nformerTime = -1;\nFuelAtmosphericTanks = {}\nFuelSpaceTanks = {}\nFuelRocketTanks = {}\nFuelAtmosphericTotal = 0;\nFuelSpaceTotal = 0;\nFuelRocketTotal = 0;\nFuelAtmosphericCurrent = 0;\nFuelSpaceTotalCurrent = 0;\nFuelRocketTotalCurrent = 0;\nformerFuelAtmosphericTotal = -1;\nformerFuelSpaceTotal = -1;\nformerFuelRocketTotal = -1;\nhexTable = {\n \"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"A\", \"B\", \"C\", \"D\", \"E\",\n \"F\"\n}\ncolorIDIndex = 1;\ncolorIDTable = {\n [1] = {\n id = \"ColorPrimary\",\n desc = \"Main HUD Color\",\n basec = \"FF6700\",\n newc = \"FF6700\"\n },\n [2] = {\n id = \"ColorSecondary\",\n desc = \"Secondary HUD Color\",\n basec = \"FFFFFF\",\n newc = \"FFFFFF\"\n },\n [3] = {\n id = \"ColorTertiary\",\n desc = \"Tertiary HUD Color\",\n basec = \"000000\",\n newc = \"000000\"\n },\n [4] = {\n id = \"ColorHealthy\",\n desc = \"Color code for Healthy/Okay\",\n basec = \"00FF00\",\n newc = \"00FF00\"\n },\n [5] = {\n id = \"ColorWarning\",\n desc = \"Color code for Damaged/Warning\",\n basec = \"FFFF00\",\n newc = \"FFFF00\"\n },\n [6] = {\n id = \"ColorCritical\",\n desc = \"Color code for Broken/Critical\",\n basec = \"FF0000\",\n newc = \"FF0000\"\n },\n [7] = {\n id = \"ColorBackground\",\n desc = \"Background Color\",\n basec = \"000000\",\n newc = \"000000\"\n },\n [8] = {\n id = \"ColorBackgroundPattern\",\n desc = \"Background Pattern Color\",\n basec = \"4F4F4F\",\n newc = \"4F4F4F\"\n },\n [9] = {\n id = \"ColorFuelAtmospheric\",\n desc = \"Color for Atmo Fuel/Elements\",\n basec = \"004444\",\n newc = \"004444\"\n },\n [10] = {\n id = \"ColorFuelSpace\",\n desc = \"Color for Space Fuel/Elements\",\n basec = \"444400\",\n newc = \"444400\"\n },\n [11] = {\n id = \"ColorFuelRocket\",\n desc = \"Color for Rocket Fuel/Elements\",\n basec = \"440044\",\n newc = \"440044\"\n }\n}\nfunction InitiateSlots()\n for a, b in pairs(unit) do\n if type(b) == \"table\" and type(b.export) == \"table\" and\n b.getElementClass then\n local c = b.getElementClass():lower()\n if c:find(\"coreunit\") then\n core = b;\n local d = core.getMaxHitPoints()\n if d > 10000 then\n coreWorldOffset = 128\n elseif d > 1000 then\n coreWorldOffset = 64\n elseif d > 150 then\n coreWorldOffset = 32\n else\n coreWorldOffset = 16\n end\n elseif c == 'databankunit' then\n db = b\n elseif c == \"screenunit\" then\n local e = \"startup\"\n screens[#screens + 1] = {\n element = b,\n id = b.getId(),\n mode = e,\n submode = \"\",\n ClickAreas = {},\n refresh = true,\n active = false,\n fuelA = true,\n fuelS = true,\n fuelR = true,\n fuelIndex = 1\n }\n end\n end\n end\nend\nfunction LoadFromDatabank()\n if db == nil then\n return\n else\n for f, g in pairs(SaveVars) do\n if db.hasKey(g) then\n local h = json.decode(db.getStringValue(g))\n if h ~= nil then\n if g == \"YourShipsName\" or g == \"AddSummertimeHour\" or g ==\n \"UpdateDataInterval\" or g == \"HighlightBlinkingInterval\" or\n g == \"SkillRepairToolEfficiency\" or g ==\n \"SkillRepairToolOptimization\" or g ==\n \"SkillAtmosphericFuelEfficiency\" or g ==\n \"SkillSpaceFuelEfficiency\" or g ==\n \"SkillRocketFuelEfficiency\" or g ==\n \"StatAtmosphericFuelTankHandling\" or g ==\n \"StatSpaceFuelTankHandling\" or g ==\n \"StatRocketFuelTankHandling\" then\n else\n _G[g] = h\n end\n end\n end\n end\n for i, j in ipairs(screens) do\n for k, l in ipairs(dscreens) do\n if screens[i].id == dscreens[k].id then\n screens[i].mode = dscreens[k].mode;\n screens[i].submode = dscreens[k].submode;\n screens[i].active = dscreens[k].active;\n screens[i].refresh = true;\n screens[i].fuelA = dscreens[k].fuelA;\n screens[i].fuelS = dscreens[k].fuelS;\n screens[i].fuelR = dscreens[k].fuelR;\n screens[i].fuelIndex = dscreens[k].fuelIndex\n end\n end\n end\n end\nend\nfunction SaveToDatabank()\n if db == nil then\n return\n else\n dscreens = {}\n for i, m in ipairs(screens) do\n dscreens[i] = {}\n dscreens[i].id = m.id;\n dscreens[i].mode = m.mode;\n dscreens[i].submode = m.submode;\n dscreens[i].active = m.active;\n dscreens[i].fuelA = m.fuelA;\n dscreens[i].fuelS = m.fuelS;\n dscreens[i].fuelR = m.fuelR;\n dscreens[i].fuelIndex = m.fuelIndex\n end\n db.clear()\n for f, g in pairs(SaveVars) do\n db.setStringValue(g, json.encode(_G[g]))\n end\n end\nend\nfunction InitiateScreens()\n if screens ~= nil and #screens > 0 then\n for i = 1, #screens, 1 do\n screens[i] = CreateClickAreasForScreen(screens[i])\n end\n end\nend\nfunction UpdateTypeData()\n FuelAtmosphericTanks = {}\n FuelSpaceTanks = {}\n FuelRocketTanks = {}\n FuelAtmosphericTotal = 0;\n FuelAtmosphericCurrent = 0;\n FuelSpaceTotal = 0;\n FuelSpaceCurrent = 0;\n FuelRocketCurrent = 0;\n FuelRocketTotal = 0;\n local n = 4;\n local o = 6;\n local p = 0.8;\n if StatContainerOptimization > 0 then\n n = n - 0.05 * StatContainerOptimization * n;\n o = o - 0.05 * StatContainerOptimization * o;\n p = p - 0.05 * StatContainerOptimization * p\n end\n if StatFuelTankOptimization > 0 then\n n = n - 0.05 * StatFuelTankOptimization * n;\n o = o - 0.05 * StatFuelTankOptimization * o;\n p = p - 0.05 * StatFuelTankOptimization * p\n end\n for i, q in ipairs(typeElements) do\n local r = core.getElementNameById(q) or \"\"\n local s = core.getElementTypeById(q) or \"\"\n local t = core.getElementPositionById(q) or 0;\n local u = core.getElementHitPointsById(q) or 0;\n local v = core.getElementMaxHitPointsById(q) or 0;\n local w = core.getElementMassById(q) or 0;\n local x = \"\"\n local y = 0;\n local z = 0;\n local A = 0;\n local B = 0;\n if s == \"Atmospheric Fuel Tank\" then\n if v > 10000 then\n x = \"L\"\n z = 5480;\n y = 12800\n elseif v > 1300 then\n x = \"M\"\n z = 988.67;\n y = 1600\n elseif v > 150 then\n x = \"S\"\n z = 182.67;\n y = 400\n else\n x = \"XS\"\n z = 35.03;\n y = 100\n end\n if StatAtmosphericFuelTankHandling > 0 then\n y = 0.2 * StatAtmosphericFuelTankHandling * y + y\n end\n A = w - z;\n if A <= 10 then A = 0 end\n B = string.format(\"%.0f\", A / n)\n cPercent = string.format(\"%.1f\", math.floor(100 / y * tonumber(B)))\n table.insert(FuelAtmosphericTanks, {\n type = 1,\n id = q,\n name = r,\n maxhp = v,\n hp = GetHPforElement(q),\n pos = t,\n size = x,\n mass = z,\n vol = y,\n cvol = B,\n percent = cPercent\n })\n if u > 0 then\n FuelAtmosphericCurrent = FuelAtmosphericCurrent + B\n end\n FuelAtmosphericTotal = FuelAtmosphericTotal + y\n elseif s == \"Space Fuel Tank\" then\n if v > 10000 then\n x = \"L\"\n z = 5480;\n y = 12800\n elseif v > 1300 then\n x = \"M\"\n z = 988.67;\n y = 1600\n else\n x = \"S\"\n z = 182.67;\n y = 400\n end\n if StatSpaceFuelTankHandling > 0 then\n y = 0.2 * StatSpaceFuelTankHandling * y + y\n end\n A = w - z;\n if A <= 10 then A = 0 end\n B = string.format(\"%.0f\", A / o)\n cPercent = string.format(\"%.1f\", 100 / y * tonumber(B))\n table.insert(FuelSpaceTanks, {\n type = 2,\n id = q,\n name = r,\n maxhp = v,\n hp = GetHPforElement(q),\n pos = t,\n size = x,\n mass = z,\n vol = y,\n cvol = B,\n percent = cPercent\n })\n if u > 0 then FuelSpaceCurrent = FuelSpaceCurrent + B end\n FuelSpaceTotal = FuelSpaceTotal + y\n elseif s == \"Rocket Fuel Tank\" then\n if v > 65000 then\n x = \"L\"\n z = 25740;\n y = 50000\n elseif v > 6000 then\n x = \"M\"\n z = 4720;\n y = 6400\n elseif v > 700 then\n x = \"S\"\n z = 886.72;\n y = 800\n else\n x = \"XS\"\n z = 173.42;\n y = 400\n end\n if StatRocketFuelTankHandling > 0 then\n y = 0.1 * StatRocketFuelTankHandling * y + y\n end\n A = w - z;\n if A <= 10 then A = 0 end\n B = string.format(\"%.0f\", A / p)\n cPercent = string.format(\"%.1f\", 100 / y * tonumber(B))\n table.insert(FuelRocketTanks, {\n type = 3,\n id = q,\n name = r,\n maxhp = v,\n hp = GetHPforElement(q),\n pos = t,\n size = x,\n mass = z,\n vol = y,\n cvol = B,\n percent = cPercent\n })\n if u > 0 then FuelRocketCurrent = FuelRocketCurrent + B end\n FuelRocketTotal = FuelRocketTotal + y\n end\n end\n if FuelAtmosphericCurrent ~= formerFuelAtmosphericCurrent then\n SetRefresh(\"fuel\")\n formerFuelAtmosphericCurrent = FuelAtmosphericCurrent\n end\n if FuelSpaceCurrent ~= formerFuelSpaceCurrent then\n SetRefresh(\"fuel\")\n formerFuelSpaceCurrent = FuelSpaceCurrent\n end\n if FuelRocketCurrent ~= formerFuelRocketCurrent then\n SetRefresh(\"fuel\")\n formerFuelRocketCurrent = FuelRocketCurrent\n end\nend\nfunction UpdateDamageData(C)\n C = C or false;\n if SimulationActive == true then return end\n local formerTotalShipHP = totalShipHP;\n totalShipHP = 0;\n totalShipMaxHP = 0;\n totalShipIntegrity = 100;\n damagedElements = {}\n brokenElements = {}\n healthyElements = {}\n if C == true then typeElements = {} end\n ElementCounter = 0;\n elementsIdList = core.getElementIdList()\n for i, q in pairs(elementsIdList) do\n ElementCounter = ElementCounter + 1;\n local r = core.getElementNameById(q)\n local s = core.getElementTypeById(q)\n local t = core.getElementPositionById(q)\n local u = core.getElementHitPointsById(q)\n local v = core.getElementMaxHitPointsById(q)\n if SimulationMode == true then\n SimulationActive = true;\n local D = math.random(0, 10)\n if D < 2 and #brokenElements < 30 then\n u = 0\n elseif D >= 2 and D < 4 and #damagedElements < 30 then\n u = math.random(1, math.ceil(v))\n else\n u = v\n end\n end\n totalShipHP = totalShipHP + u;\n totalShipMaxHP = totalShipMaxHP + v;\n if v - u > constants.epsilon then\n if u > 0 then\n table.insert(damagedElements, {\n id = q,\n name = r,\n type = s,\n counter = ElementCounter,\n hp = u,\n maxhp = v,\n missinghp = v - u,\n percent = math.ceil(100 / v * u),\n pos = t\n })\n else\n table.insert(brokenElements, {\n id = q,\n name = r,\n type = s,\n counter = ElementCounter,\n hp = u,\n maxhp = v,\n missinghp = v - u,\n percent = 0,\n pos = t\n })\n end\n else\n table.insert(healthyElements, {\n id = q,\n name = r,\n type = s,\n counter = ElementCounter,\n hp = u,\n maxhp = v,\n pos = t\n })\n if q == highlightID then\n highlightID = 0;\n highlightOn = false;\n HideHighlight()\n hudSelectedIndex = 0\n end\n end\n if C == true then\n if s == \"Atmospheric Fuel Tank\" or s == \"Space Fuel Tank\" or s ==\n \"Rocket Fuel Tank\" then table.insert(typeElements, q) end\n end\n end\n SortDamageTables()\n rE = {}\n if #brokenElements > 0 then\n for f, j in ipairs(brokenElements) do\n table.insert(rE, {\n id = j.id,\n missinghp = j.missinghp,\n hp = j.hp,\n name = j.name,\n type = j.type,\n pos = j.pos\n })\n end\n end\n if #damagedElements > 0 then\n for f, j in ipairs(damagedElements) do\n table.insert(rE, {\n id = j.id,\n missinghp = j.missinghp,\n hp = j.hp,\n name = j.name,\n type = j.type,\n pos = j.pos\n })\n end\n end\n if #rE > 0 then\n table.sort(rE, function(E, F) return E.missinghp > F.missinghp end)\n end\n totalShipIntegrity = string.format(\"%2.0f\",\n 100 / totalShipMaxHP * totalShipHP)\n if formerTotalShipHP ~= totalShipHP then\n forceDamageRedraw = true;\n formerTotalShipHP = totalShipHP\n else\n forceDamageRedraw = false\n end\nend\nfunction GetHPforElement(q)\n for i, j in ipairs(brokenElements) do if j.id == q then return 0 end end\n for i, j in ipairs(damagedElements) do if j.id == q then return j.hp end end\n for i, j in ipairs(healthyElements) do\n if j.id == q then return j.maxhp end\n end\nend\nfunction UpdateClickArea(G, H, I)\n for i, m in ipairs(screens) do\n for J, j in pairs(screens[i].ClickAreas) do\n if j.id == G and j.mode == I then\n screens[i].ClickAreas[J] = H\n end\n end\n end\nend\nfunction AddClickArea(I, H)\n for i, m in ipairs(screens) do\n if screens[i].mode == I then\n table.insert(screens[i].ClickAreas, H)\n end\n end\nend\nfunction AddClickAreaForScreenID(K, H)\n for i, m in ipairs(screens) do\n if screens[i].id == K then table.insert(screens[i].ClickAreas, H) end\n end\nend\nfunction DisableClickArea(G, I)\n UpdateClickArea(G, {id = G, mode = I, x1 = -1, x2 = -1, y1 = -1, y2 = -1})\nend\nfunction SetRefresh(I, L)\n I = I or \"all\"\n L = L or \"all\"\n if screens ~= nil and #screens > 0 then\n for i = 1, #screens, 1 do\n if screens[i].mode == I or I == \"all\" then\n if screens[i].submode == L or L == \"all\" then\n screens[i].refresh = true\n end\n end\n end\n end\nend\nfunction WipeClickAreasForScreen(m)\n m.ClickAreas = {}\n return m\nend\nfunction CreateBaseClickAreas(m)\n table.insert(m.ClickAreas, {\n mode = \"all\",\n id = \"ToggleHudMode\",\n x1 = 1537,\n x2 = 1728,\n y1 = 1015,\n y2 = 1075\n })\n table.insert(m.ClickAreas, {\n mode = \"all\",\n id = \"ButtonPress\",\n param = \"damage\",\n x1 = 193,\n x2 = 384,\n y1 = 1015,\n y2 = 1075\n })\n table.insert(m.ClickAreas, {\n mode = \"all\",\n id = \"ButtonPress\",\n param = \"damageoutline\",\n x1 = 385,\n x2 = 576,\n y1 = 1015,\n y2 = 1075\n })\n table.insert(m.ClickAreas, {\n mode = \"all\",\n id = \"ButtonPress\",\n param = \"fuel\",\n x1 = 577,\n x2 = 768,\n y1 = 1015,\n y2 = 1075\n })\n table.insert(m.ClickAreas, {\n mode = \"all\",\n id = \"ButtonPress\",\n param = \"time\",\n x1 = 0,\n x2 = 192,\n y1 = 1015,\n y2 = 1075\n })\n table.insert(m.ClickAreas, {\n mode = \"all\",\n id = \"ButtonPress\",\n param = \"settings1\",\n x1 = 1729,\n x2 = 1920,\n y1 = 1015,\n y2 = 1075\n })\n return m\nend\nfunction CreateClickAreasForScreen(m)\n if m == nil then return {} end\n if m.mode == \"flight\" then\n elseif m.mode == \"damage\" then\n table.insert(m.ClickAreas, {\n mode = \"damage\",\n id = \"ToggleElementLabel\",\n x1 = 70,\n x2 = 425,\n y1 = 325,\n y2 = 355\n })\n table.insert(m.ClickAreas, {\n mode = \"damage\",\n id = \"ToggleElementLabel2\",\n x1 = 980,\n x2 = 1400,\n y1 = 325,\n y2 = 355\n })\n elseif m.mode == \"damageoutline\" then\n table.insert(m.ClickAreas, {\n mode = \"damageoutline\",\n id = \"DMGOChangeView\",\n param = \"top\",\n x1 = 60,\n x2 = 439,\n y1 = 150,\n y2 = 200\n })\n table.insert(m.ClickAreas, {\n mode = \"damageoutline\",\n id = \"DMGOChangeView\",\n param = \"side\",\n x1 = 440,\n x2 = 824,\n y1 = 150,\n y2 = 200\n })\n table.insert(m.ClickAreas, {\n mode = \"damageoutline\",\n id = \"DMGOChangeView\",\n param = \"front\",\n x1 = 825,\n x2 = 1215,\n y1 = 150,\n y2 = 200\n })\n table.insert(m.ClickAreas, {\n mode = \"damageoutline\",\n id = \"DMGOChangeStretch\",\n x1 = 1530,\n x2 = 1580,\n y1 = 150,\n y2 = 200\n })\n elseif m.mode == \"fuel\" then\n elseif m.mode == \"cargo\" then\n elseif m.mode == \"agg\" then\n elseif m.mode == \"map\" then\n elseif m.mode == \"time\" then\n elseif m.mode == \"settings1\" then\n table.insert(m.ClickAreas, {\n mode = \"settings1\",\n id = \"ToggleBackground\",\n x1 = 75,\n x2 = 860,\n y1 = 170,\n y2 = 215\n })\n table.insert(m.ClickAreas, {\n mode = \"settings1\",\n id = \"PreviousBackground\",\n x1 = 75,\n x2 = 460,\n y1 = 235,\n y2 = 285\n })\n table.insert(m.ClickAreas, {\n mode = \"settings1\",\n id = \"NextBackground\",\n x1 = 480,\n x2 = 860,\n y1 = 235,\n y2 = 285\n })\n table.insert(m.ClickAreas, {\n mode = \"settings1\",\n id = \"DecreaseOpacity\",\n x1 = 75,\n x2 = 460,\n y1 = 300,\n y2 = 350\n })\n table.insert(m.ClickAreas, {\n mode = \"settings1\",\n id = \"IncreaseOpacity\",\n x1 = 480,\n x2 = 860,\n y1 = 300,\n y2 = 350\n })\n table.insert(m.ClickAreas, {\n mode = \"settings1\",\n id = \"ResetColors\",\n x1 = 75,\n x2 = 860,\n y1 = 370,\n y2 = 415\n })\n table.insert(m.ClickAreas, {\n mode = \"settings1\",\n id = \"PreviousColorID\",\n x1 = 90,\n x2 = 140,\n y1 = 500,\n y2 = 550\n })\n table.insert(m.ClickAreas, {\n mode = \"settings1\",\n id = \"NextColorID\",\n x1 = 795,\n x2 = 845,\n y1 = 500,\n y2 = 550\n })\n table.insert(m.ClickAreas, {\n mode = \"settings1\",\n id = \"ColorPosUp\",\n param = \"1\",\n x1 = 210,\n x2 = 290,\n y1 = 655,\n y2 = 700\n })\n table.insert(m.ClickAreas, {\n mode = \"settings1\",\n id = \"ColorPosUp\",\n param = \"2\",\n x1 = 300,\n x2 = 380,\n y1 = 655,\n y2 = 700\n })\n table.insert(m.ClickAreas, {\n mode = \"settings1\",\n id = \"ColorPosUp\",\n param = \"3\",\n x1 = 385,\n x2 = 465,\n y1 = 655,\n y2 = 700\n })\n table.insert(m.ClickAreas, {\n mode = \"settings1\",\n id = \"ColorPosUp\",\n param = \"4\",\n x1 = 470,\n x2 = 550,\n y1 = 655,\n y2 = 700\n })\n table.insert(m.ClickAreas, {\n mode = \"settings1\",\n id = \"ColorPosUp\",\n param = \"5\",\n x1 = 560,\n x2 = 640,\n y1 = 655,\n y2 = 700\n })\n table.insert(m.ClickAreas, {\n mode = \"settings1\",\n id = \"ColorPosUp\",\n param = \"6\",\n x1 = 645,\n x2 = 725,\n y1 = 655,\n y2 = 700\n })\n table.insert(m.ClickAreas, {\n mode = \"settings1\",\n id = \"ColorPosDown\",\n param = \"1\",\n x1 = 210,\n x2 = 290,\n y1 = 740,\n y2 = 780\n })\n table.insert(m.ClickAreas, {\n mode = \"settings1\",\n id = \"ColorPosDown\",\n param = \"2\",\n x1 = 300,\n x2 = 380,\n y1 = 740,\n y2 = 780\n })\n table.insert(m.ClickAreas, {\n mode = \"settings1\",\n id = \"ColorPosDown\",\n param = \"3\",\n x1 = 385,\n x2 = 465,\n y1 = 740,\n y2 = 780\n })\n table.insert(m.ClickAreas, {\n mode = \"settings1\",\n id = \"ColorPosDown\",\n param = \"4\",\n x1 = 470,\n x2 = 550,\n y1 = 740,\n y2 = 780\n })\n table.insert(m.ClickAreas, {\n mode = \"settings1\",\n id = \"ColorPosDown\",\n param = \"5\",\n x1 = 560,\n x2 = 640,\n y1 = 740,\n y2 = 780\n })\n table.insert(m.ClickAreas, {\n mode = \"settings1\",\n id = \"ColorPosDown\",\n param = \"6\",\n x1 = 645,\n x2 = 725,\n y1 = 740,\n y2 = 780\n })\n table.insert(m.ClickAreas, {\n mode = \"settings1\",\n id = \"ResetPosColor\",\n x1 = 160,\n x2 = 340,\n y1 = 885,\n y2 = 935\n })\n table.insert(m.ClickAreas, {\n mode = \"settings1\",\n id = \"ApplyPosColor\",\n x1 = 355,\n x2 = 780,\n y1 = 885,\n y2 = 935\n })\n elseif m.mode == \"startup\" then\n end\n m = CreateBaseClickAreas(m)\n return m\nend\nfunction CheckClick(M, N, O)\n M = M * 1920;\n N = N * 1120;\n O = O or \"\"\n HitPayload = {}\n if screens ~= nil and #screens > 0 then\n for i = 1, #screens, 1 do\n if screens[i].active == true and screens[i].element.getMouseX() ~=\n -1 and screens[i].element.getMouseY() ~= -1 then\n if O == \"\" then\n for J, j in pairs(screens[i].ClickAreas) do\n if j ~= nil and M >= j.x1 and M <= j.x2 and N >= j.y1 and\n N <= j.y2 then\n O = j.id;\n HitPayload = j;\n break\n end\n end\n end\n if O == \"ButtonPress\" then\n if screens[i].mode == HitPayload.param then\n screens[i].mode = \"startup\"\n else\n screens[i].mode = HitPayload.param\n end\n if screens[i].mode == \"damageoutline\" then\n if screens[i].submode == \"\" then\n screens[i].submode = \"top\"\n end\n end\n screens[i].refresh = true;\n screens[i].ClickAreas = {}\n SaveToDatabank()\n SetRefresh()\n RenderScreens()\n elseif O == \"ToggleBackground\" and\n (HitPayload.mode == screens[i].mode or HitPayload.mode ==\n \"all\") then\n if BackgroundMode == \"\" then\n BackgroundSelected = 1;\n BackgroundMode = backgroundModes[BackgroundSelected]\n else\n BackgroundSelected = 1;\n BackgroundMode = \"\"\n end\n for J, m in pairs(screens) do\n screens[J].refresh = true\n end\n SaveToDatabank()\n SetRefresh()\n RenderScreens()\n elseif O == \"PreviousBackground\" and\n (HitPayload.mode == screens[i].mode or HitPayload.mode ==\n \"all\") then\n if BackgroundMode == \"\" then\n BackgroundSelected = 1;\n BackgroundMode = backgroundModes[BackgroundSelected]\n else\n if BackgroundSelected <= 1 then\n BackgroundSelected = #backgroundModes\n else\n BackgroundSelected = BackgroundSelected - 1\n end\n BackgroundMode = backgroundModes[BackgroundSelected]\n end\n for J, m in pairs(screens) do\n screens[J].refresh = true\n end\n SaveToDatabank()\n SetRefresh()\n RenderScreens()\n elseif O == \"NextBackground\" and\n (HitPayload.mode == screens[i].mode or HitPayload.mode ==\n \"all\") then\n if BackgroundMode == \"\" then\n BackgroundSelected = 1;\n BackgroundMode = backgroundModes[BackgroundSelected]\n else\n if BackgroundSelected >= #backgroundModes then\n BackgroundSelected = 1\n else\n BackgroundSelected = BackgroundSelected + 1\n end\n BackgroundMode = backgroundModes[BackgroundSelected]\n end\n for J, m in pairs(screens) do\n screens[J].refresh = true\n end\n SaveToDatabank()\n SetRefresh()\n RenderScreens()\n elseif O == \"DecreaseOpacity\" and\n (HitPayload.mode == screens[i].mode or HitPayload.mode ==\n \"all\") then\n if BackgroundModeOpacity > 0.1 then\n BackgroundModeOpacity = BackgroundModeOpacity - 0.05;\n for J, m in pairs(screens) do\n screens[J].refresh = true\n end\n SaveToDatabank()\n SetRefresh()\n RenderScreens()\n end\n elseif O == \"IncreaseOpacity\" and\n (HitPayload.mode == screens[i].mode or HitPayload.mode ==\n \"all\") then\n if BackgroundModeOpacity < 1.0 then\n BackgroundModeOpacity = BackgroundModeOpacity + 0.05;\n for J, m in pairs(screens) do\n screens[J].refresh = true\n end\n SaveToDatabank()\n SetRefresh()\n RenderScreens()\n end\n elseif O == \"ResetColors\" and\n (HitPayload.mode == screens[i].mode or HitPayload.mode ==\n \"all\") then\n db.clear()\n ColorPrimary = \"FF6700\"\n ColorSecondary = \"FFFFFF\"\n ColorTertiary = \"000000\"\n ColorHealthy = \"00FF00\"\n ColorWarning = \"FFFF00\"\n ColorCritical = \"FF0000\"\n ColorBackground = \"000000\"\n ColorBackgroundPattern = \"4f4f4f\"\n ColorFuelAtmospheric = \"004444\"\n ColorFuelSpace = \"444400\"\n ColorFuelRocket = \"440044\"\n BackgroundMode = \"deathstar\"\n BackgroundSelected = 1;\n BackgroundModeOpacity = 0.25;\n colorIDTable = {\n [1] = {\n id = \"ColorPrimary\",\n desc = \"Main HUD Color\",\n basec = \"FF6700\",\n newc = \"FF6700\"\n },\n [2] = {\n id = \"ColorSecondary\",\n desc = \"Secondary HUD Color\",\n basec = \"FFFFFF\",\n newc = \"FFFFFF\"\n },\n [3] = {\n id = \"ColorTertiary\",\n desc = \"Tertiary HUD Color\",\n basec = \"000000\",\n newc = \"000000\"\n },\n [4] = {\n id = \"ColorHealthy\",\n desc = \"Color code for Healthy/Okay\",\n basec = \"00FF00\",\n newc = \"00FF00\"\n },\n [5] = {\n id = \"ColorWarning\",\n desc = \"Color code for Damaged/Warning\",\n basec = \"FFFF00\",\n newc = \"FFFF00\"\n },\n [6] = {\n id = \"ColorCritical\",\n desc = \"Color code for Broken/Critical\",\n basec = \"FF0000\",\n newc = \"FF0000\"\n },\n [7] = {\n id = \"ColorBackground\",\n desc = \"Background Color\",\n basec = \"000000\",\n newc = \"000000\"\n },\n [8] = {\n id = \"ColorBackgroundPattern\",\n desc = \"Background Pattern Color\",\n basec = \"4F4F4F\",\n newc = \"4F4F4F\"\n },\n [9] = {\n id = \"ColorFuelAtmospheric\",\n desc = \"Color for Atmo Fuel/Elements\",\n basec = \"004444\",\n newc = \"004444\"\n },\n [10] = {\n id = \"ColorFuelSpace\",\n desc = \"Color for Space Fuel/Elements\",\n basec = \"444400\",\n newc = \"444400\"\n },\n [11] = {\n id = \"ColorFuelRocket\",\n desc = \"Color for Rocket Fuel/Elements\",\n basec = \"440044\",\n newc = \"440044\"\n }\n }\n SaveToDatabank()\n SetRefresh()\n RenderScreens()\n elseif O == \"PreviousColorID\" and\n (HitPayload.mode == screens[i].mode or HitPayload.mode ==\n \"all\") then\n colorIDIndex = colorIDIndex - 1;\n if colorIDIndex < 1 then\n colorIDIndex = #colorIDTable\n end\n SaveToDatabank()\n SetRefresh(\"settings1\")\n RenderScreens(\"settings1\")\n elseif O == \"NextColorID\" and\n (HitPayload.mode == screens[i].mode or HitPayload.mode ==\n \"all\") then\n colorIDIndex = colorIDIndex + 1;\n if colorIDIndex > #colorIDTable then\n colorIDIndex = 1\n end\n SaveToDatabank()\n SetRefresh(\"settings1\")\n RenderScreens(\"settings1\")\n elseif O == \"ColorPosUp\" and\n (HitPayload.mode == screens[i].mode or HitPayload.mode ==\n \"all\") then\n local P = tonumber(string.sub(\n colorIDTable[colorIDIndex].newc,\n HitPayload.param, HitPayload.param),\n 16)\n P = P + 1;\n if P > 15 then P = 0 end\n colorIDTable[colorIDIndex].newc =\n replace_char(HitPayload.param,\n colorIDTable[colorIDIndex].newc,\n hexTable[P + 1])\n SaveToDatabank()\n SetRefresh(\"settings1\")\n RenderScreens(\"settings1\")\n elseif O == \"ColorPosDown\" and\n (HitPayload.mode == screens[i].mode or HitPayload.mode ==\n \"all\") then\n local P = tonumber(string.sub(\n colorIDTable[colorIDIndex].newc,\n HitPayload.param, HitPayload.param),\n 16)\n P = P - 1;\n if P < 0 then P = 15 end\n colorIDTable[colorIDIndex].newc =\n replace_char(HitPayload.param,\n colorIDTable[colorIDIndex].newc,\n hexTable[P + 1])\n SaveToDatabank()\n SetRefresh(\"settings1\")\n RenderScreens(\"settings1\")\n elseif O == \"ResetPosColor\" and\n (HitPayload.mode == screens[i].mode or HitPayload.mode ==\n \"all\") then\n colorIDTable[colorIDIndex].newc =\n colorIDTable[colorIDIndex].basec;\n _G[colorIDTable[colorIDIndex].id] =\n colorIDTable[colorIDIndex].basec;\n SaveToDatabank()\n SetRefresh()\n RenderScreens()\n elseif O == \"ApplyPosColor\" and\n (HitPayload.mode == screens[i].mode or HitPayload.mode ==\n \"all\") then\n _G[colorIDTable[colorIDIndex].id] =\n colorIDTable[colorIDIndex].newc;\n SaveToDatabank()\n SetRefresh()\n RenderScreens()\n elseif O == \"DamagedPageDown\" and\n (HitPayload.mode == screens[i].mode or HitPayload.mode ==\n \"all\") then\n CurrentDamagedPage = CurrentDamagedPage + 1;\n if CurrentDamagedPage >\n math.ceil(#damagedElements / DamagePageSize) then\n CurrentDamagedPage =\n math.ceil(#damagedElements / DamagePageSize)\n end\n HudDeselectElement()\n SaveToDatabank()\n SetRefresh(\"damage\")\n RenderScreens(\"damage\")\n elseif O == \"DamagedPageUp\" and\n (HitPayload.mode == screens[i].mode or HitPayload.mode ==\n \"all\") then\n CurrentDamagedPage = CurrentDamagedPage - 1;\n if CurrentDamagedPage < 1 then\n CurrentDamagedPage = 1\n end\n HudDeselectElement()\n SaveToDatabank()\n SetRefresh(\"damage\")\n RenderScreens(\"damage\")\n elseif O == \"BrokenPageDown\" and\n (HitPayload.mode == screens[i].mode or HitPayload.mode ==\n \"all\") then\n CurrentBrokenPage = CurrentBrokenPage + 1;\n if CurrentBrokenPage >\n math.ceil(#brokenElements / DamagePageSize) then\n CurrentBrokenPage =\n math.ceil(#brokenElements / DamagePageSize)\n end\n HudDeselectElement()\n SaveToDatabank()\n SetRefresh(\"damage\")\n RenderScreens(\"damage\")\n elseif O == \"BrokenPageUp\" and\n (HitPayload.mode == screens[i].mode or HitPayload.mode ==\n \"all\") then\n CurrentBrokenPage = CurrentBrokenPage - 1;\n if CurrentBrokenPage < 1 then\n CurrentBrokenPage = 1\n end\n HudDeselectElement()\n SaveToDatabank()\n SetRefresh(\"damage\")\n RenderScreens(\"damage\")\n elseif O == \"DMGOChangeView\" and\n (HitPayload.mode == screens[i].mode or HitPayload.mode ==\n \"all\") then\n screens[i].submode = HitPayload.param;\n UpdateViewDamageoutline(screens[i])\n SaveToDatabank()\n SetRefresh(\"damageoutline\", screens[i].submode)\n RenderScreens(\"damageoutline\", screens[i].submode)\n elseif O == \"DMGOChangeStretch\" and\n (HitPayload.mode == screens[i].mode or HitPayload.mode ==\n \"all\") then\n if DMGOStretch == true then\n DMGOStretch = false\n else\n DMGOStretch = true\n end\n UpdateViewDamageoutline(screens[i])\n SaveToDatabank()\n SetRefresh(\"damageoutline\")\n RenderScreens(\"damageoutline\")\n elseif O == \"ToggleDisplayAtmosphere\" and\n (HitPayload.mode == screens[i].mode or HitPayload.mode ==\n \"all\") then\n if screens[i].fuelA == true then\n screens[i].fuelA = false\n else\n screens[i].fuelA = true\n end\n screens[i].fuelIndex = 1;\n SaveToDatabank()\n SetRefresh(\"fuel\")\n RenderScreens(\"fuel\")\n elseif O == \"ToggleDisplaySpace\" and\n (HitPayload.mode == screens[i].mode or HitPayload.mode ==\n \"all\") then\n if screens[i].fuelS == true then\n screens[i].fuelS = false\n else\n screens[i].fuelS = true\n end\n screens[i].fuelIndex = 1;\n SaveToDatabank()\n SetRefresh(\"fuel\")\n RenderScreens(\"fuel\")\n elseif O == \"ToggleDisplayRocket\" and\n (HitPayload.mode == screens[i].mode or HitPayload.mode ==\n \"all\") then\n if screens[i].fuelR == true then\n screens[i].fuelR = false\n else\n screens[i].fuelR = true\n end\n screens[i].fuelIndex = 1;\n SaveToDatabank()\n SetRefresh(\"fuel\")\n RenderScreens(\"fuel\")\n elseif O == \"DecreaseFuelIndex\" and\n (HitPayload.mode == screens[i].mode or HitPayload.mode ==\n \"all\") then\n screens[i].fuelIndex = screens[i].fuelIndex - 1;\n if screens[i].fuelIndex < 1 then\n screens[i].fuelIndex = 1\n end\n SaveToDatabank()\n SetRefresh(\"fuel\")\n RenderScreens(\"fuel\")\n elseif O == \"IncreaseFuelIndex\" and\n (HitPayload.mode == screens[i].mode or HitPayload.mode ==\n \"all\") then\n screens[i].fuelIndex = screens[i].fuelIndex + 1;\n SaveToDatabank()\n SetRefresh(\"fuel\")\n RenderScreens(\"fuel\")\n elseif O == \"ToggleHudMode\" and\n (HitPayload.mode == screens[i].mode or HitPayload.mode ==\n \"all\") then\n if HUDMode == true then\n HUDMode = false;\n forceDamageRedraw = true;\n HudDeselectElement()\n SaveToDatabank()\n SetRefresh()\n RenderScreens()\n else\n HUDMode = true;\n forceDamageRedraw = true;\n HudDeselectElement()\n SaveToDatabank()\n SetRefresh()\n RenderScreens()\n end\n elseif O == \"ToggleSimulation\" and\n (HitPayload.mode == screens[i].mode or HitPayload.mode ==\n \"all\") then\n CurrentDamagedPage = 1;\n CurrentBrokenPage = 1;\n if SimulationMode == true then\n SimulationMode = false;\n SimulationActive = false;\n UpdateDamageData()\n UpdateTypeData()\n forceDamageRedraw = true;\n HudDeselectElement()\n SetRefresh(\"damage\")\n SetRefresh(\"damageoutline\")\n SetRefresh(\"settings1\")\n SetRefresh(\"fuel\")\n SaveToDatabank()\n RenderScreens()\n else\n SimulationMode = true;\n SimulationActive = false;\n UpdateDamageData()\n UpdateTypeData()\n forceDamageRedraw = true;\n HudDeselectElement()\n SetRefresh(\"damage\")\n SetRefresh(\"damageoutline\")\n SetRefresh(\"settings1\")\n SetRefresh(\"fuel\")\n SaveToDatabank()\n RenderScreens()\n end\n elseif (O == \"ToggleElementLabel\" or O == \"ToggleElementLabel2\") and\n (HitPayload.mode == screens[i].mode or HitPayload.mode ==\n \"all\") then\n if UseMyElementNames == true then\n UseMyElementNames = false;\n SetRefresh(\"damage\")\n RenderScreens(\"damage\")\n else\n UseMyElementNames = true;\n SetRefresh(\"damage\")\n RenderScreens(\"damage\")\n end\n elseif (O == \"SwitchScrapTier\" or O == \"SwitchScrapTier2\") and\n (HitPayload.mode == screens[i].mode or HitPayload.mode ==\n \"all\") then\n ScrapTier = ScrapTier + 1;\n if ScrapTier > 4 then ScrapTier = 1 end\n SetRefresh(\"damage\")\n RenderScreens(\"damage\")\n end\n end\n end\n end\nend\nfunction GetContentFlight()\n local Q = \"\"\n Q = Q .. GetHeader(\"Flight Data Report\") .. [[\n \n ]]\n return Q\nend\nfunction GetContentDamage()\n local Q = \"\"\n if SimulationMode == true then\n Q = Q .. GetHeader(\"Damage Report (Simulated damage)\") .. [[]]\n else\n Q = Q .. GetHeader(\"Damage Report\") .. [[]]\n end\n Q = Q .. GetContentDamageScreen()\n return Q\nend\nfunction GetContentDamageoutline(m)\n UpdateDataDamageoutline()\n UpdateViewDamageoutline(m)\n local Q = \"\"\n Q =\n Q .. GetHeader(\"Damage Ship Outline Report\") .. GetDamageoutlineShip() ..\n [[]]\n if m.submode == \"top\" then\n Q = Q .. [[\n \n Top View\n \n Side View\n \n Front View\n ]]\n elseif m.submode == \"side\" then\n Q = Q .. [[\n \n Top View\n \n Side View\n \n Front View\n ]]\n elseif m.submode == \"front\" then\n Q = Q .. [[\n \n Top View\n \n Side View\n \n Front View\n ]]\n else\n end\n Q =\n Q .. [[]] .. #dmgoElements .. [[ of ]] ..\n ElementCounter .. [[ shown]]\n Q = Q ..\n [[]]\n if DMGOStretch == true then\n Q = Q ..\n [[]]\n end\n Q = Q .. [[Stretch both axis]]\n return Q\nend\nfunction GetContentFuel(m)\n if #FuelAtmosphericTanks < 1 and #FuelSpaceTanks < 1 and #FuelRocketTanks <\n 1 then return \"\" end\n local R = 0;\n local Q = \"\"\n local S = {}\n FuelDisplay = {m.fuelA, m.fuelS, m.fuelR}\n if FuelDisplay[1] == true and #FuelAtmosphericTanks > 0 then\n table.insert(S, \"Atmospheric\")\n R = R + 1\n end\n if FuelDisplay[2] == true and #FuelSpaceTanks > 0 then\n table.insert(S, \"Space\")\n R = R + 1\n end\n if FuelDisplay[3] == true and #FuelRocketTanks > 0 then\n table.insert(S, \"Rocket\")\n R = R + 1\n end\n Q = Q .. GetHeader(\"Fuel Report (\" .. table.concat(S, \", \") .. \")\") .. [[\n ]]\n local T = 150;\n local U = 0;\n local V = 0;\n if FuelDisplay[1] == true and #FuelAtmosphericTanks > 0 then\n if R == 1 then\n V = 50\n elseif R == 2 then\n V = 6\n elseif R == 3 then\n V = 0\n end\n Q = Q .. [[\n \n \n \n ]]\n Q =\n Q .. [[]] ..\n GenerateCommaValue(FuelAtmosphericCurrent, true) .. [[ of ]] ..\n GenerateCommaValue(FuelAtmosphericTotal, true) ..\n [[ | Total Atmospheric Fuel in ]] .. #FuelAtmosphericTanks ..\n [[ tank]] .. (#FuelAtmosphericTanks == 1 and \"\" or \"s\") ..\n [[ (]] ..\n math.floor(100 / FuelAtmosphericTotal * FuelAtmosphericCurrent) ..\n [[%)]]\n U = U + 1\n end\n if FuelDisplay[2] == true and #FuelSpaceTanks > 0 then\n if R == 1 then\n V = 50\n elseif R == 2 then\n V = 6\n elseif R == 3 then\n V = 0\n end\n Q = Q .. [[\n \n \n \n ]]\n Q =\n Q .. [[]] ..\n GenerateCommaValue(FuelSpaceCurrent, true) .. [[ of ]] ..\n GenerateCommaValue(FuelSpaceTotal, true) ..\n [[ | Total Space Fuel in ]] .. #FuelSpaceTanks .. [[ tank]] ..\n (#FuelSpaceTanks == 1 and \"\" or \"s\") .. [[ (]] ..\n math.floor(100 / FuelSpaceTotal * FuelSpaceCurrent) ..\n [[%)]]\n U = U + 1\n end\n if FuelDisplay[3] == true and #FuelRocketTanks > 0 then\n if R == 1 then\n V = 50\n elseif R == 2 then\n V = 6\n elseif R == 3 then\n V = 0\n end\n Q = Q .. [[\n \n \n \n ]]\n Q =\n Q .. [[]] ..\n GenerateCommaValue(FuelRocketCurrent, true) .. [[ of ]] ..\n GenerateCommaValue(FuelRocketTotal, true) ..\n [[ | Total Rocket Fuel in ]] .. #FuelRocketTanks .. [[ tank]] ..\n (#FuelRocketTanks == 1 and \"\" or \"s\") .. [[ (]] ..\n math.floor(100 / FuelRocketTotal * FuelRocketCurrent) ..\n [[%)]]\n end\n Q = Q .. [[\n \n \n \n ]]\n local W = {}\n if m.fuelIndex == nil or m.fuelIndex < 1 then m.fuelIndex = 1 end\n if FuelDisplay[1] == true then\n for f, j in ipairs(FuelAtmosphericTanks) do table.insert(W, j) end\n end\n if FuelDisplay[2] == true then\n for f, j in ipairs(FuelSpaceTanks) do table.insert(W, j) end\n end\n if FuelDisplay[3] == true then\n for f, j in ipairs(FuelRocketTanks) do table.insert(W, j) end\n end\n table.sort(W, function(E, F)\n return E.type < F.type or E.type == F.type and E.id < F.id\n end)\n local X = 0;\n for i = m.fuelIndex, m.fuelIndex + 6, 1 do\n if W[i] ~= nil then\n local Y = W[i]\n X = X + 1;\n local Z = \"\"\n if Y.type == 1 then\n Z = \"a\"\n elseif Y.type == 2 then\n Z = \"s\"\n elseif Y.type == 3 then\n Z = \"r\"\n end\n local _ = 1853 / 100;\n if Y.percent == nil or Y.percent == 0 then\n _ = 0\n else\n _ = _ * Y.percent\n end\n if Y.cvol == nil then Y.cvol = 0 end\n if Y.name == nil then Y.name = \"\" end\n Q = Q .. [[\n \n \n \n ]]\n if Y.hp == 0 then\n Q = Q ..\n [[]]\n elseif Y.maxhp - Y.hp > constants.epsilon then\n Q = Q ..\n [[]]\n else\n Q = Q ..\n [[]]\n end\n if Y.hp == 0 then\n Q = Q .. [[]] .. Y.size ..\n [[]]\n else\n Q = Q .. [[]] .. Y.size ..\n [[]]\n end\n if Y.hp == 0 then\n Q = Q .. [[Broken]] ..\n [[0 of ]] ..\n GenerateCommaValue(Y.vol) .. [[]]\n elseif tonumber(Y.percent) < 10 then\n Q = Q .. [[]] .. Y.percent ..\n [[%]] .. [[]] ..\n GenerateCommaValue(Y.cvol) .. [[ of ]] ..\n GenerateCommaValue(Y.vol) .. [[]]\n elseif tonumber(Y.percent) < 30 then\n Q = Q .. [[]] .. Y.percent ..\n [[%]] .. [[]] ..\n GenerateCommaValue(Y.cvol) .. [[ of ]] ..\n GenerateCommaValue(Y.vol) .. [[]]\n else\n Q = Q .. [[]] .. Y.percent ..\n [[%]] .. [[]] ..\n GenerateCommaValue(Y.cvol) .. [[ of ]] ..\n GenerateCommaValue(Y.vol) .. [[]]\n end\n Q = Q .. [[]] .. Y.name .. [[]]\n Q = Q .. [[]]\n end\n end\n if #FuelAtmosphericTanks > 0 then\n Q = Q ..\n [[]]\n if FuelDisplay[1] == true then\n Q = Q ..\n [[]]\n end\n Q = Q .. [[ATM]]\n AddClickAreaForScreenID(m.id, {\n mode = \"fuel\",\n id = \"ToggleDisplayAtmosphere\",\n x1 = 50,\n x2 = 100,\n y1 = 270,\n y2 = 320\n })\n end\n if #FuelSpaceTanks > 0 then\n Q = Q ..\n [[]]\n if FuelDisplay[2] == true then\n Q = Q ..\n [[]]\n end\n Q = Q .. [[SPC]]\n AddClickAreaForScreenID(m.id, {\n mode = \"fuel\",\n id = \"ToggleDisplaySpace\",\n x1 = 200,\n x2 = 250,\n y1 = 270,\n y2 = 320\n })\n end\n if #FuelRocketTanks > 0 then\n Q = Q ..\n [[]]\n if FuelDisplay[3] == true then\n Q = Q ..\n [[]]\n end\n Q = Q .. [[RKT]]\n AddClickAreaForScreenID(m.id, {\n mode = \"fuel\",\n id = \"ToggleDisplayRocket\",\n x1 = 350,\n x2 = 400,\n y1 = 270,\n y2 = 320\n })\n end\n if m.fuelIndex > 1 then\n Q = Q .. [[\n \n \n ]]\n AddClickAreaForScreenID(m.id, {\n mode = \"fuel\",\n id = \"DecreaseFuelIndex\",\n x1 = 1470,\n x2 = 1670,\n y1 = 270,\n y2 = 320\n })\n end\n if m.fuelIndex + X - 1 < #W then\n Q = Q .. [[\n \n \n ]]\n AddClickAreaForScreenID(m.id, {\n mode = \"fuel\",\n id = \"IncreaseFuelIndex\",\n x1 = 1680,\n x2 = 1880,\n y1 = 270,\n y2 = 320\n })\n end\n if X > 0 then\n Q = Q .. [[]] .. #W .. [[ Tank]] ..\n (#W == 1 and \"\" or \"s\") .. [[ (Showing ]] .. m.fuelIndex ..\n [[ to ]] .. m.fuelIndex + X - 1 .. [[)]]\n end\n return Q\nend\nfunction GetContentCargo()\n local Q = \"\"\n Q = Q .. GetHeader(\"Cargo Report\") .. [[\n \n ]]\n return Q\nend\nfunction GetContentAGG()\n local Q = \"\"\n Q = Q .. GetHeader(\"Anti-Grav Control\") .. [[\n \n ]]\n return Q\nend\nfunction GetContentMap()\n local Q = \"\"\n Q = Q .. GetHeader(\"Map Overview\") .. [[\n \n ]]\n return Q\nend\nfunction GetContentTime()\n local Q = \"\"\n Q = Q .. GetHeader(\"Time\") .. epochTime()\n Q = Q .. [[\n \n \n \n \n \n \n \n \n \n \n \n \n ]]\n return Q\nend\nfunction GetContentSettings1()\n local Q = \"\"\n Q = Q .. GetHeader(\"Settings\") ..\n [[]]\n if BackgroundMode == \"\" then\n Q = Q ..\n [[Activate background]]\n else\n Q = Q ..\n [[Deactivate background (']] ..\n BackgroundMode .. [[', ]] ..\n string.format(\"%.0f\", BackgroundModeOpacity * 100) ..\n [[%)]]\n end\n Q = Q .. [[\n \n Previous background\n \n Next background\n\n \n Decrease Opacity\n \n Increase Opacity\n ]]\n Q = Q ..\n [[]] ..\n [[Reset background and all colors]]\n Q = Q .. [[]] ..\n [[]] ..\n [[]] ..\n [[Select and change any of the ]] ..\n #colorIDTable .. [[ HUD colors]] ..\n [[]] ..\n [[]] ..\n [[]] ..\n [[]] ..\n [[]] ..\n [[]] ..\n colorIDTable[colorIDIndex].desc .. [[]] ..\n [[]] ..\n [[Current color]] ..\n [[]] ..\n [[]] ..\n [[]] ..\n [[]] ..\n [[]] ..\n [[]] ..\n [[]] ..\n [[]] ..\n [[]] ..\n [[]] ..\n [[]] ..\n [[]] ..\n [[]] ..\n [[#]] ..\n [[]] ..\n [[]] ..\n string.sub(colorIDTable[colorIDIndex].newc, 1, 1) .. [[]] ..\n [[]] ..\n [[]] ..\n string.sub(colorIDTable[colorIDIndex].newc, 2, 2) .. [[]] ..\n [[]] ..\n [[]] ..\n string.sub(colorIDTable[colorIDIndex].newc, 3, 3) .. [[]] ..\n [[]] ..\n [[]] ..\n string.sub(colorIDTable[colorIDIndex].newc, 4, 4) .. [[]] ..\n [[]] ..\n [[]] ..\n string.sub(colorIDTable[colorIDIndex].newc, 5, 5) .. [[]] ..\n [[]] ..\n [[]] ..\n string.sub(colorIDTable[colorIDIndex].newc, 6, 6) .. [[]] ..\n [[]] ..\n [[]] ..\n [[]] ..\n [[]] ..\n [[]] ..\n [[]] ..\n [[]] ..\n [[]] ..\n [[]] ..\n [[]] ..\n [[]] ..\n [[]] ..\n [[]] .. [[]] ..\n [[New color]] ..\n [[]] ..\n [[Apply new color]] ..\n [[]] ..\n [[Reset]] .. [[]]\n Q = Q .. [[]] ..\n [[]] ..\n [[]] ..\n [[Explanation / Hints]] ..\n [[Coming soon.]]\n Q = Q .. [[]]\n if SimulationMode == true then\n Q = Q ..\n [[Simulating Damage to elements]]\n AddClickArea(\"settings1\", {\n id = \"ToggleSimulation\",\n mode = \"settings1\",\n x1 = 940,\n x2 = 1850,\n y1 = 919,\n y2 = 969\n })\n else\n Q = Q ..\n [[Simulate Damage to elements]]\n AddClickArea(\"settings1\", {\n id = \"ToggleSimulation\",\n mode = \"settings1\",\n x1 = 940,\n x2 = 1850,\n y1 = 919,\n y2 = 969\n })\n end\n return Q\nend\nfunction GetContentStartup()\n local Q = \"\"\n Q = Q .. GetElementLogo(812, 380, \"f\", \"f\", \"f\")\n if YourShipsName == \"Enter here\" then\n Q = Q .. [[Spaceship ID ]] ..\n ShipID .. [[]]\n else\n Q = Q .. [[]] .. YourShipsName ..\n [[]]\n end\n if ShowWelcomeMessage == true then\n Q =\n Q .. [[Greetings, Commander ]] ..\n PlayerName .. [[.]]\n end\n if #Warnings > 0 then\n Q = Q .. [[Warning: ]] ..\n table.concat(Warnings, \" \") .. [[]]\n end\n Q = Q ..\n [[Damage Report v]] ..\n VERSION ..\n [[, by DorianGray - Discord: Dorian Gray#2623. Under GNU Public License 3.0.]]\n return Q\nend\nfunction RenderScreen(m, a0)\n if a0 == nil then\n PrintConsole(\"ERROR: contentToRender is nil.\")\n unit.exit()\n end\n CreateClickAreasForScreen(m)\n local Q = \"\"\n Q = Q .. [[\n \n \n ]]\n Q = Q .. a0;\n if m.mode == \"startup\" then\n Q = Q ..\n [[]]\n else\n Q = Q ..\n [[]]\n end\n Q = Q .. [[\n \n \n \n TIME\n DMG\n DMGO\n FUEL]]\n Q = Q .. [[\n HUD\n SETS\n \n \n \n ]] ..\n [[\n ]]\n if HUDMode == true then\n Q = Q .. [[\n \n HUD\n ]]\n end\n if m.mode == \"damage\" then\n Q = Q .. [[\n \n DMG\n ]]\n elseif m.mode == \"damageoutline\" then\n Q = Q .. [[\n \n DMGO\n ]]\n elseif m.mode == \"fuel\" then\n Q = Q .. [[\n \n FUEL\n ]]\n elseif m.mode == \"flight\" then\n Q = Q .. [[\n \n FLGT\n ]]\n elseif m.mode == \"cargo\" then\n Q = Q .. [[\n \n CRGO\n ]]\n elseif m.mode == \"agg\" then\n Q = Q .. [[\n \n AGG\n ]]\n elseif m.mode == \"map\" then\n Q = Q .. [[\n \n MAP\n ]]\n elseif m.mode == \"time\" then\n Q = Q .. [[\n \n TIME\n ]]\n elseif m.mode == \"settings1\" then\n Q = Q .. [[\n \n SETS\n ]]\n end\n Q = Q .. [[]]\n Q = Q .. [[]]\n local a1 = string.len(Q)\n m.element.setSVG(Q)\nend\nfunction RenderScreens(a2, a3)\n a2 = a2 or \"all\"\n a3 = a3 or \"all\"\n if screens ~= nil and #screens > 0 then\n local a4 = \"\"\n local a5 = \"\"\n local a6 = \"\"\n local a7 = \"\"\n local a8 = \"\"\n local a9 = \"\"\n local aa = \"\"\n local ab = \"\"\n local ac = \"\"\n local ad = \"\"\n local ae = \"\"\n local af = \"\"\n for J, m in pairs(screens) do\n if m.refresh == true then\n local a0 = \"\"\n if m.mode == \"flight\" and (a2 == \"flight\" or a2 == \"all\") then\n if a4 == \"\" then a4 = GetContentFlight() end\n a0 = a4\n elseif m.mode == \"damage\" and (a2 == \"damage\" or a2 == \"all\") then\n if a5 == \"\" then a5 = GetContentDamage() end\n a0 = a5\n elseif m.mode == \"damageoutline\" and\n (a2 == \"damageoutline\" or a2 == \"all\") then\n if m.submode == \"\" then\n m.submode = \"top\"\n screens[J].submode = \"top\"\n end\n if m.submode == \"top\" and (a3 == \"top\" or a3 == \"all\") then\n if a6 == \"\" then\n a6 = GetContentDamageoutline(m)\n end\n a0 = a6\n end\n if m.submode == \"side\" and (a3 == \"side\" or a3 == \"all\") then\n if a7 == \"\" then\n a7 = GetContentDamageoutline(m)\n end\n a0 = a7\n end\n if m.submode == \"front\" and (a3 == \"front\" or a3 == \"all\") then\n if a8 == \"\" then\n a8 = GetContentDamageoutline(m)\n end\n a0 = a8\n end\n elseif m.mode == \"fuel\" and (a2 == \"fuel\" or a2 == \"all\") then\n m = WipeClickAreasForScreen(screens[J])\n a0 = GetContentFuel(m)\n elseif m.mode == \"cargo\" and (a2 == \"cargo\" or a2 == \"all\") then\n if aa == \"\" then aa = GetContentCargo() end\n a0 = aa\n elseif m.mode == \"agg\" and (a2 == \"agg\" or a2 == \"all\") then\n if ab == \"\" then ab = GetContentAGG() end\n a0 = ab\n elseif m.mode == \"map\" and (a2 == \"map\" or a2 == \"all\") then\n if ac == \"\" then ac = GetContentMap() end\n a0 = ac\n elseif m.mode == \"time\" and (a2 == \"time\" or a2 == \"all\") then\n if ad == \"\" then ad = GetContentTime() end\n a0 = ad\n elseif m.mode == \"settings1\" and\n (a2 == \"settings1\" or a2 == \"all\") then\n if ae == \"\" then\n ae = GetContentSettings1()\n end\n a0 = ae\n elseif m.mode == \"startup\" and (a2 == \"startup\" or a2 == \"all\") then\n if af == \"\" then af = GetContentStartup() end\n a0 = af\n else\n a0 = \"Invalid screen mode. ('\" .. m.mode .. \"')\"\n end\n if a0 ~= \"\" then\n RenderScreen(m, a0)\n else\n DrawCenteredText(\n \"ERROR: No contentToRender delivered for \" .. m.mode)\n PrintConsole(\"ERROR: No contentToRender delivered for \" ..\n m.mode)\n unit.exit()\n end\n screens[J].refresh = false\n end\n end\n end\n if HUDMode == true then\n system.setScreen(GetContentDamageHUDOutput())\n system.showScreen(1)\n else\n system.showScreen(0)\n end\nend\nfunction OnTickData(C)\n if formerTime + 60 < system.getTime() then SetRefresh(\"time\") end\n totalShipMass = core.getConstructMass()\n if formerTotalShipMass ~= totalShipMass then\n UpdateDamageData(true)\n UpdateTypeData()\n SetRefresh()\n formerTotalShipMass = totalShipMass\n else\n UpdateDamageData(C)\n UpdateTypeData()\n end\n RenderScreens()\nend\nunit.hide()\nClearConsole()\nPrintConsole(\"DAMAGE REPORT v\" .. VERSION .. \" STARTED\", true)\nInitiateSlots()\nLoadFromDatabank()\nSwitchScreens(\"on\")\nInitiateScreens()\nif core == nil then\n PrintConsole(\"ERROR: Connect the core to the programming board.\")\n unit.exit()\nelse\n OperatorID = unit.getMasterPlayerId()\n OperatorData = database.getPlayer(OperatorID)\n PlayerName = OperatorData[\"name\"]\n ShipID = core.getConstructId()\nend\nif db == nil then\n table.insert(Warnings, \"No databank connected, won't save/load settings.\")\nend\nif YourShipsName == \"Enter here\" then\n table.insert(Warnings, \"No ship name set in LUA settings.\")\nend\nif SkillRepairToolEfficiency == 0 and SkillRepairToolOptimization == 0 and\n StatFuelTankOptimization == 0 and StatContainerOptimization == 0 and\n StatAtmosphericFuelTankHandling == 0 and StatSpaceFuelTankHandling == 0 and\n StatRocketFuelTankHandling == 0 then\n table.insert(Warnings, \"No talents/stats set in LUA settings.\")\nend\nif SkillRepairToolEfficiency < 0 or SkillRepairToolOptimization < 0 or\n StatFuelTankOptimization < 0 or StatContainerOptimization < 0 or\n StatAtmosphericFuelTankHandling < 0 or StatSpaceFuelTankHandling < 0 or\n StatRocketFuelTankHandling < 0 or SkillRepairToolEfficiency > 5 or\n SkillRepairToolOptimization > 5 or StatFuelTankOptimization > 5 or\n StatContainerOptimization > 5 or StatAtmosphericFuelTankHandling > 5 or\n StatSpaceFuelTankHandling > 5 or StatRocketFuelTankHandling > 5 then\n PrintConsole(\n \"ERROR: Talents/stats can only range from 0 to 5. Please set correctly in LUA settings and reactivate script.\")\n unit.exit()\nend\nif screens == nil or #screens == 0 then\n HUDMode = true;\n PrintConsole(\"Warning: No screens connected. Entering HUD mode only.\")\nend\nOnTickData(true)\nunit.setTimer('UpdateData', UpdateDataInterval)\nunit.setTimer('UpdateHighlight', HighlightBlinkingInterval)\n","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/README.md b/README.md index 4458e70..fbe73bc 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ -### Returned to the project after some time gone. Please allow me some days to get back into LUA and update the script. :) - ![Standard View](https://github.com/DorianTheGrey/DU-DamageReport/blob/main/img/DR_Logo1.png) -# Damage Report v3.13 (DU-DamageReport) +# Damage Report v3.2 (DU-DamageReport) ### A multi-screen (and HUD) capable, touch enabled, easy to install ship damage reporting script for **Dual Universe**. @@ -14,7 +12,7 @@ Very soon we will be linking a YouTube video here explaning the installation and *Created By Dorian Gray* -*Thanks to NovaQuark for creating the best MMO of the century. Thanks to Jericho, Dmentia and Archaegeo from DU Open Source Initiative for learning a lot about DU LUA from their fine scripts. Thanks to TheBlacklist for his testing and his many wonderful suggestions. SVG patterns by Hero Patterns. DU atlas data from Jayle Break.* +*Thanks to Bayouking1 and kalazzerx for managing their forks of this script during my long absence to support the community, also thanks to Bayouking1 for fixing rocket fuel calculations. :)Thanks to NovaQuark for creating the best MMO of the century. Thanks to Jericho, Dmentia and Archaegeo from DU Open Source Initiative for learning a lot about DU LUA from their fine scripts. Thanks to TheBlacklist for his testing and his many wonderful suggestions. SVG patterns by Hero Patterns. DU atlas data from Jayle Break.* ![1a](https://github.com/DorianTheGrey/DU-DamageReport/blob/main/img/1a.png) ![1](https://github.com/DorianTheGrey/DU-DamageReport/blob/main/img/1.png) @@ -36,7 +34,7 @@ Having said all of this, I successfully used the script on a 1100 element L core 2. Place a Progamming Board and a databank on your ship. 3. Link the Programming Board to your ships core, then link the Programming Board to the databank, then link the Programming Board to your screen. You can link it to more than one screens, but I highly recommend you start with 1-3 screens only as adding more screens will most probably will make you run into script shutdowns due to the CPU limit. 4. [Optionally] You can run the script without connecting any screens at all, but you will only be able to use the "HUD Mode" and will miss out on most features of the script. -5. Copy the latest config file of https://github.com/DorianTheGrey/DU-DamageReport, it's called "DamageReport_X_XX.conf". Click on the file, click on "Raw", copy everything. (This is the latest file: https://raw.githubusercontent.com/DorianTheGrey/DU-DamageReport/main/DamageReport_3_11.conf) +5. Copy the latest config file of https://github.com/DorianTheGrey/DU-DamageReport, it's called "DamageReport_X_XX.conf". Click on the file, click on "Raw", copy everything. (This is the latest file: https://raw.githubusercontent.com/DorianTheGrey/DU-DamageReport/main/DamageReport_3_2.conf) 6. Rightclick on your Programming Board -> Advanced -> Paste LUA configuation from clipboard. 7. Activate Programming Board. 8. Rightclick on your programming board -> advanced -> edit lua parameters. Here you can enter the name of your ship. **Do not remove the quotation marks.** diff --git a/src/DamageReport_3_2_UnitStart_1.lua b/src/DamageReport_3_2_UnitStart_1.lua new file mode 100644 index 0000000..a13fa35 --- /dev/null +++ b/src/DamageReport_3_2_UnitStart_1.lua @@ -0,0 +1,2362 @@ +--[[ + 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 .. [[ + + + + TIME + DMG + DMGO + FUEL]] + Q = Q .. [[ + HUD + SETS + + + + ]] .. + [[ + ]] + if HUDMode == true then + Q = Q .. [[ + + HUD + ]] + end + if m.mode == "damage" then + Q = Q .. [[ + + DMG + ]] + elseif m.mode == "damageoutline" then + Q = Q .. [[ + + DMGO + ]] + elseif m.mode == "fuel" then + Q = Q .. [[ + + FUEL + ]] + elseif m.mode == "flight" then + Q = Q .. [[ + + FLGT + ]] + elseif m.mode == "cargo" then + Q = Q .. [[ + + CRGO + ]] + elseif m.mode == "agg" then + Q = Q .. [[ + + AGG + ]] + elseif m.mode == "map" then + Q = Q .. [[ + + MAP + ]] + elseif m.mode == "time" then + Q = Q .. [[ + + TIME + ]] + elseif m.mode == "settings1" then + Q = Q .. [[ + + SETS + ]] + 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 new file mode 100644 index 0000000..ccf9c1b --- /dev/null +++ b/src/DamageReport_3_2_UnitStart_2.lua @@ -0,0 +1,1471 @@ +--[[ + 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/DamageReport_3_13.conf b/versions/DamageReport_3_13.conf similarity index 100% rename from DamageReport_3_13.conf rename to versions/DamageReport_3_13.conf