chatcommands.lua 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. -- ===================================================================
  2. -- Minetest commands
  3. -- ===================================================================
  4. local chat_table -- MT chat command definitions table
  5. local regchat -- Chat-command registration function
  6. regchat = minetest.register_chatcommand
  7. -- ===================================================================
  8. -- /addorg /add_org
  9. -- This code defines a chat command which creates a new
  10. -- "org". Presently, the command makes the user the sole member of the
  11. -- "org".
  12. chat_table = {
  13. privs = {} ,
  14. func = function (user, param)
  15. local success, message = modpol.add_org (param, { user })
  16. return true, message
  17. end
  18. }
  19. regchat ("addorg" , chat_table)
  20. regchat ("add_org" , chat_table)
  21. -- ===================================================================
  22. -- /listorg /listorgs /list_org /list_orgs
  23. -- In Minetest mode, this code defines a chat command which lists the
  24. -- existing "orgs".
  25. -- The list shows one "org" per line in the following format:
  26. -- org_name (member, member, ...)
  27. chat_table = {
  28. privs = {} ,
  29. func = function (user, param)
  30. return true, "Orgs:\n" .. modpol.list_orgs()
  31. end
  32. }
  33. regchat ("listorg" , chat_table)
  34. regchat ("listorgs" , chat_table)
  35. regchat ("list_org" , chat_table)
  36. regchat ("list_orgs" , chat_table)
  37. -- ===================================================================
  38. -- /listplayers
  39. minetest.register_chatcommand(
  40. "listplayers", {
  41. privs = {},
  42. func = function(user)
  43. local result = table.concat(modpol.list_users(),", ")
  44. return true, "All players: " .. result
  45. end,
  46. })
  47. -- ===================================================================
  48. -- /joinorg
  49. minetest.register_chatcommand(
  50. "joinorg", {
  51. privs = {},
  52. func = function(user, param)
  53. local success, result = modpol.add_member(param, user)
  54. return true, result
  55. end,
  56. })
  57. -- ===================================================================
  58. -- /pollself [question]
  59. -- asks the user a question specified in param
  60. minetest.register_chatcommand(
  61. "pollself", {
  62. privs = {},
  63. func = function(user, param)
  64. modpol.binary_poll_user(user, param)
  65. return true, result
  66. end,
  67. })