chatcommands.lua 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. -- ===================================================================
  2. -- Minetest commands
  3. -- ===================================================================
  4. command_list = {} -- user-facing table of commands
  5. local chat_table -- MT chat command definitions table
  6. local regchat -- Chat-command registration function
  7. regchat = minetest.register_chatcommand
  8. regchat = function(name, command_table)
  9. minetest.register_chatcommand(name, command_table)
  10. table.insert(command_list, name)
  11. end
  12. -- ===================================================================
  13. -- /mp
  14. -- Presents a menu of options to users
  15. regchat(
  16. "mp", {
  17. privs = {},
  18. func = function(user)
  19. modpol.interactions.dashboard(user)
  20. end,
  21. })
  22. -- ===================================================================
  23. -- /mptest
  24. -- For testing only, accessible to admin users
  25. -- Clears the system and recreates instance with all players
  26. -- opens dashboard too for fun.
  27. regchat(
  28. "mptest", {
  29. privs = {privs=true},
  30. func = function(user)
  31. modpol.instance.members = modpol.list_users()
  32. modpol.orgs.reset()
  33. modpol.interactions.dashboard(user)
  34. return true, "Reset orgs"
  35. end,
  36. })
  37. -- ===================================================================
  38. -- /addorg
  39. -- This code defines a chat command which creates a new
  40. -- "org". Presently, the command makes the user the sole member of the
  41. -- "org".
  42. regchat(
  43. "addorg", {
  44. privs = {} ,
  45. func = function (user, param)
  46. local success, message = modpol.instance:add_org (param)
  47. return true, message
  48. end
  49. })
  50. -- ===================================================================
  51. -- /listorgs
  52. -- In Minetest mode, this code defines a chat command which lists
  53. -- existing "orgs".
  54. -- The list shows one "org" per line in the following format:
  55. -- org_name (member, member, ...)
  56. regchat(
  57. "listorgs", {
  58. privs = {} ,
  59. func = function (user, param)
  60. return true, "Orgs: " ..
  61. table.concat(modpol.orgs.list_all(), ", ")
  62. end
  63. })