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

+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