Move community details into a scenario feature and drop preset colours (#498)

* 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>

* Move greetings to exp_scenario and drop preset colours

The greeting reads the community name and Discord link from the new
community_details feature, which exp_legacy can not depend on, so it moves
to exp_scenario/control/greetings.lua along with its commands and
locale. The custom message still lives in PlayerData for now.

The hardcoded per-player join messages in config/join_messages.lua are
removed with their fallback, as are the preset player colours. Player
sync already restores the colour of returning players, so new players
keep the colour Factorio gives them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cooldude2606andClaude Opus 5.5 authored and GitHub committed 2026-10-14 23:13:33 +01:00
commit 5180cc39d6
19 files changed
+157 -192

No files matched your search

+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",
})
+1
View File
@@ -52,6 +52,7 @@ add(require("modules/exp_scenario/control/discord_alerts"))
add(require("modules/exp_scenario/control/features"))
add(require("modules/exp_scenario/control/extra_logging"))
add(require("modules/exp_scenario/control/fast_deconstruction"))
add(require("modules/exp_scenario/control/greetings"))
add(require("modules/exp_scenario/control/help_bubbles"))
add(require("modules/exp_scenario/control/inserter_pickup"))
add(require("modules/exp_scenario/control/inventory_clear"))
+46
View File
@@ -0,0 +1,46 @@
--[[-- Control - Greetings
Greets players when they join, players can set a message shown to everyone instead
]]
local Commands = require("modules/exp_commands")
local community_details = require("modules/exp_scenario/config/community_details").config
local PlayerData = require("modules.exp_legacy.expcore.player_data")
local CustomMessages = PlayerData.Settings:combine("JoinMessage")
CustomMessages:set_metadata{
permission = "exp_scenario.command.set_join_message",
}
--- Show the message of a player once their data loads, or greet them
CustomMessages:on_load(function(player_name, player_message)
local player = assert(game.get_player(player_name))
if player_message then
game.print(player_message, { color = player.color })
else
player.print{ "exp_greetings.greet", community_details.community_name, community_details.discord }
end
end)
--- Set your custom join message
Commands.new("set-join-message", { "exp_greetings.description-set" })
:optional("message", { "exp_greetings.arg-message" }, Commands.types.string_max_length(255))
:enable_auto_concatenation()
:add_aliases{ "join-message" }
:register(function(player, message)
--- @cast message string?
if message then
CustomMessages:set(player, message)
return Commands.status.success{ "exp_greetings.message-set" }
else
return Commands.status.success{ "exp_greetings.message-get", CustomMessages:get(player) or "" }
end
end)
--- Removes your custom join message
Commands.new("remove-join-message", { "exp_greetings.description-remove" })
:register(function(player)
CustomMessages:remove(player)
return Commands.status.success{ "exp_greetings.message-cleared" }
end)
return {}
+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))
+9
View File
@@ -586,6 +586,15 @@ chat-enabled=enabled
chat-disabled=disabled
chat-toggle=Fast decon has been __1__
[exp_greetings]
description-set=Sets / Gets your custom join message.
description-remove=Removes you custom join message.
arg-message=Your custom join message.
greet=[color=0,1,0] Welcome to __1__ community server! If you like the server join our discord: __2__ [/color]
message-set=Your join message has been updated.
message-get=Your join message is: __1__
message-cleared=Your join message has been cleared.
[exp_nuke-protection]
chat-found=You cannot have __1__ in your inventory, so it was placed into the chests at spawn.
+9
View File
@@ -578,6 +578,15 @@ chat-enabled=啟用
chat-disabled=停用
chat-toggle=樹木快速拆除已 __1__
[exp_greetings]
description-set=設定 / 取得你的加入信息。
description-remove=移除你的加入信息。
arg-message=你的加入信息。
greet=[color=0,1,0] 歡迎來到 __1__ 的服務器! 若果你喜歡本服務器可加入 Discord: __2__ [/color]
message-set=你的加入信息已更新。
message-get=你的加入信息為: __1__
message-cleared=你的加入信息已清除。
[exp_nuke-protection]
chat-found=你的用戶組不允許你有 __1__ ,所以該物品已放在出生點的箱子。
+9
View File
@@ -578,6 +578,15 @@ chat-enabled=啟用
chat-disabled=停用
chat-toggle=樹木快速拆除已 __1__
[exp_greetings]
description-set=設定 / 取得你的加入信息。
description-remove=移除你的加入信息。
arg-message=你的加入信息。
greet=[color=0,1,0] 歡迎來到 __1__ 的服務器! 若果你喜歡本服務器可加入 Discord: __2__ [/color]
message-set=你的加入信息已更新。
message-get=你的加入信息為: __1__
message-cleared=你的加入信息已清除。
[exp_nuke-protection]
chat-found=你的用戶組不允許你有 __1__ ,所以該物品已放在出生點的箱子。