Page 1 of 1

[FORGET IT, Don't waste your time] Organizing the Inventory?

Posted: Thu Oct 08, 2020 23:04
by Steamed_Punk
I have 12 new blocks (end of the day) so to finish up i checked everything was in place but noticed that the objects display in the inventory (creative) but not in an order I can see how to re-arrange. They are not showing in Alphabetical order or by date/hour of creation. I have checked the 3Dmodels.obj files but using a simple text editor and I can't see anything in there concerning name etc that could effect the display order.

My .lua file has them in the order I would like them to be read and displayed by MT but that doesn't seem to be the way it works.

Sure I have ducked :D around by can't find anything that seems to be related.

Is there anything I can do to get the inventory to show my nodes in the order I want them to?
cheers

Re: Organizing the Inventory?

Posted: Fri Oct 09, 2020 07:48
by joe7575
Here a simple approach to sort the inventory items in alphabetical order by means of the chat command "/sort":

Code: Select all

minetest.register_chatcommand("sort", {
	description = "Sort the player inventory in alphabetical order",
	func = function(name, param)
		local inv = minetest.get_inventory({type="player", name=name})
		local list = inv:get_list("main")
		table.sort(list, function (a, b)
				local name_a = a:get_name()
				local name_b = b:get_name()
				if name_a == "" and name_b ~= "" then return false end
				if name_a ~= "" and name_b == "" then return true end
				return string.lower(name_a) < string.lower(name_b)
			end)
		inv:set_list("main", list)
	end
})

Re: Organizing the Inventory?

Posted: Fri Oct 09, 2020 09:53
by Steamed_Punk
joe7575 wrote:
Fri Oct 09, 2020 07:48
Here a simple approach to sort the inventory items in alphabetical order by means of the chat command "/sort":

Code: Select all

minetest.register_chatcommand("sort", {
	description = "Sort the player inventory in alphabetical order",
	func = function(name, param)
		local inv = minetest.get_inventory({type="player", name=name})
		local list = inv:get_list("main")
		table.sort(list, function (a, b)
				local name_a = a:get_name()
				local name_b = b:get_name()
				if name_a == "" and name_b ~= "" then return false end
				if name_a ~= "" and name_b == "" then return true end
				return string.lower(name_a) < string.lower(name_b)
			end)
		inv:set_list("main", list)
	end
})
Thanks for that it's pretty cool. But I guess I didn't explain myself correctly. It's not what the player has in his personal inventory I want to organize, but what displays in creative when all the blocks are displayed. I am not trying to re-organize everything, just my blocks.

for example:
A full node, three_quarter node, half node and a quarter node (heights). All aligned in that order.

Re: Organizing the Inventory?

Posted: Fri Oct 09, 2020 09:54
by rubenwardy
You can use the creative mod to create custom tabs. Also, the order in the creative inventory will probably be alphabetical based on item name or based on registration order, I forget

Re: Organizing the Inventory?

Posted: Fri Oct 09, 2020 10:01
by Steamed_Punk
rubenwardy wrote:
Fri Oct 09, 2020 09:54
You can use the creative mod to create custom tabs. Also, the order in the creative inventory will probably be alphabetical based on item name or based on registration order, I forget
I had read somewhere about tabs, and forgot, I will dig into that it looks like it could be a good solution.

Thanks

Re: Organizing the Inventory?

Posted: Fri Oct 09, 2020 11:25
by Steamed_Punk
Never mind I will stick to just modelling and texturing and just throw stuff at Minetest the best way I can.

@rubenwardy I have tried your modding book but can't make head nor tail of it.
https://rubenwardy.com/minetest_modding ... sfinv.html

I managed to add a new tab and change it's name and apart from showing hello world in the example I am lost.
I have also tried rebuilding and renaming the models in the correct order. Nothing, MT just throws them in there without any order 'Alphabetic or other'.

I took a look at the inventory.lua in the creative mod to get some idea. I am just wasting creative time again. Obviously I am wasting other peoples time as well.