forked from mtcontrib/chesttools
Compare commits
7 Commits
nalc-1.0
...
c8edc24ad2
Author | SHA1 | Date | |
---|---|---|---|
c8edc24ad2 | |||
07fcfe2342 | |||
d1093fe448 | |||
6bc54f0f3a | |||
31366d3fc9 | |||
5f9ba4148d | |||
06f4befded |
@ -1 +0,0 @@
|
|||||||
default
|
|
@ -1,29 +0,0 @@
|
|||||||
|
|
||||||
This mod adds a shared locked chest with additional features to Minetest.
|
|
||||||
|
|
||||||
Who can access the chest?
|
|
||||||
|
|
||||||
- If placed in an area that is not protected: The owner of the chest.
|
|
||||||
- If the place is protected: Anyone who is allowed to build or dig at the place where the chest is standing.
|
|
||||||
|
|
||||||
Quick access buttons:
|
|
||||||
|
|
||||||
- Main: Acces your main inventory. This is all normal chests and locked chests can do.
|
|
||||||
- Craft: Access your crafting area directly. Take items out of your chest, put them directly into your crafting grid, craft something, and put the result back into the chest if you like. This can save a lot of clicks!
|
|
||||||
- Bag1: Directly access the inventory of your first bag. No need to put what you collected in your bags into your main inventory first and from there to the chests. It's much faster to do it directly!
|
|
||||||
- Bag2: Same for your second bag.
|
|
||||||
- Bag3: And the third.
|
|
||||||
- Bag4: Four bags are supported.
|
|
||||||
|
|
||||||
- DA: Drop All of your currently selected inventory (main, craft, or one of the bags) directly into the chest with one click.
|
|
||||||
- TA: Take All of the chest's inventory and put it into your currently selected inventory (main, craft or one of the bags).
|
|
||||||
- SA: Swap All - take all inventory out of the chest and put it into your currently selected inventory - and put all from your currently selected inventory into the bag. Just one click.
|
|
||||||
- FA: Filter All - Filter your currently selected inventory and put those items of which there's already at least one in the chest from your inventory into the chest. Good for i.e. quickly putting all ores, wood or farming products into one chest. Just put a sample inside the chest and no longer worry about having to put anything you gathered in the right chest - it'll automaticly get added if it belongs to that particular chest.
|
|
||||||
|
|
||||||
Supports:
|
|
||||||
- unified_inventory with its bags
|
|
||||||
|
|
||||||
Additional features:
|
|
||||||
|
|
||||||
- Add a label for the chest in the "Title/Content:" field. You'll now see that title when you hover over the chest with your mouse.
|
|
||||||
- Wield the blue chest and click on a normal, locked or other blue shared chest. You can now change the type of the chest - i.e. turn your locked chests into shared ones. Upgrades cost one steel ingot each.
|
|
38
init.lua
38
init.lua
@ -53,12 +53,12 @@ if( minetest.get_modpath( 'pipeworks' )) then
|
|||||||
tubedevice = 1, tubedevice_receiver = 1 };
|
tubedevice = 1, tubedevice_receiver = 1 };
|
||||||
chesttools.chest_add.tube = {
|
chesttools.chest_add.tube = {
|
||||||
insert_object = function(pos, node, stack, direction)
|
insert_object = function(pos, node, stack, direction)
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
return inv:add_item("main", stack)
|
return inv:add_item("main", stack)
|
||||||
end,
|
end,
|
||||||
can_insert = function(pos, node, stack, direction)
|
can_insert = function(pos, node, stack, direction)
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
return inv:room_for_item("main", stack)
|
return inv:room_for_item("main", stack)
|
||||||
end,
|
end,
|
||||||
@ -116,13 +116,16 @@ chesttools.on_receive_fields = function(pos, formname, fields, player)
|
|||||||
|
|
||||||
local meta = minetest.get_meta( pos );
|
local meta = minetest.get_meta( pos );
|
||||||
local chestname = meta:get_string( 'chestname' );
|
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 ) then
|
||||||
chestname = tostring( fields.chestname );
|
chestname = tostring( fields.chestname );
|
||||||
meta:set_string( 'chestname', chestname );
|
meta:set_string( 'chestname', chestname );
|
||||||
meta:set_string("infotext", "\""..chestname.."\" Chest (owned by "..meta:get_string("owner")..")")
|
meta:set_string("infotext", "\""..chestname.."\" Chest (owned by "..meta:get_string("owner")..")")
|
||||||
-- update the normal formspec
|
-- update the normal formspec
|
||||||
meta:set_string("formspec", chesttools.formspec..
|
meta:set_string("formspec", chesttools.formspec..
|
||||||
"field[1.8,10.0;6,0.5;chestname;;"..chestname.."]");
|
"listring[current_name;main]"..
|
||||||
|
"listring[current_player;main]"..
|
||||||
|
"field[1.8,10.0;6,0.5;chestname;;"..chestname.."]");
|
||||||
end
|
end
|
||||||
|
|
||||||
local formspec = "size[9,10]"..
|
local formspec = "size[9,10]"..
|
||||||
@ -133,7 +136,7 @@ chesttools.on_receive_fields = function(pos, formname, fields, player)
|
|||||||
"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]"..
|
||||||
"button[8.0,4.5;0.5,0.5;swap_all;SA]"..
|
"button[8.0,4.5;0.5,0.5;swap_all;SA]"..
|
||||||
"button[8.5,4.5;0.5,0.5;filter_all;FA]";
|
"button[8.5,4.5;0.5,0.5;filter_all;FA]"
|
||||||
local bm = "button[0.0,4.5;1,0.5;main;Main]";
|
local bm = "button[0.0,4.5;1,0.5;main;Main]";
|
||||||
local bc = "button[1.0,4.5;1,0.5;craft;Craft]";
|
local bc = "button[1.0,4.5;1,0.5;craft;Craft]";
|
||||||
local b1 = "button[2.0,4.5;1,0.5;bag1;Bag 1]";
|
local b1 = "button[2.0,4.5;1,0.5;bag1;Bag 1]";
|
||||||
@ -219,7 +222,9 @@ chesttools.on_receive_fields = function(pos, formname, fields, player)
|
|||||||
if( fields[ 'main'] or selected=='main' or fields['set_chestname']) then
|
if( fields[ 'main'] or selected=='main' or fields['set_chestname']) then
|
||||||
bag_nr = 0;
|
bag_nr = 0;
|
||||||
formspec = formspec..
|
formspec = formspec..
|
||||||
"list[current_player;main;0.5,5.5;8,4;]";
|
"list[current_player;main;0.5,5.5;8,4;]"..
|
||||||
|
"listring[nodemeta:" .. spos .. ";main]"..
|
||||||
|
"listring[current_player;main]"
|
||||||
bm = "label[0.0,4.4;Main]";
|
bm = "label[0.0,4.4;Main]";
|
||||||
selected = 'main';
|
selected = 'main';
|
||||||
|
|
||||||
@ -228,7 +233,9 @@ chesttools.on_receive_fields = function(pos, formname, fields, player)
|
|||||||
formspec = formspec..
|
formspec = formspec..
|
||||||
"label[0,5.5;Crafting]"..
|
"label[0,5.5;Crafting]"..
|
||||||
"list[current_player;craftpreview;6.5,6.5;1,1;]"..
|
"list[current_player;craftpreview;6.5,6.5;1,1;]"..
|
||||||
"list[current_player;craft;2.5,6.5;3,3;]";
|
"list[current_player;craft;2.5,6.5;3,3;]"..
|
||||||
|
"listring[nodemeta:" .. spos .. ";main]"..
|
||||||
|
"listring[current_player;craft]"
|
||||||
bc = "label[1.0,4.4;Craft]";
|
bc = "label[1.0,4.4;Craft]";
|
||||||
selected = 'craft';
|
selected = 'craft';
|
||||||
|
|
||||||
@ -258,10 +265,16 @@ chesttools.on_receive_fields = function(pos, formname, fields, player)
|
|||||||
local pname_esc = minetest.formspec_escape(player:get_player_name());
|
local pname_esc = minetest.formspec_escape(player:get_player_name());
|
||||||
formspec = formspec.."list[detached:"..pname_esc.."_bags;bag"..
|
formspec = formspec.."list[detached:"..pname_esc.."_bags;bag"..
|
||||||
tostring(bag_nr)..";1.5,5.5;1,1;]";
|
tostring(bag_nr)..";1.5,5.5;1,1;]";
|
||||||
|
local bag = minetest.get_inventory({type="detached", name=pname_esc.."_bags"},"bag"..tostring(bag_nr))
|
||||||
local slots = 4*8;
|
local slots = 4*8;
|
||||||
if( slots and slots>0 ) then -- no bag present?
|
if( bag and not(bag:get_stack("bag"..tostring(bag_nr),1):is_empty())) then -- no bag present?
|
||||||
formspec = formspec..
|
formspec = formspec..
|
||||||
"list[current_player;bag"..tostring(bag_nr).."contents;0.5,6.5;8,"..tostring(slots/8)..";]";
|
"list[current_player;bag"..tostring(bag_nr).."contents;0.5,6.5;8,"..tostring(slots/8)..";]"..
|
||||||
|
"listring[nodemeta:" .. spos .. ";main]"..
|
||||||
|
"listring[current_player;bag"..tostring(bag_nr).."contents]"
|
||||||
|
else
|
||||||
|
formspec = formspec..
|
||||||
|
"label[0.5,6.5;You have no bag in this slot.]"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -366,7 +379,7 @@ chesttools.update_chest = function(pos, formname, fields, player)
|
|||||||
local inv_size = inv:get_size("main");
|
local inv_size = inv:get_size("main");
|
||||||
for i=1, inv_size do
|
for i=1, inv_size do
|
||||||
main_inv[ i ] = inv:get_stack( "main", i);
|
main_inv[ i ] = inv:get_stack( "main", i);
|
||||||
print("Found: "..tostring( main_inv[ i ]:get_name()));
|
-- print("Found: "..tostring( main_inv[ i ]:get_name()));
|
||||||
end
|
end
|
||||||
|
|
||||||
-- actually change and initialize the new chest
|
-- actually change and initialize the new chest
|
||||||
@ -413,8 +426,10 @@ chesttools.form_input_handler = function( player, formname, fields)
|
|||||||
end
|
end
|
||||||
if( formname == "chesttools:shared_chest") then
|
if( formname == "chesttools:shared_chest") then
|
||||||
chesttools.on_receive_fields(pos, formname, fields, player);
|
chesttools.on_receive_fields(pos, formname, fields, player);
|
||||||
|
return true; -- this function was responsible for handling the input
|
||||||
elseif( formname == "chesttools:update") then
|
elseif( formname == "chesttools:update") then
|
||||||
chesttools.update_chest( pos, formname, fields, player);
|
chesttools.update_chest( pos, formname, fields, player);
|
||||||
|
return true; -- this function was responsible for handling the input
|
||||||
end
|
end
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -450,7 +465,8 @@ minetest.register_node( 'chesttools:shared_chest', {
|
|||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
inv:set_size("main", 8*4)
|
inv:set_size("main", 8*4)
|
||||||
meta:set_string("formspec", chesttools.formspec..
|
meta:set_string("formspec", chesttools.formspec..
|
||||||
"list[current_player;main;0.5,5.5;8,4;]");
|
"listring[current_name;main]"..
|
||||||
|
"listring[current_player;main]")
|
||||||
end,
|
end,
|
||||||
|
|
||||||
can_dig = function(pos,player)
|
can_dig = function(pos,player)
|
||||||
@ -512,7 +528,7 @@ minetest.register_node( 'chesttools:shared_chest', {
|
|||||||
local name = user:get_player_name();
|
local name = user:get_player_name();
|
||||||
|
|
||||||
local pos = minetest.get_pointed_thing_position( pointed_thing, mode );
|
local pos = minetest.get_pointed_thing_position( pointed_thing, mode );
|
||||||
local node = minetest.env:get_node_or_nil( pos );
|
local node = minetest.get_node_or_nil( pos );
|
||||||
|
|
||||||
if( node == nil or not( node.name )) then
|
if( node == nil or not( node.name )) then
|
||||||
return nil;
|
return nil;
|
||||||
|
Reference in New Issue
Block a user