From 614c2fae9882afae4749de29bb6ce45031f33139 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 11 Feb 2017 04:33:06 +0100 Subject: [PATCH] Add mcl_util wrapper, like minetest.rotate_node --- mods/mcl_end/init.lua | 4 +--- mods/mcl_util/init.lua | 11 ++++++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/mods/mcl_end/init.lua b/mods/mcl_end/init.lua index 06e36e6ea4..6cdb470c9b 100644 --- a/mods/mcl_end/init.lua +++ b/mods/mcl_end/init.lua @@ -30,9 +30,7 @@ minetest.register_node("mcl_end:purpur_pillar", { stack_max = 64, paramtype2 = "facedir", is_ground_content = false, - on_place = function(itemstack, player, pointed_thing) - mcl_util.axis_place(itemstack, player, pointed_thing, minetest.setting_getbool("creative_mode"), player:get_player_control().sneak) - end, + on_place = mcl_util.rotate_axis, tiles = {"mcl_end_purpur_pillar_top.png", "mcl_end_purpur_pillar_top.png", "mcl_end_purpur_pillar.png"}, groups = {cracky=3,building_block=1}, sounds = mcl_core.node_sound_stone_defaults(), diff --git a/mods/mcl_util/init.lua b/mods/mcl_util/init.lua index bdc92a6cc0..e24bdf45fa 100644 --- a/mods/mcl_util/init.lua +++ b/mods/mcl_util/init.lua @@ -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 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) if not unode then return @@ -88,3 +88,12 @@ function mcl_util.axis_place(itemstack, placer, pointed_thing, infinitestacks, i 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 +