mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-11-20 23:33:12 +09:00
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:
1 parent
4fe9148ab7
commit
a6c453a88e
5 files changed
+83
-33
No files matched your search
@@ -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", "!"),
|
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",
|
name: "custom_start",
|
||||||
title: "Custom Start",
|
title: "Custom Start",
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
local ExpUtil = require("modules/exp_util")
|
local ExpUtil = require("modules/exp_util")
|
||||||
local Feature = require("modules/exp_scenario/features")
|
local Feature = require("modules/exp_scenario/features")
|
||||||
local Async = require("modules/exp_util/async")
|
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 floor = math.floor
|
||||||
local random = math.random
|
local random = math.random
|
||||||
@@ -20,6 +20,15 @@ local send_message_async =
|
|||||||
end
|
end
|
||||||
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 = {
|
local afk_time_units = {
|
||||||
minutes = true,
|
minutes = true,
|
||||||
seconds = true,
|
seconds = true,
|
||||||
@@ -28,13 +37,13 @@ local afk_time_units = {
|
|||||||
return Feature.register("chat_auto_reply", {
|
return Feature.register("chat_auto_reply", {
|
||||||
--- @type table<string, LocalisedString | fun(player: LuaPlayer, is_command: boolean): LocalisedString>
|
--- @type table<string, LocalisedString | fun(player: LuaPlayer, is_command: boolean): LocalisedString>
|
||||||
messages = { -- will trigger when ever the word is said
|
messages = { -- will trigger when ever the word is said
|
||||||
["discord"] = { "info.discord", config_server_detail["discord"] },
|
["discord"] = server_link("discord"),
|
||||||
["expgaming"] = { "info.website", config_server_detail["website"] },
|
["expgaming"] = server_link("website"),
|
||||||
["website"] = { "info.website", config_server_detail["website"] },
|
["website"] = server_link("website"),
|
||||||
["status"] = { "info.status", config_server_detail["status"] },
|
["status"] = server_link("status"),
|
||||||
["github"] = { "info.github", config_server_detail["github"] },
|
["github"] = server_link("github"),
|
||||||
["patreon"] = { "info.patreon", config_server_detail["patreon"] },
|
["patreon"] = server_link("patreon"),
|
||||||
["donate"] = { "info.patreon", config_server_detail["patreon"] },
|
["donate"] = server_link("patreon"),
|
||||||
["command"] = { "info.custom-commands" },
|
["command"] = { "info.custom-commands" },
|
||||||
["commands"] = { "info.custom-commands" },
|
["commands"] = { "info.custom-commands" },
|
||||||
["softmod"] = { "info.softmod" },
|
["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",
|
||||||
|
})
|
||||||
@@ -5,7 +5,7 @@ Adds friendly biters that walk around and give helpful messages
|
|||||||
local Async = require("modules/exp_util/async")
|
local Async = require("modules/exp_util/async")
|
||||||
local Storage = require("modules/exp_util/storage")
|
local Storage = require("modules/exp_util/storage")
|
||||||
local Feature = require("modules/exp_scenario/features")
|
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")
|
local feature = Feature.register("help_bubbles")
|
||||||
|
|
||||||
@@ -17,18 +17,21 @@ local locations = {
|
|||||||
spawn_position = { x = 0, y = 0 },
|
spawn_position = { x = 0, y = 0 },
|
||||||
spawn_surface = "nauvis",
|
spawn_surface = "nauvis",
|
||||||
entity_name = "small-biter",
|
entity_name = "small-biter",
|
||||||
messages = {
|
--- Built each cycle so changes to community_details show without a restart
|
||||||
{ "info.website", config_server_detail["website"] },
|
messages = function()
|
||||||
{ "info.read-readme" },
|
return {
|
||||||
{ "info.discord", config_server_detail["discord"] },
|
{ "info.website", community_details.website },
|
||||||
{ "info.softmod" },
|
{ "info.read-readme" },
|
||||||
{ "info.redmew" },
|
{ "info.discord", community_details.discord },
|
||||||
{ "info.custom-commands" },
|
{ "info.softmod" },
|
||||||
{ "info.status", config_server_detail["status"] },
|
{ "info.redmew" },
|
||||||
{ "info.lhd" },
|
{ "info.custom-commands" },
|
||||||
{ "info.github", config_server_detail["github"] },
|
{ "info.status", community_details.status },
|
||||||
{ "info.patreon", config_server_detail["patreon"] },
|
{ "info.lhd" },
|
||||||
},
|
{ "info.github", community_details.github },
|
||||||
|
{ "info.patreon", community_details.patreon },
|
||||||
|
}
|
||||||
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -41,7 +44,8 @@ end)
|
|||||||
|
|
||||||
--- @class speech_bubble_task_param
|
--- @class speech_bubble_task_param
|
||||||
--- @field entity LuaEntity
|
--- @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 previous_message LuaEntity?
|
||||||
--- @field current_message_index number
|
--- @field current_message_index number
|
||||||
|
|
||||||
@@ -60,8 +64,9 @@ local speech_bubble_task =
|
|||||||
return Async.status.complete()
|
return Async.status.complete()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local messages = task.messages or locations[task.location].messages()
|
||||||
local index = task.current_message_index
|
local index = task.current_message_index
|
||||||
if index > #task.messages then
|
if index > #messages then
|
||||||
index = 1
|
index = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -71,7 +76,7 @@ local speech_bubble_task =
|
|||||||
end
|
end
|
||||||
|
|
||||||
speech_bubble_param.source = entity
|
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.previous_message = entity.surface.create_entity(speech_bubble_param)
|
||||||
|
|
||||||
task.current_message_index = index + 1
|
task.current_message_index = index + 1
|
||||||
@@ -114,7 +119,11 @@ local function check_persistent_locations()
|
|||||||
goto continue
|
goto continue
|
||||||
end
|
end
|
||||||
|
|
||||||
persistent_locations[name] = register_entity(entity, location.messages)
|
persistent_locations[name] = speech_bubble_task{
|
||||||
|
entity = entity,
|
||||||
|
location = name,
|
||||||
|
current_message_index = 1,
|
||||||
|
}
|
||||||
::continue::
|
::continue::
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ local Roles = require("modules/exp_roles")
|
|||||||
local Commands = require("modules/exp_commands")
|
local Commands = require("modules/exp_commands")
|
||||||
local PlayerData = require("modules.exp_legacy.expcore.player_data")
|
local PlayerData = require("modules.exp_legacy.expcore.player_data")
|
||||||
local ExpServerList = require("modules/exp_server_list")
|
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_number = require("util").format_number
|
||||||
local format_time = ExpUtil.format_time_factory_locale{ format = "long", days = true, hours = true, minutes = true }
|
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
|
--- @class ExpGui_Readme.elements
|
||||||
local 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 = {}
|
local tabs = {}
|
||||||
|
|
||||||
--- Register a readme tab
|
--- Register a readme tab
|
||||||
--- @param caption LocalisedString
|
--- @param caption LocalisedString
|
||||||
--- @param tooltip LocalisedString
|
--- @param tooltip LocalisedString | fun(): LocalisedString Functions are called when the readme opens
|
||||||
--- @param element ExpElement
|
--- @param element ExpElement
|
||||||
local function define_tab(caption, tooltip, element)
|
local function define_tab(caption, tooltip, element)
|
||||||
tabs[#tabs + 1] = { caption = caption, tooltip = tooltip, element = element }
|
tabs[#tabs + 1] = { caption = caption, tooltip = tooltip, element = element }
|
||||||
@@ -202,13 +202,13 @@ end
|
|||||||
--- Welcome tab
|
--- Welcome tab
|
||||||
define_tab(
|
define_tab(
|
||||||
{ "exp-gui_readme.welcome-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")
|
Gui.define("readme/welcome")
|
||||||
:draw(function(_, parent)
|
:draw(function(_, parent)
|
||||||
local player = Gui.get_player(parent)
|
local player = Gui.get_player(parent)
|
||||||
|
|
||||||
local server_details = {
|
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.",
|
welcome = "Failed to load description: disconnected from the controller.",
|
||||||
reset_time = "Not Set",
|
reset_time = "Not Set",
|
||||||
}
|
}
|
||||||
@@ -248,7 +248,7 @@ define_tab(
|
|||||||
frame_width,
|
frame_width,
|
||||||
{
|
{
|
||||||
"exp-gui_readme.welcome-general",
|
"exp-gui_readme.welcome-general",
|
||||||
config_server_detail["community_name"],
|
community.community_name,
|
||||||
format_time(game.tick),
|
format_time(game.tick),
|
||||||
server_details.reset_time,
|
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)
|
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
|
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, 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
|
end
|
||||||
|
|
||||||
return container
|
return container
|
||||||
@@ -651,11 +651,16 @@ Elements.container = Gui.define("readme/container")
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, tab in ipairs(tabs) do
|
for _, tab in ipairs(tabs) do
|
||||||
|
local tooltip = tab.tooltip
|
||||||
|
if type(tooltip) == "function" then
|
||||||
|
tooltip = tooltip()
|
||||||
|
end
|
||||||
|
|
||||||
local gui_tab = pane.add{
|
local gui_tab = pane.add{
|
||||||
type = "tab",
|
type = "tab",
|
||||||
style = "frame_tab",
|
style = "frame_tab",
|
||||||
caption = tab.caption,
|
caption = tab.caption,
|
||||||
tooltip = tab.tooltip,
|
tooltip = tooltip,
|
||||||
}
|
}
|
||||||
|
|
||||||
pane.add_tab(gui_tab, tab.element(pane))
|
pane.add_tab(gui_tab, tab.element(pane))
|
||||||
|
|||||||
Reference in new issue
Block a user