mirror of
https://github.com/Wyrrrd/Autofilter.git
synced 2026-06-30 10:02:27 +02:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| aed3caddda | |||
| d3ca77eede | |||
| 94e7309dd0 | |||
| a7a7816f89 | |||
| 3a859a941d | |||
| 50d63e8e3c | |||
| d87491c622 | |||
| 5ed50dcfb3 |
@@ -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.
|
||||
+27
-1
@@ -1,4 +1,30 @@
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Version: 0.18.6
|
||||
Date: 27. 2. 2020
|
||||
Changes:
|
||||
- Updated retroactive downgrade to be on par with this version
|
||||
|
||||
Bugfixes:
|
||||
- Fixed empty filter check, so it checks all slots instead of just the first one
|
||||
---------------------------------------------------------------------------------------------------
|
||||
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 +54,7 @@ Date: 22. 2. 2020
|
||||
- Added player mod setting to control mod behaviour
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Version: 0.17.0
|
||||
Date: 22. 2. 2020
|
||||
Date: 27. 2. 2020
|
||||
Info:
|
||||
- Retroactive downgrade
|
||||
---------------------------------------------------------------------------------------------------
|
||||
+26
-13
@@ -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
|
||||
end
|
||||
return true
|
||||
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
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"name": "Autofilter",
|
||||
"version": "0.18.3",
|
||||
"version": "0.18.6",
|
||||
"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"
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
[mod-description]
|
||||
Autofilter=Setzt Greifarmfilter automatisch, basierend auf dem angrenzenden Inventar.
|
||||
|
||||
[mod-setting-name]
|
||||
Autofilter_Mode=Autofilter-Modus
|
||||
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
[mod-description]
|
||||
Autofilter=Automatically set inserter filters based on adjacent inventory.
|
||||
|
||||
[mod-setting-name]
|
||||
Autofilter_Mode=Autofilter Mode
|
||||
|
||||
|
||||
Reference in New Issue
Block a user