Add spectating.
This commit is contained in:
parent
d31128b45f
commit
ddd94b3bb6
@ -1,8 +1,8 @@
|
||||
--Drop the item the player was holding
|
||||
minetest.register_on_dieplayer(function(player)
|
||||
local pos = player:getpos()
|
||||
inv = player:get_inventory()
|
||||
inventorylist = inv:get_list("main")
|
||||
--Drop all players items
|
||||
for i,v in pairs(inventorylist) do
|
||||
obj = minetest.env:add_item({x=math.floor(pos.x)+math.random(), y=pos.y, z=math.floor(pos.z)+math.random()}, v)
|
||||
if obj ~= nil then
|
||||
|
@ -12,6 +12,13 @@ glass_arena.set_size(200)
|
||||
--Set texture of the arena. [SAFE]
|
||||
glass_arena.set_texture("default_glass.png")
|
||||
|
||||
-----------------------------------
|
||||
--------Spawn configuration--------
|
||||
|
||||
--Set what happens to players on death.
|
||||
--Defaults to nothing.
|
||||
spawning.on_death("spectate")
|
||||
|
||||
-----------------------------------
|
||||
--------Chest configuration--------
|
||||
local chest_item = random_chests.register_item
|
||||
|
17
mods/spawning/init.lua
Normal file
17
mods/spawning/init.lua
Normal file
@ -0,0 +1,17 @@
|
||||
spawning = {}
|
||||
|
||||
|
||||
function spawning.on_death(mode)
|
||||
if mode == "spectate" then
|
||||
minetest.register_on_dieplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
local privs = minetest.get_player_privs(name)
|
||||
privs.fast = true
|
||||
privs.fly = true
|
||||
privs.interact = false
|
||||
minetest.set_player_privs(name, privs)
|
||||
minetest.auth_reload()
|
||||
minetest.chat_send_player(name, "You are now spectating")
|
||||
end
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user