Dynamic Wield Textures

Post Reply
Nota
Member
Posts: 37
Joined: Wed Feb 14, 2018 07:49

Dynamic Wield Textures

by Nota » Post

Hi, my first post here! Such a cool game and community. I'm working day & night on a fork of an existing game and can't wait to reveal it.

I'm wondering if you can *dynamically* change the texture of a wielded item. I've hunted all over. The closest I've gotten is:

Code: Select all

minetest.override_item(wielded_item, {inventory_image = "weapons_thingy_different.png",})
This does work, but it only loads on startup, and isn't dynamic. I need to do it on the fly in response to a condition!

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

Re: Dynamic Wield Textures

by texmex » Post

Welcome to Minetest!

There's no built-in support for dynamic textures at all, but what you can do specifically for wielded items is what the compass mods are doing. See what ccompass does to register all possible variants and update the wielditem accordingly.

A big drawback is that the engine will perform an item switching animation on updates, and this can't be overridden.

Nota
Member
Posts: 37
Joined: Wed Feb 14, 2018 07:49

Re: Dynamic Wield Textures

by Nota » Post

Wow, this is *exactly* the solution I came up with last night on my own! But it took me many hours of experimenting to figure out that it's the only way to do this.

It's working great, but I wish there was a way to turn off the switch animation OR dynamically change the wield_image in register_tool.

Just for reference for anyone else trying this:

Code: Select all

player:set_wielded_item("stuff:thingy_different")
Also, don't forget to hide the duplicate item from crafting recipes:

Code: Select all

groups = {not_in_creative_inventory=1}

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests