mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-02-21 19:20:17 +02:00
84 lines
3.1 KiB
Lua
84 lines
3.1 KiB
Lua
|
local RPG = require 'maps.scrapyard.rpg'
|
||
|
local Scrap_table = require 'maps.scrapyard.table'
|
||
|
local floor = math.floor
|
||
|
local format_number = require 'util'.format_number
|
||
|
|
||
|
local function create_gui(player)
|
||
|
local label
|
||
|
local line
|
||
|
|
||
|
local frame = player.gui.top.add({type = 'frame', name = 'scrapyard'})
|
||
|
frame.style.minimal_height = 38
|
||
|
frame.style.maximal_height = 38
|
||
|
|
||
|
label = frame.add({type = 'label', caption = ' ', name = 'label'})
|
||
|
label.style.font_color = {r = 0.88, g = 0.88, b = 0.88}
|
||
|
label.style.font = 'default-bold'
|
||
|
label.style.font_color = {r = 0.33, g = 0.66, b = 0.9}
|
||
|
|
||
|
label = frame.add({type = 'label', caption = ' ', name = 'global_pool'})
|
||
|
label.style.font_color = {r = 0.88, g = 0.88, b = 0.88}
|
||
|
label.style.font = 'default-bold'
|
||
|
label.style.right_padding = 4
|
||
|
label.style.font_color = {r = 0.33, g = 0.66, b = 0.9}
|
||
|
|
||
|
line = frame.add({type = 'line', direction = 'vertical'})
|
||
|
line.style.left_padding = 4
|
||
|
line.style.right_padding = 4
|
||
|
|
||
|
label = frame.add({type = 'label', caption = ' ', name = 'scrap_mined'})
|
||
|
label.style.font_color = {r = 0.88, g = 0.88, b = 0.88}
|
||
|
label.style.font = 'default-bold'
|
||
|
label.style.right_padding = 4
|
||
|
label.style.font_color = {r = 0.33, g = 0.66, b = 0.9}
|
||
|
|
||
|
line = frame.add({type = 'line', direction = 'vertical'})
|
||
|
line.style.left_padding = 4
|
||
|
line.style.right_padding = 4
|
||
|
|
||
|
label = frame.add({type = 'label', caption = ' ', name = 'biters_killed'})
|
||
|
label.style.font_color = {r = 0.88, g = 0.88, b = 0.88}
|
||
|
label.style.font = 'default-bold'
|
||
|
label.style.right_padding = 4
|
||
|
label.style.font_color = {r = 0.33, g = 0.66, b = 0.9}
|
||
|
|
||
|
line = frame.add({type = 'line', direction = 'vertical'})
|
||
|
line.style.left_padding = 4
|
||
|
line.style.right_padding = 4
|
||
|
|
||
|
label = frame.add({type = 'label', caption = ' ', name = 'train_upgrades'})
|
||
|
label.style.font_color = {r = 0.88, g = 0.88, b = 0.88}
|
||
|
label.style.font = 'default-bold'
|
||
|
label.style.right_padding = 4
|
||
|
label.style.font_color = {r = 0.33, g = 0.66, b = 0.9}
|
||
|
end
|
||
|
|
||
|
local function update_gui(player)
|
||
|
local rpg = RPG.get_table()
|
||
|
local st = Scrap_table.get_table()
|
||
|
|
||
|
if not player.gui.top.scrapyard then
|
||
|
create_gui(player)
|
||
|
end
|
||
|
local gui = player.gui.top.scrapyard
|
||
|
|
||
|
if rpg.global_pool == 0 then
|
||
|
gui.global_pool.caption = 'XP: 0'
|
||
|
gui.global_pool.tooltip = 'Dig, handcraft or run to increase the pool!'
|
||
|
elseif rpg.global_pool > 0 then
|
||
|
gui.global_pool.caption = 'XP: ' .. format_number(floor(rpg.global_pool), true)
|
||
|
gui.global_pool.tooltip = 'Get this number over 5k to get some of this mad XP! \\o/'
|
||
|
end
|
||
|
|
||
|
gui.scrap_mined.caption = ' [img=entity.mineable-wreckage]: ' .. format_number(st.mined_scrap, true)
|
||
|
gui.scrap_mined.tooltip = 'Amount of scrap mined.'
|
||
|
|
||
|
gui.biters_killed.caption = ' [img=entity.small-biter]: ' .. format_number(st.biters_killed, true)
|
||
|
gui.biters_killed.tooltip = 'Amount of biters killed.'
|
||
|
|
||
|
gui.train_upgrades.caption = ' [img=entity.locomotive]: ' .. format_number(st.train_upgrades, true)
|
||
|
gui.train_upgrades.tooltip = 'Amount of train upgrades.'
|
||
|
end
|
||
|
|
||
|
return update_gui
|