From 8b2948b42b55828ad61ef0e0e9557d9a56a86eb5 Mon Sep 17 00:00:00 2001 From: Patrick 'Quezler' Mounier Date: Tue, 22 Jul 2025 14:53:44 +0200 Subject: [PATCH 1/3] Update data.lua --- data.lua | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/data.lua b/data.lua index b0ac749..1f30949 100644 --- a/data.lua +++ b/data.lua @@ -15,4 +15,23 @@ styles["fh_deep_frame"] = { -- left_margin = 8, -- right_margin = 8, -- bottom_margin = 4 -} \ No newline at end of file +} + +-- in order to override the logic for an entity just add their name pointing to a remote interface in your own mod: +-- data.raw["mod-data"]["fh_add_items_drop_target_entity"].data["assembling-machine-3"] = {"interface", "function"} +data:extend{ + { + type = "mod-data", + name = "fh_add_items_drop_target_entity", + data = {}, + }, + { + type = "mod-data", + name = "fh_add_items_pickup_target_entity", + data = {}, + }, +} +-- in your remote interface you will receive the entity and an empty array of items for your convenience, +-- the array of items should always be returned, items are allowed to be in several formats. +-- (see fh_util for details, most notably: item_name, {name = "name"} & prototypes) +-- note: your mod becomes responsible for ALL suggestions for that entity, like burn results and spoilage. From 91b296617437af3b9df0e33fc8a15a371d0ccc6d Mon Sep 17 00:00:00 2001 From: Patrick 'Quezler' Mounier Date: Tue, 22 Jul 2025 14:54:31 +0200 Subject: [PATCH 2/3] Update control.lua --- control.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/control.lua b/control.lua index 860ae5e..621e690 100644 --- a/control.lua +++ b/control.lua @@ -1,6 +1,15 @@ local get_filter_updater = require("filter_updaters") local fh_util = require("fh_util") +-- validate the mod data to ensure each entity name exists and points to a valid remote interface. +for _, hook in ipairs({"fh_add_items_drop_target_entity", "fh_add_items_pickup_target_entity"}) do + for entity_name, data in pairs(prototypes.mod_data[hook].data) do + assert(prototypes.entity[entity_name], string.format('prototypes.entity["%s"] == nil', entity_name)) + -- assert(remote.interfaces[data[1]], string.format('remote.interfaces["%s"] == nil', data[1])) + -- assert(remote.interfaces[data[1]][data[2]], string.format('remote.interfaces["%s"]["%s"] == nil', data[1], data[2])) + end +end + local function contains(table, val) for i = 1, #table do if table[i] == val then @@ -285,6 +294,14 @@ end ---@param items table ---Adds to the filter item list based on an entity being taken from function FilterHelper.add_items_pickup_target_entity(target, items) + local mod_data = prototypes.mod_data["fh_add_items_pickup_target_entity"].get(target.name) + if mod_data then + for _, item in ipairs(remote.call(mod_data[1], mod_data[2], target, {})) do + fh_util.add_item_to_table(items, item) + end + return + end + if fh_util.get_effective_type(target) == "assembling-machine" then local recipe, quality = target.get_recipe() if recipe then @@ -357,6 +374,14 @@ end ---@param items table ---Adds to the filter item list based on an entity being given to function FilterHelper.add_items_drop_target_entity(target, items) + local mod_data = prototypes.mod_data["fh_add_items_drop_target_entity"].get(target.name) + if mod_data then + for _, item in ipairs(remote.call(mod_data[1], mod_data[2], target, {})) do + fh_util.add_item_to_table(items, item) + end + return + end + if contains({ "assembling-machine", "rocket-silo" }, fh_util.get_effective_type(target)) then local recipe, quality = target.get_recipe() if recipe then From 19a527ce322809428f4d0b4765bb21253f4ac35a Mon Sep 17 00:00:00 2001 From: Patrick 'Quezler' Mounier Date: Tue, 22 Jul 2025 14:56:16 +0200 Subject: [PATCH 3/3] Update changelog.txt --- changelog.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index 980e359..75d4b20 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,6 +2,7 @@ Version: 0.2.21 Date: ???? Changes: + - Added support for overriding the suggested filters for an entity through a remote interface. --------------------------------------------------------------------------------------------------- Version: 0.2.20 Date: 2025-06-29 @@ -226,4 +227,4 @@ Date: 2023-06-14 - Intial release - Reads chest contents - Reads recipe input/output - - Reads fuel input/output \ No newline at end of file + - Reads fuel input/output