forked from cuberite/Core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
motd.lua
40 lines (33 loc) · 902 Bytes
/
motd.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
function HandleMOTDCommand( Split, Player )
ShowMOTDTo( Player )
return true
end
function LoadMotd()
-- Check if the file 'motd.txt' exists, if not, create it with default content:
if (not cFile:IsFile("motd.txt")) then
CreateFile = io.open( "motd.txt", "w" )
CreateFile:write("@6Welcome to the Cuberite test server!\n@6http://www.cuberite.org/\n@6Type /help for all commands")
CreateFile:close()
end
for line in io.lines( "motd.txt" ) do
line = line:gsub("(@.)",
function(a_Str)
local Char = a_Str:sub(2, 2)
if (Char == "@") then
-- If the input was "@@" then simply replace it with a single "@"
return "@"
end
local Color = ReturnColorFromChar(Char)
if (Color) then
return Color
end
end
)
table.insert(Messages, line)
end
end
function ShowMOTDTo( Player )
for I=1, #Messages do
Player:SendMessage(Messages[I])
end
end