2021-02-10 23:40:28 -05:00
|
|
|
-- ===================================================================
|
|
|
|
|
-- Minetest commands
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
2021-03-15 18:08:06 -06:00
|
|
|
command_list = {} -- user-facing table of commands
|
|
|
|
|
|
2021-02-10 23:40:28 -05:00
|
|
|
local chat_table -- MT chat command definitions table
|
|
|
|
|
local regchat -- Chat-command registration function
|
|
|
|
|
|
|
|
|
|
regchat = minetest.register_chatcommand
|
|
|
|
|
|
2021-03-15 19:26:16 +00:00
|
|
|
regchat = function(name, command_table)
|
|
|
|
|
minetest.register_chatcommand(name, command_table)
|
|
|
|
|
table.insert(command_list, name)
|
|
|
|
|
end
|
|
|
|
|
|
2021-02-10 23:40:28 -05:00
|
|
|
-- ===================================================================
|
2021-04-17 21:46:14 -06:00
|
|
|
-- /modpol
|
2021-03-14 22:51:53 -06:00
|
|
|
-- Presents a menu of options to users
|
2021-03-15 19:26:16 +00:00
|
|
|
regchat(
|
2021-04-17 21:46:14 -06:00
|
|
|
"modpol", {
|
2021-03-14 22:51:53 -06:00
|
|
|
privs = {},
|
|
|
|
|
func = function(user)
|
2021-04-17 23:37:56 -06:00
|
|
|
modpol.interactions.dashboard(user)
|
2021-03-14 22:51:53 -06:00
|
|
|
end,
|
|
|
|
|
})
|
|
|
|
|
|
2021-03-15 18:08:06 -06:00
|
|
|
-- ===================================================================
|
|
|
|
|
-- /reset
|
|
|
|
|
-- For testing only
|
|
|
|
|
-- Clears the system and recreates instance with all players
|
|
|
|
|
regchat(
|
|
|
|
|
"reset", {
|
|
|
|
|
privs = {},
|
|
|
|
|
func = function(user)
|
2021-04-15 00:21:56 -04:00
|
|
|
modpol.orgs.reset();
|
2021-03-15 18:08:06 -06:00
|
|
|
return true, "Reset orgs"
|
|
|
|
|
end,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-03-14 22:51:53 -06:00
|
|
|
-- ===================================================================
|
2021-03-28 16:26:14 -04:00
|
|
|
-- /addorg
|
2021-02-10 23:40:28 -05:00
|
|
|
-- This code defines a chat command which creates a new
|
|
|
|
|
-- "org". Presently, the command makes the user the sole member of the
|
|
|
|
|
-- "org".
|
|
|
|
|
|
2021-03-28 16:26:14 -04:00
|
|
|
regchat(
|
|
|
|
|
"addorg", {
|
|
|
|
|
privs = {} ,
|
|
|
|
|
func = function (user, param)
|
2021-04-15 00:21:56 -04:00
|
|
|
local success, message = modpol.instance:add_org (param)
|
2021-03-28 16:26:14 -04:00
|
|
|
return true, message
|
|
|
|
|
end
|
|
|
|
|
})
|
2021-02-10 23:40:28 -05:00
|
|
|
|
|
|
|
|
-- ===================================================================
|
2021-04-17 09:50:18 -06:00
|
|
|
-- /listorgs
|
|
|
|
|
-- In Minetest mode, this code defines a chat command which lists
|
2021-02-10 23:40:28 -05:00
|
|
|
-- existing "orgs".
|
|
|
|
|
-- The list shows one "org" per line in the following format:
|
|
|
|
|
-- org_name (member, member, ...)
|
|
|
|
|
|
2021-03-28 16:26:14 -04:00
|
|
|
regchat(
|
2021-04-17 09:50:18 -06:00
|
|
|
"listorgs", {
|
2021-03-28 16:26:14 -04:00
|
|
|
privs = {} ,
|
|
|
|
|
func = function (user, param)
|
2021-04-17 09:50:18 -06:00
|
|
|
return true, "Orgs: " ..
|
|
|
|
|
table.concat(modpol.orgs.list_all(), ", ")
|
2021-03-28 16:26:14 -04:00
|
|
|
end
|
|
|
|
|
})
|
2021-02-10 23:40:28 -05:00
|
|
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
-- /listplayers
|
2021-03-15 19:26:16 +00:00
|
|
|
regchat(
|
2021-02-10 23:40:28 -05:00
|
|
|
"listplayers", {
|
|
|
|
|
privs = {},
|
|
|
|
|
func = function(user)
|
|
|
|
|
local result = table.concat(modpol.list_users(),", ")
|
|
|
|
|
return true, "All players: " .. result
|
|
|
|
|
end,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
-- /joinorg
|
2021-03-15 19:26:16 +00:00
|
|
|
regchat(
|
2021-02-10 23:40:28 -05:00
|
|
|
"joinorg", {
|
|
|
|
|
privs = {},
|
|
|
|
|
func = function(user, param)
|
2021-04-15 00:21:56 -04:00
|
|
|
local org = modpol.orgs.get_org(param)
|
|
|
|
|
local success, result = org:add_member(user)
|
2021-02-10 23:40:28 -05:00
|
|
|
return true, result
|
|
|
|
|
end,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
|
-- /pollself [question]
|
|
|
|
|
-- asks the user a question specified in param
|
2021-03-15 19:26:16 +00:00
|
|
|
regchat(
|
2021-02-10 23:40:28 -05:00
|
|
|
"pollself", {
|
|
|
|
|
privs = {},
|
|
|
|
|
func = function(user, param)
|
2021-04-17 21:46:14 -06:00
|
|
|
modpol.interactions.binary_poll_user(user, param)
|
2021-02-10 23:40:28 -05:00
|
|
|
return true, result
|
|
|
|
|
end,
|
|
|
|
|
})
|