Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/thoda-dev/DU-Industry-HUD. A simple HUD for monitoring and managing industry in Dual Universe
dual-universe lua
Something went wrong. Try again.
3.8 kB · 1 line
JSON
at junie-init
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":[]}},"-3":{"name":"player","type":{"events":[],"methods":[]}},"-2":{"name":"construct","type":{"events":[],"methods":[]}},"-4":{"name":"system","type":{"events":[],"methods":[]}},"-5":{"name":"library","type":{"events":[],"methods":[]}}},"handlers":[{"code":"--[[\n DU Industry HUD By Jericho\n]]\n\nlocal version = \"V 4.0.1\"\nlocal log_split = \"=================================================\"\n--printing version in lua chat\nsystem.print(log_split)local a=\"\"local b=math.ceil((50-#version-2)/2)for c=1,b,1 do a=a..'='end;a=a..\" \"..version..\" \"for c=1,b,1 do a=a..'='end;system.print(a)system.print(log_split)\n\nunit.hideWidget()\n\n--[[\n\tsplit a string on a delimiter\n\tBy jericho\n]]\nfunction strSplit(s, delimiter)\n result = {};\n for match in (s..delimiter):gmatch(\"(.-)\"..delimiter) do\n table.insert(result, match);\n end\n return result;\nend\n\n--[[\n\tcheck if a table contains an element\n\tBy Jericho\n]]\nfunction hasValue(tab, val)\n for _,v in ipairs(tab) do\n if v == val then\n return true\n end\n end\n return false\nend\n\n\n\nfunction removeQualityInName(name)\n if not name then return '' end\n return name:lower():gsub('basic ', ''):gsub('uncommon ', ''):gsub('advanced ', ''):gsub('rare ', ''):gsub('exotic ', '')\nend\n\ndatabank = nil\nindustries = {}\nfor slot_name, slot in pairs(unit) do\n if\n type(slot) == \"table\"\n and type(slot.export) == \"table\"\n and slot.getClass\n then\n slot_type = slot.getClass():lower()\n if slot_type == 'databankunit' then\n databank = slot\n end\n if (slot_type:find(\"industry\")) then\n table.insert(industries, slot)\n end\n end\nend\nif databank ~= nil then\n for _,slot in pairs(industries) do\n local slot_id = slot.getLocalId()\n if databank.hasKey(tostring(slot_id)) then\n local command = databank.getStringValue(slot_id)\n if command ~= nil and command ~= \"\" then\n if command:lower() == \"start\" then\n slot.startRun()\n elseif command:lower():find(\"maintain\") then\n local splitted = strSplit(command, \"_\")\n local quantity = tonumber(splitted[2])\n slot.startMaintain(quantity)\n elseif command:lower():find(\"batch\") then\n local splitted = strSplit(command, \"_\")\n local quantity = tonumber(splitted[2])\n slot.startFor(quantity)\n elseif command:lower() == \"stop\" then\n slot.stop(true, false)\n elseif command:lower() == \"soft_stop\" then\n slot.stop(false, false)\n elseif command:lower() == \"hard_stop\" then\n slot.stop(true, true)\n end\n databank.setStringValue(id, \"\")\n end\n end\n end\nend\nunit.exit()","filter":{"args":[],"signature":"onStart()","slotKey":"-1"},"key":"0"}],"methods":[],"events":[]}