commands.lua 813 B

123456789101112131415161718192021222324252627282930
  1. local S = minetest.get_translator("mob_spawning_director")
  2. minetest.register_chatcommand("mobspawning",
  3. {
  4. params = "[on|off]",
  5. privs = {server = true},
  6. description = S("Toggles mob spawning on or off"),
  7. func = function(name, param)
  8. local on = mob_spawning_director.get_enablation_state()
  9. if param == "on" and not on
  10. then
  11. mob_spawning_director.enable()
  12. return true, S("Enabled mob spawning")
  13. elseif param == "off" and on
  14. then
  15. mob_spawning_director.disable()
  16. return true, S("Disabled mob spawning")
  17. elseif (param == "on" and on) or (param == "off" and not on)
  18. then
  19. return true, S("Mob spawning was already " .. (on and "enabled" or "disabled"))
  20. else
  21. return true, S("Mob spawning is " .. (on and "enabled" or "disabled"))
  22. end
  23. end,
  24. })