How to make a tool unable of digging?

User avatar
Wuzzy
Member
 
Posts: 2161
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

How to make a tool unable of digging?

by Wuzzy » Thu Mar 30, 2017 02:03

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. :-)
I'm creating MineClone 2, a Minecraft clone for Minetest.
I made the Help modpack, adding in-game help to Minetest.
 

User avatar
wilkgr76
Member
 
Posts: 680
Joined: Wed Feb 18, 2015 02:44
GitHub: wilkgr76
IRC: wilkgr
In-game: wilkgr

Re: How to make a tool unable of digging?

by wilkgr76 » Sat Apr 01, 2017 01:22

Could you set cracky=0 (and for the other groups) rather than just leaving it empty?
I do not care.
 

User avatar
Wuzzy
Member
 
Posts: 2161
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Re: How to make a tool unable of digging?

by Wuzzy » Sat Apr 01, 2017 05:49

This doesn't solve anything. The group rating 0 has the same meaning as if the group is not defined at all (nil).
I'm creating MineClone 2, a Minecraft clone for Minetest.
I made the Help modpack, adding in-game help to Minetest.
 

User avatar
wilkgr76
Member
 
Posts: 680
Joined: Wed Feb 18, 2015 02:44
GitHub: wilkgr76
IRC: wilkgr
In-game: wilkgr

Re: How to make a tool unable of digging?

by wilkgr76 » Sat Apr 01, 2017 11:12

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.
I do not care.
 

User avatar
AiTechEye
Member
 
Posts: 409
Joined: Fri May 29, 2015 21:14

Re: How to make a tool unable of digging?

by AiTechEye » Sat Apr 01, 2017 13:51

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
Alive AI Mine/Build AI NPC
Gravitygun HL2
Portalgun Portal
Marssurvive Survive on mars
Bows bows + arrows
SoundCloud (Music)
SoundCloud (Classic)
YouTube
 

User avatar
Wuzzy
Member
 
Posts: 2161
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Re: How to make a tool unable of digging?

by Wuzzy » Sat Apr 01, 2017 14:29

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. :-/
I'm creating MineClone 2, a Minecraft clone for Minetest.
I made the Help modpack, adding in-game help to Minetest.
 

User avatar
AiTechEye
Member
 
Posts: 409
Joined: Fri May 29, 2015 21:14

Re: How to make a tool unable of digging?

by AiTechEye » Sat Apr 01, 2017 16:41

add users to a minetest.register_globalstep function?

will look glitchy, but better then nothing
Alive AI Mine/Build AI NPC
Gravitygun HL2
Portalgun Portal
Marssurvive Survive on mars
Bows bows + arrows
SoundCloud (Music)
SoundCloud (Classic)
YouTube
 


Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 3 guests

cron