minetest / minetest

Minetest is an open source voxel game-creation platform with easy modding and game creation

Home Page:https://www.minetest.net/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add functionality to change texture of ItemStack at runtime

LandonAConway opened this issue · comments

Problem

It would be very convenient to have the ability to change the texture of an ItemStack that shows in the inventory, or the wield image that shows when a player holds the stack but at runtime.

Solution

Something like this could suffice.

local sam = minetest.get_player_by_name("sam")
local stack = sam:get_wielded_item()

--set texture of ItemStack
stack:get_meta():set_string("texture", "new_texture.png")

--set texture back to default
stack:get_meta():set_string("texture", "")

sam:set_wielded_item(stack)

This would eliminate the requirement to create several items for one item that has a certain functionality.

This is a weird way to search issues. Maybe use the search bar or Google next time

Duplicate of #5686