How can I capture what tool was used to dig a block, or in my hand?

User avatar
Neuromancer
Member
 
Posts: 793
Joined: Tue Jun 12, 2012 22:28
GitHub: Neuromancer56

How can I capture what tool was used to dig a block, or in my hand?

by Neuromancer » Sun Dec 23, 2012 13:34

Is there a way to tell what tool is being used to dig a block, or what tool is in my hand? I need to then use some logic that if a certain tool is being used, then run different code.
 

User avatar
LorenzoVulcan
Member
 
Posts: 437
Joined: Mon Mar 12, 2012 06:46

by LorenzoVulcan » Sun Dec 23, 2012 13:40

Developer of the BlockForge 2# Project!
Official thread: http://minetest.net/forum/viewtopic.php?pid=54290#p54290
 

User avatar
Neuromancer
Member
 
Posts: 793
Joined: Tue Jun 12, 2012 22:28
GitHub: Neuromancer56

by Neuromancer » Sun Dec 23, 2012 14:50

Thanks much! get_wielded_item and get_wear did the trick!


Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_on_punchnode( function(pos, node, puncher)

    hit_with = puncher:get_wielded_item()
    wear=hit_with:get_wear()
    --print (temp["wear"])

if node.name == "phonics:c"
 then
     if wear == 0 then
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 24 guests

cron