79 lines
2.3 KiB
Lua
79 lines
2.3 KiB
Lua
|
|
-- ===================================================================
|
||
|
|
-- Minetest commands
|
||
|
|
-- ===================================================================
|
||
|
|
|
||
|
|
local chat_table -- MT chat command definitions table
|
||
|
|
local regchat -- Chat-command registration function
|
||
|
|
|
||
|
|
regchat = minetest.register_chatcommand
|
||
|
|
|
||
|
|
-- ===================================================================
|
||
|
|
-- /addorg /add_org
|
||
|
|
-- This code defines a chat command which creates a new
|
||
|
|
-- "org". Presently, the command makes the user the sole member of the
|
||
|
|
-- "org".
|
||
|
|
|
||
|
|
chat_table = {
|
||
|
|
privs = {} ,
|
||
|
|
func = function (user, param)
|
||
|
|
local result = modpol.add_org (param, { user })
|
||
|
|
return true, result
|
||
|
|
end
|
||
|
|
}
|
||
|
|
regchat ("addorg" , chat_table)
|
||
|
|
regchat ("add_org" , chat_table)
|
||
|
|
|
||
|
|
-- ===================================================================
|
||
|
|
-- /listorg /listorgs /list_org /list_orgs
|
||
|
|
-- In Minetest mode, this code defines a chat command which lists the
|
||
|
|
-- existing "orgs".
|
||
|
|
-- The list shows one "org" per line in the following format:
|
||
|
|
-- org_name (member, member, ...)
|
||
|
|
|
||
|
|
chat_table = {
|
||
|
|
privs = {} ,
|
||
|
|
func = function (user, param)
|
||
|
|
return true, "Orgs:\n" .. modpol.list_orgs()
|
||
|
|
end
|
||
|
|
}
|
||
|
|
|
||
|
|
regchat ("listorg" , chat_table)
|
||
|
|
regchat ("listorgs" , chat_table)
|
||
|
|
regchat ("list_org" , chat_table)
|
||
|
|
regchat ("list_orgs" , chat_table)
|
||
|
|
|
||
|
|
-- ===================================================================
|
||
|
|
-- /listplayers
|
||
|
|
minetest.register_chatcommand(
|
||
|
|
"listplayers", {
|
||
|
|
privs = {},
|
||
|
|
func = function(user)
|
||
|
|
local result = table.concat(modpol.list_users(),", ")
|
||
|
|
return true, "All players: " .. result
|
||
|
|
end,
|
||
|
|
})
|
||
|
|
|
||
|
|
-- ===================================================================
|
||
|
|
-- /joinorg
|
||
|
|
minetest.register_chatcommand(
|
||
|
|
"joinorg", {
|
||
|
|
privs = {},
|
||
|
|
func = function(user, param)
|
||
|
|
local result = modpol.add_member(param, user)
|
||
|
|
return true, result
|
||
|
|
end,
|
||
|
|
})
|
||
|
|
|
||
|
|
|
||
|
|
-- ===================================================================
|
||
|
|
-- /pollself [question]
|
||
|
|
-- asks the user a question specified in param
|
||
|
|
minetest.register_chatcommand(
|
||
|
|
"pollself", {
|
||
|
|
privs = {},
|
||
|
|
func = function(user, param)
|
||
|
|
modpol.binary_poll_user(user, param)
|
||
|
|
return true, result
|
||
|
|
end,
|
||
|
|
})
|