Minor refactoring

master
Wuzzy 2015-02-16 01:33:58 +01:00
parent 67e39274c9
commit fa9d331afd
1 changed files with 1 additions and 3 deletions

View File

@ -11,15 +11,13 @@ teletool.settings = {}
function teletool.teleport(player, pointed_thing)
local pos = pointed_thing.above
local over1 = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z})
local over2 = minetest.get_node({x=pos.x,y=pos.y+2,z=pos.z})
local src = player:getpos()
local dest = {x=pos.x, y=math.ceil(pos.y)-0.5, z=pos.z}
local destnode = minetest.get_node(dest)
-- This trick prevents the player's head to spawn in a walkable node if the player clicked on the lower side of a node
-- NOTE: This piece of code must be updated as soon the collision boxes of players become configurable
local destnode_above = minetest.get_node({x=dest.x, y=dest.y + 1, z=dest.z})
if minetest.registered_nodes[destnode_above.name].walkable then
if minetest.registered_nodes[over1.name].walkable then
dest.y = dest.y - 1
end