mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-11-17 14:25:27 +09:00
Rework features into a Feature class with per field events
Review points from Cooldude: - Feature.register(name[, config]) is required again and returns a feature object. Each feature has its config, its fields, and its overrides, so one registry holds all the data. Only the overrides are stored. On load each feature points at its own stored table again. - The methods are feature:guard(lib), feature:update_config(enabled, values), and feature:is_enabled(). Feature.get(name) looks up a feature, and commands flag the feature object. - update_config raises on_config_updated once per changed value, with the feature name, path, old value, and new value. The gui refresh only reacts to the "enabled" path. - apply only sets values. on_apply is gone. Lookup sets built from lists use Feature.to_set, which is cached by the list itself. A replaced list gets a new set, so the sets are also correct after a load. Protection exposes getters for its protected names and types. Web: settings use small inputs, the same size as the config pages. Fields are shaped like clusterio config field definitions. A field with an inputComponent renders the component registered with the web interface, so the role setting now uses core's role input, and other plugin inputs can be used later. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4bc1773c82
commit
628e4df514
26 files changed
+468
-430
No files matched your search
@@ -3,10 +3,10 @@ Makes markers on the map where places have died and reclaims items if not recove
|
||||
]]
|
||||
|
||||
local ExpUtil = require("modules/exp_util")
|
||||
local Features = require("modules/exp_scenario/features")
|
||||
local Feature = require("modules/exp_scenario/features")
|
||||
local Storage = require("modules/exp_util/storage")
|
||||
|
||||
local config = Features.config("death_markers", {
|
||||
local feature = Feature.register("death_markers", {
|
||||
collect_corpses = true, --- @setting collect_corpses enables items being returned to the spawn point in chests upon corpse expiring
|
||||
show_map_markers = true, --- @setting show_map_markers shows markers on the map where bodies are
|
||||
clean_map_markers = false, --- @setting clean_map_markers removes the map marker once the body is gone
|
||||
@@ -15,6 +15,7 @@ local config = Features.config("death_markers", {
|
||||
show_light_at_corpse = true, --- @setting show_light_at_corpse if a light should be rendered at the corpse
|
||||
show_line_to_corpse = true, --- @setting show_line_to_corpse if a line should be rendered from you to your corpse
|
||||
})
|
||||
local config = feature.config
|
||||
|
||||
local map_tag_time_format = ExpUtil.format_time_factory{ format = "short", hours = true, minutes = true }
|
||||
|
||||
@@ -147,7 +148,7 @@ end
|
||||
|
||||
local e = defines.events
|
||||
|
||||
return Features.guard(config, {
|
||||
return feature:guard{
|
||||
on_nth_tick = {
|
||||
[60 * 60 * 5] = check_map_tags,
|
||||
},
|
||||
@@ -157,4 +158,4 @@ return Features.guard(config, {
|
||||
[e.on_player_respawned] = on_player_respawned,
|
||||
[e.on_character_corpse_expired] = on_character_corpse_expired,
|
||||
},
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user