mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-11-24 15:33:13 +09:00
Send every value, register protected entities, fix the pattern offset
- The instance sends every value of a feature, defaults included, so update_config is one loop which sets each field and compares. The stored table is the last set of values, and _apply is gone. - values_equal compares table sizes before the contents. - Protected entities are registered with register_on_object_destroyed and forgotten in on_object_destroyed, which covers every way an entity can go. The four removal handlers and the validity checks are gone. Entities destroyed while the feature is disabled are swept when it is enabled again. Saves from before the registrations table get it through the Storage on_init callback. - Spawn area applied the water offset twice and the pattern offset never. The pattern tiles now move with the entities above them. - pruneFeatureValues reads a validation result instead of catching an error, and FeaturesPage hands its pending state and unsaved bar to helpers. - Shorter comments throughout. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
f90b8fcee1
commit
2959d7476b
11 files changed
+300
-350
No files matched your search
@@ -45,18 +45,29 @@ local Protection = {
|
||||
--- @field last uint Tick of the last protected removal
|
||||
--- @field count number Protected removals since the last repeat violation
|
||||
|
||||
local protected_entities = {} --- @type table<uint, table<string, LuaEntity>> Keyed by surface index then entity key
|
||||
local protected_areas = {} --- @type table<uint, table<string, BoundingBox>> Keyed by surface index then area key
|
||||
local repeats = {} --- @type table<string, ExpScenario_Protection.Repeat> Keyed by player name
|
||||
--- @class ExpScenario_Protection.Registration
|
||||
--- @field surface_index uint
|
||||
--- @field key string
|
||||
--- @field entity LuaEntity
|
||||
|
||||
local protected_entities = {} --- @type table<uint, table<string, LuaEntity>> By surface index then entity key
|
||||
local protected_areas = {} --- @type table<uint, table<string, BoundingBox>> By surface index then area key
|
||||
local registrations = {} --- @type table<uint64, ExpScenario_Protection.Registration> By on_object_destroyed registration number
|
||||
local repeats = {} --- @type table<string, ExpScenario_Protection.Repeat> By player name
|
||||
|
||||
Storage.register({
|
||||
protected_entities = protected_entities,
|
||||
protected_areas = protected_areas,
|
||||
registrations = registrations,
|
||||
repeats = repeats,
|
||||
}, function(tbl)
|
||||
protected_entities = tbl.protected_entities
|
||||
protected_areas = tbl.protected_areas
|
||||
registrations = tbl.registrations
|
||||
repeats = tbl.repeats
|
||||
end, function(tbl)
|
||||
-- Saves from before entities were registered
|
||||
tbl.registrations = tbl.registrations or {}
|
||||
end)
|
||||
|
||||
--- Get the key an entity is stored under
|
||||
@@ -73,15 +84,18 @@ function Protection.get_area_key(area)
|
||||
return format_string("%i,%i", floor(area.left_top.x), floor(area.left_top.y))
|
||||
end
|
||||
|
||||
--- Protect an entity
|
||||
--- Protect an entity, it is forgotten when destroyed
|
||||
--- @param entity LuaEntity
|
||||
function Protection.add_entity(entity)
|
||||
local entities = protected_entities[entity.surface.index]
|
||||
local surface_index = entity.surface.index
|
||||
local entities = protected_entities[surface_index]
|
||||
if not entities then
|
||||
entities = {}
|
||||
protected_entities[entity.surface.index] = entities
|
||||
protected_entities[surface_index] = entities
|
||||
end
|
||||
entities[Protection.get_entity_key(entity)] = entity
|
||||
local key = Protection.get_entity_key(entity)
|
||||
entities[key] = entity
|
||||
registrations[script.register_on_object_destroyed(entity)] = { surface_index = surface_index, key = key, entity = entity }
|
||||
end
|
||||
|
||||
--- Remove the protection from an entity
|
||||
@@ -89,21 +103,18 @@ end
|
||||
function Protection.remove_entity(entity)
|
||||
local entities = protected_entities[entity.surface.index]
|
||||
if not entities then return end
|
||||
entities[Protection.get_entity_key(entity)] = nil
|
||||
local key = Protection.get_entity_key(entity)
|
||||
if entities[key] == entity then
|
||||
entities[key] = nil
|
||||
registrations[script.register_on_object_destroyed(entity)] = nil
|
||||
end
|
||||
end
|
||||
|
||||
--- Get the protected entities on a surface, always protected entities are not included
|
||||
-- Entities removed while the feature was disabled, or without an event, are forgotten here
|
||||
--- @param surface LuaSurface
|
||||
--- @return table<string, LuaEntity>
|
||||
function Protection.get_entities(surface)
|
||||
local entities = protected_entities[surface.index] or {}
|
||||
for key, entity in pairs(entities) do
|
||||
if not entity.valid then
|
||||
entities[key] = nil
|
||||
end
|
||||
end
|
||||
return entities
|
||||
return protected_entities[surface.index] or {}
|
||||
end
|
||||
|
||||
--- Check if an entity is protected, either directly or by its name or type
|
||||
@@ -113,13 +124,7 @@ function Protection.is_entity_protected(entity)
|
||||
if config.always_protected_names[entity.name] or config.always_protected_types[entity.type] then return true end
|
||||
local entities = protected_entities[entity.surface.index]
|
||||
if not entities then return false end
|
||||
local key = Protection.get_entity_key(entity)
|
||||
local protected = entities[key]
|
||||
if protected and not protected.valid then
|
||||
entities[key] = nil
|
||||
return false
|
||||
end
|
||||
return protected == entity
|
||||
return entities[Protection.get_entity_key(entity)] == entity
|
||||
end
|
||||
|
||||
--- Protect every position within an area
|
||||
@@ -200,7 +205,7 @@ local function raise_violation(event, player)
|
||||
end
|
||||
end
|
||||
|
||||
--- Raise the protection events when a protected entity is mined, then forget the entity
|
||||
--- Raise the protection events when a protected entity is mined
|
||||
--- @param event EventData.on_pre_player_mined_item
|
||||
local function on_pre_player_mined_item(event)
|
||||
local entity = event.entity
|
||||
@@ -211,14 +216,36 @@ local function on_pre_player_mined_item(event)
|
||||
then
|
||||
raise_violation(event, player)
|
||||
end
|
||||
|
||||
Protection.remove_entity(entity)
|
||||
end
|
||||
|
||||
--- Forget an entity once it no longer exists
|
||||
--- @param event { entity: LuaEntity }
|
||||
local function on_entity_removed(event)
|
||||
Protection.remove_entity(event.entity)
|
||||
--- Forget a protected entity once it is destroyed, unless another one took its place
|
||||
--- @param registration_number uint64
|
||||
--- @param registration ExpScenario_Protection.Registration
|
||||
local function forget_entity(registration_number, registration)
|
||||
registrations[registration_number] = nil
|
||||
local entities = protected_entities[registration.surface_index]
|
||||
if entities and entities[registration.key] == registration.entity then
|
||||
entities[registration.key] = nil
|
||||
end
|
||||
end
|
||||
|
||||
--- @param event EventData.on_object_destroyed
|
||||
local function on_object_destroyed(event)
|
||||
local registration = registrations[event.registration_number]
|
||||
if registration then
|
||||
forget_entity(event.registration_number, registration)
|
||||
end
|
||||
end
|
||||
|
||||
--- Entities destroyed while the feature was disabled were not forgotten
|
||||
--- @param event EventData.ExpScenario.on_config_updated
|
||||
local function on_config_updated(event)
|
||||
if event.feature_name ~= feature.name or event.path ~= "enabled" then return end
|
||||
for registration_number, registration in pairs(registrations) do
|
||||
if not registration.entity.valid then
|
||||
forget_entity(registration_number, registration)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- Forget protected removals older than the repeat lifetime
|
||||
@@ -234,10 +261,8 @@ end
|
||||
local e = defines.events
|
||||
|
||||
Protection.events[e.on_pre_player_mined_item] = on_pre_player_mined_item
|
||||
Protection.events[e.on_space_platform_pre_mined] = on_entity_removed
|
||||
Protection.events[e.on_robot_pre_mined] = on_entity_removed
|
||||
Protection.events[e.on_entity_died] = on_entity_removed
|
||||
Protection.events[e.script_raised_destroy] = on_entity_removed
|
||||
Protection.events[e.on_object_destroyed] = on_object_destroyed
|
||||
Protection.events[Feature.events.on_config_updated] = on_config_updated
|
||||
Protection.on_nth_tick[3600 * 5] = clear_old_repeats
|
||||
|
||||
return feature:guard(Protection)
|
||||
@@ -35,7 +35,7 @@ end
|
||||
apply_offset_to_array(config.turrets.locations, config.turrets.offset, 1, 2)
|
||||
apply_offset_to_array(config.afk_belts.locations, config.afk_belts.offset, 1, 2)
|
||||
apply_offset_to_array(config.water.locations, config.water.offset, 1, 2)
|
||||
apply_offset_to_array(config.water.locations, config.water.offset, 1, 2)
|
||||
apply_offset_to_array(config.pattern.locations, config.pattern.offset, 1, 2)
|
||||
apply_offset_to_array(config.entities.locations, config.entities.offset, 2, 3)
|
||||
|
||||
--- Get or create the force used for entities in spawn
|
||||
|
||||
@@ -1,22 +1,18 @@
|
||||
--[[-- ExpScenario - Features
|
||||
Features which the controller can enable, disable, and configure while the game is running
|
||||
|
||||
A feature's config table is changed in place when the controller sends overrides,
|
||||
so read values when they are used rather than copying them into locals when the
|
||||
file loads. Booleans, numbers, and strings can be overridden, as can lists and
|
||||
sets of strings made with Feature.list and Feature.set, and values with no default
|
||||
made with Feature.optional. Tables with string keys are nested sections whose
|
||||
values are addressed as "section.key", other tables can not be overridden. Values used while the file
|
||||
loads, such as on_nth_tick periods, stay as plain values and are not listed in
|
||||
features.ts.
|
||||
The config table is changed in place when the controller sends values, so read
|
||||
them where they are used rather than caching them when the file loads. Values
|
||||
read while the file loads, such as on_nth_tick periods, are not listed in features.ts.
|
||||
|
||||
--- Registering a feature, small configs live at the top of the file which uses them:
|
||||
local Feature = require("modules/exp_scenario/features")
|
||||
local feature, config = Feature.register("my_feature", {
|
||||
show_message = true,
|
||||
role_id = Feature.optional("number"),
|
||||
item_names = Feature.set{ "iron-plate" },
|
||||
show_message = true, -- booleans, numbers, and strings
|
||||
role_id = Feature.optional("number"), -- no default
|
||||
item_names = Feature.set{ "iron-plate" }, -- indexed by name
|
||||
surface_names = Feature.list{ "nauvis" },
|
||||
section = { count = 1 }, -- addressed as "section.count"
|
||||
})
|
||||
|
||||
--- Handlers do nothing while the feature is disabled:
|
||||
@@ -24,17 +20,10 @@ return feature:guard{
|
||||
events = { [defines.events.on_player_joined_game] = on_player_joined_game },
|
||||
}
|
||||
|
||||
--- Toolbar buttons are hidden while disabled, which also hides their left element:
|
||||
Gui.toolbar.create_button{
|
||||
visible = function(player, element) return feature:is_enabled() end,
|
||||
}
|
||||
|
||||
--- Commands are denied and left out of help while disabled:
|
||||
--- Toolbar buttons and commands:
|
||||
Gui.toolbar.create_button{ visible = function(player) return feature:is_enabled() end }
|
||||
Commands.new("my_command", { "..." }):add_flags{ feature = feature }
|
||||
|
||||
--- Sets are kept as sets, the controller sends a list which is converted when it is applied:
|
||||
if config.item_names[item.name] then end
|
||||
|
||||
--- Changes are raised per value:
|
||||
[Feature.events.on_config_updated] = function(event) end, -- { feature_name, path, old_value, new_value }
|
||||
]]
|
||||
@@ -42,32 +31,31 @@ if config.item_names[item.name] then end
|
||||
local Storage = require("modules/exp_util/storage")
|
||||
|
||||
--- @class ExpScenario.FeatureField
|
||||
--- @field parent table The table holding the value within the config
|
||||
--- @field key string The key of the value within its parent
|
||||
--- @field path string
|
||||
--- @field parent table
|
||||
--- @field key string
|
||||
--- @field default any
|
||||
--- @field type string "boolean", "number", "string", "list" or "set" of strings, or a type which can not be overridden
|
||||
--- @field type string "boolean", "number", "string", "list", "set", or a type which can not be set
|
||||
|
||||
--- @class ExpScenario.Features
|
||||
local Feature = {
|
||||
_registered = {}, --- @type table<string, ExpScenario.Feature>
|
||||
events = {
|
||||
--- Raised for each value which changes when the controller updates a feature
|
||||
--- @type EventData.ExpScenario.on_config_updated
|
||||
on_config_updated = script.generate_event_name(),
|
||||
},
|
||||
}
|
||||
|
||||
--- The methods of every feature, kept apart from the lib so they are not called on it by mistake
|
||||
--- @class ExpScenario.Feature
|
||||
--- @field name string
|
||||
--- @field config table Changed in place when the config is updated
|
||||
--- @field fields table<string, ExpScenario.FeatureField> The values in the config by path
|
||||
--- @field overrides table<string, any> The overrides from the controller by path, restored from storage on load
|
||||
--- @field config table
|
||||
--- @field fields table<string, ExpScenario.FeatureField> By path
|
||||
--- @field values table<string, any> Last received from the controller, restored from storage on load
|
||||
Feature._prototype = {}
|
||||
|
||||
--- @class EventData.ExpScenario.on_config_updated : EventData
|
||||
--- @field feature_name string
|
||||
--- @field path string The path of the value within the config, "enabled" when the feature is enabled or disabled
|
||||
--- @field path string "enabled" when the feature is enabled or disabled
|
||||
--- @field old_value any
|
||||
--- @field new_value any
|
||||
|
||||
@@ -75,17 +63,18 @@ local Feature_mt = {
|
||||
__index = Feature._prototype,
|
||||
}
|
||||
|
||||
--- The overrides of each feature by name, only these are stored because the rest is rebuilt when the file loads
|
||||
local stored_overrides = {} --- @type table<string, table<string, any>>
|
||||
Storage.register(stored_overrides, function(tbl)
|
||||
stored_overrides = tbl
|
||||
--- Only the values are stored, the rest is rebuilt when the file loads
|
||||
local stored_values = {} --- @type table<string, table<string, any>>
|
||||
Storage.register(stored_values, function(tbl)
|
||||
stored_values = tbl
|
||||
for name, feature in pairs(Feature._registered) do
|
||||
feature.overrides = tbl[name] or {}
|
||||
feature:_apply()
|
||||
feature.values = tbl[name] or {}
|
||||
for path, field in pairs(feature.fields) do
|
||||
feature:_set_field(field, feature.values[path])
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
--- Check if a value is a list of strings, as sent by the controller for lists and sets
|
||||
--- @param value any
|
||||
--- @return boolean
|
||||
local function is_string_list(value)
|
||||
@@ -97,25 +86,22 @@ local function is_string_list(value)
|
||||
return true
|
||||
end
|
||||
|
||||
--- Check if two values are equal, lists and sets are compared by their contents
|
||||
--- Lists and sets are compared by their contents
|
||||
--- @param a any
|
||||
--- @param b any
|
||||
--- @return boolean
|
||||
local function values_equal(a, b)
|
||||
if type(a) ~= "table" or type(b) ~= "table" then return a == b end
|
||||
if table_size(a) ~= table_size(b) then return false end
|
||||
for key, value in pairs(a) do
|
||||
if b[key] ~= value then return false end
|
||||
end
|
||||
for key in pairs(b) do
|
||||
if a[key] == nil then return false end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
--- Marks a default made by Feature.list, Feature.set, or Feature.optional with the type of the field
|
||||
--- Marks a default made by Feature.list, Feature.set, or Feature.optional
|
||||
local typed_mt = {}
|
||||
|
||||
--- Convert a list of strings into a set
|
||||
--- @param list string[]
|
||||
--- @return table<string, true>
|
||||
local function list_to_set(list)
|
||||
@@ -126,58 +112,58 @@ local function list_to_set(list)
|
||||
return set
|
||||
end
|
||||
|
||||
--- Collect the values of a config table, recursing into nested sections
|
||||
--- Nested tables with string keys are sections
|
||||
--- @param fields table<string, ExpScenario.FeatureField>
|
||||
--- @param tbl table
|
||||
--- @param prefix string
|
||||
local function collect_fields(fields, tbl, prefix)
|
||||
for key, value in pairs(tbl) do
|
||||
if type(key) == "string" then
|
||||
local field = { parent = tbl, key = key, default = value, type = type(value) }
|
||||
local path = prefix .. key
|
||||
local field = { path = path, parent = tbl, key = key, default = value, type = type(value) }
|
||||
if type(value) == "table" then
|
||||
local typed = getmetatable(value) == typed_mt and value
|
||||
if typed then
|
||||
field.type = typed.type
|
||||
field.default = typed.default
|
||||
tbl[key] = typed.default
|
||||
if getmetatable(value) == typed_mt then
|
||||
field.type = value.type
|
||||
field.default = value.default
|
||||
tbl[key] = value.default
|
||||
elseif type(next(value)) == "string" then
|
||||
collect_fields(fields, value, prefix .. key .. ".")
|
||||
collect_fields(fields, value, path .. ".")
|
||||
field = nil
|
||||
end
|
||||
end
|
||||
if field then
|
||||
fields[prefix .. key] = field
|
||||
fields[path] = field
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- Declare a value with no default, the argument is the type it can be overridden with
|
||||
--- A value with no default, the argument is the type it accepts
|
||||
--- @param value_type "boolean" | "number" | "string"
|
||||
--- @return any
|
||||
function Feature.optional(value_type)
|
||||
return setmetatable({ type = value_type }, typed_mt)
|
||||
end
|
||||
|
||||
--- Declare a list of strings which can be overridden
|
||||
--- A list of strings
|
||||
--- @param items string[]
|
||||
--- @return string[]
|
||||
function Feature.list(items)
|
||||
return setmetatable({ type = "list", default = items }, typed_mt)
|
||||
end
|
||||
|
||||
--- Declare a set of strings which can be overridden, the controller sends a list which is converted when applied
|
||||
--- A set of strings, the controller sends a list
|
||||
--- @param items string[]
|
||||
--- @return table<string, true>
|
||||
function Feature.set(items)
|
||||
return setmetatable({ type = "set", default = list_to_set(items) }, typed_mt)
|
||||
end
|
||||
|
||||
--- Register a feature and its config, features are enabled unless the config says otherwise
|
||||
--- Features are enabled unless the config says otherwise
|
||||
--- @param name string
|
||||
--- @param config table?
|
||||
--- @return ExpScenario.Feature feature
|
||||
--- @return table config The same table as feature.config
|
||||
--- @return table config
|
||||
function Feature.register(name, config)
|
||||
assert(Feature._registered[name] == nil, "Feature already registered: " .. name)
|
||||
config = config or {}
|
||||
@@ -192,21 +178,19 @@ function Feature.register(name, config)
|
||||
name = name,
|
||||
config = config,
|
||||
fields = fields,
|
||||
overrides = {},
|
||||
values = {},
|
||||
}, Feature_mt) --[[@as ExpScenario.Feature]]
|
||||
|
||||
Feature._registered[name] = feature
|
||||
return feature, config
|
||||
end
|
||||
|
||||
--- Get a registered feature by name
|
||||
--- @param name string
|
||||
--- @return ExpScenario.Feature
|
||||
function Feature.get(name)
|
||||
return Feature._registered[name] or error("Unknown feature: " .. tostring(name), 2)
|
||||
end
|
||||
|
||||
--- Check if a field can take a value
|
||||
--- @param field ExpScenario.FeatureField
|
||||
--- @param value any
|
||||
--- @return boolean
|
||||
@@ -217,18 +201,18 @@ local function is_valid(field, value)
|
||||
return type(value) == field.type and (field.type == "boolean" or field.type == "number" or field.type == "string")
|
||||
end
|
||||
|
||||
--- Set a value to its override, or its default when there is no valid override
|
||||
--- Set a value, nil or an invalid value means the default
|
||||
--- @package
|
||||
--- @param path string
|
||||
--- @param field ExpScenario.FeatureField
|
||||
--- @param value any
|
||||
--- @return any # The value which was set
|
||||
function Feature._prototype:_apply_field(path, field)
|
||||
local value = self.overrides[path]
|
||||
function Feature._prototype:_set_field(field, value)
|
||||
if value ~= nil and not is_valid(field, value) then
|
||||
log("[WARNING] Invalid value for " .. self.name .. "." .. field.path .. ", using the default")
|
||||
value = nil
|
||||
end
|
||||
if value == nil then
|
||||
value = field.default
|
||||
elseif not is_valid(field, value) then
|
||||
log("[WARNING] Invalid override for " .. self.name .. "." .. path .. ", using the default")
|
||||
value = field.default
|
||||
elseif field.type == "set" then
|
||||
value = list_to_set(value)
|
||||
end
|
||||
@@ -236,21 +220,12 @@ function Feature._prototype:_apply_field(path, field)
|
||||
return value
|
||||
end
|
||||
|
||||
--- Set every value to its override, or its default when there is no valid override
|
||||
--- @package
|
||||
function Feature._prototype:_apply()
|
||||
for path, field in pairs(self.fields) do
|
||||
self:_apply_field(path, field)
|
||||
end
|
||||
end
|
||||
|
||||
--- Check if the feature is enabled
|
||||
--- @return boolean
|
||||
function Feature._prototype:is_enabled()
|
||||
return self.config.enabled
|
||||
end
|
||||
|
||||
--- Make the event and on_nth_tick handlers of an event handler lib do nothing while the feature is disabled
|
||||
--- Make the event and on_nth_tick handlers of a lib do nothing while the feature is disabled
|
||||
--- @generic T : table
|
||||
--- @param lib T
|
||||
--- @return T
|
||||
@@ -269,39 +244,16 @@ function Feature._prototype:guard(lib)
|
||||
return lib
|
||||
end
|
||||
|
||||
--- Replace the overrides of the feature, then raise on_config_updated for each value which changed
|
||||
--- @param enabled boolean
|
||||
--- @param values table<string, boolean | number | string | string[]>
|
||||
function Feature._prototype:update_config(enabled, values)
|
||||
local old_overrides = self.overrides
|
||||
local overrides = { enabled = enabled }
|
||||
for path, value in pairs(values) do
|
||||
if self.fields[path] == nil then
|
||||
log("[WARNING] Unknown override for " .. self.name .. "." .. path)
|
||||
else
|
||||
overrides[path] = value
|
||||
end
|
||||
end
|
||||
self.overrides = overrides
|
||||
stored_overrides[self.name] = overrides
|
||||
|
||||
-- Only a value whose override was added, removed, or replaced can change
|
||||
local paths = {}
|
||||
for path in pairs(overrides) do
|
||||
paths[path] = true
|
||||
end
|
||||
for path in pairs(old_overrides) do
|
||||
-- A save can hold overrides for settings which no longer exist
|
||||
if self.fields[path] then
|
||||
paths[path] = true
|
||||
end
|
||||
end
|
||||
--- Replace every value, then raise on_config_updated for each one which changed
|
||||
--- @param values table<string, any> By path, "enabled" included
|
||||
function Feature._prototype:update_config(values)
|
||||
self.values = values
|
||||
stored_values[self.name] = values
|
||||
|
||||
local updates = {}
|
||||
for path in pairs(paths) do
|
||||
local field = self.fields[path]
|
||||
for path, field in pairs(self.fields) do
|
||||
local old_value = field.parent[field.key]
|
||||
local new_value = self:_apply_field(path, field)
|
||||
local new_value = self:_set_field(field, values[path])
|
||||
if not values_equal(old_value, new_value) then
|
||||
updates[#updates + 1] = { feature_name = self.name, path = path, old_value = old_value, new_value = new_value }
|
||||
end
|
||||
@@ -314,16 +266,15 @@ end
|
||||
|
||||
--- @class ExpScenario.FeatureUpdate
|
||||
--- @field name string
|
||||
--- @field enabled boolean
|
||||
--- @field values table<string, boolean | number | string | string[]>
|
||||
--- @field values table<string, any>
|
||||
|
||||
--- Called over rcon by the instance plugin with the features which changed, unknown features are ignored
|
||||
--- Called over rcon by the instance plugin, unknown features are ignored
|
||||
--- @param updates ExpScenario.FeatureUpdate[]
|
||||
function Feature.receive_update(updates)
|
||||
for _, update in ipairs(updates) do
|
||||
local feature = Feature._registered[update.name]
|
||||
if feature then
|
||||
feature:update_config(update.enabled, update.values)
|
||||
feature:update_config(update.values)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user