From 06c9f9e589080bdbe63b9a43149fec6bce5d1f22 Mon Sep 17 00:00:00 2001
From: Quadrum <38959426+Quadrum1@users.noreply.github.com>
Date: Wed, 9 Dec 2020 13:36:35 +0100
Subject: [PATCH] Update message_on_join_data.lua

Customizable layout of on_join_message by providing "{name}" as a string replaced by the username when printing
---
 utils/datastore/message_on_join_data.lua | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/utils/datastore/message_on_join_data.lua b/utils/datastore/message_on_join_data.lua
index c39a9416..00b6e817 100644
--- a/utils/datastore/message_on_join_data.lua
+++ b/utils/datastore/message_on_join_data.lua
@@ -19,7 +19,8 @@ local fetch =
             return
         end
         if type(value) == 'table' then
-            game.print('>> ' .. player.name .. ' << ' .. value.msg, value.color)
+            local message = string.gsub(value.msg, "{name}", player.name)
+            game.print(message, value.color)
         end
     end
 )
@@ -41,7 +42,7 @@ end
 
 commands.add_command(
     'save-message',
-    'Sets your custom join message.',
+    'Sets your custom join message. "{name}" will be replaced with your username',
     function(cmd)
         local player = game.player
         if not player or not player.valid then