Fixed a bug in which players could use the conveyor to move up into nodes, and fixed a bug where escalators would take longer than intended.
This commit is contained in:
parent
8eb6a3781a
commit
20d23a4c5f
14
conveyor.lua
14
conveyor.lua
|
@ -59,6 +59,11 @@ minetest.register_abm({
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
local getdef = function (pos)
|
||||||
|
return minetest.registered_nodes[minetest.get_node(pos).name]
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
minetest.register_globalstep(function (dtime)
|
minetest.register_globalstep(function (dtime)
|
||||||
for pos,node in pairs(queue) do
|
for pos,node in pairs(queue) do
|
||||||
local facedir = minetest.facedir_to_dir(node.param2)
|
local facedir = minetest.facedir_to_dir(node.param2)
|
||||||
|
@ -70,17 +75,19 @@ minetest.register_globalstep(function (dtime)
|
||||||
local new_pos = vector.add(entity:getpos(), movementDir)
|
local new_pos = vector.add(entity:getpos(), movementDir)
|
||||||
local rounded_pos = {x=math.floor(new_pos.x+0.5),y=math.floor(new_pos.y+0.5),z=math.floor(new_pos.z+0.5)}
|
local rounded_pos = {x=math.floor(new_pos.x+0.5),y=math.floor(new_pos.y+0.5),z=math.floor(new_pos.z+0.5)}
|
||||||
|
|
||||||
if not minetest.registered_nodes[minetest.get_node(rounded_pos).name].walkable then
|
if not getdef(rounded_pos).walkable then
|
||||||
entity:setpos(new_pos)
|
entity:setpos(new_pos)
|
||||||
end
|
|
||||||
entity_queue[entity] = true
|
entity_queue[entity] = true
|
||||||
queue[pos] = nil
|
queue[pos] = nil
|
||||||
|
end
|
||||||
elseif math.abs(offset.x) < 2 and math.abs(offset.z) < 2 and offset.y < 0 then
|
elseif math.abs(offset.x) < 2 and math.abs(offset.z) < 2 and offset.y < 0 then
|
||||||
-- Take the movementDir, and subtract it from my position. Then subtract y=0.5. Players here should move UP.
|
-- Take the movementDir, and subtract it from my position. Then subtract y=0.5. Players here should move UP.
|
||||||
-- No checking for nodes there is required, because then the player's head would already be in a node.
|
|
||||||
local moveUpPos = vector.subtract(vector.subtract(pos, movementDir), {x=0,y=0.5,z=0})
|
local moveUpPos = vector.subtract(vector.subtract(pos, movementDir), {x=0,y=0.5,z=0})
|
||||||
local offset = vector.subtract(entity:getpos(), moveUpPos)
|
local offset = vector.subtract(entity:getpos(), moveUpPos)
|
||||||
local new_pos = vector.add(vector.add(entity:getpos(), {x=0,y=1,z=0}), movementDir)
|
local new_pos = vector.add(vector.add(entity:getpos(), {x=0,y=1,z=0}), movementDir)
|
||||||
|
local obpos = vector.add(pos, {x=0,y=1,z=0}) -- check the node 1 above of us.
|
||||||
|
local obpos2 = vector.add(pos, {x=0,y=2,z=0}) -- 2 above.
|
||||||
|
if not (getdef(obpos).walkable or getdef(obpos2).walkable) then
|
||||||
if math.abs(offset.x) < 0.5 and math.abs(offset.z) < 0.5 and math.abs(offset.y) < 0.5 then
|
if math.abs(offset.x) < 0.5 and math.abs(offset.z) < 0.5 and math.abs(offset.y) < 0.5 then
|
||||||
entity:setpos(new_pos)
|
entity:setpos(new_pos)
|
||||||
entity_queue[entity] = true
|
entity_queue[entity] = true
|
||||||
|
@ -90,5 +97,6 @@ minetest.register_globalstep(function (dtime)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
queue = {}
|
queue = {}
|
||||||
end)
|
end)
|
||||||
|
|
Reference in New Issue