mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 03:25:23 +09:00
.
This commit is contained in:
@@ -21,14 +21,39 @@ local font_color = {
|
||||
}
|
||||
|
||||
local function format_n(n)
|
||||
local _i, _j, m, i, f = tostring(n):find("([-]?)(%d+)([.]?%d*)")
|
||||
i = i:reverse():gsub("(%d%d%d)", "%1,")
|
||||
|
||||
if f ~= "" then
|
||||
return m .. i:reverse():gsub("^,", "") .. string.format("%.1f", f)
|
||||
else
|
||||
return m .. i:reverse():gsub("^,", "") .. ".0"
|
||||
if n < 0.1 then
|
||||
return "0.0"
|
||||
end
|
||||
|
||||
local suffix = ""
|
||||
local suffix_list = {
|
||||
["P"] = 1000000000000000,
|
||||
["T"] = 1000000000000,
|
||||
["G"] = 1000000000,
|
||||
["M"] = 1000000,
|
||||
["k"] = 1000,
|
||||
}
|
||||
|
||||
for letter, limit in pairs(suffix_list) do
|
||||
if math.abs(n) >= limit then
|
||||
n = string.format("%.1f", n / limit)
|
||||
suffix = letter
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
local k
|
||||
local formatted = n
|
||||
|
||||
while true do
|
||||
formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", "%1,%2")
|
||||
|
||||
if (k == 0) then
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
return formatted .. " " .. suffix
|
||||
end
|
||||
|
||||
--- Display group
|
||||
@@ -77,26 +102,20 @@ local production_data_set = Gui.element("production_data_set")
|
||||
:draw(function(_, parent, name)
|
||||
local production_set = parent.add{ type = "flow", direction = "vertical", name = name }
|
||||
local disp = Gui.elements.scroll_table(production_set, 350, 4, "disp")
|
||||
|
||||
production_data_group(disp, 0)
|
||||
|
||||
disp["production_0_1"].caption = { "production.label-prod" }
|
||||
disp["production_0_2"].caption = { "production.label-con" }
|
||||
disp["production_0_3"].caption = { "production.label-bal" }
|
||||
|
||||
for i = 1, 8 do
|
||||
production_data_group(disp, i)
|
||||
end
|
||||
|
||||
return production_set
|
||||
end)
|
||||
|
||||
production_container = Gui.element("production_container")
|
||||
:draw(function(def, parent)
|
||||
local container = Gui.elements.container(parent, 350)
|
||||
|
||||
production_data_set(container, "production_st")
|
||||
|
||||
return container.parent
|
||||
end)
|
||||
|
||||
@@ -118,11 +137,9 @@ Event.on_nth_tick(60, function()
|
||||
local stat = player.force.get_item_production_statistics(player.surface) -- Allow remote view
|
||||
local precision_value = precision[container.frame["production_st"].disp.table["production_0_e"].selected_index]
|
||||
local table = container.frame["production_st"].disp.table
|
||||
|
||||
for i = 1, 8 do
|
||||
local production_prefix = "production_" .. i
|
||||
local item = table[production_prefix .. "_e"].elem_value --[[ @as string ]]
|
||||
|
||||
if item then
|
||||
local add = math.floor(stat.get_flow_count{ name = item, category = "input", precision_index = precision_value, count = false } / 6) / 10
|
||||
local minus = math.floor(stat.get_flow_count{ name = item, category = "output", precision_index = precision_value, count = false } / 6) / 10
|
||||
|
||||
Reference in New Issue
Block a user