Skip to content

Commit

Permalink
Ported to 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Quezler committed Jan 10, 2025
1 parent e99ec82 commit 3a8cdbd
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---------------------------------------------------------------------------------------------------
Version: 2.0.0
Date: 2025. 01. 10
Info:
- Ported to 2.0
---------------------------------------------------------------------------------------------------
Version: 1.0.3
Date: 2024. 02. 09
Info:
- Ignore labs with no bottles in them at all
---------------------------------------------------------------------------------------------------
Version: 1.0.2
Date: 2023. 12. 28
Info:
- Ignore science packs that are only missing once (inserters / old lab / etc)
---------------------------------------------------------------------------------------------------
Version: 1.0.1
Date: 2023. 12. 28
Info:
- Bring to front instead of killing the parent and its children
---------------------------------------------------------------------------------------------------
Version: 1.0.0
Date: 2023. 12. 28
Info:
- Publish `Show missing bottles for current research`
---------------------------------------------------------------------------------------------------
Version: 0.0.1
Date: 2023. 12. 28
Info:
- Stash show-missing-bottles-for-current-research concept
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
local util = require('util')

local function on_configuration_changed(event)
global.lab_inputs = {}
for _, entity_prototype in pairs(game.get_filtered_entity_prototypes({{filter = 'type', type = 'lab'}})) do
global.lab_inputs[entity_prototype.name] = util.list_to_map(entity_prototype.lab_inputs)
storage.lab_inputs = {}
for _, entity_prototype in pairs(prototypes.get_entity_filtered({{filter = 'type', type = 'lab'}})) do
storage.lab_inputs[entity_prototype.name] = util.list_to_map(entity_prototype.lab_inputs)
end
end

Expand All @@ -12,14 +12,14 @@ script.on_configuration_changed(on_configuration_changed)
local function on_created_entity(event)
local entity = event.created_entity or event.entity or event.destination

global.structs[entity.unit_number] = {
storage.structs[entity.unit_number] = {
-- unit_number = entity.unit_number,
entity = entity,
}
end

script.on_init(function(event)
global.structs = {}
storage.structs = {}

on_configuration_changed()

Expand Down Expand Up @@ -96,18 +96,18 @@ end
local function get_missing_counts(force, list)
local missing_counts = {}

for unit_number, struct in pairs(global.structs) do
for unit_number, struct in pairs(storage.structs) do
if not struct.entity.valid then
global.structs[unit_number] = nil
storage.structs[unit_number] = nil
else

if struct.entity.force == force then
if struct.entity.status == defines.entity_status.missing_science_packs then
local inventory = struct.entity.get_inventory(defines.inventory.lab_input)
if inventory.is_empty() == false then

for _, item_name in ipairs(list) do
if global.lab_inputs[struct.entity.name][item_name] then -- ignore labs that cannot use this item
if storage.lab_inputs[struct.entity.name][item_name] then -- ignore labs that cannot use this item
if inventory.get_item_count(item_name) == 0 then
-- game.print(serpent.line({
-- item_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"name": "show-missing-bottles-for-current-research",
"title": "Show missing bottles for current research",
"description": "Research-kun why are you stuck?",
"version": "1.0.3",
"version": "2.0.0",
"author": "Quezler",
"factorio_version": "1.1",
"factorio_version": "2.0",
"dependencies": [
]
}

0 comments on commit 3a8cdbd

Please sign in to comment.