mirror of
https://github.com/Wyrrrd/Autofilter.git
synced 2026-06-30 18:07:19 +02:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d3ca77eede | |||
| 94e7309dd0 | |||
| a7a7816f89 | |||
| 3a859a941d | |||
| 50d63e8e3c | |||
| d87491c622 | |||
| 5ed50dcfb3 | |||
| 312cb20225 | |||
| 7ec64d2f62 | |||
| fc2afea961 | |||
| acb9688477 | |||
| 3b9424d6ca | |||
| 776ebf9eff | |||
| ab4339a87d |
@@ -1,7 +1,9 @@
|
||||
# Autofilter
|
||||

|
||||
<img src="https://raw.githubusercontent.com/Wyrrrd/Autofilter/master/thumbnail.png" width="128" height="128">
|
||||
|
||||
Description
|
||||
- When you place a filter inserter, it reads either the inventory contents or inventory filters on the input side and sets it's filter to those items.
|
||||
- Works only until the inserter filter is full (of course).
|
||||
- The mode can be changed or disabled in player mod settings on the fly as needed.
|
||||
### 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.
|
||||
+48
-2
@@ -1,6 +1,52 @@
|
||||
---------------------------------------------------------------------------------------------------
|
||||
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:
|
||||
- Minor improvements (typos, code style)
|
||||
- Added incompatibility with Upgrade Builder and Planner (until crash is fixed, see https://mods.factorio.com/mod/Autofilter/discussion/5e5177cbf26569000bdd51eb)
|
||||
|
||||
Graphics:
|
||||
- Changed thumbnail to the better
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Version: 0.18.2
|
||||
Date: 22. 2. 2020
|
||||
Changes:
|
||||
- Matched changelog file format to what Factorio expects
|
||||
|
||||
Info:
|
||||
- Also downgraded to Factorio 0.17, see below
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Version: 0.18.1
|
||||
Date: 22. 2. 2020
|
||||
Bugfixes:
|
||||
- Added missing entity check (caused game crash on inserter placement without adjacent entity)
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Version: 0.18.0
|
||||
Date: 22. 2. 2020
|
||||
Changes:
|
||||
- Initial release
|
||||
Features:
|
||||
- Added automatic setting of filter on inserter placement
|
||||
- Added player mod setting to control mod behaviour
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Version: 0.17.0
|
||||
Date: 24. 2. 2020
|
||||
Info:
|
||||
- Retroactive downgrade
|
||||
---------------------------------------------------------------------------------------------------
|
||||
+29
-13
@@ -1,9 +1,18 @@
|
||||
--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,count in pairs(inventory.get_contents()) do
|
||||
for item,_ in pairs(inventory.get_contents()) do
|
||||
if #items < inserter.filter_slot_count then
|
||||
items[#items+1] = item
|
||||
end
|
||||
@@ -13,7 +22,7 @@ end
|
||||
|
||||
local function get_items_by_filter(inserter,inventory)
|
||||
local items = {}
|
||||
for slot = 1,#inventory,1 do
|
||||
for slot = 1,#inventory do
|
||||
if #items < inserter.filter_slot_count and inventory.get_filter(slot) then
|
||||
items[#items+1] = inventory.get_filter(slot)
|
||||
end
|
||||
@@ -23,17 +32,24 @@ end
|
||||
|
||||
local function on_built_entity(event)
|
||||
local inserter = event.created_entity
|
||||
if inserter.filter_slot_count then
|
||||
local inventory = inserter.surface.find_entities_filtered({position = inserter.pickup_position, limit = 1})[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
|
||||
end
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
{
|
||||
"name": "Autofilter",
|
||||
"version": "0.18.0",
|
||||
"version": "0.18.5",
|
||||
"title": "Autofilter",
|
||||
"author": "Wyrrrd",
|
||||
"dependencies": ["base >= 0.18.0"],
|
||||
"dependencies": [
|
||||
"base >= 0.18.0",
|
||||
"(?)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
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 110 KiB After Width: | Height: | Size: 174 KiB |
Reference in New Issue
Block a user