SOLVED: Fast mining/digging without tool

Post Reply
freefall
Member
Posts: 19
Joined: Mon Dec 21, 2020 12:20

SOLVED: Fast mining/digging without tool

by freefall » Post

Hi there,

I hope this is the right board for my question.

I'd like to enable fast digging for all players without a tool in creative mode. I was looking for a configuration switch or a mod out there, but wasn't able to find one. I found the tools.lua but I'm new to lua and Minetest modding and lack the idea of what I would have to modify there.

Any help appreciated.

Have fun,

freefall.
Last edited by freefall on Thu Jan 14, 2021 21:11, edited 1 time in total.

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

Re: Fast mining/digging without tool

by Linuxdirk » Post

What exactly do you mean? Creative mode?

User avatar
AspireMint
Member
Posts: 415
Joined: Mon Jul 09, 2012 12:59
GitHub: AspireMint
IRC: AspireMint
In-game: AspireMint
Location: Stuck at spawn

Re: Fast mining/digging without tool

by AspireMint » Post

Super fast digging:
create new mod, init.lua:

Code: Select all

minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing)
	local player_name = puncher and puncher:get_player_name() or ""
	if not minetest.is_protected(pos, player_name) then
		minetest.node_dig(pos, node, puncher)
	end
end)

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

Re: Fast mining/digging without tool

by Linuxdirk » Post

AspireMint wrote:
Thu Jan 14, 2021 10:02
Super fast digging:
create new mod, init.lua:
If you create a new mod anyways, why not simply override the tool capabilities of : (which is the hand)?

User avatar
AspireMint
Member
Posts: 415
Joined: Mon Jul 09, 2012 12:59
GitHub: AspireMint
IRC: AspireMint
In-game: AspireMint
Location: Stuck at spawn

Re: Fast mining/digging without tool

by AspireMint » Post

Linuxdirk wrote:
Thu Jan 14, 2021 10:30
AspireMint wrote:
Thu Jan 14, 2021 10:02
Super fast digging:
create new mod, init.lua:
If you create a new mod anyways, why not simply override the tool capabilities of : (which is the hand)?
Isn't my solution simple enough, I believe there are more options, but will that ":" also override tool capabilities of other tools?
Please, provide some code. Thanks.

freefall
Member
Posts: 19
Joined: Mon Dec 21, 2020 12:20

Re: Fast mining/digging without tool

by freefall » Post

@AspireMint

Wow, that is really super fast... Frankly, for me, this is too fast. Is there a way to modify your code to end up with something like 1-3 punches per block, no matter which material is involved?

freefall
Member
Posts: 19
Joined: Mon Dec 21, 2020 12:20

Re: Fast mining/digging without tool

by freefall » Post

Linuxdirk wrote:
Thu Jan 14, 2021 08:24
What exactly do you mean? Creative mode?
I do not really need to differentiate. But I'd assume that in survival mode, the digging/mining speed is essential for the balance of the game. In creative mode, players have access to all materials and they want to build what's on their mind without game mechanics stepping in their way.

In Minecraft, you can mine/dig a lot faster - and without the need of switching tools - in creative mode than in survival mode. I'd like to see about that speed in Minetest creative mode, too.

User avatar
AspireMint
Member
Posts: 415
Joined: Mon Jul 09, 2012 12:59
GitHub: AspireMint
IRC: AspireMint
In-game: AspireMint
Location: Stuck at spawn

Re: Fast mining/digging without tool

by AspireMint » Post

freefall wrote:
Thu Jan 14, 2021 15:31
@AspireMint

Wow, that is really super fast... Frankly, for me, this is too fast. Is there a way to modify your code to end up with something like 1-3 punches per block, no matter which material is involved?
Yup, but now i think overriding tools as Linuxdirk said would simpler,
but then you can't set digging time to any value (there are some limits).
Correct me if im wrong.

So here is modified my solution: https://github.com/AspireMint/fast_puncher
To set digging time (any), just edit first/second line of init.lua.
You wont see digging animation with this mod :-(
But digging with any tool takes same time to dig node.

(mod can be buggy so use at your own risk x) )

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

Re: Fast mining/digging without tool

by Linuxdirk » Post

AspireMint wrote:
Thu Jan 14, 2021 14:51
but will that ":" also override tool capabilities of other tools?
No, it won’t, don’t worry.

Basically the hand is just a tool with benefits :) You can easily modify, replace, override, or change it without affecting anything else – like every other tool. : can be overridden by just using an empty string as item in minetest.override_item().
AspireMint wrote:
Thu Jan 14, 2021 14:51
Please, provide some code. Thanks.

Code: Select all

-- Only alter the “hand tool” when in creative mode, otherwise return early
-- and do nothing.
local is_creative = minetest.is_yes(minetest.settings:get('creative_mode'))
if is_creative == false then return end


-- The times set here cause nodes to be broken/dug with three punches and
-- regardless of group.
local desired_times = { [1] = 0.7, [2] = 0.7, [3] = 0.7 }


-- Alter the hand after all other mods are loaded so mods that modify the
-- hand run first and not override our overrides.
minetest.register_on_mods_loaded(function()
    minetest.override_item('', {
        tool_capabilities = {
            groupcaps = {
                -- You can add groupcaps for more groups here if needed
                oddly_breakable_by_hand = { times = desired_times },
                dig_immediate = { times = desired_times },
                crumbly = { times = desired_times },
                cracky = { times = desired_times },
                choppy = { times = desired_times },
                snappy = { times = desired_times },
            }
        }
    })
end)
With desired_times set to 0 for all values you get super fast digging (instant digging and only hardcoded 0.15 seconds pause between digging of individual nodes).

About the dig_immediate group
About the other groups
About the hardcoded 0.15 seconds pause
… just read the whole chapter :)

freefall
Member
Posts: 19
Joined: Mon Dec 21, 2020 12:20

Re: Fast mining/digging without tool

by freefall » Post

AspireMint wrote:
Thu Jan 14, 2021 20:07
So here is modified my solution: https://github.com/AspireMint/fast_puncher
That's exactly what I was looking for. 0.5 works fine for me. No problem with the missing animation.

Thank you very much.

Have fun,

freefall.

freefall
Member
Posts: 19
Joined: Mon Dec 21, 2020 12:20

Re: Fast mining/digging without tool

by freefall » Post

Linuxdirk wrote:
Thu Jan 14, 2021 20:24
With desired_times set to 0 for all values you get super fast digging (instant digging and only hardcoded 0.15 seconds pause between digging of individual nodes).
This would go into an init.lua of a mod, as well, right?

EDIT: It does.

Have fun,

freefall.
Last edited by freefall on Thu Jan 14, 2021 21:12, edited 1 time in total.

freefall
Member
Posts: 19
Joined: Mon Dec 21, 2020 12:20

Re: Fast mining/digging without tool

by freefall » Post

Linuxdirk wrote:
Thu Jan 14, 2021 20:24
With desired_times set to 0 for all values you get super fast digging (instant digging and only hardcoded 0.15 seconds pause between digging of individual nodes).
This solution also provides the animations. Wonderful. Thanks to both of you!

Have fun,

freefall.

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests