Skip to content

Commit

Permalink
Add a version for player logistic requests
Browse files Browse the repository at this point in the history
Same as the one other one, but exclusively for the player logistic requests
  • Loading branch information
Sil3ntStorm committed Nov 6, 2019
1 parent 292f8d4 commit 9057fd6
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 5 deletions.
6 changes: 3 additions & 3 deletions control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion info.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 2 additions & 0 deletions locale/en/en.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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.
7 changes: 7 additions & 0 deletions migrations/0.0.2.lua
Original file line number Diff line number Diff line change
@@ -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
24 changes: 23 additions & 1 deletion prototypes/combinator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 });

0 comments on commit 9057fd6

Please sign in to comment.