From d335f5cf0343c1341777b2ea2485d96097ecb9f2 Mon Sep 17 00:00:00 2001 From: Sokomine Date: Sun, 21 Aug 2022 21:07:38 +0200 Subject: [PATCH] prepared for colored chests (8 colors) --- init.lua | 28 ++++++++++++++++------- textures/chesttools_palette.png | Bin 0 -> 160 bytes textures/chesttools_white_chest_lock.png | Bin 0 -> 717 bytes textures/chesttools_white_chest_side.png | Bin 0 -> 538 bytes textures/chesttools_white_chest_top.png | Bin 0 -> 559 bytes 5 files changed, 20 insertions(+), 8 deletions(-) create mode 100644 textures/chesttools_palette.png create mode 100644 textures/chesttools_white_chest_lock.png create mode 100644 textures/chesttools_white_chest_side.png create mode 100644 textures/chesttools_white_chest_top.png diff --git a/init.lua b/init.lua index cf9807d..b127f79 100644 --- a/init.lua +++ b/init.lua @@ -33,8 +33,10 @@ chesttools.update_price = { chesttools.chest_add = {}; chesttools.chest_add.tiles = { - "chesttools_blue_chest_top.png", "chesttools_blue_chest_top.png", "chesttools_blue_chest_side.png", - "chesttools_blue_chest_side.png", "chesttools_blue_chest_side.png", "chesttools_blue_chest_lock.png"}; +-- "chesttools_blue_chest_top.png", "chesttools_blue_chest_top.png", "chesttools_blue_chest_side.png", +-- "chesttools_blue_chest_side.png", "chesttools_blue_chest_side.png", "chesttools_blue_chest_lock.png"}; + "chesttools_white_chest_top.png", "chesttools_white_chest_top.png", "chesttools_white_chest_side.png", + "chesttools_white_chest_side.png", "chesttools_white_chest_side.png", "chesttools_white_chest_lock.png"}; chesttools.chest_add.groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}; chesttools.chest_add.tube = {}; @@ -69,9 +71,11 @@ end chesttools.formspec = "size[9,10]".. "list[current_name;main;0.5,0.3;8,4;]".. - "label[0.0,9.7;Title/Content:]".. + "label[0.5,9.7;Name:]".. "field[1.8,10.0;6,0.5;chestname;;]".. - "button[7.5,9.7;1,0.5;set_chestname;Store]".. + "button[7.5,9.7;1,0.5;set_chestname;Store\nName]".. +-- "button[8.6,9.7;0.5,0.5;change_color;C]".. + "image_button[8.4,9.7;0.5,0.5;chesttools_palette.png;change_color;]".. "label[0.0,4.4;Main]".. "button[1.0,4.5;1,0.5;craft;Craft]".. "button[7.0,4.5;0.5,0.5;drop_all;DA]".. @@ -129,9 +133,11 @@ chesttools.on_receive_fields = function(pos, formname, fields, player) end local formspec = "size[9,10]".. - "label[0.0,9.7;Title/Content:]".. + "label[0.5,9.7;Name:]".. "field[1.8,10.0;6,0.5;chestname;;"..tostring( chestname or "unconfigured").."]".. - "button[7.5,9.7;1,0.5;set_chestname;Store]".. + "button[7.5,9.7;1,0.5;set_chestname;Store\nName]".. +-- "button[8.6,9.7;0.5,0.5;change_color;C]".. + "image_button[8.4,9.7;0.5,0.5;chesttools_palette.png;change_color;]".. "list[current_name;main;0.5,0.3;8,4;]".. "button[7.0,4.5;0.5,0.5;drop_all;DA]".. "button[7.5,4.5;0.5,0.5;take_all;TA]".. @@ -144,6 +150,11 @@ 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 -- check if the player has sufficient access to the chest @@ -447,7 +458,8 @@ minetest.register_node( 'chesttools:shared_chest', { tiles = chesttools.chest_add.tiles, groups = chesttools.chest_add.groups, tube = chesttools.chest_add.tube, - paramtype2 = "facedir", + paramtype2 = "colorfacedir", + palette = "chesttools_palette.png", legacy_facedir_simple = true, is_ground_content = false, sounds = default.node_sound_wood_defaults(), @@ -472,7 +484,7 @@ minetest.register_node( 'chesttools:shared_chest', { can_dig = function(pos,player) local meta = minetest.get_meta(pos); local inv = meta:get_inventory() - return inv:is_empty("main") and player:get_player_name() == meta:get_string('owner'); + return inv:is_empty("main") and player and player:is_player() and player:get_player_name() == meta:get_string('owner'); end, allow_metadata_inventory_move = function(pos, from_list, from_index, diff --git a/textures/chesttools_palette.png b/textures/chesttools_palette.png new file mode 100644 index 0000000000000000000000000000000000000000..eab2dd110f8e84bdf4db4623e7e8db971a895792 GIT binary patch literal 160 zcmeAS@N?(olHy`uVBq!ia0vp^EI`b}!VDyP+Y$nRlth3}h${obij@ou1_lO;82%ql zVqlod@c%!<|Ie42ng9O;s$op>c6VXuV3qX%aySb-B8wRqxP?HN@zUM8KR`kD5>H=O z_J?dzyix)zS&;@nAwEwR#}JO|$pRe72IWi)OmPeklDKw%1YAX9X8WNB|8RBvx=!KdMT00075 zNklqGkYZ)6G!x+P0Fre4# z(Qda94-XG^adDB^*;xRTQUIiB`qvsDiXtvAFA*;>P07;T?czDRg#RUNK^YgS?EqvbxAP559-{0BV z+CubtJ=^d1ky4_yMhL;(-5m=H3lv2`mSxmxH9DOR^?Ds^EyLlE@$qq_l!&vlGh1di z#vr9+dwZLmogJp8rntSmrCP1hYPAT%5Un**N(O@g0OIxa)vm0p{OEqa-=|)$({8r` zSYBS{>gtMGt;TRTq*AHiI1Z<$r-`zD|8bY+IeUA1-x0zv{KKI9N!j3%e|fI8W`BPl@$~d$ zH#RnKUH8Yszo|6H^PJt?-ERtwMq@N-|DtkIJDtu?ga1(!MOYAX9X8WNB|8RBvx=!KdMT0004{ zNklK9cOc2} zdhl@X=}Et+@Bh21ngu~Xj^jWG0U-ncfH8(ztp)&4N5*y0k3oV_=%5Rh|}$1y~eCbi3WaIY*x7&~+V#VSq7)G)-X`2BefQO%qZ|5E1e` zN3+?4QVMLjToM4-wq2>z>viOLj>qEx&N-A)&@>HFN(dpqIY*XdPbcT|nfm?yud1+G zt-ub41C2%_bh}+Rj`L4}aUA1%y*>fQby8eVwK$!Z1V>MNbF&{hr3-FI0e;Ju07 zbMXxjh9UKOy&oOCg5o&-`w719)BS#jWm(X59YToe%eLEX2qB=90_Pk=gd|B|nkHJU c7K9M^19x5^n7$Lq_5c6?07*qoM6N<$f)hUKLI3~& literal 0 HcmV?d00001 diff --git a/textures/chesttools_white_chest_top.png b/textures/chesttools_white_chest_top.png new file mode 100644 index 0000000000000000000000000000000000000000..03f2f1de50a6d7826526b00ec4524d0bffae4b23 GIT binary patch literal 559 zcmV+~0?_@5P)YAX9X8WNB|8RBvx=!KdMT0005H zNklj$EA=4VviK?n@{fosyhr=Nu z1XPvZQdLq)q?7>g-s7A@RVj)B=Nw;OUpHVp9%HTLnNn5W-rg|FP8X4d;hR5ih>v;s>)2&*w8C x1gy1`Wm!*QyWQq`z2cn1IadR}^HNn6e*n+ULemV~%$5KE002ovPDHLkV1ixF{2~AV literal 0 HcmV?d00001