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>
This commit is contained in:
bbassieandClaude Opus 5.5 committed 2026-10-14 22:10:22 +00:00
1 parent a6c453a88e
commit 4d3c4de5b1
15 files changed
+74 -159

No files matched your search

@@ -1,50 +0,0 @@
--- Greets players on join
-- @data Greetings
local config = require("modules.exp_legacy.config.join_messages") --- @dep config.join_messages
local config_server_detail = require("modules.exp_legacy.config.server_detail") --- @dep config.server_detail
local Commands = require("modules/exp_commands")
--- Stores the join message that the player have
local PlayerData = require("modules.exp_legacy.expcore.player_data") --- @dep expcore.player_data
local CustomMessages = PlayerData.Settings:combine("JoinMessage")
CustomMessages:set_metadata{
permission = "exp_scenario.command.set_join_message",
}
--- When a players data loads show their message
CustomMessages:on_load(function(player_name, player_message)
local player = game.players[player_name]
local custom_message = player_message or config[player_name]
if custom_message then
game.print(custom_message, { color = player.color })
else
player.print{
"join-message.greet",
config_server_detail["community_name"],
config_server_detail["discord"]
}
end
end)
--- Set your custom join message
Commands.new("set-join-message", { "join-message.description-add" })
:optional("message", false, 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{ "join-message.message-set" }
else
return Commands.status.success{ "join-message.message-get", CustomMessages:get(player) }
end
end)
--- Removes your custom join message
Commands.new("remove-join-message", { "join-message.description-remove" })
:register(function(player)
CustomMessages:remove(player)
return Commands.status.success{ "join-message.message-cleared" }
end)
@@ -1,28 +0,0 @@
--- Gives players random colours when they are created, also applies preset colours to those who have them
--- Inventory sync restores the colour of players who have played before
-- @data Player-Colours
local Event = require("modules/exp_legacy/utils/event") --- @dep utils.event
local Colours = require("modules/exp_util/include/color")
local config = require("modules.exp_legacy.config.preset_player_colours") --- @dep config.preset_player_colours
--- Returns a colour that is a bit lighter than the one given
local function lighten(c)
return { r = 255 - (255 - c.r) * 0.5, g = 255 - (255 - c.g) * 0.5, b = 255 - (255 - c.b) * 0.5, a = 255 }
end
--- Apply the preset colour of the player, or a random one if there is none
Event.add(defines.events.on_player_created, function(event)
local player = game.players[event.player_index]
local colour = config.players[player.name]
if not colour then
local colour_name = "white"
while config.disallow[colour_name] do
colour_name = table.get_random(Colours, true)
end
colour = Colours[colour_name]
end
player.color = colour
player.chat_color = lighten(colour)
end)