Add mcl_util wrapper, like minetest.rotate_node

This commit is contained in:
Wuzzy 2017-02-11 04:33:06 +01:00
parent bf60a42341
commit 614c2fae98
2 changed files with 11 additions and 4 deletions

View File

@ -30,9 +30,7 @@ minetest.register_node("mcl_end:purpur_pillar", {
stack_max = 64, stack_max = 64,
paramtype2 = "facedir", paramtype2 = "facedir",
is_ground_content = false, is_ground_content = false,
on_place = function(itemstack, player, pointed_thing) on_place = mcl_util.rotate_axis,
mcl_util.axis_place(itemstack, player, pointed_thing, minetest.setting_getbool("creative_mode"), player:get_player_control().sneak)
end,
tiles = {"mcl_end_purpur_pillar_top.png", "mcl_end_purpur_pillar_top.png", "mcl_end_purpur_pillar.png"}, tiles = {"mcl_end_purpur_pillar_top.png", "mcl_end_purpur_pillar_top.png", "mcl_end_purpur_pillar.png"},
groups = {cracky=3,building_block=1}, groups = {cracky=3,building_block=1},
sounds = mcl_core.node_sound_stone_defaults(), sounds = mcl_core.node_sound_stone_defaults(),

View File

@ -16,7 +16,7 @@ This function is a simplified version of minetest.rotate_and_place.
The Minetest function is seen as inappropriate because this includes mirror The Minetest function is seen as inappropriate because this includes mirror
images of possible orientations, causing problems with pillar shadings. images of possible orientations, causing problems with pillar shadings.
]] ]]
function mcl_util.axis_place(itemstack, placer, pointed_thing, infinitestacks, invert_wall) function mcl_util.rotate_axis_and_place(itemstack, placer, pointed_thing, infinitestacks, invert_wall)
local unode = minetest.get_node_or_nil(pointed_thing.under) local unode = minetest.get_node_or_nil(pointed_thing.under)
if not unode then if not unode then
return return
@ -88,3 +88,12 @@ function mcl_util.axis_place(itemstack, placer, pointed_thing, infinitestacks, i
end end
end end
-- Wrapper of above function for use as `on_place` callback (Recommended).
-- Similar to minetest.rotate_node.
function mcl_util.rotate_axis(itemstack, placer, pointed_thing)
mcl_util.rotate_axis_and_place(itemstack, placer, pointed_thing,
core.setting_getbool("creative_mode"),
placer:get_player_control().sneak)
return itemstack
end