diff --git a/control.lua b/control.lua index 4c3924c..6197138 100644 --- a/control.lua +++ b/control.lua @@ -7,14 +7,14 @@ if not global.logistic_signals then end local function onEntityCreated(event) - if (event.created_entity.name == "sil-unfulfilled-requests-combinator") then + if (event.created_entity.name == "sil-unfulfilled-requests-combinator" or event.created_entity.name == "sil-player-requests-combinator") then event.created_entity.operable = false; table.insert(global.logistic_signals, event.created_entity); end end local function onEntityDeleted(event) - if (event.entity.name == "sil-unfulfilled-requests-combinator") then + if (event.entity.name == "sil-unfulfilled-requests-combinator" or event.entity.name == "sil-player-requests-combinator") then for i = #global.logistic_signals, 1, -1 do if (global.logistic_signals[i].unit_number == event.entity.unit_number) then table.remove(global.logistic_signals, i); @@ -38,7 +38,7 @@ script.on_event(defines.events.on_tick, function(event) if (network ~= nil) then -- more useless indentation levels (LUA sux) for _, req in pairs(network.requesters) do - if (req.type ~= "character") then + if ((req.type ~= "character" and obj.name == "sil-unfulfilled-requests-combinator") or (req.type == "character" and obj.name == "sil-player-requests-combinator")) then local log_point = req.get_logistic_point(defines.logistic_member_index.logistic_container); if (log_point and log_point.valid and (log_point.mode == defines.logistic_mode.buffer or log_point.mode == defines.logistic_mode.requester)) then for i = 1, req.request_slot_count do diff --git a/info.json b/info.json index 34e30b6..37a0e7c 100644 --- a/info.json +++ b/info.json @@ -1,7 +1,7 @@ { "name": "logistic-signals", "title": "Logistic Signals", - "version": "0.0.1", + "version": "0.0.2", "author": "Sil3ntSt0rm", "contact": "", "homepage": "https://github.com/Sil3ntStorm/logistic-signals", diff --git a/locale/en/en.cfg b/locale/en/en.cfg index 21e3e1d..8849cb4 100644 --- a/locale/en/en.cfg +++ b/locale/en/en.cfg @@ -6,6 +6,8 @@ [entity-name] sil-unfulfilled-requests-combinator=Unfulfilled Requests Detector +sil-player-requests-combinator=Player Requests Detector [entity-description] sil-unfulfilled-requests-combinator=Provides signals for all items that are requested within the logistic network within which it is placed, but are not currently present. If a requester chest requests 100 iron plates and only has 10 in its inventory, a signal of 90 iron plates will be emitted.\nTakes into account items currently being delivered or scheduled to be taken (e.g. on buffer chests) by robots in flight. +sil-player-requests-combinator=Provides signals for all items requested by players within the logistic network within which it is placed.\nTakes into account items currently being delivered or scheduled to be taken by robots in flight. diff --git a/migrations/0.0.2.lua b/migrations/0.0.2.lua new file mode 100644 index 0000000..77dbb47 --- /dev/null +++ b/migrations/0.0.2.lua @@ -0,0 +1,7 @@ +-- Copyright 2019 Sil3ntStorm https://github.com/Sil3ntStorm +-- +-- Licensed under MS-RL, see https://opensource.org/licenses/MS-RL + +for _, force in pairs(game.forces) do + force.recipes["sil-player-requests-combinator"].enabled = force.technologies["circuit-network"].researched; +end diff --git a/prototypes/combinator.lua b/prototypes/combinator.lua index 8c72ec8..34c510b 100644 --- a/prototypes/combinator.lua +++ b/prototypes/combinator.lua @@ -23,4 +23,26 @@ recipe.result = entity.name; data:extend{entity, item, recipe}; -table.insert(data.raw["technology"]["circuit-network"].effects, { type = "unlock-recipe", recipe = recipe.name}); +table.insert(data.raw["technology"]["circuit-network"].effects, { type = "unlock-recipe", recipe = recipe.name }); + +local playerComb = table.deepcopy(data.raw["constant-combinator"]["sil-unfulfilled-requests-combinator"]); +playerComb.name = "sil-player-requests-combinator"; +playerComb.icons = {{ + icon = data.raw["constant-combinator"]["constant-combinator"].icon, + tint = {r = 0.113, g = 0.888, b = 0.106, a = 0.85} +}} +playerComb.minable.result = playerComb.name; +playerComb.operable = false; + +local pcItem = table.deepcopy(data.raw.item["sil-unfulfilled-requests-combinator"]); +pcItem.name = playerComb.name; +pcItem.icons = playerComb.icons; +pcItem.place_result = playerComb.name; + +local pcRepice = table.deepcopy(data.raw.recipe["sil-unfulfilled-requests-combinator"]); +pcRepice.name = playerComb.name; +pcRepice.result = playerComb.name; + +data:extend{playerComb, pcItem, pcRepice}; + +table.insert(data.raw["technology"]["circuit-network"].effects, { type = "unlock-recipe", recipe = pcRepice.name });