chatcommands.lua 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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.orgs.reset()
  32. modpol.interactions.dashboard(user)
  33. return true, "Reset orgs"
  34. end,
  35. })
  36. -- ===================================================================
  37. -- /addorg
  38. -- This code defines a chat command which creates a new
  39. -- "org". Presently, the command makes the user the sole member of the
  40. -- "org".
  41. regchat(
  42. "addorg", {
  43. privs = {} ,
  44. func = function (user, param)
  45. local success, message = modpol.instance:add_org (param)
  46. return true, message
  47. end
  48. })
  49. -- ===================================================================
  50. -- /listorgs
  51. -- In Minetest mode, this code defines a chat command which lists
  52. -- existing "orgs".
  53. -- The list shows one "org" per line in the following format:
  54. -- org_name (member, member, ...)
  55. regchat(
  56. "listorgs", {
  57. privs = {} ,
  58. func = function (user, param)
  59. return true, "Orgs: " ..
  60. table.concat(modpol.orgs.list_all(), ", ")
  61. end
  62. })