Request: automatic item stacking for chests

Post Reply
chlue
Member
Posts: 19
Joined: Wed Dec 21, 2011 23:08

Request: automatic item stacking for chests

by chlue » Post

Hello maybe there already exists such a mod, but so far I have not found anything.

I would like to have four additional button's in the chest interface:
1. store all
2. take all
3. autostack all items from inventory to chest if there is a partial stack of the same item in the chest
4. autostack all items from chest to inventory if there is a partial stack of the same item in the inventory

For example in the 2-d game terraria such buttons exist and once you have played such a game a bit you will sorely miss them. This is especially true for minetest due to the fact that inventory operations are quiet laggy and you are not only limited by click speed here.

Usecases:
1. store all
- put your current gear in a chest to switch to a different task (example mining --> farming)
2. take all
- get a predefined gear for a specific task
- want to move a chest to a different location, but the chest is full
3. autostack inventory --> chest
- semiautomatic sorting (having chest with partial stacks for ores, stones, foods,...)
4. autostack chest --> inventory
- refresh your food/torces stack in inventory

So a typical 'workday' in minetest could be like this:
1. use 'take all' on the mining chest
2. do some mining and come back home
3. visit your ore and stone chests and use the 'autostack' feature to unload your goods in the predefined chests
4. use 'store all' on the mining chests to clear your remaining inventory (put your mining equip back)
5. go to your farming area and use 'take all' on the farming chest
6. harvest your crops and go back to your farming chest(s)
7. ... guess you see the pattern

User avatar
TenPlus1
Member
Posts: 3722
Joined: Mon Jul 29, 2013 13:38
In-game: TenPlus1
Contact:

by TenPlus1 » Post

It could be handy to have two arrow buttons at the side of the inventory view for chests which let you click UP to move and sort all your inventory to a chest and DOWN to move and sort all the chest into your inventory... or... Double-clicking an item would quick copy it to and from a chest/inventory...

Sokomine
Member
Posts: 4290
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine
IRC: Sokomine
In-game: Sokomine

by Sokomine » Post

Such chests would be very helpful. I got very annoyed about the standard locked chest which got made broken by that "feature" that hides content from non-owners. Most servers are far too slow for that functionality, and most of the time you just want to check what's in which chest.

When returning from mining operation, a chest that "sucks" all cobble out of inventory *and* bags would be fine and save a lot of time. Sorting the ores is usually less of a problem.

For building purposes, that store all/retrieve all functionality would be very helpful. Even and especially on servers dedicated to building.

Taking entire filled chests, carrying them around and placing them elsewere can be done with the wrench included in the technic mod/game.
A list of my mods can be found here.

User avatar
Evergreen
Member
Posts: 2135
Joined: Sun Jan 06, 2013 01:22
GitHub: 4Evergreen4
IRC: EvergreenTree
In-game: Evergreen
Location: A forest in the midwest
Contact:

by Evergreen » Post

Sokomine wrote:Such chests would be very helpful. I got very annoyed about the standard locked chest which got made broken by that "feature" that hides content from non-owners. Most servers are far too slow for that functionality, and most of the time you just want to check what's in which chest.

When returning from mining operation, a chest that "sucks" all cobble out of inventory *and* bags would be fine and save a lot of time. Sorting the ores is usually less of a problem.

For building purposes, that store all/retrieve all functionality would be very helpful. Even and especially on servers dedicated to building.

Taking entire filled chests, carrying them around and placing them elsewere can be done with the wrench included in the technic mod/game.
Actually, ashenk made a mod that does that. It is really cool, and would definitely be a must for me.
Back from the dead!

User avatar
texmex
Member
Posts: 1753
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

Re: Request: automatic item stacking for chests

by texmex » Post

Sorry for resurrecting but I'm still looking for this. Any new leads?

User avatar
TenPlus1
Member
Posts: 3722
Joined: Mon Jul 29, 2013 13:38
In-game: TenPlus1
Contact:

Re: Request: automatic item stacking for chests

by TenPlus1 » Post

Protector Redo has a protected chest with these buttons added and a box to name chest.


User avatar
texmex
Member
Posts: 1753
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

Re: Request: automatic item stacking for chests

by texmex » Post

They all add new chests though. As the original poster stated:
I would like to have four additional button's in the chest interface
No new chests, just new buttons.

User avatar
Lord_Vlad
Member
Posts: 112
Joined: Thu Jul 20, 2017 07:58

Re: Request: automatic item stacking for chests

by Lord_Vlad » Post

Bump. I'd like to see that too

Also a way to destroy a chest or furnace and get all of it's content, or have it drop, would be nice. Having to empty chest by opening them is tiresome.

User avatar
Linuxdirk
Member
Posts: 3219
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

Re: Request: automatic item stacking for chests

by Linuxdirk » Post

No buttons, but you can shift-click items since a few versions to move them from or to other inventories. (Works with furnaces, too.)

Mod developers have to define a listring for their inventories.

User avatar
Lord_Vlad
Member
Posts: 112
Joined: Thu Jul 20, 2017 07:58

Re: Request: automatic item stacking for chests

by Lord_Vlad » Post

That helps a bit, but that is definetly not what we're looking for.

User avatar
sorcerykid
Member
Posts: 1847
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

Re: Request: automatic item stacking for chests

by sorcerykid » Post

I know this subject has been brought up before, and I mentioned sharing the code that I use for chests (and all other containers) on my server.

viewtopic.php?f=3&t=16671

Image

So here is the my node registration for the default locked chests:

Code: Select all

minetest.register_node( "default:chest_locked", {
	description = "Locked Chest",
	tiles = { "default_chest_top.png", "default_chest_top.png", "default_chest_side.png",
		"default_chest_side.png", "default_chest_side.png", "default_chest_lock.png" },
	paramtype2 = "facedir",
	groups = { choppy = 2, oddly_breakable_by_hand = 2 },
	legacy_facedir_simple = true,
	is_ground_content = false,
	sounds = default.node_sound_wood_defaults( ),

	after_place_node = function( pos, player )
		local owner = player:get_player_name( ) or "singleplayer"
		local meta = minetest.get_meta( pos )
		meta:set_string( "infotext", "Locked Chest (owned by " .. owner .. ")" )
		meta:set_string( "owner", owner )
	end,
	on_construct = function ( pos )
		local meta = minetest.get_meta( pos )
		meta:get_inventory( ):set_size( "main", 8 * 4 )
		meta:set_string( "infotext", "Locked Chest" )
		meta:set_string( "oldtime", os.time( ) )
		meta:set_string( "newtime", os.time( ) )
	end,
	can_dig = function ( pos, player )
		return default.is_empty( pos ) and default.is_owner( pos, player )
	end,
	allow_metadata_inventory_move = function( pos, from_list, from_index, to_list, to_index, count, player )
		if not default.is_owner( pos, player ) then
			return 0
		end
		return count
	end,
	allow_metadata_inventory_put = function( pos, listname, index, stack, player )
		if not default.is_owner( pos, player ) then
			return 0
		end
		return stack:get_count( )
	end,
	allow_metadata_inventory_take = function( pos, listname, index, stack, player )
		if not default.is_owner( pos, player ) then
			return 0
		end
		return stack:get_count( )
	end,
	on_metadata_inventory_move = function( pos, from_list, from_index, to_list, to_index, count, player )
		minetest.log( "action", string.format( default.STATUS_CONTAINER_SET, player:get_player_name( ), "locked chest", minetest.pos_to_string( pos ) ) )
	end,
	on_metadata_inventory_put = function( pos, listname, index, stack, player )
		minetest.log( "action", string.format( default.STATUS_CONTAINER_PUT, player:get_player_name( ), "locked chest", minetest.pos_to_string( pos ) ) )
	end,
	on_metadata_inventory_take = function( pos, listname, index, stack, player )
		minetest.log( "action", string.format( default.STATUS_CONTAINER_GET, player:get_player_name( ), "locked chest", minetest.pos_to_string( pos ) ) )
	end,
	on_open = function( pos, player )
		local spos = pos.x .. "," .. pos.y .. "," .. pos.z
		local formspec =
			"size[8,9]" ..
			default.gui_bg ..
			default.gui_bg_img ..
			default.gui_slots ..
			"list[nodemeta:%s;main;0,0;8,4;]"..
			"button[2,4.3;2,0.3;put;Put Items]" ..
			"button[0,4.3;2,0.3;get;Get Items]" ..
			"list[current_player;main;0,5;8,1;]" ..
			"list[current_player;main;0,6.2;8,3;8]" ..
			"listring[nodemeta:%s;main]"..
			"listring[current_player;main]" ..
			"hidden[context;true]" ..
			default.get_hotbar_bg(0,5)

		if default.is_owner( pos, player ) then
			minetest.sound_play( "default_chest_open", { pos = pos, gain = 0.2, max_hear_distance = 5, loop = false } )
			return string.format( formspec, spos, spos )
		end
	end,
	on_close = function( pos, player, fields )
		local chest_inv = minetest.get_meta( pos ):get_inventory( )
		local player_inv = player:get_inventory( )

		if default.is_owner( pos, player ) then
			if fields.get then
				default.get_contents( chest_inv, player_inv )
				minetest.log( "action", string.format( default.STATUS_CONTAINER_GET, player:get_player_name( ), "locked chest", minetest.pos_to_string( pos ) ) )
			elseif fields.put then
				default.put_contents( chest_inv, player_inv )
				minetest.log( "action", string.format( default.STATUS_CONTAINER_PUT, player:get_player_name( ), "locked chest", minetest.pos_to_string( pos ) ) )
			elseif fields.del then
				default.del_contents( chest_inv )
				minetest.log( "action", string.format( default.STATUS_CONTAINER_DEL, player:get_player_name( ), "locked chest", minetest.pos_to_string( pos ) ) )
			elseif fields.quit then
				minetest.sound_play( "default_chest_close", { pos = pos, gain = 0.2, max_hear_distance = 5, loop = false } )
			end
		end
	end,
	on_blast = function( ) end,	-- during explosion, don't allow dropping of items from locked chest
})
Several methods and constants are dependent on my Active Formspecs API, however (which is a more fully featured replacement for Minetest's builtin formspecs). I will try to get that posted here on the forums or in my GitHub at some point soon.

User avatar
Lord_Vlad
Member
Posts: 112
Joined: Thu Jul 20, 2017 07:58

Re: Request: automatic item stacking for chests

by Lord_Vlad » Post

Keep us informed.
That's nearly exactly what I've been looking for (exept I mostly need it for chests, not locked chests)
Thanks Sorcerykid

User avatar
sorcerykid
Member
Posts: 1847
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

Re: Request: automatic item stacking for chests

by sorcerykid » Post

Sure thing, I'll try to get something posted by next week. The underlying framework makes it very easy to add the buttons to all containers (i.e. mailboxes, bookshelves, etc.) just by copying and pasting the callbacks. I made it very modular. And it's been working flawlessly on JT2 for the past seven months, so I can vouch that it's stable and secure.

Post Reply

Who is online

Users browsing this forum: No registered users and 39 guests