Add dynamic spawning option

This commit is contained in:
Splizard 2013-01-28 13:53:46 +13:00
parent b07583a8f0
commit 1a44c43c3e
3 changed files with 7 additions and 11 deletions
mods
glass_arena
hungry_games
spawning

@ -58,9 +58,6 @@ minetest.register_node("glass_arena:wall_end",{
})
--Teleport player within boundary
local glass_arena = {}
glass_arena.rise = function(player)
local pos = player:getpos()
if pos then
@ -87,20 +84,13 @@ glass_arena.rise = function(player)
end
end
local function teleport(player)
function glass_arena.teleport(player)
local pos = player:getpos()
player:setpos({x=math.random(-arena_size+1,arena_size-1),y=0,z=math.random(-arena_size+1,arena_size-1)})
minetest.after(1, glass_arena.rise, player)
return true
end
minetest.register_on_joinplayer(teleport)
minetest.register_on_newplayer(function(player)
player:get_inventory():add_item('main', 'default:ladder 10')
end)
minetest.register_on_respawnplayer(teleport)
--Regenerate walls if pieces are missing
minetest.register_abm({
nodenames = {"glass_arena:wall_middle"},

@ -24,6 +24,8 @@ spawning.on_join("spectate")
spawning.on_death("spectate")
--Set spawn point. [SAFE]
--Can be set as static: spawning.set_spawn("static", {0,0,0})
--or dynamic (random spawn): spawning.set_spawn("dynamic")
spawning.set_spawn("static", {0,0,0})
-----------------------------------

@ -73,5 +73,9 @@ function spawning.set_spawn(mode, param)
minetest.register_on_respawnplayer(spawn)
minetest.register_on_joinplayer(spawn)
spawning.spawn = spawn
elseif mode == "dynamic" then
minetest.register_on_respawnplayer(glass_arena.teleport)
minetest.register_on_joinplayer(glass_arena.teleport)
spawning.spawn = glass_arena.teleport
end
end