Page 1 of 1

How to make a tool unable of digging?

PostPosted: Thu Mar 30, 2017 02:03
by Wuzzy
How do I create a tool/item which is unable to dig anything at all (not even like the hand) AND I can still continously punch while holding down the left mouse button?

What I've tried so far:
  • Set empty table for groupcaps (the tool still digs like a hand)
  • Set on_use (I can no longer continously punch by holding down the left on_use)
  • Use both of the above (has the same problems)

Use case:
I want to create a sword which can attack and dig in “normal” mode but can only attack, but not dig when in Creative Mode.

Any help is greatly appreciated. :-)

Re: How to make a tool unable of digging?

PostPosted: Sat Apr 01, 2017 01:22
by wilkgr76
Could you set cracky=0 (and for the other groups) rather than just leaving it empty?

Re: How to make a tool unable of digging?

PostPosted: Sat Apr 01, 2017 05:49
by Wuzzy
This doesn't solve anything. The group rating 0 has the same meaning as if the group is not defined at all (nil).

Re: How to make a tool unable of digging?

PostPosted: Sat Apr 01, 2017 11:12
by wilkgr76
Wuzzy wrote:This doesn't solve anything. The group rating 0 has the same meaning as if the group is not defined at all (nil).

Oh ok. Just a guess of the top of my head.

On the other hand, could you take an approach similar to that of maptools' admin pick? It checks each time you break a block what tool you use, and if you used an admin pick, it removes the block.

Re: How to make a tool unable of digging?

PostPosted: Sat Apr 01, 2017 13:51
by AiTechEye
i think the only way is to registry the tool in 2 ways.

in survive mod, reg tool_capabilities

creative, reg on_use only


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
if minetest.setting_get("creative_mode")=="true" then
   minetest.register_tools("ctool:tool", {
      description = "tool",
      on_use = function(itemstack, user, pointed_thing)
         if pointed_thing.type=="object" then
            pointed_thing.ref:punch(user,1,{full_punch_interval=1,damage_groups={fleshy=8}})
            return itemstack
         end
      end
   })
else
   minetest.register_tools("ctool:tool", {
      description = "tool",
      tool_capabilities = {
         full_punch_interval = 1,
         max_drop_level=1,
         damage_groups = {fleshy=8},
      },
   })
end

Re: How to make a tool unable of digging?

PostPosted: Sat Apr 01, 2017 14:29
by Wuzzy
No, AiTechEye, this doesn't work. :-(
As soon as I make use of on_use, I can't swing the sword continously anymore (by holding the left mouse button). But I want still be able to swing the sword continously, a capability which all other tools have by default. I don't want to lose this. :-/

Re: How to make a tool unable of digging?

PostPosted: Sat Apr 01, 2017 16:41
by AiTechEye
add users to a minetest.register_globalstep function?

will look glitchy, but better then nothing