Improve rotation
More general function, checks for falling.
This commit is contained in:
parent
6fc8c6a2c0
commit
64c104b68d
|
@ -6,6 +6,25 @@ function mesecon.move_node(pos, newpos)
|
||||||
minetest.get_meta(pos):from_table(meta)
|
minetest.get_meta(pos):from_table(meta)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- An on_rotate callback for mesecons components.
|
||||||
|
function mesecon.on_rotate(pos, node, user, mode, new_param2)
|
||||||
|
minetest.swap_node(pos, {name = "air"})
|
||||||
|
mesecon.on_dignode(pos, node)
|
||||||
|
node.param2 = new_param2
|
||||||
|
minetest.swap_node(pos, node)
|
||||||
|
mesecon.on_placenode(pos, node)
|
||||||
|
minetest.check_for_falling(pos)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
-- An on_rotate callback for components which stay horizontal.
|
||||||
|
function mesecon.on_rotate_horiz(pos, node, user, mode, new_param2)
|
||||||
|
if not minetest.global_exists("screwdriver") or mode ~= screwdriver.ROTATE_FACE then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
return mesecon.on_rotate(pos, node, user, mode, new_param2)
|
||||||
|
end
|
||||||
|
|
||||||
-- Rules rotation Functions:
|
-- Rules rotation Functions:
|
||||||
function mesecon.rotate_rules_right(rules)
|
function mesecon.rotate_rules_right(rules)
|
||||||
local nr = {}
|
local nr = {}
|
||||||
|
@ -452,22 +471,6 @@ function mesecon.swap_node_force(pos, name, update_light)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- An on_rotate callback for components which stay horizontal.
|
|
||||||
function mesecon.on_rotate_horiz(pos, node, user, mode, new_param2)
|
|
||||||
if not minetest.global_exists("screwdriver") then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
if mode ~= screwdriver.ROTATE_FACE then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
minetest.swap_node(pos, {name = "air"})
|
|
||||||
mesecon.on_dignode(pos, node)
|
|
||||||
node.param2 = new_param2
|
|
||||||
minetest.swap_node(pos, node)
|
|
||||||
mesecon.on_placenode(pos, node)
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Autoconnect Hooks
|
-- Autoconnect Hooks
|
||||||
-- Nodes like conductors may change their appearance and their connection rules
|
-- Nodes like conductors may change their appearance and their connection rules
|
||||||
-- right after being placed or after being dug, e.g. the default wires use this
|
-- right after being placed or after being dug, e.g. the default wires use this
|
||||||
|
|
|
@ -270,5 +270,6 @@ function mesecon.buttonlike_onrotate(pos, node, user, mode, new_param2)
|
||||||
minetest.swap_node(pos, node)
|
minetest.swap_node(pos, node)
|
||||||
mesecon.on_placenode(pos, node)
|
mesecon.on_placenode(pos, node)
|
||||||
mesecon.receiver_place(pos)
|
mesecon.receiver_place(pos)
|
||||||
|
minetest.check_for_falling(pos)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue