Add a community_details feature for the community name and links

The community name, Discord, website, status, GitHub, and Patreon links
lived in exp_legacy/config/server_detail.lua, so changing them meant
editing the scenario. They are now the community_details feature and can
be edited from the Scenario Features page.

Chat auto reply, help bubbles, and the readme read the live config
instead of copying the values when the file loads, so an edit shows up
without a restart. Help bubbles store the location name in their task
and build the messages each cycle; the readme tab tooltip can be a
function which is called when the readme opens.

Every feature gets an enabled switch from the framework. There is no
sensible meaning for a disabled community name, so the values are
always used and the feature description says the switch does nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
bbassieandClaude Opus 5.5 committed 2026-10-14 22:10:22 +00:00
1 parent 4fe9148ab7
commit a6c453a88e
5 files changed
+83 -33

No files matched your search

+13
View File
@@ -81,6 +81,19 @@ export const features: Feature[] = [
str("command_prefix", "Command prefix", "Prefix for chat commands, and for key words to reply to everyone", "!"),
],
},
{
name: "community_details",
title: "Community Details",
description: "The community name and links shown in chat, the readme, help bubbles, and the greeting. These are always used, the switch has no effect",
fields: [
str("community_name", "Community name", "Name of the community", "Explosive Gaming"),
str("discord", "Discord", "Invite link to the Discord server", "https://discord.explosivegaming.nl"),
str("website", "Website", "Link to the website", "https://www.explosivegaming.nl"),
str("status", "Status page", "Link to the server status page", "https://status.explosivegaming.nl"),
str("github", "GitHub", "Link to the source code", "https://github.com/explosivegaming/ExpCluster"),
str("patreon", "Patreon", "Link to donate", "https://www.patreon.com/ExpGaming"),
],
},
{
name: "custom_start",
title: "Custom Start",
+17 -8
View File
@@ -4,7 +4,7 @@
local ExpUtil = require("modules/exp_util")
local Feature = require("modules/exp_scenario/features")
local Async = require("modules/exp_util/async")
local config_server_detail = require("modules.exp_legacy.config.server_detail") --- @dep config.server_detail
local community_details = require("modules/exp_scenario/config/community_details").config
local floor = math.floor
local random = math.random
@@ -20,6 +20,15 @@ local send_message_async =
end
end)
--- Reply with a link from community_details, read when the reply is sent
--- @param key string
--- @return fun(): LocalisedString
local function server_link(key)
return function()
return { "info." .. key, community_details[key] }
end
end
local afk_time_units = {
minutes = true,
seconds = true,
@@ -28,13 +37,13 @@ local afk_time_units = {
return Feature.register("chat_auto_reply", {
--- @type table<string, LocalisedString | fun(player: LuaPlayer, is_command: boolean): LocalisedString>
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"] },
["discord"] = server_link("discord"),
["expgaming"] = server_link("website"),
["website"] = server_link("website"),
["status"] = server_link("status"),
["github"] = server_link("github"),
["patreon"] = server_link("patreon"),
["donate"] = server_link("patreon"),
["command"] = { "info.custom-commands" },
["commands"] = { "info.custom-commands" },
["softmod"] = { "info.softmod" },
@@ -0,0 +1,14 @@
--- Names and links of the community, shown in chat, the readme, and the greeting
-- @config Community-Details
local Feature = require("modules/exp_scenario/features")
--- The values are always used, disabling the feature changes nothing
return Feature.register("community_details", {
community_name = "Explosive Gaming",
discord = "https://discord.explosivegaming.nl",
website = "https://www.explosivegaming.nl",
status = "https://status.explosivegaming.nl",
github = "https://github.com/explosivegaming/ExpCluster",
patreon = "https://www.patreon.com/ExpGaming",
})
+26 -17
View File
@@ -5,7 +5,7 @@ Adds friendly biters that walk around and give helpful messages
local Async = require("modules/exp_util/async")
local Storage = require("modules/exp_util/storage")
local Feature = require("modules/exp_scenario/features")
local config_server_detail = require("modules.exp_legacy.config.server_detail")
local community_details = require("modules/exp_scenario/config/community_details").config
local feature = Feature.register("help_bubbles")
@@ -17,18 +17,21 @@ local locations = {
spawn_position = { x = 0, y = 0 },
spawn_surface = "nauvis",
entity_name = "small-biter",
messages = {
{ "info.website", config_server_detail["website"] },
{ "info.read-readme" },
{ "info.discord", config_server_detail["discord"] },
{ "info.softmod" },
{ "info.redmew" },
{ "info.custom-commands" },
{ "info.status", config_server_detail["status"] },
{ "info.lhd" },
{ "info.github", config_server_detail["github"] },
{ "info.patreon", config_server_detail["patreon"] },
},
--- Built each cycle so changes to community_details show without a restart
messages = function()
return {
{ "info.website", community_details.website },
{ "info.read-readme" },
{ "info.discord", community_details.discord },
{ "info.softmod" },
{ "info.redmew" },
{ "info.custom-commands" },
{ "info.status", community_details.status },
{ "info.lhd" },
{ "info.github", community_details.github },
{ "info.patreon", community_details.patreon },
}
end,
}
}
@@ -41,7 +44,8 @@ end)
--- @class speech_bubble_task_param
--- @field entity LuaEntity
--- @field messages LocalisedString[]
--- @field messages LocalisedString[]?
--- @field location string? Used when there are no messages, a key of locations
--- @field previous_message LuaEntity?
--- @field current_message_index number
@@ -60,8 +64,9 @@ local speech_bubble_task =
return Async.status.complete()
end
local messages = task.messages or locations[task.location].messages()
local index = task.current_message_index
if index > #task.messages then
if index > #messages then
index = 1
end
@@ -71,7 +76,7 @@ local speech_bubble_task =
end
speech_bubble_param.source = entity
speech_bubble_param.text = task.messages[index]
speech_bubble_param.text = messages[index]
task.previous_message = entity.surface.create_entity(speech_bubble_param)
task.current_message_index = index + 1
@@ -114,7 +119,11 @@ local function check_persistent_locations()
goto continue
end
persistent_locations[name] = register_entity(entity, location.messages)
persistent_locations[name] = speech_bubble_task{
entity = entity,
location = name,
current_message_index = 1,
}
::continue::
end
end
+13 -8
View File
@@ -8,7 +8,7 @@ local Roles = require("modules/exp_roles")
local Commands = require("modules/exp_commands")
local PlayerData = require("modules.exp_legacy.expcore.player_data")
local ExpServerList = require("modules/exp_server_list")
local config_server_detail = require("modules.exp_legacy.config.server_detail") --- @dep config.server_detail
local community = require("modules/exp_scenario/config/community_details").config
local format_number = require("util").format_number
local format_time = ExpUtil.format_time_factory_locale{ format = "long", days = true, hours = true, minutes = true }
@@ -37,12 +37,12 @@ end
--- @class ExpGui_Readme.elements
local Elements = {}
--- @type table<number, { caption: LocalisedString, tooltip: LocalisedString, element: ExpElement }>
--- @type table<number, { caption: LocalisedString, tooltip: LocalisedString | (fun(): LocalisedString), element: ExpElement }>
local tabs = {}
--- Register a readme tab
--- @param caption LocalisedString
--- @param tooltip LocalisedString
--- @param tooltip LocalisedString | fun(): LocalisedString Functions are called when the readme opens
--- @param element ExpElement
local function define_tab(caption, tooltip, element)
tabs[#tabs + 1] = { caption = caption, tooltip = tooltip, element = element }
@@ -202,13 +202,13 @@ end
--- Welcome tab
define_tab(
{ "exp-gui_readme.welcome-tab" },
{ "exp-gui_readme.welcome-tooltip", config_server_detail["community_name"] },
function() return { "exp-gui_readme.welcome-tooltip", community.community_name } end,
Gui.define("readme/welcome")
:draw(function(_, parent)
local player = Gui.get_player(parent)
local server_details = {
name = config_server_detail["community_name"] .. " S0 - Local",
name = community.community_name .. " S0 - Local",
welcome = "Failed to load description: disconnected from the controller.",
reset_time = "Not Set",
}
@@ -248,7 +248,7 @@ define_tab(
frame_width,
{
"exp-gui_readme.welcome-general",
config_server_detail["community_name"],
community.community_name,
format_time(game.tick),
server_details.reset_time,
}
@@ -353,7 +353,7 @@ define_tab(
local external_links = Elements.title_table(scroll_pane, 235, { "exp-gui_readme.servers-external" }, 2)
for _, key in ipairs{ "discord", "website", "patreon", "status", "github" } do
Gui.elements.centered_label(external_links, 110, key:gsub("^%l", string.upper))
Gui.elements.centered_label(external_links, 460, config_server_detail[key], { "exp-gui_readme.servers-open-in-browser" })
Gui.elements.centered_label(external_links, 460, community[key], { "exp-gui_readme.servers-open-in-browser" })
end
return container
@@ -651,11 +651,16 @@ Elements.container = Gui.define("readme/container")
}
for _, tab in ipairs(tabs) do
local tooltip = tab.tooltip
if type(tooltip) == "function" then
tooltip = tooltip()
end
local gui_tab = pane.add{
type = "tab",
style = "frame_tab",
caption = tab.caption,
tooltip = tab.tooltip,
tooltip = tooltip,
}
pane.add_tab(gui_tab, tab.element(pane))