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

Post Reply
User avatar
Steamed_Punk
Member
Posts: 157
Joined: Sat Aug 10, 2019 13:31
GitHub: steamed-punk

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

by Steamed_Punk » Post

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
Last edited by Steamed_Punk on Fri Oct 09, 2020 11:44, edited 3 times in total.
The sky is not the limit - It's my playground

User avatar
joe7575
Member
Posts: 495
Joined: Mon Apr 24, 2017 20:38
GitHub: joe7575
In-game: JoSto wuffi
Location: Germany, in the deep south

Re: Organizing the Inventory?

by joe7575 » Post

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
})
Sent from my Commodore 64. Some of my Mods: Tech Age, TechPack, Hyperloop, Tower Crane, Lumberjack, Iron Age, Minecart, Signs Bot.

User avatar
Steamed_Punk
Member
Posts: 157
Joined: Sat Aug 10, 2019 13:31
GitHub: steamed-punk

Re: Organizing the Inventory?

by Steamed_Punk » Post

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.
The sky is not the limit - It's my playground

User avatar
rubenwardy
Moderator
Posts: 6297
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: United Kingdom
Contact:

Re: Organizing the Inventory?

by rubenwardy » Post

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

User avatar
Steamed_Punk
Member
Posts: 157
Joined: Sat Aug 10, 2019 13:31
GitHub: steamed-punk

Re: Organizing the Inventory?

by Steamed_Punk » Post

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
The sky is not the limit - It's my playground

User avatar
Steamed_Punk
Member
Posts: 157
Joined: Sat Aug 10, 2019 13:31
GitHub: steamed-punk

Re: Organizing the Inventory?

by Steamed_Punk » Post

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.
The sky is not the limit - It's my playground

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests