mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-11-15 16:24:52 +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
@@ -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
|
||||
|
||||
Reference in new issue
Block a user