corpse.lua 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. for i = 1,7 do
  2. minetest.register_node('lobby:corpse_'..i, {
  3. description = 'Corpse',
  4. drawtype = 'mesh',
  5. mesh = 'lobby_corpse.obj',
  6. tiles = {'gamer_skin_'..i..'.png^lobby_corpse.png', 'lobby_blood.png'},
  7. use_texture_alpha = 'blend',
  8. walkable = false,
  9. groups = {breakable=1, not_in_creative_inventory=1},
  10. paramtype = 'light',
  11. paramtype2 = 'facedir',
  12. selection_box = {
  13. type = 'fixed',
  14. fixed = {-.6, -.5, -.6, .6, -.2, .6}, -- Right, Bottom, Back, Left, Top, Front
  15. },
  16. collision_box = {
  17. type = 'fixed',
  18. fixed = {-.6, -.5, -.6, .6, -.2, .6}, -- Right, Bottom, Back, Left, Top, Front
  19. },
  20. on_rightclick = function(pos, node, clicker, itemstack)
  21. local name = clicker:get_player_name()
  22. local player_attributes = clicker:get_meta()
  23. local mode = player_attributes:get_string('mode')
  24. local voting = player_attributes:get_string('voting')
  25. local map_id = lobby.game[name]
  26. if voting == 'false' then
  27. if map_id ~= 'lobby' and mode == 'player' then
  28. minetest.remove_node(pos)
  29. local game_data = lobby.savedata.data[map_id]
  30. local game_pos = game_data['level_pos']
  31. lobby.votes[map_id] = 0
  32. for _, player in pairs(minetest.get_connected_players()) do
  33. local rname = player:get_player_name()
  34. if lobby.game[rname] == map_id then
  35. lobby.voted[rname] = false
  36. player:set_physics_override({speed=0})
  37. player_attributes:set_string('voting', 'true')
  38. minetest.chat_send_player(rname, minetest.colorize('#FF0000', 'Somebody discovered a corpse!'))
  39. minetest.show_formspec(rname, 'lobby:voting', lobby.voting_formspec(map_id, true))
  40. player:set_pos({x=game_pos.x+(math.random(-3,3)),y=game_pos.y,z=game_pos.z+(math.random(-3,3))})
  41. end
  42. end
  43. end
  44. end
  45. end,
  46. })
  47. end