From 827fe97f4cb6a510d1feaaf49df0282187ddba7c Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 8 Jun 2017 16:59:06 +0200 Subject: [PATCH] Add free_rotation --- API.md | 2 ++ init.lua | 13 ++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/API.md b/API.md index 4cbe65a..37c55a5 100644 --- a/API.md +++ b/API.md @@ -44,6 +44,8 @@ This also registers two crafting recipes of this shape Default: 1st texture of the original block. * `no_craft`: Optional. If `true`, no crafting recipes are registered. Default: `false` +* `free_rotation`: Optional: If `true`, rotation by screwdriver is unrestricted. + Default: Rotation is restricted to 3 axes ### Return value diff --git a/init.lua b/init.lua index 7d2211c..56ffcf3 100644 --- a/init.lua +++ b/init.lua @@ -37,7 +37,7 @@ end -- Shifted blocks -shifted_blocks.register_shifted_block = function(itemstring, original_block, description, side_texture, help, block_texture, no_craft) +shifted_blocks.register_shifted_block = function(itemstring, original_block, description, side_texture, help, block_texture, no_craft, free_rotation) local stone = side_texture or minetest.registered_nodes[original_block].tiles[1] local normal = block_texture or minetest.registered_nodes[original_block].tiles[1] @@ -52,13 +52,20 @@ shifted_blocks.register_shifted_block = function(itemstring, original_block, des help = nil end + local rotate = on_rotate + local place_param2 = 0 + if free_rotation then + rotate = nil + place_param2 = nil + end + minetest.register_node(itemstring, { description = description, _doc_items_longdesc = help, - on_rotate = on_rotate, + on_rotate = rotate, paramtype2 = "facedir", -- TODO: Place node according to view direction (restrict param2 to 0 or 3) - place_param2 = 0, + place_param2 = place_param2, tiles = {combine, combine, stone, stone, combine.."^[transformFX", combine}, is_ground_content = false, groups = minetest.registered_nodes[original_block].groups,