Add setspawn.

This commit is contained in:
Duane 2016-06-25 15:22:50 -05:00
parent 36af3b1d92
commit af524bf009
2 changed files with 27 additions and 6 deletions

View file

@ -38,11 +38,10 @@ end
if not fun_caves.db then
fun_caves.db = {}
end
if not fun_caves.db.teleport_data then
fun_caves.db.teleport_data = {}
end
if not fun_caves.db.hunger then
fun_caves.db.hunger = {}
for _, i in pairs({'teleport_data', 'hunger', 'spawn'}) do
if not fun_caves.db[i] then
fun_caves.db[i] = {}
end
end
@ -116,6 +115,15 @@ end
--fun_caves.print_recipes()
minetest.register_on_respawnplayer(function(player)
local name = player:get_player_name()
if fun_caves.db.spawn[name] then
player:setpos(fun_caves.db.spawn[name])
return true
end
end)
local hunger_mod = minetest.get_modpath("hunger")
fun_caves.hunger_id = {}
@ -129,7 +137,7 @@ function fun_caves.hunger_change(player, change)
end
local hp = player:get_hp()
if change < 0 or hp >= 20 then
if change < 0 or hp >= 16 then
fun_caves.db.hunger[name] = math.min(20, math.max(0, fun_caves.db.hunger[name] + change))
player:hud_change(fun_caves.hunger_id[name], 'number', fun_caves.db.hunger[name])
if fun_caves.db.hunger[name] == 0 then