mirror of
https://github.com/Wyrrrd/Autofilter.git
synced 2026-06-30 10:02:27 +02:00
Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 27fa26ee13 | |||
| 8ce0cbbf8e | |||
| aed3caddda | |||
| d3ca77eede | |||
| 94e7309dd0 | |||
| a7a7816f89 | |||
| 3a859a941d | |||
| 50d63e8e3c | |||
| d87491c622 | |||
| 5ed50dcfb3 | |||
| 312cb20225 | |||
| 7ec64d2f62 | |||
| fc2afea961 | |||
| acb9688477 | |||
| 3b9424d6ca | |||
| 776ebf9eff |
@@ -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.
|
||||
+61
-5
@@ -1,12 +1,68 @@
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Version: 0.18.8
|
||||
Date: 6. 3. 2020
|
||||
Changes:
|
||||
- Merged Informatron pages into single one
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Version: 0.18.7
|
||||
Date: 5. 3. 2020
|
||||
Features:
|
||||
- Added integration with Informatron (for german and english locales)
|
||||
Changes:
|
||||
- Minor code readability improvements
|
||||
- Added earlier check for setting "none" to prevent more code from running
|
||||
---------------------------------------------------------------------------------------------------
|
||||
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:
|
||||
- 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
|
||||
Bug:
|
||||
- Added missing entity check
|
||||
(caused game crash on inserter placement without adjacent entity)
|
||||
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: 27. 2. 2020
|
||||
Info:
|
||||
- Retroactive downgrade
|
||||
---------------------------------------------------------------------------------------------------
|
||||
+32
-16
@@ -1,9 +1,19 @@
|
||||
--control.lua
|
||||
require("integrations.informatron.control")
|
||||
|
||||
--functions definitions
|
||||
local function get_items_by_content(inserter,inventory)
|
||||
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_contents(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
|
||||
@@ -22,20 +32,26 @@ local function get_items_by_filter(inserter,inventory)
|
||||
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)
|
||||
local mode = game.players[event.player_index].mod_settings["autofilter_mode"].value
|
||||
if mode ~= "none" then
|
||||
local inserter = event.created_entity
|
||||
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
|
||||
if mode == "contents" and not inventory.is_empty() then
|
||||
for slot,item in pairs(get_items_by_contents(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,13 @@
|
||||
{
|
||||
"name": "Autofilter",
|
||||
"version": "0.18.1",
|
||||
"version": "0.18.8",
|
||||
"title": "Autofilter",
|
||||
"author": "Wyrrrd",
|
||||
"dependencies": ["base >= 0.18.0"],
|
||||
"dependencies": [
|
||||
"base >= 0.18.0",
|
||||
"(?) bobinserters >= 0.18.0",
|
||||
"? informatron >= 0.1.5"
|
||||
],
|
||||
"description": "Automatically set inserter filters based on adjacent inventory.",
|
||||
"factorio_version": "0.18"
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
if script.active_mods["informatron"] then
|
||||
remote.add_interface("autofilter", {
|
||||
informatron_menu = function(data)
|
||||
return autofilter_menu(data.player_index)
|
||||
end,
|
||||
informatron_page_content = function(data)
|
||||
return autofilter_page_content(data.page_name, data.player_index, data.element)
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
function autofilter_menu(player_index)
|
||||
return {}
|
||||
end
|
||||
|
||||
function autofilter_page_content(page_name, player_index, element)
|
||||
if page_name == "autofilter" then
|
||||
element.add{type="button", name="image_autofilter", style="autofilter_thumbnail"}
|
||||
element.add{type="label", name="text_autofilter", caption={"autofilter.page_autofilter_text"}}
|
||||
element.add{type="label", name="heading_modes", caption={"autofilter.page_modes_heading"}, style="heading_1_label"}
|
||||
element.add{type="label", name="heading_contents", caption={"autofilter.page_contents_heading"}, style="heading_2_label"}
|
||||
element.add{type="button", name="image_contents", style="autofilter_settings_contents"}
|
||||
element.add{type="label", name="text_contents", caption={"autofilter.page_contents_text"}}
|
||||
element.add{type="label", name="heading_filter", caption={"autofilter.page_filter_heading"}, style="heading_2_label"}
|
||||
element.add{type="button", name="image_filter", style="autofilter_settings_filter"}
|
||||
element.add{type="label", name="text_filter", caption={"autofilter.page_filter_text"}}
|
||||
element.add{type="label", name="heading_none", caption={"autofilter.page_none_heading"}, style="heading_2_label"}
|
||||
element.add{type="button", name="image_none", style="autofilter_settings_none"}
|
||||
element.add{type="label", name="text_none", caption={"autofilter.page_none_text"}}
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
if mods["informatron"] then
|
||||
informatron_make_image("autofilter_thumbnail", "__Autofilter__/integrations/informatron/thumbnail.png", 360, 156)
|
||||
informatron_make_image("autofilter_settings_contents", "__Autofilter__/integrations/informatron/settings_contents.png", 400, 128)
|
||||
informatron_make_image("autofilter_settings_filter", "__Autofilter__/integrations/informatron/settings_filter.png", 400, 128)
|
||||
informatron_make_image("autofilter_settings_none", "__Autofilter__/integrations/informatron/settings_none.png", 400, 128)
|
||||
end
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 80 KiB |
+20
-5
@@ -1,10 +1,25 @@
|
||||
[mod-description]
|
||||
Autofilter=Setzt Greifarmfilter automatisch, basierend auf dem angrenzenden Inventar.
|
||||
|
||||
[mod-setting-name]
|
||||
Autofilter_Mode=Autofilter-Modus
|
||||
autofilter_mode=Autofilter-Modus
|
||||
|
||||
[mod-setting-description]
|
||||
Autofilter_Mode=Ändere, ob Greifarmfilter durch Inventarinhalt, Inventarfilter oder gar nicht gesetzt werden sollen.
|
||||
autofilter_mode=Ändere, ob Greifarmfilter durch Inventarinhalt, Inventarfilter oder gar nicht gesetzt werden sollen.
|
||||
|
||||
[string-mod-setting]
|
||||
Autofilter_Mode-content=Inhalt
|
||||
Autofilter_Mode-filter=Filter
|
||||
Autofilter_Mode-none=Keiner
|
||||
autofilter_mode-contents=Inhalt
|
||||
autofilter_mode-filter=Filter
|
||||
autofilter_mode-none=Keiner
|
||||
|
||||
[autofilter]
|
||||
menu_autofilter=Autofilter
|
||||
title_autofilter=Autofilter
|
||||
page_autofilter_text=Diese Mod sorgt dafür, dass Greifarmfilter beim manuellen Platzieren automatischgesetzt werden, basierend auf dem angrenzenden Inventar. Der Modus, nachdem die Gegenstände für den Filter ausgewählt werden, kann in den Spieler-Mod-Einstellungen während des Spiels angepasst werden.
|
||||
page_modes_heading=Modus
|
||||
page_contents_heading=Inhalt
|
||||
page_contents_text=Bei Verwendung des Inhaltsmodus wird der Filter manuell platzierter Filtergreifarme auf die Gegenstände gesetzt, die sich am Aufnahmepunkt in einem Inventar (Kiste, Wagon, etc.) befinden. Es können natürlich maximal so viele verschiedene Gegenstände als Filter gesetzt werden, wie Platz im Greifarmfilter ist.
|
||||
page_filter_heading=Filter
|
||||
page_filter_text=Bei Verwendung des Filtermodus wird der Filter manuell platzierter Filtergreifarme auf die Gegenstände gesetzt, auf die das am Aufnahmepunkt befindliche Inventar (Kiste, Wagon, etc.) gefiltert ist. Hierbei ist irrelevant, ob das Inventar komplett oder nur teilweise gefiltert ist.
|
||||
page_none_heading=Keiner
|
||||
page_none_text=Bei Deaktivierung des Modus funktioniert die Platzierung von Filtergreifarmen normal. Der Greifarmfilter wird nicht automatisch gesetzt.
|
||||
+20
-5
@@ -1,10 +1,25 @@
|
||||
[mod-description]
|
||||
Autofilter=Automatically set inserter filters based on adjacent inventory.
|
||||
|
||||
[mod-setting-name]
|
||||
Autofilter_Mode=Autofilter Mode
|
||||
autofilter_mode=Autofilter Mode
|
||||
|
||||
[mod-setting-description]
|
||||
Autofilter_Mode=Change if inserter filters should be set from inventory items, inventory filter or not at all.
|
||||
autofilter_mode=Change if inserter filters should be set from inventory items, inventory filter or not at all.
|
||||
|
||||
[string-mod-setting]
|
||||
Autofilter_Mode-content=Content
|
||||
Autofilter_Mode-filter=Filter
|
||||
Autofilter_Mode-none=None
|
||||
autofilter_mode-contents=Contents
|
||||
autofilter_mode-filter=Filter
|
||||
autofilter_mode-none=None
|
||||
|
||||
[Autofilter]
|
||||
menu_autofilter=Autofilter
|
||||
title_autofilter=Autofilter
|
||||
page_autofilter_text=This mod causes inserter filters to be set automatically on manual placement, based on the adjacent inventory. The modus, which specifies the items used for the filter, can be changed on the fly in player mod settings.
|
||||
page_modes_heading=Modus
|
||||
page_contents_heading=Contents
|
||||
page_contents_text=When using contents mode, the filter of manually placed filter inserters is set to the items in an inventory (chest, waggon, etc.) at the pickup point. Naturally, the filter can only be set to as many items as there are filter slots in the inserter.
|
||||
page_filter_heading=Filter
|
||||
page_filter_text=When using filter mode, the filter of manually placed filter inserters is set to the filtered slots of an inventory (chest, waggon, etc.) at the pickup point. It is irrelevant, if the inventory is partially or completely filtered.
|
||||
page_none_heading=None
|
||||
page_none_text=When disabling the mode, manual placement of filter inserters works as usual. The inserter filter is not set automatically.
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
data:extend({
|
||||
{
|
||||
type = "string-setting",
|
||||
name = "Autofilter_Mode",
|
||||
default_value = "content",
|
||||
allowed_values = {"content","filter","none"},
|
||||
name = "autofilter_mode",
|
||||
default_value = "contents",
|
||||
allowed_values = {"contents","filter","none"},
|
||||
setting_type = "runtime-per-user",
|
||||
order = "a",
|
||||
},
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 110 KiB After Width: | Height: | Size: 174 KiB |
Reference in New Issue
Block a user