mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-11-12 15:54:52 +09:00
- Feature.register returns the config as a second value, so files write `local feature, config = Feature.register(...)`. - The lib is ExpScenario.Features and the instance class with its fields sits on Feature._prototype, which is the __index, the same shape as exp_commands. - update_config only looks at values whose override was added, removed, or replaced. _apply_field sets one value and returns it, so the comparison happens while applying and the second loop only raises. Overrides dropped from the previous set count as candidates because the value reverts to its default. - The `@setting name` tags are gone from the config comments. - Protection is guarded as a whole instead of checking config.enabled in one handler. The handlers also forget mined entities, so get_entities and is_entity_protected now drop invalid references, which also covers entities destroyed without an event. The list getters are gone, the selection overlay builds its lists from Protection.config. - Chat and damage popups are one feature in control/popups.lua. - ignore_admins and command_admin_only are removed, roles cover them. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
50 lines
1.8 KiB
Lua
50 lines
1.8 KiB
Lua
--[[-- Test environment for module/features.lua
|
|
Extends the shared stubs with a fresh copy of the features module and a stub
|
|
of exp_util storage which lets tests act out on_init and on_load.
|
|
|
|
Run as a chunk by test/lua/runner.js, receiving the shared folder. The suite
|
|
returned here becomes `...` in each test file.
|
|
]]
|
|
|
|
local shared_root = ... --- @type string
|
|
local source = assert(debug.getinfo(1, "S")).source:gsub("\\", "/")
|
|
local plugin_root = assert(source:match("^@(.*)/test/module/env%.lua$"))
|
|
|
|
local Framework = assert(loadfile(shared_root .. "/framework.lua"))() --- @type Framework
|
|
|
|
--- @class ExpScenario.TestEnv : Stubs
|
|
--- @field Feature ExpScenario.Features A fresh copy of the features module
|
|
--- @field storage table The table registered with storage, as on_init would store it
|
|
--- @field on_load fun(tbl: table) Act out on_load with the given storage table
|
|
--- @field load_config fun(name: string): ExpScenario.Feature Load module/config/<name>.lua
|
|
--- @field logged string[] Messages passed to log
|
|
|
|
return Framework.suite(function(env)
|
|
--- @cast env ExpScenario.TestEnv
|
|
local callback --- @type fun(tbl: table)
|
|
env.logged = {}
|
|
log = function(message) env.logged[#env.logged + 1] = message end
|
|
env.extend_requires{
|
|
["modules/exp_util/storage"] = {
|
|
register = function(tbl, fn)
|
|
env.storage = tbl
|
|
callback = fn
|
|
end,
|
|
},
|
|
}
|
|
|
|
env.Feature = assert(loadfile(plugin_root .. "/module/features.lua"))()
|
|
env.extend_requires{ ["modules/exp_scenario/features"] = env.Feature }
|
|
|
|
function env.on_load(tbl)
|
|
env.storage = tbl
|
|
callback(tbl)
|
|
end
|
|
|
|
function env.load_config(name)
|
|
return assert(loadfile(plugin_root .. "/module/config/" .. name .. ".lua"))()
|
|
end
|
|
|
|
return env
|
|
end)
|