mirror of
https://github.com/Wyrrrd/Autofilter.git
synced 2026-06-30 18:07:19 +02:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3b9424d6ca | |||
| 776ebf9eff | |||
| ab4339a87d |
+21
-2
@@ -1,6 +1,25 @@
|
||||
---------------------------------------------------------------------------------------------------
|
||||
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: 22. 2. 2020
|
||||
Info:
|
||||
- Retroactive downgrade
|
||||
---------------------------------------------------------------------------------------------------
|
||||
+14
-11
@@ -13,7 +13,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
|
||||
@@ -24,16 +24,19 @@ 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)
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user