12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- function lobby.press_button(pos, node, clicker)
- local name = clicker:get_player_name()
- local player_attributes = clicker:get_meta()
- local voting = player_attributes:get_string('voting')
- local mode = player_attributes:get_string('mode')
- local map_id = lobby.game[name]
- if voting == 'false' then
- if map_id ~= 'lobby' and (mode == 'player' or mode == 'traitor') then
- local game_data = lobby.savedata.data[map_id]
- local game_pos = game_data['level_pos']
- lobby.votes[map_id] = 0
- minetest.log('action', name..' just called an emergency meeting.')
- for _, player in pairs(minetest.get_connected_players()) do
- local rname = player:get_player_name()
- local player_attributes = player:get_meta()
- if lobby.game[rname] == map_id then
- lobby.voted[rname] = false
- local vel = player:get_velocity()
- local vel_x = vel.x * -1
- local vel_y = vel.y * -1
- local vel_z = vel.z * -1
- player:add_velocity({x=vel_x, y=vel_y, z=vel_z})
- player:set_pos({x=game_pos.x+(math.random(-2.5,2.5)),y=game_pos.y-1,z=game_pos.z+(math.random(-2.5,2.5))})
- player:set_physics_override({speed=.001})
- player:set_armor_groups({immortal=1})
- player_attributes:set_string('voting', 'true')
- minetest.chat_send_player(rname, minetest.colorize('#FF0000', name..' called an emergency meeting!'))
- minetest.show_formspec(rname, 'lobby:voting', lobby.voting_formspec(map_id, true))
- end
- end
- end
- else
- minetest.chat_send_player(name, 'Sorry, you can\'t do that now.')
- end
- end
- minetest.register_node('lobby:emergency_button', {
- description = 'Emergency Button',
- drawtype = 'mesh',
- mesh = 'lobby_emergency_button.obj',
- tiles = {'lobby_button_frame.png', 'lobby_button_button.png'},
- use_texture_alpha = 'clip',
- groups = {breakable=1},
- paramtype = 'light',
- paramtype2 = 'facedir',
- selection_box = {
- type = 'fixed',
- fixed = {-.5, -.5, -.5, .5, -.3, .5},
- },
- collision_box = {
- type = 'fixed',
- fixed = {-.5, -.5, -.5, .5, -.3, .5},
- },
- on_place = minetest.rotate_and_place,
- on_rightclick = lobby.press_button,
- on_punch = lobby.press_button,
- })
|