Lua API: on_respawnplayer doesn't work
Posted: Sat Jan 14, 2012 09:10
I'm trying to make a Fixed-Spawn Mod, but on_respawnplayer always gets called with nil.
My Code:
My Code:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
local function readspawn()
local inp = io.open(minetest.get_modpath('fixed_spawn')..'/spawn')
local x = inp:read("*n")
if x == nil then
io.close(inp)
return {x = 0,y = 0,z = 0}
end
local y = inp:read("*n")
local z = inp:read("*n")
io.close(inp)
return {x = x,y = y,z = z}
end
minetest.register_on_newplayer(function(player)
if player ~= nil then
player:setpos(readspawn())
return true
end
return false
end)
minetest.register_on_respawnplayer(function(player)
print(dump(player))
if player ~= nil then
player:setpos(readspawn())
return true
end
return false
end)