player:set_wield_item() not working in craftitem:on_use()

Post Reply
LC Creations
Member
Posts: 157
Joined: Mon Feb 18, 2019 02:53

player:set_wield_item() not working in craftitem:on_use()

by LC Creations » Post

I have a craftitem and it uses the on_use function. However, if i use player:set_wield_item() inside the function, nothing is changed. What the heck? It is 100% required for me to be able to do this. Not exceptions no alternatives accepted. I MUST do this.

User avatar
TenPlus1
Member
Posts: 2960
Joined: Mon Jul 29, 2013 13:38
GitHub: tenplus1

Re: player:set_wield_item() not working in craftitem:on_use()

by TenPlus1 » Post

Please write what you are tying to do with this item and it's on_use and we can maybe find a solution.

Skamiz Kazzarch
Member
Posts: 197
Joined: Fri Mar 09, 2018 20:34
GitHub: Skamiz
In-game: Skamiz
Location: la lojbaugag.

Re: player:set_wield_item() not working in craftitem:on_use()

by Skamiz Kazzarch » Post

LC Creations wrote:
Sun Jul 12, 2020 04:44
set_wield_item()
https://github.com/minetest/minetest/bl ... .txt#L5971

Code: Select all

set_wielded_item()

LC Creations
Member
Posts: 157
Joined: Mon Feb 18, 2019 02:53

Re: player:set_wield_item() not working in craftitem:on_use()

by LC Creations » Post

TenPlus1 wrote:
Sun Jul 12, 2020 05:43
Please write what you are tying to do with this item and it's on_use and we can maybe find a solution.
Literally all I did was used "set_wield_item" funtion in "on_use". No other code was there. As for the item I'm setting it to, its just modifying the meta of the item stack.

User avatar
Krock
Developer
Posts: 4587
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker
Location: Switzerland
Contact:

Re: player:set_wield_item() not working in craftitem:on_use()

by Krock » Post

The return value of "on_use" overwrites the selected item after you called the function.
Modify the itemstack and return that to set the wielded item.
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests