Skip to content

Commit

Permalink
Merge pull request #148 from Jonodonozym/master
Browse files Browse the repository at this point in the history
Add YOTT compatibility beyond integer limit
  • Loading branch information
S4mpsa authored Sep 28, 2023
2 parents 544295c + 6b4ff7a commit f8d319a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
35 changes: 32 additions & 3 deletions hud/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ local fluidDisplay = require("hud.fluiddisplay")
local component = require("component")
local serialization = require("serialization")
local colors = require("lib.graphics.colors")
local parser = require("lib.utils.parser")
--

local glassData = {}
Expand Down Expand Up @@ -184,14 +185,14 @@ local function updateFluidData()
local data = fluidMaximums[id]
local maximum = 0
if not data then
maxium = getMax(amount)
fluidMaximums[id] = {max=maxium, name=name}
maximum = getMax(amount)
fluidMaximums[id] = {max=maximum, name=name}
doSave = true
else
maximum = data.max
if data.max < amount then
maxium = getMax(amount)
fluidMaximums[id] = {max=maxium, name=name}
fluidMaximums[id] = {max=maximum, name=name}
doSave = true
end
end
Expand All @@ -206,6 +207,34 @@ local function updateFluidData()
saveFluidData()
end
end

-- YOTT tanks
for address, _ in pairs(component.list("gt_machine")) do
local info = component.proxy(address).getSensorInformation()
if (info[1] == "Fluid Name:") then
local name = parser.stripColors(info[2])
local id = string.lower(string.gsub(name, " ", ""))
local amount = parser.getInteger(info[6]) / 10
local capacity = parser.getInteger(info[4])
local data = fluidMaximums[id]
local maximum = 0

if not data then
maximum = getMax(capacity)
fluidMaximums[id] = {max=maximum, name=name}
doSave = true
else
maximum = data.max
if data.max ~= amount then
maximum = getMax(capacity)
fluidMaximums[id] = {max=maximum, name=name}
doSave = true
end
end

fluidData[id] = {amount=amount, name=name, max=maximum, id=id}
end
end
end

function hud.updateFluidSettings()
Expand Down
4 changes: 4 additions & 0 deletions lib/utils/parser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,8 @@ end
function parser.percentage(number) return
(math.floor(number * 1000) / 10) .. "%" end

function parser.stripColors(string)
return string.gsub(string, "§.", "")
end

return parser

0 comments on commit f8d319a

Please sign in to comment.