defenestrate.lua 742 B

123456789101112131415161718192021222324252627
  1. minetest.register_privilege("defenestrate", {
  2. description = "User can defenestrate others.",
  3. give_to_singleplayer = false,
  4. })
  5. -- Something that needs to happen to some politicians!
  6. minetest.register_chatcommand("defenestrate", {
  7. params = "<player>",
  8. description = "Throw someone (presumably out of a window).",
  9. privs = {defenestrate=true},
  10. func = function(pname, param)
  11. local player = minetest.get_player_by_name(rename.grn(param))
  12. if not player then
  13. return false, "Cannot defenestrate unknown target <" .. param .. ">."
  14. end
  15. default.detach_player_if_attached(player)
  16. local rng = math.random
  17. local vel = {x=rng(-20, 20), y=6, z=rng(-20, 20)}
  18. player:add_velocity(vel)
  19. return true, "Target defenestrated."
  20. end,
  21. })