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.
2.7 kB · 89 lines
Lua
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990--[[ DU Industry HUD By Jericho]]
local version = "V 4.0.1"local log_split = "================================================="--printing version in lua chatsystem.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)
unit.hideWidget()
--[[ split a string on a delimiter By jericho]]function strSplit(s, delimiter) result = {}; for match in (s..delimiter):gmatch("(.-)"..delimiter) do table.insert(result, match); end return result;end
--[[ check if a table contains an element By Jericho]]function hasValue(tab, val) for _,v in ipairs(tab) do if v == val then return true end end return falseend
function removeQualityInName(name) if not name then return '' end return name:lower():gsub('basic ', ''):gsub('uncommon ', ''):gsub('advanced ', ''):gsub('rare ', ''):gsub('exotic ', '')end
databank = nilindustries = {}for slot_name, slot in pairs(unit) do if type(slot) == "table" and type(slot.export) == "table" and slot.getClass then slot_type = slot.getClass():lower() if slot_type == 'databankunit' then databank = slot end if (slot_type:find("industry")) then table.insert(industries, slot) end endendif databank ~= nil then for _,slot in pairs(industries) do local slot_id = slot.getLocalId() if databank.hasKey(tostring(slot_id)) then local command = databank.getStringValue(slot_id) if command ~= nil and command ~= "" then if command:lower() == "start" then slot.startRun() elseif command:lower():find("maintain") then local splitted = strSplit(command, "_") local quantity = tonumber(splitted[2]) slot.startMaintain(quantity) elseif command:lower():find("batch") then local splitted = strSplit(command, "_") local quantity = tonumber(splitted[2]) slot.startFor(quantity) elseif command:lower() == "stop" then slot.stop(true, false) elseif command:lower() == "soft_stop" then slot.stop(false, false) elseif command:lower() == "hard_stop" then slot.stop(true, true) end databank.setStringValue(id, "") end end endendunit.exit()