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

5 Commits

Author SHA1 Message Date
Wyrrrd 5ed50dcfb3 Added entity type check
Apparently event filters are not applied to mod-raised events
2020-02-23 15:17:15 +01:00
Wyrrrd 312cb20225 Added incompatibility (for now) 2020-02-23 10:38:53 +01:00
Wyrrrd 7ec64d2f62 Added incompatibility (for now) 2020-02-23 10:36:12 +01:00
Wyrrrd fc2afea961 Minor improvements
- Typos
- Code style
- Better thumbnail
2020-02-23 00:45:02 +01:00
Wyrrrd acb9688477 Update README.md
Matched with mod portal desciption
2020-02-22 17:11:04 +01:00
5 changed files with 44 additions and 20 deletions
+10 -5
View File
@@ -1,7 +1,12 @@
# Autofilter
![mod thumbnail](https://raw.githubusercontent.com/Wyrrrd/Autofilter/master/thumbnail.png)
<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).
- 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.
+17
View File
@@ -1,4 +1,21 @@
---------------------------------------------------------------------------------------------------
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:
+16 -14
View File
@@ -3,7 +3,7 @@
--functions definitions
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
@@ -23,19 +23,21 @@ 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
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
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "Autofilter",
"version": "0.18.2",
"version": "0.18.4",
"title": "Autofilter",
"author": "Wyrrrd",
"dependencies": ["base >= 0.18.0"],
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

After

Width:  |  Height:  |  Size: 174 KiB