From 1a44c43c3e2be31e08984cf530964a4a8bf2b10f Mon Sep 17 00:00:00 2001 From: Splizard Date: Mon, 28 Jan 2013 13:53:46 +1300 Subject: [PATCH] Add dynamic spawning option --- mods/glass_arena/init.lua | 12 +----------- mods/hungry_games/init.lua | 2 ++ mods/spawning/init.lua | 4 ++++ 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/mods/glass_arena/init.lua b/mods/glass_arena/init.lua index 3465645..470c435 100644 --- a/mods/glass_arena/init.lua +++ b/mods/glass_arena/init.lua @@ -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"}, diff --git a/mods/hungry_games/init.lua b/mods/hungry_games/init.lua index fe4d934..b349785 100644 --- a/mods/hungry_games/init.lua +++ b/mods/hungry_games/init.lua @@ -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}) ----------------------------------- diff --git a/mods/spawning/init.lua b/mods/spawning/init.lua index c4460a6..5cdedd8 100644 --- a/mods/spawning/init.lua +++ b/mods/spawning/init.lua @@ -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