-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinit.lua
More file actions
113 lines (103 loc) · 4.35 KB
/
init.lua
File metadata and controls
113 lines (103 loc) · 4.35 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
------------------------
--Individual Messaging--
------------------------
local recipient
minetest.register_chatcommand("pm", {
description = "Sends a pm to a specified player. Input no parameters to check recipient.",
func = function(param)
if param == "" then
if recipient == nil then
minetest.display_chat_message(minetest.colorize("red", "[PM]") .. " You must first select a recipient with .pm_set.")
else
minetest.display_chat_message(minetest.colorize("#00ff00", "[PM]") .. " Selected recipient: " .. recipient)
end
else
if recipient == nil then
minetest.display_chat_message(minetest.colorize("red", "[PM]") .. " You must first select a recipient with .pm_set.")
else
minetest.run_server_chatcommand("msg", recipient .. " " .. param)
end
end
end })
minetest.register_chatcommand("pm_set", {
description = "Sets the recipient for messages sent with .pm. Recipient names are case sensitive.",
func = function(param)
if param == "" then
minetest.display_chat_message(minetest.colorize("red", "[PM]") .. " You must enter a recipient.")
else
recipient = param
minetest.display_chat_message(minetest.colorize("#00ff00", "[PM]") .. " Recipient set to: " .. recipient)
end
end })
-------------------
--Group Messaging--
-------------------
local recipients = {}
minetest.register_chatcommand("pm_group", {
description = "Sends a pm to a group of players. Input no parameters to check recipients.",
func = function(param)
if param == "" then
if recipients == {} then
minetest.display_chat_message(minetest.colorize("red", "[PM]") .. " You must first add at least 1 recipient with .pm_add.")
else
local names = ""
for _,v in pairs(recipients) do
names = names .. v .. ", "
end
names = names:sub(1, -3)
if names == "" then
minetest.display_chat_message(minetest.colorize("red", "[PM]") .. " No recipients have been set")
else
minetest.display_chat_message(minetest.colorize("#00ff00", "[PM]") .. " Recipients: " .. names)
end
end
else
if recipients == {} then
minetest.display_chat_message(minetest.colorize("red", "[PM]") .. " You must first select a recipient with .pm_add.")
else
for _,v in pairs(recipients) do
minetest.run_server_chatcommand("msg", v .. " " .. param)
end
end
end
end })
minetest.register_chatcommand("pm_add", {
description = "Adds a recipient to the list. Recipient names are case sensitive.",
func = function(param)
if param == "" then
minetest.display_chat_message(minetest.colorize("red", "[PM]") .. " You must enter a recipient.")
else
table.insert(recipients, param)
minetest.display_chat_message(minetest.colorize("#00ff00", "[PM]") .. " Added recipient: " .. param)
end
end })
minetest.register_chatcommand("pm_remove", {
description = "Removes a recipient from the list. Recipient names are case sensitive.",
func = function(param)
if param == "" then
minetest.display_chat_message(minetest.colorize("red", "[PM]") .. " You must enter a recipient.")
else
local removed = false
for _,v in pairs(recipients) do
if v == param then
table.remove(recipients, _)
removed = true
end
end
if removed then
minetest.display_chat_message(minetest.colorize("#00ff00", "[PM]") .. " Removed recipient: " .. param)
else
minetest.display_chat_message(minetest.colorize("red", "[PM]") .. " Recipient name not in list. Remember recipient names are case sensitive.")
end
end
end })
minetest.register_chatcommand("pm_clear", {
description = "Clears the recipient list.",
func = function(param)
if param == "" then
recipients = {}
minetest.display_chat_message(minetest.colorize("#00ff00", "[PM]") .. " All recipients removed.")
else
minetest.display_chat_message(minetest.colorize("red", "[PM]") .. " This command does not accept parameters.")
end
end })