mirror of
https://github.com/minetest-mods/mesecons.git
synced 2025-02-22 03:50:24 +01:00
mesecons_pistons: Fix impercise placement orientation
Piston placement used to be finicky and not map correctly to the viewing angle
This commit is contained in:
parent
55359c7a0b
commit
786094ec06
@ -15,6 +15,7 @@ ignore = {
|
|||||||
max_line_length = 200
|
max_line_length = 200
|
||||||
|
|
||||||
read_globals = {
|
read_globals = {
|
||||||
|
"core",
|
||||||
"default",
|
"default",
|
||||||
"digiline",
|
"digiline",
|
||||||
"doors",
|
"doors",
|
||||||
|
@ -115,27 +115,13 @@ local function piston_off(pos, node)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local orientations = {
|
|
||||||
[0] = { 4, 8},
|
|
||||||
{13, 17},
|
|
||||||
{10, 6},
|
|
||||||
{20, 15},
|
|
||||||
}
|
|
||||||
|
|
||||||
local function piston_orientate(pos, placer)
|
local function piston_orientate(pos, placer)
|
||||||
mesecon.mvps_set_owner(pos, placer)
|
mesecon.mvps_set_owner(pos, placer)
|
||||||
if not placer then
|
if not placer then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local pitch = math.deg(placer:get_look_vertical())
|
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
if pitch > 55 then
|
node.param2 = core.dir_to_facedir(placer:get_look_dir(), true)
|
||||||
node.param2 = orientations[node.param2][1]
|
|
||||||
elseif pitch < -55 then
|
|
||||||
node.param2 = orientations[node.param2][2]
|
|
||||||
else
|
|
||||||
return
|
|
||||||
end
|
|
||||||
minetest.swap_node(pos, node)
|
minetest.swap_node(pos, node)
|
||||||
-- minetest.after, because on_placenode for unoriented piston must be processed first
|
-- minetest.after, because on_placenode for unoriented piston must be processed first
|
||||||
minetest.after(0, mesecon.on_placenode, pos, node)
|
minetest.after(0, mesecon.on_placenode, pos, node)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user