mirror of
https://github.com/Wyrrrd/Autofilter.git
synced 2026-03-25 16:09:49 +01:00
Added entity type check
Apparently event filters are not applied to mod-raised events
This commit is contained in:
@@ -1,4 +1,12 @@
|
||||
---------------------------------------------------------------------------------------------------
|
||||
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
control.lua
28
control.lua
@@ -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,12 +1,9 @@
|
||||
{
|
||||
"name": "Autofilter",
|
||||
"version": "0.18.3",
|
||||
"version": "0.18.4",
|
||||
"title": "Autofilter",
|
||||
"author": "Wyrrrd",
|
||||
"dependencies": [
|
||||
"base >= 0.18.0",
|
||||
"!upgrade-planner-next"
|
||||
],
|
||||
"dependencies": ["base >= 0.18.0"],
|
||||
"description": "Automatically set inserter filters based on adjacent inventory.",
|
||||
"factorio_version": "0.18"
|
||||
}
|
||||
Reference in New Issue
Block a user