diff --git a/cybersyn/scripts/gui/util.lua b/cybersyn/scripts/gui/util.lua index 074dbba..9187e8c 100644 --- a/cybersyn/scripts/gui/util.lua +++ b/cybersyn/scripts/gui/util.lua @@ -92,36 +92,29 @@ function util.slot_table_build_from_station(station) local item = v.signal local count = v.count local name = item.name - local sprite - local color - if count > 0 then - color = "green" - else - color = "red" - end - if item.type then - sprite = item.type .. "/" .. name - else - if name then - sprite = string.gsub(name, ",", "/") + local sprite = util.build_sprite_path(name) + if sprite ~= nil then + local color + if count > 0 then + color = "green" else - --idunno? + color = "red" + end + if game.is_valid_sprite_path(sprite) then + children[#children + 1] = { + type = "sprite-button", + enabled = false, + style = "ltnm_small_slot_button_" .. color, + sprite = sprite, + tooltip = { + "", + "[img=" .. sprite .. "]", + { "item-name." .. name }, + "\n"..format.number(count), + }, + number = count + } end - end - if game.is_valid_sprite_path(sprite) then - children[#children + 1] = { - type = "sprite-button", - enabled = false, - style = "ltnm_small_slot_button_" .. color, - sprite = sprite, - tooltip = { - "", - "[img=" .. sprite .. "]", - { "item-name." .. name }, - "\n"..format.number(count), - }, - number = count - } end end end @@ -132,33 +125,32 @@ function util.slot_table_build_from_deliveries(station) ---@type GuiElemDef[] local children = {} local deliveries = station.deliveries - local sprite = "" + for item, count in pairs(deliveries) do - local color - if count > 0 then - color = "green" - else - color = "blue" - end - if game.is_valid_sprite_path("item/" .. item) then - sprite = "item/" .. item - elseif game.is_valid_sprite_path("fluid/" .. item) then - sprite = "fluid/" .. item - end - if game.is_valid_sprite_path(sprite) then - children[#children + 1] = { - type = "sprite-button", - enabled = false, - style = "ltnm_small_slot_button_" .. color, - sprite = sprite, - tooltip = { - "", - "[img=" .. sprite .. "]", - { item }, - "\n"..format.number(count), - }, - number = count - } + + local sprite = util.build_sprite_path(item) + if sprite ~= nil then + local color + if count > 0 then + color = "green" + else + color = "blue" + end + if game.is_valid_sprite_path(sprite) then + children[#children + 1] = { + type = "sprite-button", + enabled = false, + style = "ltnm_small_slot_button_" .. color, + sprite = sprite, + tooltip = { + "", + "[img=" .. sprite .. "]", + { item }, + "\n"..format.number(count), + }, + number = count + } + end end end return children @@ -180,7 +172,6 @@ function util.slot_table_build_from_control_signals(station) if item.type ~= "virtual" then goto continue else - -- don't know how to get the sprite path for signals like cybersyn-priority, so this fizzles sprite = "virtual-signal" .. "/" .. name end if game.is_valid_sprite_path(sprite) then diff --git a/cybersyn/scripts/main.lua b/cybersyn/scripts/main.lua index fbebe11..a0a0713 100644 --- a/cybersyn/scripts/main.lua +++ b/cybersyn/scripts/main.lua @@ -903,7 +903,7 @@ local function main() end - local MANAGER_ENABLED = true + local MANAGER_ENABLED = true --convert to mod setting? script.on_init(function() local setting = settings.global["cybersyn-invert-sign"] @@ -933,7 +933,7 @@ local function main() script.on_event(defines.events.on_player_removed, manager.on_player_removed) script.on_event(defines.events.on_player_created, manager.on_player_created) script.on_event(defines.events.on_lua_shortcut, manager.on_lua_shortcut) - script.on_nth_tick(60, function() + script.on_nth_tick(600, function() --TODO: tick value needs to be converted to mod setting manager.tick(global) end) end