From 81b601b37466c457dbd2013569b659c3a89c9a78 Mon Sep 17 00:00:00 2001 From: Sokomine Date: Wed, 24 Aug 2022 22:11:55 +0200 Subject: [PATCH] added colorwallmounted variant of chest --- init.lua | 64 ++++++++++++++++---- textures/chesttools_palette_wallmounted.png | Bin 0 -> 136 bytes 2 files changed, 53 insertions(+), 11 deletions(-) create mode 100644 textures/chesttools_palette_wallmounted.png diff --git a/init.lua b/init.lua index b127f79..bce7765 100644 --- a/init.lua +++ b/init.lua @@ -18,6 +18,7 @@ chesttools.update_price = { {'default:chest', 'default:steel_ingot', 0, 'normal', 1, 'nothing'}, {'default:chest_locked', 'default:steel_ingot', 1, 'locked', 2, 'steel ingot'}, {'chesttools:shared_chest', 'default:steel_ingot', 2, 'shared', 3, 'steel ingot(s)'}, + {'chesttools:shared_chest_wall', 'default:steel_ingot', 2, 'shared', 3, 'steel ingot(s)'}, {'locks:shared_locked_chest', 'default:steel_ingot', 3, 'locks', 4, 'steel ingot(s)'}, {'technic:iron_chest', 'technic:iron_chest', 1, 'iron', 5, 'Iron chest'}, {'technic:iron_locked_chest', 'technic:iron_locked_chest', 1, 'iron_locked', 6, 'Iron locked chest'}, @@ -118,10 +119,25 @@ chesttools.on_receive_fields = function(pos, formname, fields, player) return; end + if( fields.change_color ) then + local node = minetest.get_node( pos ) + local add = 0 + if(node and node.name and minetest.registered_nodes[node.name]) then + local def = minetest.registered_nodes[node.name] + if(def and def.paramtype2 == "colorfacedir") then + add = 32 + elseif(def and def.paramtype2 == "colorwallmounted") then + add = 8 + end + minetest.swap_node(pos, {name=node.name, param2=(node.param2 + add) % 256}) + return + end + end + local meta = minetest.get_meta( pos ); local chestname = meta:get_string( 'chestname' ); local spos = pos.x .. "," .. pos.y .. "," .. pos.z - if( fields.set_chestname and fields.chestname ) then + if( fields.set_chestname and fields.chestname and fields.chestname ~= chestname) then chestname = tostring( fields.chestname ); meta:set_string( 'chestname', chestname ); meta:set_string("infotext", "\""..chestname.."\" Chest (owned by "..meta:get_string("owner")..")") @@ -150,10 +166,6 @@ chesttools.on_receive_fields = function(pos, formname, fields, player) local b3 = "button[4.0,4.5;1,0.5;bag3;Bag 3]"; local b4 = "button[5.0,4.5;1,0.5;bag4;Bag 4]"; - if( fields.change_color ) then - local node = minetest.get_node( pos ) - minetest.swap_node(pos, {name=node.name, param2=(node.param2 + 32)}) - end local selected = ''; if( fields.drop_all or fields.take_all or fields.swap_all or fields.filter_all ) then @@ -452,14 +464,15 @@ end minetest.register_on_player_receive_fields( chesttools.form_input_handler ); -minetest.register_node( 'chesttools:shared_chest', { - description = 'Shared chest which can be used by all who can build at that spot', - name = 'shared chest', - tiles = chesttools.chest_add.tiles, +chesttools.register_chest = function(node_name, desc, name, paramtype2, palette, tiles) + minetest.register_node( node_name, { + description = desc, + name = name, + tiles = tiles, groups = chesttools.chest_add.groups, tube = chesttools.chest_add.tube, - paramtype2 = "colorfacedir", - palette = "chesttools_palette.png", + paramtype2 = paramtype2, + palette = palette, legacy_facedir_simple = true, is_ground_content = false, sounds = default.node_sound_wood_defaults(), @@ -590,9 +603,38 @@ minetest.register_node( 'chesttools:shared_chest', { return nil; end, }) +end + +chesttools.register_chest("chesttools:shared_chest", + 'Shared chest which can be used by all who can build at that spot', + 'shared chest', + 'colorfacedir', + 'chesttools_palette.png', + chesttools.chest_add.tiles) minetest.register_craft({ output = 'chesttools:shared_chest', type = 'shapeless', recipe = { 'default:steel_ingot', 'default:chest_locked' }, }) + +chesttools.register_chest("chesttools:shared_chest_wall", + 'Shared chest which can be used by all who can build at that spot (wallmounted)', + 'shared chest (wallmounted)', + 'colorwallmounted', + 'chesttools_palette_wallmounted.png', + {chesttools.chest_add.tiles[6], + chesttools.chest_add.tiles[3].."^[transformR180", + chesttools.chest_add.tiles[3].."^[transformR270", + chesttools.chest_add.tiles[3].."^[transformR90", + chesttools.chest_add.tiles[1].."^[transformR90", + chesttools.chest_add.tiles[1].."^[transformR90", + chesttools.chest_add.tiles[1], + }) + +minetest.register_craft({ + output = 'chesttools:shared_chest_wall', + type = 'shapeless', + recipe = { 'default:steel_ingot', 'chesttools:shared_chest' }, +}) + diff --git a/textures/chesttools_palette_wallmounted.png b/textures/chesttools_palette_wallmounted.png new file mode 100644 index 0000000000000000000000000000000000000000..8d3133b095ed7e13b16ab1cc2fa64f0043f59c07 GIT binary patch literal 136 zcmeAS@N?(olHy`uVBq!ia0vp^96-#%!2~32*1ud1r2IWy978y+s~+FT+n^xOcCr5f z7vBN3GmjarShN~Huxaz2)A(skefR3PxM?BTx=R_}-Mdx(=6UU2jw=%#SY$bKnJW?) lST@c%a6s(xfuIc=?Y%FaQ7m literal 0 HcmV?d00001