debugging for server

pull/2/head
Brandon 2014-05-16 19:00:37 -05:00
parent ccb41016be
commit b5c1b1dca1
3 changed files with 22 additions and 12 deletions

View File

@ -322,17 +322,16 @@ minetest.after(2.5, function()
local name = player:get_player_name()
local immortal = minetest.check_player_privs(name, {immortal=true})
-- only proceed if damage is enabled
if immortal == false then
if stamina_timer > HUD_STAMINA_TICK then
hud.update_stamina(player,name)
stamina_timer = 0
end
if magic_timer > HUD_MAGIC_TICK then
magic.update_magic(player,name)
magic_timer = 0
end
if stamina_timer > HUD_STAMINA_TICK then
hud.update_stamina(player,name)
stamina_timer = 0
end
if magic_timer > HUD_MAGIC_TICK then
magic.update_magic(player,name)
magic_timer = 0
end
if minetest.setting_getbool("enable_damage") and immortal == false then
local h = tonumber(hud.hunger[name])
local hp = player:get_hp()

View File

@ -7,10 +7,12 @@ player_sleephuds = {}
function hud.update_stamina(p,name)
-- loop through all online players and check their movement and update their stamina
local pos = p:getpos()
print("Stamina for "..name.." at "..minetest.pos_to_string(pos))
if player_lastpos[name] ~= nil then
print("laspos not nil")
if player_stamina[name] ~= nil then
if minetest.check_player_privs(name, {immortal=true}) then
print(name.." is immortal")
player_stamina[name] = 20
return
end
@ -38,8 +40,10 @@ function hud.update_stamina(p,name)
local hdiff = math.sqrt(math.pow(pos.x-player_lastpos[name].x, 2) + math.pow(pos.z-player_lastpos[name].z, 2))
adj = adj - ( hdiff * 0.03 )
player_stamina[name] = player_stamina[name] + adj
print("Adj "..tostring(adj))
player_stamina[name] = player_stamina[name] + adj
print("New Stamina "..tostring(player_stamina[name]))
if player_stamina[name] < 0 then
player_stamina[name] = 0
p:set_hp(p:get_hp()-1)
@ -62,6 +66,7 @@ function hud.update_stamina(p,name)
affects.affectPlayer(name,"tired")
end
else
print("Set default stamina")
player_stamina[name] = 20
end
end

View File

@ -7,13 +7,16 @@ magic.player_magic = default.deserialize_from_file(magic_file)
dofile(magicpath.."/api.lua")
function magic.update_magic(player,name)
print("Update magic for "..name)
if minetest.check_player_privs(name, {immortal=true}) then
print("Player is immortal")
magic.player_magic[name] = 20
return
end
local s = skills.get_skill(name,SKILL_MAGIC)
local baseAdj = 2
if magic.player_magic[name] ~= nil then
print("Magic not nil")
if default.player_get_animation(player) == "lay" then
baseAdj = baseAdj + 3
end
@ -23,7 +26,9 @@ function magic.update_magic(player,name)
end
local adj = baseAdj * ( s.level / 10 )
print("adj "..tostring(adj))
magic.player_magic[name] = magic.player_magic[name] + adj
print("new magic "..tostring(magic.player_magic[name]))
if magic.player_magic[name] > 20 then
magic.player_magic[name] = 20
end
@ -31,6 +36,7 @@ function magic.update_magic(player,name)
magic.player_magic[name] = 0
end
else
print("Set default magic")
magic.player_magic[name] = 20
end
end