1
0
mirror of https://github.com/Wyrrrd/Autofilter.git synced 2026-06-30 10:02:27 +02:00

7 Commits

Author SHA1 Message Date
Wyrrrd d3ca77eede Update changelog.txt
Fixed formatting (again)
2020-02-24 19:18:50 +01:00
Wyrrrd 94e7309dd0 Update README.md
Matched with mod portal description
2020-02-24 19:09:55 +01:00
Wyrrrd a7a7816f89 Update changelog.txt
Updated retroactive downgrade
2020-02-24 18:58:40 +01:00
Wyrrrd 3a859a941d Added check for empty filter and whitelist mode
Avoids overwriting filter on replacing preexisting inserters/ghosts
2020-02-24 18:56:01 +01:00
Wyrrrd 50d63e8e3c Added hidden dependency
Fixes setting filter from wrong inventory when pickup location is rotated by Bob's Adjustable Inserters
2020-02-24 18:43:00 +01:00
Wyrrrd d87491c622 Added translated mod description 2020-02-24 18:27:24 +01:00
Wyrrrd 5ed50dcfb3 Added entity type check
Apparently event filters are not applied to mod-raised events
2020-02-23 15:17:15 +01:00
6 changed files with 56 additions and 22 deletions
+3 -6
View File
@@ -1,12 +1,9 @@
# Autofilter
<img src="https://raw.githubusercontent.com/Wyrrrd/Autofilter/master/thumbnail.png" width="128" height="128">
Description:
### Description
- When you place a filter inserter, it reads either the inventory contents or inventory filters on the pickup side and sets its filter to those items.
- Fills the inserter's filter only until it is full (of course).
- Sets the inserter's filter only if there is no filter already set (for example from a replaced preconfigured ghost).
- The mode can be changed or disabled in player mod settings on the fly as needed.
- Should work with most modded filter inserters.
Notes:
- Currently does not work if a mod moves the pickup location directly after placing the inserter (for example [Bob's Logistics](https://mods.factorio.com/mod/boblogistics)).
- Filter gets overwritten when the player places a filtered inserter on a ghost that already has a filter configured. Does not overwrite when placed with bots.
- Should work with most modded filter inserters.
+19 -1
View File
@@ -1,4 +1,22 @@
---------------------------------------------------------------------------------------------------
Version: 0.18.5
Date: 24. 2. 2020
Changes:
- Added hidden dependency to Bob's Adjustable Inserters (fixes setting filter from wrong inventory when pickup location is rotated)
- Added check for empty filter and whitelist mode to avoid overwriting filter on replacing preexisting inserters/ghosts
- Updated retroactive downgrade to be on par with this version
Locale:
- Added translated mod description
---------------------------------------------------------------------------------------------------
Version: 0.18.4
Date: 23. 2. 2020
Changes:
- Removed incompatibility with Upgrade Builder and Planner (see Bugfixes)
Bugfixes:
- Added additional check for entity type, since event filters are not applied to mod-raised events
---------------------------------------------------------------------------------------------------
Version: 0.18.3
Date: 23. 2. 2020
Changes:
@@ -28,7 +46,7 @@ Date: 22. 2. 2020
- Added player mod setting to control mod behaviour
---------------------------------------------------------------------------------------------------
Version: 0.17.0
Date: 22. 2. 2020
Date: 24. 2. 2020
Info:
- Retroactive downgrade
---------------------------------------------------------------------------------------------------
+26 -13
View File
@@ -1,6 +1,15 @@
--control.lua
--functions definitions
local function is_filter_empty(inserter)
for slot = 1,inserter.filter_slot_count do
if inserter.get_filter(slot) then
return false
end
return true
end
end
local function get_items_by_content(inserter,inventory)
local items = {}
for item,_ in pairs(inventory.get_contents()) do
@@ -23,19 +32,23 @@ end
local function on_built_entity(event)
local inserter = event.created_entity
if inserter.filter_slot_count then
local pickup = inserter.surface.find_entities_filtered({position = inserter.pickup_position, limit = 1})
if #pickup > 0 then
local inventory = pickup[1].get_output_inventory()
if inventory then
local mode = game.players[event.player_index].mod_settings["Autofilter_Mode"].value
if mode == "content" and not inventory.is_empty() then
for slot,item in pairs(get_items_by_content(inserter,inventory)) do
inserter.set_filter(slot,item)
end
elseif mode == "filter" and inventory.is_filtered() then
for slot,item in pairs(get_items_by_filter(inserter,inventory)) do
inserter.set_filter(slot,item)
if inserter.type == "inserter" then
if inserter.filter_slot_count then
if is_filter_empty(inserter) and inserter.inserter_filter_mode == "whitelist" then
local pickup = inserter.surface.find_entities_filtered({position = inserter.pickup_position, limit = 1})
if #pickup > 0 then
local inventory = pickup[1].get_output_inventory()
if inventory then
local mode = game.players[event.player_index].mod_settings["Autofilter_Mode"].value
if mode == "content" and not inventory.is_empty() then
for slot,item in pairs(get_items_by_content(inserter,inventory)) do
inserter.set_filter(slot,item)
end
elseif mode == "filter" and inventory.is_filtered() then
for slot,item in pairs(get_items_by_filter(inserter,inventory)) do
inserter.set_filter(slot,item)
end
end
end
end
end
+2 -2
View File
@@ -1,11 +1,11 @@
{
"name": "Autofilter",
"version": "0.18.3",
"version": "0.18.5",
"title": "Autofilter",
"author": "Wyrrrd",
"dependencies": [
"base >= 0.18.0",
"!upgrade-planner-next"
"(?)bobinserters"
],
"description": "Automatically set inserter filters based on adjacent inventory.",
"factorio_version": "0.18"
+3
View File
@@ -1,3 +1,6 @@
[mod-description]
Autofilter=Setzt Greifarmfilter automatisch, basierend auf dem angrenzenden Inventar.
[mod-setting-name]
Autofilter_Mode=Autofilter-Modus
+3
View File
@@ -1,3 +1,6 @@
[mod-description]
Autofilter=Automatically set inserter filters based on adjacent inventory.
[mod-setting-name]
Autofilter_Mode=Autofilter Mode