mirror of
https://github.com/Wyrrrd/Autofilter.git
synced 2026-03-25 16:09:49 +01:00
Multiple things
- Fixed changelog (again) - Added integration for Informatron - Moved some capitalisation around - Added mode=none check for performance
This commit is contained in:
@@ -1,9 +1,16 @@
|
||||
---------------------------------------------------------------------------------------------------
|
||||
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
|
||||
---------------------------------------------------------------------------------------------------
|
||||
@@ -13,7 +20,6 @@ Date: 24. 2. 2020
|
||||
- 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
|
||||
---------------------------------------------------------------------------------------------------
|
||||
@@ -21,7 +27,6 @@ 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
|
||||
---------------------------------------------------------------------------------------------------
|
||||
@@ -30,7 +35,6 @@ 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
|
||||
---------------------------------------------------------------------------------------------------
|
||||
@@ -38,7 +42,6 @@ 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
|
||||
---------------------------------------------------------------------------------------------------
|
||||
|
||||
37
control.lua
37
control.lua
@@ -1,4 +1,5 @@
|
||||
--control.lua
|
||||
require("integrations.informatron.control")
|
||||
|
||||
--functions definitions
|
||||
local function is_filter_empty(inserter)
|
||||
@@ -10,7 +11,7 @@ local function is_filter_empty(inserter)
|
||||
return true
|
||||
end
|
||||
|
||||
local function get_items_by_content(inserter,inventory)
|
||||
local function get_items_by_contents(inserter,inventory)
|
||||
local items = {}
|
||||
for item,_ in pairs(inventory.get_contents()) do
|
||||
if #items < inserter.filter_slot_count then
|
||||
@@ -31,22 +32,24 @@ local function get_items_by_filter(inserter,inventory)
|
||||
end
|
||||
|
||||
local function on_built_entity(event)
|
||||
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
|
||||
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
|
||||
|
||||
2
data.lua
Normal file
2
data.lua
Normal file
@@ -0,0 +1,2 @@
|
||||
--data.lua
|
||||
require("integrations.informatron.data")
|
||||
@@ -1,11 +1,12 @@
|
||||
{
|
||||
"name": "Autofilter",
|
||||
"version": "0.18.6",
|
||||
"version": "0.18.7",
|
||||
"title": "Autofilter",
|
||||
"author": "Wyrrrd",
|
||||
"dependencies": [
|
||||
"base >= 0.18.0",
|
||||
"(?)bobinserters"
|
||||
"(?) bobinserters >= 0.18.0",
|
||||
"? informatron >= 0.1.5"
|
||||
],
|
||||
"description": "Automatically set inserter filters based on adjacent inventory.",
|
||||
"factorio_version": "0.18"
|
||||
|
||||
35
integrations/informatron/control.lua
Normal file
35
integrations/informatron/control.lua
Normal file
@@ -0,0 +1,35 @@
|
||||
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 {
|
||||
mode=1,
|
||||
}
|
||||
end
|
||||
|
||||
function autofilter_page_content(page_name, player_index, element)
|
||||
if page_name == "autofilter" then
|
||||
element.add{type="label", name="text_autofilter", caption={"autofilter.page_autofilter_text"}}
|
||||
local image_container = element.add{type="button", name="image_autofilter", style="autofilter_thumbnail"}
|
||||
image_container.style.horizontal_align = "center"
|
||||
end
|
||||
if page_name == "mode" then
|
||||
element.add{type="label", name="heading_contents", caption={"autofilter.page_contents_heading"}, style="heading_1_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_1_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_1_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
|
||||
6
integrations/informatron/data.lua
Normal file
6
integrations/informatron/data.lua
Normal file
@@ -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
|
||||
BIN
integrations/informatron/settings_contents.png
Normal file
BIN
integrations/informatron/settings_contents.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
BIN
integrations/informatron/settings_filter.png
Normal file
BIN
integrations/informatron/settings_filter.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
BIN
integrations/informatron/settings_none.png
Normal file
BIN
integrations/informatron/settings_none.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
BIN
integrations/informatron/thumbnail.png
Normal file
BIN
integrations/informatron/thumbnail.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 80 KiB |
@@ -2,12 +2,25 @@
|
||||
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=Setzt Greifarmfilter automatisch, basierend auf dem angrenzenden Inventar. Diese Funktion kann in den Mod-Einstellungen während des Spiels angepasst werden.
|
||||
menu_mode=Modus
|
||||
title_mode=Autofilter-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.
|
||||
@@ -2,12 +2,25 @@
|
||||
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=Automatically set inserter filters based on adjacent inventory. This can be changed on the fly in mod settings.
|
||||
menu_mode=Modus
|
||||
title_mode=Autofilter 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.
|
||||
@@ -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",
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user