Page 1 of 1

Ability to use item preview images as textures

PostPosted: Sun Jun 15, 2014 19:28
by MirceaKitsune
Thread for issue #1378:

Minetest generates preview images for all items depending on their drawtype, such as an image of the furnace as a cube with its faces textured accordingly. Currently this is only used to show the item on the hotbar and in inventories. The ability to also use generated image previews as textures would be very useful for modding.

One thing this would make possible are 2D representations of the wielded item in player's hands, for mods such as stu's 3D-Armor. Currently, using a Lua entity with the real drawtype and texture of the item doesn't work, since apparently there are issues with attaching things to bones due to Irrlicht. Being able to use the inventory preview as an image in this case would be extremely helpful.

Another thing this would allow are picture frames that you can put items on, similar to those Minecraft recently added. A photo frame can be placed on a wall, then right-clicking it with any item in your hand causes the photo to turn into the inventory preview of that item. Disclaimer: This isn't intended as an instigation at copying Minecraft!

Re: Ability to use item preview images as textures

PostPosted: Sun Jun 15, 2014 20:01
by Casimir
minetest.inventorycube(img1, img2, img3)
^ Returns a string for making an image of a cube (useful as an item image)

https://github.com/minetest/minetest/bl ... .txt#L1477

Re: Ability to use item preview images as textures

PostPosted: Sun Jun 15, 2014 20:08
by ExeterDad
that is a useful find! Thanks!

Re: Ability to use item preview images as textures

PostPosted: Sun Jun 15, 2014 20:27
by webdesigner97
Casimir wrote:
minetest.inventorycube(img1, img2, img3)
^ Returns a string for making an image of a cube (useful as an item image)

https://github.com/minetest/minetest/bl ... .txt#L1477

Which only works for drawtype "normal" AFAIK. Nodeboxes and other drawtypes won't work.

Re: Ability to use item preview images as textures

PostPosted: Sun Jun 15, 2014 20:45
by MirceaKitsune
webdesigner97 wrote:
Casimir wrote:
minetest.inventorycube(img1, img2, img3)
^ Returns a string for making an image of a cube (useful as an item image)

https://github.com/minetest/minetest/bl ... .txt#L1477

Which only works for drawtype "normal" AFAIK. Nodeboxes and other drawtypes won't work.


I saw that function in the API, but eventually got the impression it's a convenience function to return the textures of a block in a table. If it generates the preview image in realtime this is a good thing, and allows this to be done somewhat!

But like webdesigner97 said, it only works for drawtype_normal from the looks of it, not nodeboxes... so yeah.

Re: Ability to use item preview images as textures

PostPosted: Mon Jun 16, 2014 02:25
by Sokomine
MirceaKitsune wrote:Another thing this would allow are picture frames that you can put items on, similar to those Minecraft recently added. A photo frame can be placed on a wall, then right-clicking it with any item in your hand causes the photo to turn into the inventory preview of that item.

There is an itemframe mod that places entities into a frame. It can be seen in action on VanessaEs servers.

Formspec menus can display inventory images as well. They are not limited to inventory slots. Are you looking for those kind of images?

Regarding textures, it would be great to be able to change a texture to a new one upon a server command. That way, changing seasons like in the 4seasons mod would be a lot easier to handle for the server. Instead of having to change each single dirt and leaf node, it could just tell the client to apply another texture to that node.

Re: Ability to use item preview images as textures

PostPosted: Mon Jun 16, 2014 10:45
by MirceaKitsune
Sokomine wrote:There is an itemframe mod that places entities into a frame. It can be seen in action on VanessaEs servers.

Formspec menus can display inventory images as well. They are not limited to inventory slots. Are you looking for those kind of images?

Regarding textures, it would be great to be able to change a texture to a new one upon a server command. That way, changing seasons like in the 4seasons mod would be a lot easier to handle for the server. Instead of having to change each single dirt and leaf node, it could just tell the client to apply another texture to that node.


Didn't know that, need to check it out then! Question is if said itemframe uses pre-made preview images for each item, or if it fetches the generated inventory icons. I'll look at the code since I'm curious myself now.

And yes, I'd like to know how formspecs can display the item icons outside of inventory slots, as images for instance. My curiosity otherwise is if a mesh material (player / Lua entity) can be textured to use it, for things like wielditem support.

[EDIT] Not surprisingly, the Item Frames mod uses a Lua entity of type "wielditem", which I already know about and doesn't involve using the inventory image. So it doesn't tell me anything, although it's a cool mod otherwise!

Re: Ability to use item preview images as textures

PostPosted: Mon Jun 16, 2014 11:53
by Sokomine
MirceaKitsune wrote:And yes, I'd like to know how formspecs can display the item icons outside of inventory slots, as images for instance. My curiosity otherwise is if a mesh material (player / Lua entity) can be textured to use it, for things like wielditem support.

In formspecs, item_image[..] and item_image_button[..] display such an image. Those formspec functions get the item name as a parameter. Making those images available elsewhere sounds like what you're looking for.

MirceaKitsune wrote:[EDIT] Not surprisingly, the Item Frames mod uses a Lua entity of type "wielditem", which I already know about and doesn't involve using the inventory image. So it doesn't tell me anything, although it's a cool mod otherwise!

That's right. It's a very nice mod. The drawback is that each run of clearallobjects requries updating each item frame manually.

Re: Ability to use item preview images as textures

PostPosted: Mon Jun 16, 2014 12:30
by MirceaKitsune
Sokomine wrote:In formspecs, item_image[..] and item_image_button[..] display such an image. Those formspec functions get the item name as a parameter. Making those images available elsewhere sounds like what you're looking for.


Aha, good to know. And yes, that's indeed what I was thinking about.

Re: Ability to use item preview images as textures

PostPosted: Thu Jul 03, 2014 09:31
by prestidigitator
I started the texture wiki page after inspecting some of the source code. I THINK the syntax can be used anywhere you can specify a texture, but I can't remember for sure now.

Re: Ability to use item preview images as textures

PostPosted: Thu Jul 03, 2014 15:02
by webdesigner97
prestidigitator wrote:I started the texture wiki page after inspecting some of the source code. I THINK the syntax can be used anywhere you can specify a texture, but I can't remember for sure now.

"^" is not an ampersand. This is an ampersand: &

Re: Ability to use item preview images as textures

PostPosted: Fri Jul 04, 2014 08:01
by prestidigitator
webdesigner97 wrote:"^" is not an ampersand. This is an ampersand: &

Right you are. Good catch. Fixed in the wiki ("caret").

Re: Ability to use item preview images as textures

PostPosted: Fri Jul 04, 2014 09:54
by webdesigner97
prestidigitator wrote:
webdesigner97 wrote:"^" is not an ampersand. This is an ampersand: &

Right you are. Good catch. Fixed in the wiki ("caret").

Just saw that while reading ;) But the article is interesting! It contains stuff I didn't know about yet...