use mineclone2s axis placement logic for movers, block breaker and logs

master
Jordach 2017-12-11 17:37:55 +00:00
parent 1ea5d9167f
commit bc8ad61b6b
4 changed files with 92 additions and 11 deletions

View File

@ -54,7 +54,7 @@ minetest.register_node("atvomat:breaker_1", {
meta:set_string("infotext", "Auto Block Breaker, Disabled.")
end,
on_place = mcore.sensible_facedir,
on_place = mcore.rotate_axis,
on_punch = function(pos, node, puncher)
@ -138,7 +138,7 @@ minetest.register_node("atvomat:breaker_2", {
meta:set_string("infotext", "Automatic Block Collector (Gently collects blocks), Disabled.")
end,
on_place = mcore.sensible_facedir,
on_place = mcore.rotate_axis,
on_punch = function(pos, node, puncher)

View File

@ -168,7 +168,7 @@ minetest.register_node("atvomat:mover",{
end,
on_place = mcore.sensible_facedir,
on_place = mcore.rotate_axis,
on_timer = function(pos, elapsed)

View File

@ -429,7 +429,7 @@ minetest.register_node("core:pine_log", {
paramtype2 = "facedir",
is_ground_content = false,
groups = {tree=1, choppy=3, flammable=2, solid=1},
on_place = mcore.sensible_facedir,
on_place = mcore.rotate_axis,
sounds = mcore.sound_wood,
})
@ -439,7 +439,7 @@ minetest.register_node("core:pine_log_grassy", {
paramtype2 = "facedir",
is_ground_content = false,
groups = {tree=1, choppy=3, flammable=2, solid=1, nodec=1},
on_place = mcore.sensible_facedir,
on_place = mcore.rotate_axis,
sounds = mcore.sound_wood,
})
@ -510,7 +510,7 @@ minetest.register_node("core:oak_log", {
paramtype2 = "facedir",
is_ground_content = false,
groups = {tree=1, choppy=3, flammable=2, solid=1},
on_place = mcore.sensible_facedir,
on_place = mcore.rotate_axis,
sounds = mcore.sound_wood,
})
@ -520,7 +520,7 @@ minetest.register_node("core:oak_log_grassy", {
paramtype2 = "facedir",
is_ground_content = false,
groups = {tree=1, choppy=3, flammable=2, solid=1, nodec=1},
on_place = mcore.sensible_facedir,
on_place = mcore.rotate_axis,
sounds = mcore.sound_wood,
})
@ -565,7 +565,7 @@ minetest.register_node("core:cherry_log", {
paramtype2 = "facedir",
is_ground_content = false,
groups = {tree=1, choppy=3, flammable=2, solid=1},
on_place = mcore.sensible_facedir,
on_place = mcore.rotate_axis,
sounds = mcore.sound_wood,
})
@ -575,7 +575,7 @@ minetest.register_node("core:cherry_log_grassy", {
paramtype2 = "facedir",
is_ground_content = false,
groups = {tree=1, choppy=3, flammable=2, solid=1, nodec=1},
on_place = mcore.sensible_facedir,
on_place = mcore.rotate_axis,
sounds = mcore.sound_wood,
})
@ -637,7 +637,7 @@ minetest.register_node("core:birch_log", {
paramtype2 = "facedir",
is_ground_content = false,
groups = {tree=1, choppy=3, flammable=2, solid=1},
on_place = mcore.sensible_facedir,
on_place = mcore.rotate_axis,
sounds = mcore.sound_wood,
})
@ -647,7 +647,7 @@ minetest.register_node("core:birch_log_grassy", {
paramtype2 = "facedir",
is_ground_content = false,
groups = {tree=1, choppy=3, flammable=2, solid=1, nodec=1},
on_place = mcore.sensible_facedir,
on_place = mcore.rotate_axis,
sounds = mcore.sound_wood,
})

View File

@ -348,6 +348,87 @@ function mcore.get_node_from_rear(pos)
end
-- borrowed mineclone2's axis facedir:
function mcore.rotate_axis_and_place(itemstack, placer, pointed_thing, infinitestacks, invert_wall)
local unode = minetest.get_node_or_nil(pointed_thing.under)
if not unode then
return
end
local undef = minetest.registered_nodes[unode.name]
if undef and undef.on_rightclick then
undef.on_rightclick(pointed_thing.under, unode, placer,
itemstack, pointed_thing)
return
end
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
local wield_name = itemstack:get_name()
local above = pointed_thing.above
local under = pointed_thing.under
local is_x = (above.x ~= under.x)
local is_y = (above.y ~= under.y)
local is_z = (above.z ~= under.z)
local anode = minetest.get_node_or_nil(above)
if not anode then
return
end
local pos = pointed_thing.above
local node = anode
if undef and undef.buildable_to then
pos = pointed_thing.under
node = unode
end
if minetest.is_protected(pos, placer:get_player_name()) then
minetest.record_protection_violation(pos, placer:get_player_name())
return
end
local ndef = minetest.registered_nodes[node.name]
if not ndef or not ndef.buildable_to then
return
end
local p2
if is_y then
if invert_wall then
if fdir == 3 or fdir == 1 then
p2 = 12
else
p2 = 6
end
end
elseif is_x then
if invert_wall then
p2 = 0
else
p2 = 12
end
elseif is_z then
if invert_wall then
p2 = 0
else
p2 = 6
end
end
minetest.set_node(pos, {name = wield_name, param2 = p2})
if not infinitestacks then
itemstack:take_item()
return itemstack
end
end
function mcore.rotate_axis(itemstack, placer, pointed_thing)
mcore.rotate_axis_and_place(itemstack, placer, pointed_thing,
false,
placer:get_player_control().sneak)
return itemstack
end
-- dofiles for loading files required by "core"
dofile(minetest.get_modpath("core").."/sounds.lua")
dofile(minetest.get_modpath("core").."/mapgen.lua")