Skip to content

Commit

Permalink
save changes
Browse files Browse the repository at this point in the history
  • Loading branch information
bengardner committed Oct 11, 2023
1 parent 1a13141 commit c9312fb
Show file tree
Hide file tree
Showing 14 changed files with 77 additions and 19 deletions.
1 change: 1 addition & 0 deletions data-final-fixes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ function M.add_network_chest_as_pastable_target_for_assemblers()
for _, assembler in pairs(data.raw["assembling-machine"]) do
local entities = assembler.additional_pastable_entities or {}
table.insert(entities, "network-chest")
table.insert(entities, "network-chest-provider")
assembler.additional_pastable_entities = entities
end
end
Expand Down
Binary file modified graphics/entities/hr-network-chest-provider.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified graphics/entities/hr-network-chest-provider.xcf
Binary file not shown.
Binary file modified graphics/entities/network-chest-provider.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified graphics/entities/network-chest-provider.xcf
Binary file not shown.
Binary file modified graphics/icons/network-chest-provider.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified graphics/icons/network-chest-provider.xcf
Binary file not shown.
28 changes: 18 additions & 10 deletions src/GlobalState.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function M.inner_setup()
end
end
if n_tanks > 0 then
game.print(
clog(
"Migrated Item Network fluids to include temperatures. Warning: If you provide a fluid at a non-default temperature (like steam), you will have to update every requester tank to use the new fluid temperature.")
end
global.mod.has_run_fluid_temp_conversion = true
Expand Down Expand Up @@ -678,6 +678,14 @@ function M.resolve_name(name)
end
end

prot = game.entity_prototypes[name]
if prot ~= nil then
local mp = prot.mineable_properties
if mp.minable and #mp.products == 1 then
return mp.products[1].name
end
end

-- FIXME: figure out how to not hard-code this
if name == "curved-rail" then
return "rail", 4
Expand All @@ -686,12 +694,12 @@ function M.resolve_name(name)
return "rail", 1
end

game.print(string.format("Unable to resolve %s", name))
clog("Unable to resolve %s", name)
return nil
end

function M.update_queue_log()
game.print(string.format("item-network queue sizes: active: %s inactive: %s", global.mod.scan_queue.size, global.mod.scan_queue_inactive.size))
clog("item-network queue sizes: active: %s inactive: %s", global.mod.scan_queue.size, global.mod.scan_queue_inactive.size)
end

function M.update_queue_dual(update_entity)
Expand Down Expand Up @@ -812,11 +820,11 @@ M.update_queue = M.update_queue_dual
function M.log_entity(title, entity)
if entity ~= nil then
if entity.name == "entity-ghost" or entity.name == "tile-ghost" then
game.print(string.format("%s: [%s] GHOST %s @ (%s,%s)",
title, entity.unit_number, entity.ghost_name, entity.position.x, entity.position.y))
clog("%s: [%s] GHOST %s @ (%s,%s)",
title, entity.unit_number, entity.ghost_name, entity.position.x, entity.position.y)
else
game.print(string.format("%s: [%s] %s @ (%s,%s)",
title, entity.unit_number, entity.name, entity.position.x, entity.position.y))
clog("%s: [%s] %s @ (%s,%s)",
title, entity.unit_number, entity.name, entity.position.x, entity.position.y)
end
end
end
Expand All @@ -839,7 +847,7 @@ function M.auto_network_chest(entity)
local entities = entity.surface.find_entities_filtered{ position=entity.position, radius=3,
type={"inserter", "loader", "mining-drill" }}

game.print(string.format(" ++ found %s entities", #entities))
clog(" ++ found %s entities", #entities)

-- NOTE: is seems like the inserter doesn't set pickup_target or drop_target until it needs to
--[[
Expand All @@ -856,10 +864,10 @@ function M.auto_network_chest(entity)
if ent.unit_number ~= nil then
if ent.drop_target == entity then
M.log_entity(string.format("%s is drop_target:", idx), ent)
game.print(string.format(" entity name=%s type=%s", ent.name, ent.type))
clog(" entity name=%s type=%s", ent.name, ent.type)
else
M.log_entity(string.format("%s NOT drop_target:", idx), ent)
game.print(string.format(" entity name=%s type=%s", ent.name, ent.type))
clog(" entity name=%s type=%s", ent.name, ent.type)
end
end
--[[
Expand Down
46 changes: 44 additions & 2 deletions src/NetworkChest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,54 @@ function M.on_entity_settings_pasted(event)
GlobalState.set_chest_requests(dest.unit_number, requests)
end
end

elseif dest.name == "network-tank" then
if source.name == "network-tank" then
GlobalState.copy_tank_config(source.unit_number, dest.unit_number)
end

elseif dest.name == "network-chest-provider" then
if source.type == "assembling-machine" then
-- paste a filter slot per
local recipe = source.get_recipe()
local dinv = dest.get_output_inventory()
if recipe ~= nil and dinv ~= nil then
-- move items to the net to keep things simple
GlobalState.put_inventory_in_network(dinv)

-- get existing filters
local filters = {}
local fidx = 1
while fidx <= #dinv do
local cf = dinv.get_filter(fidx)
if cf ~= nil then
filters[cf] = true
end
fidx = fidx + 1
end

-- add new filters
for _, prod in ipairs(recipe.products) do
if prod.type == "item" then
filters[prod.name] = true
end
end

-- update the filters
fidx = 1
for name, _ in pairs(filters) do
dinv.set_filter(fidx, name)
fidx = fidx + 1
end
dinv.set_bar(fidx)

-- clear any extra filters (shouldn't happen)
while fidx <= #dinv do
dinv.set_filter(fidx, nil)
fidx = fidx + 1
end
end
end
end
end

Expand Down Expand Up @@ -1094,8 +1138,6 @@ function M.check_alerts()
local tent = entity.get_upgrade_target()
if tent ~= nil then
M.handle_missing_material(entity, tent.name)
else
GlobalState.log_entity("Missing", entity)
end
end
end
Expand Down
12 changes: 7 additions & 5 deletions src/NetworkChestGui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,7 @@ function Modal.try_to_auto(player_index)
end

-- print the chest_req
--[[
game.print("Chest Req")
for _, rr in ipairs(chest_req) do
game.print(string.format(" -- %s @ %s", rr.item, rr.buffer))
Expand All @@ -726,10 +727,11 @@ function Modal.try_to_auto(player_index)
game.print(string.format(" -- type=%s item=%s id=%s",
old_req.type, old_req.item, old_req.id))
end
]]

-- convert to the ui format
local ui_req = M.get_ui_requests_from_chest_requests(chest_req)
game.print("UI Req")
--game.print("UI Req")
for _, rr in ipairs(ui_req) do
--local edit_req_id = ""
local edit_mode = "add"
Expand All @@ -749,9 +751,9 @@ function Modal.try_to_auto(player_index)
break
end
end
game.print(string.format(" -- mode=%s type=%s item=%s buffer=%s limit=%s id=%s",
edit_mode,
rr.type, rr.item, rr.buffer, rr.limit, rr.id))
--game.print(string.format(" -- mode=%s type=%s item=%s buffer=%s limit=%s id=%s",
-- edit_mode,
-- rr.type, rr.item, rr.buffer, rr.limit, rr.id))

--table.insert(chest_ui.requests, request)
--M.add_request_element(request, chest_ui.requests_scroll)
Expand Down Expand Up @@ -787,7 +789,7 @@ function Modal.try_to_confirm(player_index)
return
end

game.print(string.format("try_to_confirm: rtype=%s item=%s buffer=%s limit=%s", request_type, item, buffer, limit))
--game.print(string.format("try_to_confirm: rtype=%s item=%s buffer=%s limit=%s", request_type, item, buffer, limit))

-- "take" must buffer something, "give" can have no buffer.
-- give limit=0 means use global limit
Expand Down
2 changes: 1 addition & 1 deletion src/NetworkViewUi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function M.open_main_frame(player_index)
end

-- log something for debug
GlobalState.update_queue_log()
--GlobalState.update_queue_log()

--local width = M.WIDTH
local height = M.HEIGHT + 22
Expand Down
2 changes: 2 additions & 0 deletions src/UiHandlers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ M.event_handlers = {
NetworkChestGui.open_modal(player, "add")
end,
},
--[[
{
name = UiConstants.AUTO_ITEM_BTN_NAME,
event = "on_gui_click",
Expand All @@ -33,6 +34,7 @@ M.event_handlers = {
NetworkChestGui.Modal.try_to_auto(event.player_index)
end,
},
]]
{
name = UiConstants.MODAL_CHOOSE_TAKE_BTN_NAME,
event = "on_gui_checked_state_changed",
Expand Down
4 changes: 3 additions & 1 deletion src/log_console.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
local M = {}

function M.log(...)
local text = string.format(...)
print(text)
if game ~= nil then
game.print(string.format(...))
game.print(text)
end
end

Expand Down
1 change: 1 addition & 0 deletions src/prototypes/network-chests.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ local function add_chest(variant)
item.name = name
item.place_result = name
item.order = "a[items]-0[network-chest]-" .. variant
item.icon = Paths.graphics .. "/icons/network-chest-" .. variant .. ".png"


-- create a dummy inventory
Expand Down

0 comments on commit c9312fb

Please sign in to comment.