How do i check for a specific item or itemgroup wielded?

User avatar
Drachenbauer32
Member
 
Posts: 98
Joined: Wed Aug 28, 2019 18:11

How do i check for a specific item or itemgroup wielded?

by Drachenbauer32 » Thu Oct 24, 2019 19:40

Hello

How can i make a script check the wielded item for a specific name-part or itemgroup?
Sample: in an empty fireplace should appear wood by rightclick, but only, if a tree is the wielded item.
i have the node-models and the function for the node-switching, but i need the if-condition for this.
 

User avatar
Linuxdirk
Member
 
Posts: 2200
Joined: Wed Sep 17, 2014 11:21
Location: Germany
In-game: Linuxdirk

Re: How do i check for a specific item or itemgroup wielded?

by Linuxdirk » Thu Oct 24, 2019 22:49

I assume you already have the player object. So player:get_wielded_item() gets you the ItemStack for the currently wielded item.

https://github.com/minetest/minetest/bl ... 5294-L5343

You can use player:get_wielded_item():get_name() get the ID of the wielded thing, for example default:wood.

You can then do all the checks with it you want to.
 

User avatar
Drachenbauer32
Member
 
Posts: 98
Joined: Wed Aug 28, 2019 18:11
 


Return to Modding Discussion



Who is online

Users browsing this forum: No registered users and 2 guests