From f20996976a350aba0262272d1460cdfc88e0904c Mon Sep 17 00:00:00 2001 From: ademant Date: Fri, 8 Feb 2019 14:07:14 +0100 Subject: [PATCH] changed to new calc of killed mobs --- init.lua | 2 +- register.lua | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/init.lua b/init.lua index b79ff69..adb6493 100644 --- a/init.lua +++ b/init.lua @@ -18,7 +18,7 @@ dofile(xpfw.path .. "/register.lua") -- Registering functions dofile(xpfw.path .. "/config.lua") -- API dofile(xpfw.path .. "/chat_commands.lua") if cmi ~= nil then - dofile(xpfw.path .. "/cmi.lua") +-- dofile(xpfw.path .. "/cmi.lua") end minetest.log("action", "[MOD]"..minetest.get_current_modname().." -- loaded ") diff --git a/register.lua b/register.lua index f431af8..6924753 100644 --- a/register.lua +++ b/register.lua @@ -132,7 +132,7 @@ minetest.register_globalstep(function(dtime) xpfw.player_add_attribute(player,"playtime",dtime) local act_pos=player:get_pos() - -- calculating distance to last known position + -- calculating distance to last known position (including teleporting) if playerdata.last_pos ~= nil then local tdist=vector.distance(act_pos,playerdata.last_pos) if tdist > 0 then @@ -153,7 +153,6 @@ minetest.register_globalstep(function(dtime) vel_action="swam" vel_ref=2 end - -- local tvelo=vector.distance(tvel,{x=0,y=0,z=0}) local tvelo=tvel.x*tvel.x+tvel.y*tvel.y+tvel.z*tvel.z if tvelo>0 then tvelo=math.sqrt(tvelo) @@ -180,6 +179,7 @@ minetest.register_globalstep(function(dtime) end end + if playerdata.gtimer1 > 0.75 then playerdata.gtimer1=0 if playerdata.hidx ~= nil then @@ -188,10 +188,24 @@ minetest.register_globalstep(function(dtime) for i,attn in ipairs(xpfw.hud_intern) do act_print=act_print..attn..":"..math.ceil(xpfw.player_get_attribute(player,attn)).."\n" end --- act_print=act_print.."logon: "..math.ceil(xpfw.player_get_attribute(player,"lastlogin")+act_logon) act_print=act_print.."logon: "..math.ceil(act_logon) player:hud_change(playerdata.hidx,"text",act_print) end + + -- check for killed mobs + if mobs ~= nil then + if mobs.killed_mobs ~= nil then + if mobs.killed_mobs[playername] ~= nil then + if playerdata.killed_mobs == nil then + playerdata.killed_mobs = 0 + end + if mobs_killed_mobs[playername] > playerdata.killed_mobs then + xpfw.player_add_attribute(player,"killed_mobs",mobs_killed_mobs[playername]-playerdata.killed_mobs) + playerdata.killed_mobs=mobs.killed_mobs[playername] + end + end + end + end end if playerdata.dtime>xpfw.rtime then