implement rudimentary explorer experience (#55)

* implement rudimentary explorer experience

* move explorer_xp to xp folder
This commit is contained in:
pandaro 2017-04-16 14:48:34 +02:00 committed by cd2
parent ea36aca347
commit 2aa5b584f4

View File

@ -154,5 +154,24 @@ function xp.save_levels()
end
end
function xp.explorer_xp()
minetest.register_on_generated(function(minp, maxp, blockseed)
local center={x=minp.x+math.abs(minp.x-maxp.x),y=minp.y+math.abs(minp.y-maxp.y),z=minp.z+math.abs(minp.z-maxp.z)}
local nearest=nil
for i,v in pairs(minetest.get_connected_players()) do
local pos =v:getpos()
local dist=vector.distance(center, pos)
if nearest==nil then
nearest={name=v,dist=dist}
elseif dist < nearest.dist then
nearest.dist = dist
nearest.name=v
end
end
xp.add_xp(nearest.name, 0.1)
end)
end
xp.explorer_xp()
xp.load_xp()
xp.load_levels()