add respawn on death
This commit is contained in:
parent
316b8a8253
commit
a8b6568cbb
@ -2,7 +2,7 @@
|
||||
|
||||
A spawn command for Minetest without needing a fixed point
|
||||
|
||||
If no static spawning point is defined, each player is given a spawn location somewhere near 0,0,0.
|
||||
If no `static_spawnpoint` is defined in `minetest.conf`, each player is given a spawn location somewhere near 0,0,0.
|
||||
|
||||
If static spawn point is defined, that point is used as origin instead.
|
||||
|
||||
@ -10,6 +10,10 @@ Players will not spawn in spaces that are protected by any other player than the
|
||||
|
||||
Players can request a new spawn point by typing `/newspawn` if they have the `newspawn` privilege.
|
||||
|
||||
Player will respawn at ths spawnpoint if they die.
|
||||
|
||||
TODO - integrate with beds API to allow bed to override the spawn.
|
||||
|
||||
## License
|
||||
|
||||
(C) 2017 Tai "DuCake" Kedzierski
|
||||
|
12
init.lua
12
init.lua
@ -26,11 +26,10 @@ local function newspawn(radius)
|
||||
if not radius then
|
||||
radius = 32
|
||||
end
|
||||
if radius > 200 then
|
||||
minetest.debug("No valid spawnable location")
|
||||
if radius > 256 then
|
||||
minetest.log("error", "No valid spawnable location")
|
||||
return
|
||||
end
|
||||
minetest.debug("Re-spawn: Trying radius "..tostring(radius))
|
||||
|
||||
local pos1 = {x=origin.x-radius, y=origin.y, z=origin.z-radius}
|
||||
local pos2 = {x=origin.x+radius, y=origin.y+(radius/2), z=origin.z+radius}
|
||||
@ -51,6 +50,7 @@ local function newspawn(radius)
|
||||
end
|
||||
|
||||
if #validnodes > 0 then
|
||||
minetest.log("info", "New spawn point found with radius "..tostring(radius))
|
||||
return validnodes[math.random(1,#validnodes)]
|
||||
end
|
||||
|
||||
@ -119,3 +119,9 @@ minetest.register_on_joinplayer(function(player)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
minetest.register_on_respawnplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
player:setpos(playerspawns[name])
|
||||
return true
|
||||
end)
|
||||
|
Loading…
x
Reference in New Issue
Block a user