mirror of
https://github.com/Sokomine/chesttools.git
synced 2025-01-09 17:40:37 +01:00
prepared for colored chests (8 colors)
This commit is contained in:
parent
a532518d61
commit
d335f5cf03
28
init.lua
28
init.lua
@ -33,8 +33,10 @@ chesttools.update_price = {
|
|||||||
|
|
||||||
chesttools.chest_add = {};
|
chesttools.chest_add = {};
|
||||||
chesttools.chest_add.tiles = {
|
chesttools.chest_add.tiles = {
|
||||||
"chesttools_blue_chest_top.png", "chesttools_blue_chest_top.png", "chesttools_blue_chest_side.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_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.groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2};
|
||||||
chesttools.chest_add.tube = {};
|
chesttools.chest_add.tube = {};
|
||||||
|
|
||||||
@ -69,9 +71,11 @@ end
|
|||||||
|
|
||||||
chesttools.formspec = "size[9,10]"..
|
chesttools.formspec = "size[9,10]"..
|
||||||
"list[current_name;main;0.5,0.3;8,4;]"..
|
"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;;]"..
|
"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]"..
|
"label[0.0,4.4;Main]"..
|
||||||
"button[1.0,4.5;1,0.5;craft;Craft]"..
|
"button[1.0,4.5;1,0.5;craft;Craft]"..
|
||||||
"button[7.0,4.5;0.5,0.5;drop_all;DA]"..
|
"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
|
end
|
||||||
|
|
||||||
local formspec = "size[9,10]"..
|
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").."]"..
|
"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;]"..
|
"list[current_name;main;0.5,0.3;8,4;]"..
|
||||||
"button[7.0,4.5;0.5,0.5;drop_all;DA]"..
|
"button[7.0,4.5;0.5,0.5;drop_all;DA]"..
|
||||||
"button[7.5,4.5;0.5,0.5;take_all;TA]"..
|
"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 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]";
|
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 = '';
|
local selected = '';
|
||||||
if( fields.drop_all or fields.take_all or fields.swap_all or fields.filter_all ) then
|
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
|
-- 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,
|
tiles = chesttools.chest_add.tiles,
|
||||||
groups = chesttools.chest_add.groups,
|
groups = chesttools.chest_add.groups,
|
||||||
tube = chesttools.chest_add.tube,
|
tube = chesttools.chest_add.tube,
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "colorfacedir",
|
||||||
|
palette = "chesttools_palette.png",
|
||||||
legacy_facedir_simple = true,
|
legacy_facedir_simple = true,
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
@ -472,7 +484,7 @@ minetest.register_node( 'chesttools:shared_chest', {
|
|||||||
can_dig = function(pos,player)
|
can_dig = function(pos,player)
|
||||||
local meta = minetest.get_meta(pos);
|
local meta = minetest.get_meta(pos);
|
||||||
local inv = meta:get_inventory()
|
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,
|
end,
|
||||||
|
|
||||||
allow_metadata_inventory_move = function(pos, from_list, from_index,
|
allow_metadata_inventory_move = function(pos, from_list, from_index,
|
||||||
|
BIN
textures/chesttools_palette.png
Normal file
BIN
textures/chesttools_palette.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 160 B |
BIN
textures/chesttools_white_chest_lock.png
Normal file
BIN
textures/chesttools_white_chest_lock.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 717 B |
BIN
textures/chesttools_white_chest_side.png
Normal file
BIN
textures/chesttools_white_chest_side.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 538 B |
BIN
textures/chesttools_white_chest_top.png
Normal file
BIN
textures/chesttools_white_chest_top.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 559 B |
Loading…
Reference in New Issue
Block a user