mirror of
https://github.com/minetest-mods/mesecons.git
synced 2025-02-21 11:30:26 +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
|
||||
|
||||
read_globals = {
|
||||
"core",
|
||||
"default",
|
||||
"digiline",
|
||||
"doors",
|
||||
|
@ -115,27 +115,13 @@ local function piston_off(pos, node)
|
||||
end
|
||||
end
|
||||
|
||||
local orientations = {
|
||||
[0] = { 4, 8},
|
||||
{13, 17},
|
||||
{10, 6},
|
||||
{20, 15},
|
||||
}
|
||||
|
||||
local function piston_orientate(pos, placer)
|
||||
mesecon.mvps_set_owner(pos, placer)
|
||||
if not placer then
|
||||
return
|
||||
end
|
||||
local pitch = math.deg(placer:get_look_vertical())
|
||||
local node = minetest.get_node(pos)
|
||||
if pitch > 55 then
|
||||
node.param2 = orientations[node.param2][1]
|
||||
elseif pitch < -55 then
|
||||
node.param2 = orientations[node.param2][2]
|
||||
else
|
||||
return
|
||||
end
|
||||
node.param2 = core.dir_to_facedir(placer:get_look_dir(), true)
|
||||
minetest.swap_node(pos, node)
|
||||
-- minetest.after, because on_placenode for unoriented piston must be processed first
|
||||
minetest.after(0, mesecon.on_placenode, pos, node)
|
||||
|
Loading…
x
Reference in New Issue
Block a user