mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-31 04:51:40 +09:00
Added Custom Join Message
This commit is contained in:
@@ -32,8 +32,6 @@ return {
|
|||||||
'modules.commands.quickbar',
|
'modules.commands.quickbar',
|
||||||
|
|
||||||
--- Addons
|
--- Addons
|
||||||
'modules.addons.station-auto-name',
|
|
||||||
'modules.addons.greetings',
|
|
||||||
'modules.addons.chat-popups',
|
'modules.addons.chat-popups',
|
||||||
'modules.addons.damage-popups',
|
'modules.addons.damage-popups',
|
||||||
'modules.addons.death-logger',
|
'modules.addons.death-logger',
|
||||||
@@ -42,11 +40,15 @@ return {
|
|||||||
'modules.addons.compilatron',
|
'modules.addons.compilatron',
|
||||||
'modules.addons.scorched-earth',
|
'modules.addons.scorched-earth',
|
||||||
'modules.addons.pollution-grading',
|
'modules.addons.pollution-grading',
|
||||||
'modules.addons.player-colours',
|
'modules.addons.station-auto-name',
|
||||||
'modules.addons.discord-alerts',
|
'modules.addons.discord-alerts',
|
||||||
'modules.addons.chat-reply',
|
'modules.addons.chat-reply',
|
||||||
'modules.addons.tree-decon',
|
'modules.addons.tree-decon',
|
||||||
|
|
||||||
|
--- Data
|
||||||
|
'modules.data.player-colours',
|
||||||
|
'modules.data.greetings',
|
||||||
|
|
||||||
--- GUI
|
--- GUI
|
||||||
'modules.gui.readme',
|
'modules.gui.readme',
|
||||||
'modules.gui.rocket-info',
|
'modules.gui.rocket-info',
|
||||||
|
|||||||
@@ -78,6 +78,3 @@ get-mead-2= Skål!
|
|||||||
get-beer-1= 🍺 Pouring A Glass 🍺
|
get-beer-1= 🍺 Pouring A Glass 🍺
|
||||||
get-beer-2= 🍻 Chears Mate 🍻
|
get-beer-2= 🍻 Chears Mate 🍻
|
||||||
verify=Please return to our discord and type r!verify __1__
|
verify=Please return to our discord and type r!verify __1__
|
||||||
|
|
||||||
[greetings]
|
|
||||||
greet=[color=0,1,0] Welcome to explosive gaming community server! If you like the server join our discord: __1__ [/color]
|
|
||||||
@@ -76,3 +76,7 @@ home-get=Your home point is at x: __1__ y: __2__
|
|||||||
|
|
||||||
[expcom-server-ups]
|
[expcom-server-ups]
|
||||||
no-ext=No external source was found, cannot display server ups.
|
no-ext=No external source was found, cannot display server ups.
|
||||||
|
|
||||||
|
[expcom-join-message]
|
||||||
|
greet=[color=0,1,0] Welcome to explosive gaming community server! If you like the server join our discord: __1__ [/color]
|
||||||
|
message-set=Your join message has been updated.
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
--- Greets players on join
|
|
||||||
-- @addon greetings
|
|
||||||
|
|
||||||
local Event = require 'utils.event' --- @dep utils.event
|
|
||||||
local Game = require 'utils.game' --- @dep utils.event
|
|
||||||
local config = require 'config.join_messages' --- @dep config.join_messages
|
|
||||||
local Global = require 'utils.global' --- @dep utils.global
|
|
||||||
require 'overrides.table'
|
|
||||||
|
|
||||||
Global.register(config, function(tbl)
|
|
||||||
config = tbl
|
|
||||||
end)
|
|
||||||
|
|
||||||
local greet =
|
|
||||||
function(event)
|
|
||||||
local player = Game.get_player_by_index(event.player_index)
|
|
||||||
local custom_message = config[player.name]
|
|
||||||
if custom_message then
|
|
||||||
game.print(custom_message, player.color)
|
|
||||||
else
|
|
||||||
player.print{'greetings.greet', {'links.discord'}}
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
Event.add(defines.events.on_player_joined_game, greet)
|
|
||||||
32
modules/data/greetings.lua
Normal file
32
modules/data/greetings.lua
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
--- Greets players on join
|
||||||
|
-- @addon greetings
|
||||||
|
|
||||||
|
local Commands = require 'expcore.commands' ---@dep expcore.commands
|
||||||
|
local config = require 'config.join_messages' --- @dep config.join_messages
|
||||||
|
|
||||||
|
--- Stores the join message that the player have
|
||||||
|
local PlayerData = require 'expcore.player_data' --- @dep expcore.player_data
|
||||||
|
local CustomMessages = PlayerData.Settings:combine('JoinMessage')
|
||||||
|
|
||||||
|
--- 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, player.color)
|
||||||
|
else
|
||||||
|
player.print{'expcom-join-message.greet', {'links.discord'}}
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
--- Set your custom join message
|
||||||
|
-- @command join-message
|
||||||
|
-- @tparam string message The custom join message that will be used
|
||||||
|
Commands.new_command('join-message', 'Sets your custom join message')
|
||||||
|
:add_param('message', false)
|
||||||
|
:enable_auto_concat()
|
||||||
|
:register(function(player, message)
|
||||||
|
if not player then return end
|
||||||
|
CustomMessages:set(player, message)
|
||||||
|
return {'expcom-join-message.message-set'}
|
||||||
|
end)
|
||||||
Reference in New Issue
Block a user