tool.lua 1.0 KB

123456789101112131415161718192021222324252627282930
  1. minetest.register_craftitem('lobby:shank', {
  2. description = 'Traitor\'s Shank',
  3. inventory_image = 'lobby_shank.png',
  4. groups = {not_in_creative_inventory=1},
  5. on_use = function(itemstack, player, pointed_thing)
  6. local physics_table = player:get_physics_override()
  7. if physics_table.speed ~= 0 then
  8. local traitor = player:get_player_name()
  9. local obj = pointed_thing.ref
  10. if obj and pointed_thing.type == "object" then
  11. local player_name = obj:get_player_name()
  12. if player_name ~= '' then
  13. local map_name = lobby.game[traitor]
  14. local victim = minetest.get_player_by_name(player_name)
  15. victim:set_hp(0)
  16. local count = lobby.map[map_name]
  17. if count == 1 then
  18. lobby.traitor_win(traitor, map_name)
  19. itemstack:take_item()
  20. return itemstack
  21. end
  22. end
  23. end
  24. end
  25. end,
  26. on_drop = function(itemstack, dropper, pos)
  27. return
  28. end,
  29. })