From e7718a0aa5aa8b68a708e45cc620246a946cf422 Mon Sep 17 00:00:00 2001 From: DS Date: Thu, 3 Aug 2017 16:12:51 +0200 Subject: [PATCH] disallow rotating and connect tube at front of both sides (#3) --- README.md | 1 - init.lua | 17 ++++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 334c58e..4172d98 100644 --- a/README.md +++ b/README.md @@ -16,5 +16,4 @@ If you got ideas or found bugs, please tell them to me. TODO: -* disallow rotating the chest with a screwdriver * add abms when registering the chest instead of using chestdata diff --git a/init.lua b/init.lua index d03e165..9059bbe 100644 --- a/init.lua +++ b/init.lua @@ -155,21 +155,22 @@ function connected_chests.register_chest(fromname, data) -- override the original node to support connecting local place_chest = minetest.registered_nodes[fromname].on_place + local creative_mode = minetest.settings:get_bool"creative_mode" minetest.override_item(fromname, { on_place = function(itemstack, placer, pointed_thing) - if not placer then - return + if not placer + or not placer:get_player_control().sneak then + return place_chest(itemstack, placer, pointed_thing) end local pu, pa, par2 = get_pointed_info(pointed_thing, fromname) - if not pu - or not placer:get_player_control().sneak then + if not pu then return place_chest(itemstack, placer, pointed_thing) end if minetest.is_protected(pa, placer:get_player_name()) then return end connect_chests(pu, pa, par2, fromname) - if not minetest.settings:get_bool"creative_mode" then + if not creative_mode then itemstack:take_item() return itemstack end @@ -201,6 +202,12 @@ function connected_chests.register_chest(fromname, data) if data.on_rightclick then chest.on_rightclick = function()print"yem"end--data.on_rightclick end + function chest.on_rotate() + return false + end + if chest.tube then + chest.tube.connect_sides = {left = 1, back = 1, front = 1, bottom = 1, top = 1} + end if not data.front then data.front = "connected_chests_front.png"