mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-11-22 07:33:12 +09:00
Add a web page for configuring scenario features
Features can now be enabled, disabled, and configured from the web UI while the game is running, without editing Lua files. The first five features covered are AFK Kick, Chat Auto Reply, Death Markers, Mine Depletion, and Station Auto Name. Lua side: module/features.lua holds each feature's defaults, keeps the overrides from the controller in storage, and patches them onto the config table in place. Features.guard skips a feature's handlers while it is disabled. The five config files move from exp_legacy into exp_scenario/module/config and their control files now read config at runtime instead of deciding at load which handlers to register. AFK Kick times are now in minutes. Controller side: features.ts lists the editable settings and their defaults. Overrides that differ from the default are stored in exp_scenario/features.json and guarded by the existing exp_scenario.config.view/edit permissions. The instance plugin sends them over rcon on start, on every change, and again after the controller restarts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
46bb15e4a6
commit
88358b23b9
30 files changed
+1226
-89
No files matched your search
@@ -1,14 +0,0 @@
|
||||
local Roles = require("modules/exp_roles")
|
||||
|
||||
return {
|
||||
admin_as_active = true, --- @setting admin_as_active When true admins will be treated as active regardless of afk time
|
||||
trust_as_active = true, --- @setting trust_as_active When true trusted players (by playtime) will be treated as active regardless of afk time
|
||||
afk_time = 3600 * 10, --- @setting afk_time The time in ticks that must pass for a player to be considered afk
|
||||
kick_time = 3600 * 30, --- @setting kick_time The time in ticks that must pass without any active players for all players to be kicked
|
||||
trust_time = 3600 * 60 * 10, --- @setting trust_time The time in ticks that a player must be online for to count as trusted
|
||||
update_time = 3600 * 30, --- @setting update_time How often in ticks the script checks for active players
|
||||
custom_active_check = function(player)
|
||||
local veteran = Roles.get_role_by_name("Veteran")
|
||||
return veteran ~= nil and not Roles.get_player_highest_role(player):is_lower_than(veteran)
|
||||
end,
|
||||
}
|
||||
@@ -1,137 +0,0 @@
|
||||
--- This file defines the different triggers for the chat bot
|
||||
-- @config Chat-Reply
|
||||
|
||||
local ExpUtil = require("modules/exp_util")
|
||||
local Async = require("modules/exp_util/async")
|
||||
local config_server_detail = require("modules.exp_legacy.config.server_detail") --- @dep config.server_detail
|
||||
|
||||
local floor = math.floor
|
||||
local random = math.random
|
||||
local format_string = string.format
|
||||
local locale_reply = "exp_chat-auto-reply.chat-reply"
|
||||
|
||||
local send_message_async =
|
||||
Async.register(function(player, message)
|
||||
if player == nil then
|
||||
game.print(message)
|
||||
else
|
||||
player.print(message)
|
||||
end
|
||||
end)
|
||||
|
||||
local afk_time_units = {
|
||||
minutes = true,
|
||||
seconds = true,
|
||||
}
|
||||
|
||||
return {
|
||||
--- @type table<string, LocalisedString | fun(player: LuaPlayer, is_command: boolean): LocalisedString>
|
||||
messages = { --- @setting messages will trigger when ever the word is said
|
||||
["discord"] = { "info.discord", config_server_detail["discord"] },
|
||||
["expgaming"] = { "info.website", config_server_detail["website"] },
|
||||
["website"] = { "info.website", config_server_detail["website"] },
|
||||
["status"] = { "info.status", config_server_detail["status"] },
|
||||
["github"] = { "info.github", config_server_detail["github"] },
|
||||
["patreon"] = { "info.patreon", config_server_detail["patreon"] },
|
||||
["donate"] = { "info.patreon", config_server_detail["patreon"] },
|
||||
["command"] = { "info.custom-commands" },
|
||||
["commands"] = { "info.custom-commands" },
|
||||
["softmod"] = { "info.softmod" },
|
||||
["plugin"] = { "info.softmod" },
|
||||
["script"] = { "info.softmod" },
|
||||
["redmew"] = { "info.redmew" },
|
||||
["comfy"] = { "info.redmew" },
|
||||
["rhd"] = { "info.lhd" },
|
||||
["lhd"] = { "info.lhd" },
|
||||
["loop"] = { "exp_chat-auto-reply.reply-loops" },
|
||||
["roundabout"] = { "exp_chat-auto-reply.reply-loops" },
|
||||
["roundabouts"] = { "exp_chat-auto-reply.reply-loops" },
|
||||
["clusterio"] = { "exp_chat-auto-reply.reply-clusterio" },
|
||||
["players"] = function()
|
||||
return { "exp_chat-auto-reply.reply-players", #game.players }
|
||||
end,
|
||||
["online"] = function()
|
||||
return { "exp_chat-auto-reply.reply-online", #game.connected_players }
|
||||
end,
|
||||
["afk"] = function(player)
|
||||
local max = player
|
||||
for _, next_player in pairs(game.connected_players) do
|
||||
if max.afk_time < next_player.afk_time then
|
||||
max = next_player
|
||||
end
|
||||
end
|
||||
|
||||
return { "exp_chat-auto-reply.reply-afk", max.name, ExpUtil.format_time_locale(max.afk_time, "long", afk_time_units) }
|
||||
end,
|
||||
},
|
||||
allow_command_prefix_for_messages = true, --- @setting allow_command_prefix_for_messages when true any message trigger will print to all player when prefixed
|
||||
command_admin_only = false, --- @setting command_admin_only when true will only allow chat commands for admins
|
||||
command_permission = "exp_scenario.chat.commands", --- @setting command_permission the permission used to allow command prefixes
|
||||
command_prefix = "!", --- @setting command_prefix prefix used for commands below and to print to all players (if enabled above)
|
||||
--- @type table<string, LocalisedString | fun(player: LuaPlayer, is_command: boolean): LocalisedString>
|
||||
commands = { --- @setting commands will trigger only when command prefix is given
|
||||
["dev"] = { "exp_chat-auto-reply.reply-dev" },
|
||||
["magic"] = { "exp_chat-auto-reply.reply-magic" },
|
||||
["aids"] = { "exp_chat-auto-reply.reply-aids" },
|
||||
["riot"] = { "exp_chat-auto-reply.reply-riot" },
|
||||
["lenny"] = { "exp_chat-auto-reply.reply-lenny" },
|
||||
["blame"] = function(player)
|
||||
local names = { "Cooldude2606", "arty714", "badgamernl", "mark9064", "aldldl", "Drahc_pro", player.name }
|
||||
for _, next_player in pairs(game.connected_players) do
|
||||
names[#names + 1] = next_player.name
|
||||
end
|
||||
|
||||
return { "exp_chat-auto-reply.reply-blame", table.get_random(names) }
|
||||
end,
|
||||
["hodor"] = function()
|
||||
local options = { "?", ".", "!", "!!!" }
|
||||
return { "exp_chat-auto-reply.reply-hodor", table.get_random(options) }
|
||||
end,
|
||||
["evolution"] = function(player)
|
||||
return { "exp_chat-auto-reply.reply-evolution", format_string("%.2f", game.forces["enemy"].get_evolution_factor(player.surface)) }
|
||||
end,
|
||||
["makepopcorn"] = function(player)
|
||||
local timeout = floor(180 * (random() + 0.5))
|
||||
send_message_async:start_after(timeout, nil, { locale_reply, { "exp_chat-auto-reply.reply-popcorn-2", player.name } })
|
||||
return { locale_reply, { "exp_chat-auto-reply.reply-popcorn-1" } }
|
||||
end,
|
||||
["passsomesnaps"] = function(player)
|
||||
local timeout = floor(180 * (random() + 0.5))
|
||||
send_message_async:start_after(timeout, nil, { locale_reply, { "exp_chat-auto-reply.reply-snaps-2", player.name } })
|
||||
send_message_async:start_after(timeout * (random() + 0.5), nil, { locale_reply, { "exp_chat-auto-reply.reply-snaps-3", player.name } })
|
||||
return { locale_reply, { "exp_chat-auto-reply.reply-snaps-1" } }
|
||||
end,
|
||||
["makecocktail"] = function(player)
|
||||
local timeout = floor(180 * (random() + 0.5))
|
||||
send_message_async:start_after(timeout, nil, { locale_reply, { "exp_chat-auto-reply.reply-cocktail-2", player.name } })
|
||||
send_message_async:start_after(timeout * (random() + 0.5), nil, { locale_reply, { "exp_chat-auto-reply.reply-cocktail-3", player.name } })
|
||||
return { locale_reply, { "exp_chat-auto-reply.reply-cocktail-1" } }
|
||||
end,
|
||||
["makecoffee"] = function(player)
|
||||
local timeout = floor(180 * (random() + 0.5))
|
||||
send_message_async:start_after(timeout, nil, { locale_reply, { "exp_chat-auto-reply.reply-coffee-2", player.name } })
|
||||
return { locale_reply, { "exp_chat-auto-reply.reply-coffee-1" } }
|
||||
end,
|
||||
["orderpizza"] = function(player)
|
||||
local timeout = floor(180 * (random() + 0.5))
|
||||
send_message_async:start_after(timeout, nil, { locale_reply, { "exp_chat-auto-reply.reply-pizza-2", player.name } })
|
||||
send_message_async:start_after(timeout * (random() + 0.5), nil, { locale_reply, { "exp_chat-auto-reply.reply-pizza-3", player.name } })
|
||||
return { locale_reply, { "exp_chat-auto-reply.reply-pizza-1" } }
|
||||
end,
|
||||
["maketea"] = function(player)
|
||||
local timeout = floor(180 * (random() + 0.5))
|
||||
send_message_async:start_after(timeout, nil, { locale_reply, { "exp_chat-auto-reply.reply-tea-2", player.name } })
|
||||
return { locale_reply, { "exp_chat-auto-reply.reply-tea-1" } }
|
||||
end,
|
||||
["meadplease"] = function(player)
|
||||
local timeout = floor(180 * (random() + 0.5))
|
||||
send_message_async:start_after(timeout, nil, { locale_reply, { "exp_chat-auto-reply.reply-mead-2", player.name } })
|
||||
return { locale_reply, { "exp_chat-auto-reply.reply-mead-1" } }
|
||||
end,
|
||||
["passabeer"] = function(player)
|
||||
local timeout = floor(180 * (random() + 0.5))
|
||||
send_message_async:start_after(timeout, nil, { locale_reply, { "exp_chat-auto-reply.reply-beer-2", player.name } })
|
||||
return { locale_reply, { "exp_chat-auto-reply.reply-beer-1" } }
|
||||
end,
|
||||
},
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
--- This config controls what happens when a player dies mostly about map markers and item collection;
|
||||
-- allow_teleport_to_body_command and allow_collect_bodies_command can be over ridden if command_auth_runtime_disable is present;
|
||||
-- if not present then the commands will not be loaded into the game
|
||||
-- @config Death-Logger
|
||||
|
||||
return {
|
||||
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,
|
||||
include_time_of_death = true, --- @setting include_time_of_death weather to include the time of death on the map marker
|
||||
map_icon = nil, --- @setting map_icon the icon that the map marker shows; nil means no icon; format as a SingleID
|
||||
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
|
||||
period_check_map_tags = 60 * 60 * 5,
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
--- Settings for miner
|
||||
-- @config miner
|
||||
|
||||
return {
|
||||
fluid = true, --- @setting fluid When true, checks for for fluid pipes when removing miners
|
||||
chest = true, --- @setting chest When true, checks for for chest when removing miners
|
||||
beacon = true, --- @setting beacon When true, checks for for beacon when removing miners
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
return {
|
||||
--[[
|
||||
__icon__
|
||||
__item_name__
|
||||
__backer_name__
|
||||
__direction__
|
||||
__x__
|
||||
__y__
|
||||
]]
|
||||
station_name = "[L] __icon__",
|
||||
}
|
||||
Reference in new issue
Block a user