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

15 Commits

Author SHA1 Message Date
Wyrrrd 461a88e6bd Version bump for base game 1.1 2020-12-02 18:51:08 +01:00
Wyrrrd bfc4e6aa3d Added integration with Booktorio 2020-04-03 13:42:39 +02:00
Wyrrrd c36e55c961 Added wiki integration
Also moved graphics to be used by both integrations
2020-03-29 14:03:06 +02:00
Wyrrrd e6164a2d96 Update changelog.txt
Fixed formatting (again)
2020-03-07 10:47:14 +01:00
Wyrrrd e2ece3e288 Update README.md
i did a link oopsie
2020-03-06 15:33:24 +01:00
Wyrrrd 31e723c8df Update README.md
Matched to mod portal description
2020-03-06 15:29:51 +01:00
Wyrrrd 27fa26ee13 Merged Informatron pages into one 2020-03-06 15:11:53 +01:00
Wyrrrd 8ce0cbbf8e Multiple things
- Fixed changelog (again)
- Added integration for Informatron
- Moved some capitalisation around
- Added mode=none check for performance
2020-03-05 18:34:55 +01:00
Wyrrrd aed3caddda Fixed empty filter check
Now checks all slots instead of just one
2020-02-27 06:34:36 +01:00
Wyrrrd d3ca77eede Update changelog.txt
Fixed formatting (again)
2020-02-24 19:18:50 +01:00
Wyrrrd 94e7309dd0 Update README.md
Matched with mod portal description
2020-02-24 19:09:55 +01:00
Wyrrrd a7a7816f89 Update changelog.txt
Updated retroactive downgrade
2020-02-24 18:58:40 +01:00
Wyrrrd 3a859a941d Added check for empty filter and whitelist mode
Avoids overwriting filter on replacing preexisting inserters/ghosts
2020-02-24 18:56:01 +01:00
Wyrrrd 50d63e8e3c Added hidden dependency
Fixes setting filter from wrong inventory when pickup location is rotated by Bob's Adjustable Inserters
2020-02-24 18:43:00 +01:00
Wyrrrd d87491c622 Added translated mod description 2020-02-24 18:27:24 +01:00
20 changed files with 311 additions and 51 deletions
+1
View File
@@ -0,0 +1 @@
*.zip
+12 -8
View File
@@ -1,12 +1,16 @@
# 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 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.
### Features
When you manually place a filter inserter, it reads either the inventory contents or inventory filters on the pickup side and sets its filter to those items. The mode can be changed or disabled in player mod settings on the fly as needed.
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.
### Compatibility
This mod should work with all modded filter inserters, but I specifically added compatibility for the following mods:
+ [Bob's Adjustable Inserters](https://mods.factorio.com/mod/bobinserters) - rotated pickup positions
+ [Informatron](https://mods.factorio.com/mod/informatron) - informational page to explain modes
+ [Factorio Wiki Mod](https://mods.factorio.com/mod/wiki) - informational topic to explain modes
+ [Booktorio](https://mods.factorio.com/mod/Booktorio) - informational thread to explain modes
### Locale
If you want to contribute by translating this mod, you can view the existing translations [here](https://github.com/Wyrrrd/Autofilter/tree/master/locale). I'd be happy to add your language and credits to the next release.
+51 -11
View File
@@ -1,42 +1,82 @@
---------------------------------------------------------------------------------------------------
Version: 1.1.0
Date: 2020-12-02
Changes:
- Version bump for base game 1.1
---------------------------------------------------------------------------------------------------
Version: 0.18.10
Date: 2020-04-03
Features:
- Added integration with Booktorio (for german and english locales)
---------------------------------------------------------------------------------------------------
Version: 0.18.9
Date: 2020-03-29
Features:
- Added integration with Factorio Wiki Mod (for german and english locales)
---------------------------------------------------------------------------------------------------
Version: 0.18.8
Date: 2020-03-06
Changes:
- Merged Informatron pages into single one
---------------------------------------------------------------------------------------------------
Version: 0.18.7
Date: 2020-03-05
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: 2020-02-27
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: 2020-02-24
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
Date: 2020-02-23
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
Date: 2020-02-23
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
Date: 2020-02-22
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
Date: 2020-02-22
Bugfixes:
- Added missing entity check (caused game crash on inserter placement without adjacent entity)
---------------------------------------------------------------------------------------------------
Version: 0.18.0
Date: 22. 2. 2020
Date: 2020-02-22
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
Date: 2020-02-27
Info:
- Retroactive downgrade
---------------------------------------------------------------------------------------------------
- Retroactive downgrade
+32 -16
View File
@@ -1,7 +1,19 @@
--control.lua
require("integrations.informatron.control")
require("integrations.wiki.control")
require("integrations.Booktorio.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,_ in pairs(inventory.get_contents()) do
if #items < inserter.filter_slot_count then
@@ -22,21 +34,25 @@ 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
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
+4
View File
@@ -0,0 +1,4 @@
--data.lua
require("integrations.informatron.data")
require("integrations.wiki.data")
require("integrations.Booktorio.data")
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

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

+9 -3
View File
@@ -1,9 +1,15 @@
{
"name": "Autofilter",
"version": "0.18.4",
"version": "1.1.0",
"title": "Autofilter",
"author": "Wyrrrd",
"dependencies": ["base >= 0.18.0"],
"dependencies": [
"base >= 1.1.0",
"(?) bobinserters >= 0.18.0",
"? Booktorio >= 1.1.0",
"? informatron >= 0.1.5",
"? wiki >= 0.18.01"
],
"description": "Automatically set inserter filters based on adjacent inventory.",
"factorio_version": "0.18"
"factorio_version": "1.1"
}
+41
View File
@@ -0,0 +1,41 @@
local autofilter_thread =
{
name = {"autofilter.menu_autofilter"},
specified_version = 0,
topics =
{
{
name = {"autofilter.title_autofilter"},
topic =
{
{type = "image", spritename = "autofilter-logo"},
{type = "text", text = "info.page_autofilter_text"}
}
},
{
name = {"info.page_modes_heading"},
topic =
{
{type = "title", title = {"info.page_modes_heading"}},
{type = "subtitle", subtitle = {"info.page_contents_heading"}},
{type = "image", spritename = "autofilter-settings-contents"},
{type = "text", text = "info.page_contents_text"},
{type = "subtitle", subtitle = {"info.page_filter_heading"}},
{type = "image", spritename = "autofilter-settings-filter"},
{type = "text", text = "info.page_filter_text"},
{type = "subtitle", subtitle = {"info.page_none_heading"}},
{type = "image", spritename = "autofilter-settings-none"},
{type = "text", text = "info.page_none_text"}
}
}
}
}
local function registerThread()
if remote.interfaces["Booktorio"] then
remote.call("Booktorio", "add_thread", autofilter_thread)
end
end
script.on_init(registerThread)
script.on_configuration_changed(registerThread)
+37
View File
@@ -0,0 +1,37 @@
if mods["Booktorio"] then
data:extend(
{
{
type = "sprite",
name = "autofilter-logo",
filename = "__Autofilter__/graphics/logo.png",
width = 360,
height = 156,
scale = 1
},
{
type = "sprite",
name = "autofilter-settings-contents",
filename = "__Autofilter__/graphics/settings_contents.png",
width = 400,
height = 128,
scale = 1
},
{
type = "sprite",
name = "autofilter-settings-filter",
filename = "__Autofilter__/graphics/settings_filter.png",
width = 400,
height = 128,
scale = 1
},
{
type = "sprite",
name = "autofilter-settings-none",
filename = "__Autofilter__/graphics/settings_none.png",
width = 400,
height = 128,
scale = 1
}
})
end
+31
View File
@@ -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_logo"}
element.add{type="label", name="text_autofilter", caption={"info.page_autofilter_text"}}
element.add{type="label", name="heading_modes", caption={"info.page_modes_heading"}, style="heading_1_label"}
element.add{type="label", name="heading_contents", caption={"info.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={"info.page_contents_text"}}
element.add{type="label", name="heading_filter", caption={"info.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={"info.page_filter_text"}}
element.add{type="label", name="heading_none", caption={"info.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={"info.page_none_text"}}
end
end
+6
View File
@@ -0,0 +1,6 @@
if mods["informatron"] then
informatron_make_image("autofilter_logo", "__Autofilter__/graphics/logo.png", 360, 156)
informatron_make_image("autofilter_settings_contents", "__Autofilter__/graphics/settings_contents.png", 400, 128)
informatron_make_image("autofilter_settings_filter", "__Autofilter__/graphics/settings_filter.png", 400, 128)
informatron_make_image("autofilter_settings_none", "__Autofilter__/graphics/settings_none.png", 400, 128)
end
+10
View File
@@ -0,0 +1,10 @@
require("integrations.wiki.wiki")
if script.active_mods["wiki"] then
local initialize_wiki = function()
remote.call("wiki","register_mod_wiki",autofilter_wiki)
end
script.on_init(function() initialize_wiki() end)
script.on_load(function() initialize_wiki() end)
end
+5
View File
@@ -0,0 +1,5 @@
require("integrations.wiki.wiki")
if mods["wiki"] then
wiki_register_mod_wiki(autofilter_wiki)
end
+25
View File
@@ -0,0 +1,25 @@
autofilter_wiki =
{
name = "Autofilter",
title = "Autofilter",
mod_path = "__Autofilter__",
{
name = {"autofilter.title_autofilter"},
topic = {
{type = "image", name = "image_autofilter", filepath = "__Autofilter__/graphics/logo.png", width = 360, height = 156, scale = 1},
{type = "text", text = {"info.page_autofilter_text"} },
{type = "line"},
{type = "title", title = {"info.page_contents_heading"} },
{type = "image", name = "image_contents", filepath = "__Autofilter__/graphics/settings_contents.png", width = 400, height = 128, scale = 0.9},
{type = "text", text = {"info.page_contents_text"} },
{type = "line"},
{type = "title", title = {"info.page_filter_heading"} },
{type = "image", name = "image_filter", filepath = "__Autofilter__/graphics/settings_filter.png", width = 400, height = 128, scale = 0.9},
{type = "text", text = {"info.page_filter_text"} },
{type = "line"},
{type = "title", title = {"info.page_none_heading"} },
{type = "image", name = "image_none", filepath = "__Autofilter__/graphics/settings_none.png", width = 400, height = 128, scale = 0.9},
{type = "text", text = {"info.page_none_text"} },
}
}
}
+22 -5
View File
@@ -1,10 +1,27 @@
[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
[info]
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.
+22 -5
View File
@@ -1,10 +1,27 @@
[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
[info]
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
View File
@@ -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",
},