Skip to content

Commit

Permalink
fix ghost support a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
bengardner committed Feb 11, 2024
1 parent e8fdf0f commit 0ade9ed
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/GlobalState.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@ function M.mine_process()
global.mod.mine_queue = mine_later

if #mine_now > 0 then
local inv = game.create_inventory(16)
local inv = game.create_inventory(math.min(100, 4 * #mine_now))
for _, eee in ipairs(mine_now) do
local ent = eee[1]
-- print(string.format("delayed mine %s @ %s", ent.name, serpent.line(ent.position)))
Expand Down
5 changes: 4 additions & 1 deletion src/NetworkTankGui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ It replaces the dialog with one of our own.
local function network_tank_on_gui_opened(player, entity, cfg)

local self, main_flow, tank_info = common_on_gui_opened(player, entity)
if self == nil then
if self == nil or main_flow == nil or tank_info == nil then
return
end

Expand All @@ -111,6 +111,9 @@ local function network_tank_on_gui_opened(player, entity, cfg)
end

local is_requester = (cfg.type == "output")
if is_requester then
default_is_take = true
end

local elems = self.elems

Expand Down
8 changes: 6 additions & 2 deletions src/service_ghost.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@ function M.ghost_service(info)

-- check to see if we have enough items in the network
local item_list = ghost_prototype.items_to_place_this
local missing = false
for _, ing in ipairs(item_list) do
local cnt = GlobalState.get_item_count(ing.name)
if cnt < ing.count then
-- try again later
return GlobalState.UPDATE_STATUS.UPDATE_PRI_MAX
GlobalState.missing_item_set(ing.name, entity.unit_number, ing.count - cnt)
missing = true
end
end
if missing then
return GlobalState.UPDATE_STATUS.UPDATE_PRI_MAX
end

local _, revived_entity, __ = entity.revive{raise_revive = true}
if revived_entity ~= nil then
Expand Down

0 comments on commit 0ade9ed

Please sign in to comment.