Alert Scanner


Adds an alert scanner reading missing materials for ghosts in it's logistic network.

Utilities
1 year, 1 month ago
1.1
387
Logistic network Circuit network Blueprints

i Ghost on Water compatibility

1 year, 6 months ago

Is there any thought around making it compatible with Ghost on Water, so that it grabs and requests the "normal" version of the entity + landfill/scaffold, instead of the ghost version of the entity, which then can't actually be requested?

1 year, 6 months ago

I have never used Ghost on Water, what do you mean by "ghost version of the entity"?
Does this completely break the item delivery or only delay it until the landfill is placed?
Unless this is a bug in this mod I don't currently plan on adding compatibility with mods I am not using myself, unless there is definitive demand.

1 year, 3 months ago
(updated 1 year, 3 months ago)

Developer of Ghost on water here, haven't actually tested your mod yet(It looks like a good alternative to Ghost Scanner 2 which I'm currently using obiously can't use it if it dosn't work with my mod) but I assume it breaks item delivery completely since you list.
Changing a request after it has been registered does not cause the scanner to update. For example after upgrading a yellow belt ghost to a red belt the scanner still outputs a yellow belt signal
as a known issue.
Once Landfill is placed, Ghost on Water upgrades it's dummy "Water Ghost" entities to the real ones, so fixing the above issue should make it work after the landfill is placed. (maybe you need to use the on_pre_ghost_upgraded event or something)?
Making it fully compatible (as in requesting the actual items instead of trying to request the dummy items) should be easy, just add some kind of check that checks if the name of an item it's trying to request starts with "waterGhost-" if it just just get the actual item/entity name by removing "waterGhost-" prefix to get the real item name and request that instead.
I'd probably do a PR to add support (assuming it works for me) but you don't have your mod on GitHub which means I can't really do PRs.

1 year, 3 months ago

Added compatibility to my mod (did the name override thing not fixing the upgrade thing) if you want to add it
add this import at the top of your to your Util.lua
local coreUtil = require("core/lualib/util")
then change the Util.unify_item_stack_format function to this:
function Util.unify_item_stack_format(stack)
local overide_items_to_place = function(name)
local prefix = "waterGhost-"
if (coreUtil.string_starts_with(name,prefix)) then
--get the original entity name from the dummy entity name
local originalEntityName = string.sub(name, string.len(prefix) + 1)
return originalEntityName
else
return name
end
end

if type(stack) == "string" then
return {name=overide_items_to_place(stack), count=game.item_prototypes[stack].stack_size}
elseif not stack.count then
return {name=overide_items_to_place(stack.name), count=1}
else
-- technically redundant, but explicit
return {name=overide_items_to_place(stack.name), count=stack.count}
end

end

This is just the quickest implementation of the name replacement I could do you could obviously move stuff elsewhere. I guess I'll just make a fork if you don't want to add the compatibility.

1 year, 3 months ago

Sorry for the late response, I was on holiday.

It feels cleaner to substitute the entity prototype instead of the items to place, which would bundle it in Entity.get_items_to_place.
I will test if it works, just wanted to break the silence.

1 year, 3 months ago

It seems to work, I will add a release shortly.
Here is the relevant code, in case you're interested:

-- get all items required to place the prototype
local function get_items_to_place(prototype)
  Cache.ensure()
  -- fast exit if called multiple times
  if global.cache_items_to_place[prototype.name] then
    return global.cache_items_to_place[prototype.name]
  end

  -- COMPATIBILITY GhostOnWater
  local ghost_on_water_prefix = "waterGhost-"
  if prototype.name:find("^"..ghost_on_water_prefix) ~= nil then
    -- use items for non-dummy instead
    local real_name = prototype.name:sub(ghost_on_water_prefix:len() + 1)
    local real_prototype = game.entity_prototypes[real_name]
    if real_prototype then
      return get_items_to_place(real_prototype)
    end
    -- The prefix may have been caused by something else, use regular process instead
  end
  -- COMPATIBILITY END GhostOnWater


  local items_to_place_filtered = {}
  for _, stack_ in pairs(prototype.items_to_place_this) do
    local stack = Util.unify_item_stack_format(stack_)
    -- filter items flagged as hidden
    if ShowHidden or not game.item_prototypes[stack.name].has_flag("hidden") then
      if items_to_place_filtered[stack.name] then
        items_to_place_filtered[stack.name] = items_to_place_filtered[stack.name] + stack.count
      else
        items_to_place_filtered[stack.name] = stack.count
      end
    end
  end
  global.cache_items_to_place[prototype.name] = items_to_place_filtered
  return global.cache_items_to_place[prototype.name]
end

New response