Fix bug of teletool not working when y<0
parent
fa9d331afd
commit
60065e94cd
12
init.lua
12
init.lua
|
@ -10,19 +10,23 @@ teletool.settings = {}
|
||||||
|
|
||||||
function teletool.teleport(player, pointed_thing)
|
function teletool.teleport(player, pointed_thing)
|
||||||
local pos = pointed_thing.above
|
local pos = pointed_thing.above
|
||||||
local over1 = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z})
|
|
||||||
local src = player:getpos()
|
local src = player:getpos()
|
||||||
local dest = {x=pos.x, y=math.ceil(pos.y)-0.5, z=pos.z}
|
local dest = {x=pos.x, y=math.ceil(pos.y)-0.5, z=pos.z}
|
||||||
local destnode = minetest.get_node(dest)
|
local over = {x=dest.x, y=dest.y+1, z=dest.z}
|
||||||
|
local destnode = minetest.get_node({x=dest.x, y=math.ceil(dest.y), z=dest.z})
|
||||||
|
local overnode = minetest.get_node({x=over.x, y=math.ceil(over.y), z=over.z})
|
||||||
|
|
||||||
|
minetest.log("action", "[teletool] dest: "..minetest.pos_to_string(dest))
|
||||||
|
minetest.log("action", "[teletool] over: "..minetest.pos_to_string(over))
|
||||||
|
|
||||||
-- This trick prevents the player's head to spawn in a walkable node if the player clicked on the lower side of a node
|
-- 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
|
-- NOTE: This piece of code must be updated as soon the collision boxes of players become configurable
|
||||||
if minetest.registered_nodes[over1.name].walkable then
|
if minetest.registered_nodes[overnode.name].walkable then
|
||||||
dest.y = dest.y - 1
|
dest.y = dest.y - 1
|
||||||
end
|
end
|
||||||
|
|
||||||
-- The destination must be collision free
|
-- The destination must be collision free
|
||||||
local destnode = minetest.get_node(dest)
|
destnode = minetest.get_node({x=dest.x, y=math.ceil(dest.y), z=dest.z})
|
||||||
if minetest.registered_nodes[destnode.name].walkable then
|
if minetest.registered_nodes[destnode.name].walkable then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue