[Tutorial] How to make sense of digging times and types.

Post Reply
User avatar
Noriel_Sylvire
Member
Posts: 72
Joined: Mon Dec 24, 2018 02:14
GitHub: NorielSylvire
In-game: Noriel_Sylvire
Contact:

[Tutorial] How to make sense of digging times and types.

by Noriel_Sylvire » Post

Hello community!
1. Introduction
1.1 Context
1.2. What you will learn
2. Dig types, digging times, and tool uses
2.1 Dig types
2.2 Digging times
2.3 Tool uses
2.4 Other tool and node properties
3. How to add new tiers of tools and nodes
4. Suggestions for the main developpers of Minetest After struggling for years to understand digging times and dig types, reading countless questions about it in the forums with the answers generally being "My interpretation of the documentation is...." without really being any clearer, or being sure of their answers, and after researching this for a while myself, I've finally come to understand how these concepts are handled in Minetest.
Now I can finally get to coding my ideas into actual mods that work as intended! In this tutorial, you will be able to understand what the dig types are, how the digging times are calculated, what maxlevel and other values really do, how tool uses are calculated, and you will be able to create your own, new tiers of tools and nodes. To start, let's understand what dig types actually are.
Nodes (or blocks) in Minetest can be assigned to certain "groups".
In the case of nodes, groups are mostly used to define what kind of tool is needed to break this block.
For instance, let's take a loot at the definition of the diamond block:

Code: Select all

minetest.register_node("default:diamondblock", {
	description = S("Diamond Block"),
	tiles = {"default_diamond_block.png"},
	is_ground_content = false,
	groups = {cracky = 1, level = 3},
	sounds = default.node_sound_stone_defaults(),
})
This is how the default Minetest mod defines a diamond block.

In the groups section you can see that it has the cracky group assigned, which means that pickaxes are the tool intended to break them.
Other dig types include snappy, crumbly, and oddly_breakable_by_hand, among others. The full list of dig types can be found in the Lua API Documentation.

The number next to the digging type will be referred to as the node's "rating" or "group rating" from here on out.
The node's rating does not actually define how long it takes for it to be broken by a tool. It is merely an "identifier" of sorts, that allows the actual tools to decide how long it'll take them to break the node.

That is, even though most tools are programmed in a way that it takes longer to break a rating 1 node than it takes to break a rating 2 node, and it takes longer to break a rating 2 node than it takes to break a rating 3 node, there's nothing stopping YOU, the mod developper, from making a tool that breaks nodes faster the harder they are (that is, they break diamond blocks faster than they break gold blocks, and break gold blocks faster than they break stone blocks).

As I said earlier, it's the tool, not the node, that decides which nodes they break, and at which speed, depending on their group ratings.
Let's now take a look at a tool from the game:

Code: Select all

minetest.register_tool("default:pick_stone", {
	description = S("Stone Pickaxe"),
	inventory_image = "default_tool_stonepick.png",
	tool_capabilities = {
		full_punch_interval = 1.3,
		max_drop_level=0,
		groupcaps={
			cracky = {times={[2]=2.0, [3]=1.00}, uses=20, maxlevel=1},
		},
		damage_groups = {fleshy=3},
	},
	sound = {breaks = "default_tool_breaks"},
	groups = {pickaxe = 1}
})
This is the way the default mod from Minetest Game defines a stone pickaxe.

If you take a look at the groupcaps section of the table, you'll find that this tool can only break nodes that are in the cracky group (such as stone, iron ore, etc).

Furthermore, they define the maxlevel, which is the maximum level of node that this tool can break.
If you go back and look at the diamond block, you'll see that not only does it have a group and a group rating, it also has a level.

This can be used to make a tool that can break all the cracky nodes in default, but only up to and including level 2 for example, which would allow the tool to break every single block, including obsidian and bronze block, which are cracky rating 1, but that same tool would not be able to mine diamond blocks, because even though the diamond block is a cracky node, and it has a group rating of 1, which we said that our tool can break, the diamond block has a level of 3, and our tool can only break nodes up to level 2. Now that we understand how dig types, group ratings and node levels work, we will take a look at how the game calculates digging times.

If you recall from earlier, in the definition of the stone pickaxe, not only does it say that it can break cracky nodes up to and including level 1 (do not mistake level for group rating), there are also some weird numbers in between.

These numbers represent how long the tool takes to break nodes. Between [] are the group ratings of the nodes, and next to the ratings are decimal numbers that represent how long, in seconds, the tool will take to break a node.

In the case of the stone pickaxe, it can break cracky nodes that have a rating of 2 in 2.0 seconds, and cracky nodes with a rating of 3 in 1.0 seconds. Note that nodes with cracky rating of 1 or any other rating other than 2 and 3 are not mentioned in the tool definition, so any nodes that have a cracky rating of 1 will not be able to be mined by the stone pickaxe. It's not that it doesn't drop anything, it will just not be able to mine it.

You can set the time to any positive decimal value larger than 0.15. Why? Anything smaller and the game will make it take 0.15 seconds to mine each block. There is no delay when mining blocks by repeatedly clicking the nodes, this only applies to holding the left click. So you could theoretically go faster than 0.15 seconds between nodes mined by clicking really fast.

Remember that the 1, 2 and 3 ratings of all default blocks are just "identifiers", you don't need to make rating 1 nodes be mined slower than rating 2, you can set the times at any values you like. The amount of times you can use a tool, or tool uses, are calculated using a simple mathematical function.

As it is explained on the API Documentation, tool uses are calculated based on the difference between the tool's maxlevel property, and the node's level.
Note: Do not confuse a node's level, which is defined inside the node's groups property under the identifier level, with the node's group rating. As explained earlier, the groups rating is an "identifier" of sorts, for the node's tier. However, the rating isn't used in calculating the uses a tool has when breaking a node, its level is used. A node can be cracky rating 2, and node level = 3.

The way uses are calculated is simple:
For nodes with the same level as the tool's maxlevel, said tool can break as many of those nodes as its uses.
As an example, a tool with maxlevel = 3 and uses = 15 will be able to break 15 nodes that have level = 3, like, for example, default:diamondblock.

You could say that breaking a diamond block with this tool takes one use.

However, when the node you're breaking has a lower level than the tool's maxlevel, the number of nodes you can break with the tool increases exponentially, three times to be exact, for every level that the node is below the tool's maxlevel. As an example, default:obsidian has a node level of 2, so our tool will be able to break 3 times as many obsidian nodes as it can break diamond blocks. In this case, the tool would be able to mine 45 obsidian nodes before breaking.

You could say that breaking an obsidian node with this tool takes 1/3 uses, which is to say, you need to break three obsidian nodes to consume one use of the tool.

If you're more mathematically inclined, here's a formula for you to calculate the amount of actual uses a tool has, depending on the difference between a tool's maxlevel and a node's level:
leveldiff = maxlevel-level
actualuses = uses * 3^leveldiff
Note: maxlevel, level and uses are actual parameters you can set in the code, actualuses and leveldiff aren't.

In this table from the API Documentation, you can see a similar example, with a tool with maxlevel = 2, and uses = 20, the amount of actual uses the tool has depending on the leveldiff.
A leveldiff of 0, and it takes 1 node broken to consume 1 use. A leveldiff of 1 and it takes 3 broken nodes to consume 1 use. A leveldiff of 2 and it takes 9 nodes to consume 1 use. A leveldiff of 3 and it takes 27 blocks to consume one tool use. You get the idea.
Although these properties are described in the API in a way that is easy to understand, I'll give a quick summary for people here too.
If you click the property name, it will open the documentation on the exact line where that property is explained. You can also press Ctrl+F when you have opened the documentation and type the word or property you want to learn about, and it will show you exactly where that property is explained in the documentation.
full_punch_interval is a tool property that refers to the time you need to wait between clicks in order to deal full damage.
max_drop_level is the maximum level a node can have and still drop an item. If you use this tool to break a node that has a higher level than this, and this tool can still break the node, the node will not drop anything. This can be useful if you want to have a tool that can break certain nodes but not give any items after they break it. Now we finally reach the fun part!
Do you want, like me, to add new, stronger tools to your mod that can break the stronger nodes that you add?
You now can, and it's not confusing anymore. No weird, hard to understand tables.
Only clear words, straight from my experiments!

Right, so, remember how I said earlier that ratings are just identifiers of sorts, and for some reason they go in reverse? Like rating 1 means stronger than rating 3 but level 3 means stronger than level 1.
That just made no sense to me! Still doesn't really. Although I can understand how it functions, I can't understand why would the devs choose to implement such a confusing system.

In any case, as the node's group rating is just an ID, you are allowed to make your own nodes with any rating you want. For example, following the default way of adding nodes, if you wanted to add a node that was one tier above diamond, you could make it crumbly rating 0. As diamond blocks are rating 1, and the strongest tools in the default mod can only mine up to (or rather down to) rating 1, adding a node with rating 0 would essentially make all vanilla tools unable to mine this new node.
Here is an example I used for testing this, in order to eventually add new tiers to my mod:

Code: Select all

minetest.register_node("[redacted modname]:testblock", {
	description = "Test Block",
	tiles = {"[redacted]_amethyst_block.png"},
	is_ground_content = false,
	groups = {cracky = 0, level = 3},
	sounds = default.node_sound_stone_defaults(),
})
This is essentially a modified diamond block with a different texture and a rating of 0.
If we now add a new tool that can mine nodes with ratings of 0 like this:

Code: Select all

minetest.register_tool([redacted]..":pick_test", {
	description = "hello there general kenobi",
	tool_capabilities = {
		full_punch_interval = 0.5,
		max_drop_level = 3,
		inventory_image = "[redacted]_tool_mithril_pick.png",
		groupcaps = {
				cracky = {times = {[0] = 6, [1] = 3, [2] = 2, [3] = 1}, uses = 6000, maxlevel = 3}
			},
			damage_groups = {fleshy = 1}
		},
		sound = {breaks = "default_tool_breaks"},
		groups = {pickaxe = 1}
})
we would have successfully added a new tier of tool and node, that vanilla tools can't break.

But wait, it doesn't end here!
Do you want to go further?
Of course you do!
If you want to add even more tiers of tools and nodes, you could make them have a negative rating! Like, next, after rating 0, you could add a node with cracky rating -1, and a tool made to be able to break that kind of rating! I've tested it and it works!
But, again, ratings are just IDs for tiers of tools and nodes, you don't need to follow the illogical order of the default mod, you can make the next tier of nodes after diamond be cracky rating 4, and make them take longer to mine than rating 3 or 1. No need to go backwards, advance, to infinity and beyond!

Make tools and nodes with ratings of 4, 5, 6, 7, and more. It can finally make sense.

I tried it with decimal values, such as -4.5 or 5.2. These values will work and won't throw any exceptions, but thanks to a kind user named LMD, I believe the reason it works is because these numbers are being rounded/truncated to make them into integers. So don't use decimal values, it will give you unexpected and undesirable results.

This was my last test, by the way:

Code: Select all

minetest.register_tool([redacted]..":pick_test", {
	description = "hello there general kenobi",
	tool_capabilities = {
		full_punch_interval = 0.5,
		max_drop_level = 3,
		inventory_image = "[redacted]_tool_mithril_pick.png",
		groupcaps = {
				cracky = {times = {[0] = 6, [1] = 3, [2] = 2, [3] = 1, ["yes, my friend :)"] = 6}, uses = 6000, maxlevel = 3}
			},
			damage_groups = {fleshy = 1}
		},
		sound = {breaks = "default_tool_breaks"},
		groups = {pickaxe = 1}
})

minetest.register_node("[redacted]:testblock", {
	description = "Test Block",
	tiles = {"[redacted]_amethyst_block.png"},
	is_ground_content = false,
	groups = {cracky = "yes, my friend :)", level = 3},
	sounds = default.node_sound_stone_defaults(),
})
Sadly, it doesn't work. And it wasn't because of the :).
It has its limitations; the rating must be an integer between -31999 and 31999. Other than that, you're good to go.

And that's it! Have fun! I'll go back to making my mod in peace, without getting headaches because of this. Please! Update the documentation. It's extremely well explained most of the times, but when it comes to dig types and digging times it's a whole headache.
You can include bits and pieces of this tutorial if you wish, just please, make it easier for noobs like myself to understand.

Also, might be a good idea to change all the ratings of 1 to 3, and all the ratings of 3 to 1, so that it follows a logical progression of "bigger number = bigger wait for the node to become not a node anymore", and so that it's easier for people to understand how it works, how digging times are calculated, and how to add new tiers of tools and nodes to the game.

Thank you so much for this incredible program. Have an amazing day!
Last edited by Noriel_Sylvire on Sat May 20, 2023 23:53, edited 9 times in total.
My Games πŸ‘ΎπŸ‰ | My Mods πŸ”§πŸ§ͺπŸŽ„πŸŽƒ | My GitHub πŸ’»πŸ“š

User avatar
Noriel_Sylvire
Member
Posts: 72
Joined: Mon Dec 24, 2018 02:14
GitHub: NorielSylvire
In-game: Noriel_Sylvire
Contact:

Re: [Tutorial] How to make sense of digging times and types.

by Noriel_Sylvire » Post

This was my previous post about this topic. I finally understand it :D
I've also read many other posts and the documentation, and still wasn't able to understand this fully before testing around and making my own tools and blocks for the purposes of testing.
My Games πŸ‘ΎπŸ‰ | My Mods πŸ”§πŸ§ͺπŸŽ„πŸŽƒ | My GitHub πŸ’»πŸ“š

User avatar
Skamiz Kazzarch
Member
Posts: 613
Joined: Fri Mar 09, 2018 20:34
GitHub: Skamiz
In-game: Skamiz
Location: la lojbaugag.

Re: [Tutorial] How to make sense of digging times and types.

by Skamiz Kazzarch » Post

Good post. This is the kind of content that I would like to see on the dev wiki.
One thing you missed is the effect which the difference of the tools 'maxlevel' and the nodes 'level' has on numebr of uses and digging speed.

The reorganization of group levels to a more sensible order isn't happening, MTG has way too much history with the current system. Even before it was moved to maintenance mode, such a braking change would never go through.
The best you can hope for on that front is that developers of new content (who don't care to keep compatibility with the old) don't just copy the old system.

There's two or three projects buried somewhere in the forum, that completely refactor MTG to un-weave the mess that it has become due to it's gradual development and smoothen out all sorts of irreguralities, which maybe also change the group order.
And while I love the idea in principle, it just never really caught on.

User avatar
LMD
Member
Posts: 1386
Joined: Sat Apr 08, 2017 08:16
GitHub: appgurueu
IRC: appguru[eu]
In-game: LMD
Location: Germany
Contact:

Re: [Tutorial] How to make sense of digging times and types.

by LMD » Post

the rating must be a real number
Pretty sure it must be a s16 (= Java short). That is, an integer number in a range from about -32k to +32k.

Otherwise good job explaining this!
My stuff: Projects - Mods - Website

User avatar
Noriel_Sylvire
Member
Posts: 72
Joined: Mon Dec 24, 2018 02:14
GitHub: NorielSylvire
In-game: Noriel_Sylvire
Contact:

Re: [Tutorial] How to make sense of digging times and types.

by Noriel_Sylvire » Post

Skamiz Kazzarch wrote: ↑
Fri Feb 18, 2022 20:40
Good post. This is the kind of content that I would like to see on the dev wiki.
One thing you missed is the effect which the difference of the tools 'maxlevel' and the nodes 'level' has on numebr of uses and digging speed.

The reorganization of group levels to a more sensible order isn't happening, MTG has way too much history with the current system. Even before it was moved to maintenance mode, such a braking change would never go through.
The best you can hope for on that front is that developers of new content (who don't care to keep compatibility with the old) don't just copy the old system.

There's two or three projects buried somewhere in the forum, that completely refactor MTG to un-weave the mess that it has become due to it's gradual development and smoothen out all sorts of irreguralities, which maybe also change the group order.
And while I love the idea in principle, it just never really caught on.
I purposedly left that part out of the tutorial as I think it's well explained in the documentation, and less confusing than the explanation on digging times and such. But if you want me to I can update the post to include number of uses as well :)

As for the reorganisation, I found that after you actually understand how these concepts work and organise your own code a bit, it becomes feasible to work around this system: to add new tiers, I just kept 1 as the diamond tier, 3 as the stone tier, and then 4, 5, and so on represent tiers above diamond, in numerical order. Still, I'll look at those projects you talk about, they sound really interesting.
My Games πŸ‘ΎπŸ‰ | My Mods πŸ”§πŸ§ͺπŸŽ„πŸŽƒ | My GitHub πŸ’»πŸ“š

User avatar
Noriel_Sylvire
Member
Posts: 72
Joined: Mon Dec 24, 2018 02:14
GitHub: NorielSylvire
In-game: Noriel_Sylvire
Contact:

Re: [Tutorial] How to make sense of digging times and types.

by Noriel_Sylvire » Post

LMD wrote: ↑
Sat Feb 19, 2022 10:25
the rating must be a real number
Pretty sure it must be a s16 (= Java short). That is, an integer number in a range from about -32k to +32k.

Otherwise good job explaining this!
Well, I don't know what it must be according to the implementation, but the result was that, after using decimals (such as -4.5, an actual number I used) it still works and throws no errors. I didn't want to misrepresent the code, these are just the results I got from my tests.
My Games πŸ‘ΎπŸ‰ | My Mods πŸ”§πŸ§ͺπŸŽ„πŸŽƒ | My GitHub πŸ’»πŸ“š

User avatar
LMD
Member
Posts: 1386
Joined: Sat Apr 08, 2017 08:16
GitHub: appgurueu
IRC: appguru[eu]
In-game: LMD
Location: Germany
Contact:

Re: [Tutorial] How to make sense of digging times and types.

by LMD » Post

Fl4v1u5 wrote: ↑
Sat Feb 19, 2022 23:55
LMD wrote: ↑
Sat Feb 19, 2022 10:25
the rating must be a real number
Pretty sure it must be a s16 (= Java short). That is, an integer number in a range from about -32k to +32k.

Otherwise good job explaining this!
Well, I don't know what it must be according to the implementation, but the result was that, after using decimals (such as -4.5, an actual number I used) it still works and throws no errors. I didn't want to misrepresent the code, these are just the results I got from my tests.
I assume Minetest will round or floor that to -4 or -5. As said, shorts are used, see the docs. While using floating-point values might work, it has no effect other than the floored/rounded? integer values. You shouldn't be using floats where ints are expected.
My stuff: Projects - Mods - Website

User avatar
Skamiz Kazzarch
Member
Posts: 613
Joined: Fri Mar 09, 2018 20:34
GitHub: Skamiz
In-game: Skamiz
Location: la lojbaugag.

Re: [Tutorial] How to make sense of digging times and types.

by Skamiz Kazzarch » Post

Fl4v1u5 wrote: ↑
Sat Feb 19, 2022 23:53
~snip~
I think it at least bears mentioning, so people aren't taken by surprise if they didn't read the official documentation. Maybe add a link to the relevant section?

Also tested out the decimals as identifiers and they indeed seemed to round down.

User avatar
Noriel_Sylvire
Member
Posts: 72
Joined: Mon Dec 24, 2018 02:14
GitHub: NorielSylvire
In-game: Noriel_Sylvire
Contact:

Re: [Tutorial] How to make sense of digging times and types.

by Noriel_Sylvire » Post

LMD wrote: ↑
Sun Feb 20, 2022 00:14
Fl4v1u5 wrote: ↑
Sat Feb 19, 2022 23:55
LMD wrote: ↑
Sat Feb 19, 2022 10:25


Pretty sure it must be a s16 (= Java short). That is, an integer number in a range from about -32k to +32k.

Otherwise good job explaining this!
Well, I don't know what it must be according to the implementation, but the result was that, after using decimals (such as -4.5, an actual number I used) it still works and throws no errors. I didn't want to misrepresent the code, these are just the results I got from my tests.
I assume Minetest will round or floor that to -4 or -5. As said, shorts are used, see the docs. While using floating-point values might work, it has no effect other than the floored/rounded? integer values. You shouldn't be using floats where ints are expected.
That makes sense, let me edit the tutorial real quick
My Games πŸ‘ΎπŸ‰ | My Mods πŸ”§πŸ§ͺπŸŽ„πŸŽƒ | My GitHub πŸ’»πŸ“š

User avatar
Noriel_Sylvire
Member
Posts: 72
Joined: Mon Dec 24, 2018 02:14
GitHub: NorielSylvire
In-game: Noriel_Sylvire
Contact:

Re: [Tutorial] How to make sense of digging times and types.

by Noriel_Sylvire » Post

Skamiz Kazzarch wrote: ↑
Sun Feb 20, 2022 07:02
Fl4v1u5 wrote: ↑
Sat Feb 19, 2022 23:53
~snip~
I think it at least bears mentioning, so people aren't taken by surprise if they didn't read the official documentation. Maybe add a link to the relevant section?

Also tested out the decimals as identifiers and they indeed seemed to round down.
Hello! I edited the post to correct my claim about real numbers.
And indeed, I can add links to anything you want me to, as long as it's related to the topic.
Sadly, I didn't understand exactly what you mean in your reply. Do you want me to add links to the official API documentation? I can do that no problem!
My Games πŸ‘ΎπŸ‰ | My Mods πŸ”§πŸ§ͺπŸŽ„πŸŽƒ | My GitHub πŸ’»πŸ“š

User avatar
Skamiz Kazzarch
Member
Posts: 613
Joined: Fri Mar 09, 2018 20:34
GitHub: Skamiz
In-game: Skamiz
Location: la lojbaugag.

Re: [Tutorial] How to make sense of digging times and types.

by Skamiz Kazzarch » Post

Since you said that the effect of the level difference between tool and node on digging speed and how fast the tool durability degrades is sufficiently well explained in the official API documentation I thought you could just briefly mention it and provide a link to the place in the documentation where it's explained.

User avatar
Noriel_Sylvire
Member
Posts: 72
Joined: Mon Dec 24, 2018 02:14
GitHub: NorielSylvire
In-game: Noriel_Sylvire
Contact:

Re: [Tutorial] How to make sense of digging times and types.

by Noriel_Sylvire » Post

Skamiz Kazzarch wrote: ↑
Sun Feb 20, 2022 13:04
Since you said that the effect of the level difference between tool and node on digging speed and how fast the tool durability degrades is sufficiently well explained in the official API documentation I thought you could just briefly mention it and provide a link to the place in the documentation where it's explained.
Instead, what I did was add a section to the tutorial, explaining how tool uses are calculated, with links to the documentation where this and the other concepts are explained.
My Games πŸ‘ΎπŸ‰ | My Mods πŸ”§πŸ§ͺπŸŽ„πŸŽƒ | My GitHub πŸ’»πŸ“š

LCDev
Member
Posts: 11
Joined: Fri Mar 25, 2022 13:25

Re: [Tutorial] How to make sense of digging times and types.

by LCDev » Post

Thank you so much, Fl4v1u5, for explaining these concepts! Now I also finally understand how they work and how to use them correctly and effectively.

There are however still 2 values in the tool definition, which are very mysterious to me:
tool_capabilities = {
full_punch_interval = 1.3,
max_drop_level=0,

Can you or anyone else (LMD?) please explain what these are (full_punch_interval and max_drop_level) and how they are used? Most basic / low level tools seem to have a max_drop_level of 0 to 1, and then it increases as tools get more powerful...? But I still don't know what it really means. I tried to find info on these parameters, but there doesn't seem to be anything on them in the lua_api or Minetest Modding Book or anywhere else that I looked.

User avatar
StarNinjas
Member
Posts: 411
Joined: Wed Mar 14, 2018 00:32
GitHub: starninjas
IRC: StarNinjas
In-game: J1
Location: Terrarca
Contact:

Re: [Tutorial] How to make sense of digging times and types.

by StarNinjas » Post

Nice!
Don't go to bed tonight, without knowing what would happen if you died. https://thegospelfilm.org/

LCDev
Member
Posts: 11
Joined: Fri Mar 25, 2022 13:25

Re: [Tutorial] How to make sense of digging times and types.

by LCDev » Post

I looked at the Lua API again, and this time I did find the explanations about those parameters:

### Full punch interval
When used as a weapon, the item will do full damage if this time is spent between punches. If e.g. half the time is spent, the item will do half damage.

### Maximum drop level
Suggests the maximum level of node, when dug with the item, that will drop its useful item. (e.g. iron ore to drop a lump of iron). This is not automated; it is the responsibility of the node definition to implement this.

User avatar
Noriel_Sylvire
Member
Posts: 72
Joined: Mon Dec 24, 2018 02:14
GitHub: NorielSylvire
In-game: Noriel_Sylvire
Contact:

Re: [Tutorial] How to make sense of digging times and types.

by Noriel_Sylvire » Post

LCDev wrote: ↑
Sun May 15, 2022 20:11
Thank you so much, Fl4v1u5, for explaining these concepts! Now I also finally understand how they work and how to use them correctly and effectively.

There are however still 2 values in the tool definition, which are very mysterious to me:
tool_capabilities = {
full_punch_interval = 1.3,
max_drop_level=0,

Can you or anyone else (LMD?) please explain what these are (full_punch_interval and max_drop_level) and how they are used? Most basic / low level tools seem to have a max_drop_level of 0 to 1, and then it increases as tools get more powerful...? But I still don't know what it really means. I tried to find info on these parameters, but there doesn't seem to be anything on them in the lua_api or Minetest Modding Book or anywhere else that I looked.
Hi!!
First of all, I am sorry to have taken such a long time to respond. I am currently going through a number of personal circumstances that need my attention and I can't spend as much time in minetest as before.

That being said, I am incredibly happy to learn that my tutorial has helped people understand more about Minetest. I feel useful :)

And to answer your question, full_punch_interval is the time you need to wait between punches to deal full damage when you hit enemies with it. That means, if you use that item as a weapon and start spam clicking it, it will do less damane than if you just click once, wait, in your example, 1.3 seconds, and then click again. It's sort of how the new fighting system in Minecraft works, only they have a nice UI bar that fills up with time to show you when you're ready to hit and us, we don't quite have such great graphics.

The max_drop_level is the maximum level that a node can have, such that "when you break it, it drops its useful item".
What this means is, if your tool can break nodes of level 3 but its max drop level is 2, you can break level 3 nodes with that tool but they won't drop stuff. I usually leave the max_drop_level with the same value as the max_level because I don't like the idea that you can break stuff and not get stuff in return, but you're free to do as you wish!

I'll now edit the tutorial and add these definitions.

Oh wait, one more thing, I recommend that, when viewing the API, you can press Ctrl+F, and that opes a window where you can put the text you're looking for and it'll search it for you and show you where it is.
As an example, open the API link I just gave you, press Ctrl+F and type "full_punch" I bet that before you even get to type "_interval" the finder tool will have already found what you were looking for in the API. Try it, trust me :)
My Games πŸ‘ΎπŸ‰ | My Mods πŸ”§πŸ§ͺπŸŽ„πŸŽƒ | My GitHub πŸ’»πŸ“š

User avatar
Noriel_Sylvire
Member
Posts: 72
Joined: Mon Dec 24, 2018 02:14
GitHub: NorielSylvire
In-game: Noriel_Sylvire
Contact:

Re: [Tutorial] How to make sense of digging times and types.

by Noriel_Sylvire » Post

LCDev wrote: ↑
Mon May 16, 2022 14:17
I looked at the Lua API again, and this time I did find the explanations about those parameters:

### Full punch interval
When used as a weapon, the item will do full damage if this time is spent between punches. If e.g. half the time is spent, the item will do half damage.

### Maximum drop level
Suggests the maximum level of node, when dug with the item, that will drop its useful item. (e.g. iron ore to drop a lump of iron). This is not automated; it is the responsibility of the node definition to implement this.
Yes, that is where it is explained, sorry for not replying quickly enough.
My Games πŸ‘ΎπŸ‰ | My Mods πŸ”§πŸ§ͺπŸŽ„πŸŽƒ | My GitHub πŸ’»πŸ“š

LCDev
Member
Posts: 11
Joined: Fri Mar 25, 2022 13:25

Re: [Tutorial] How to make sense of digging times and types.

by LCDev » Post

Fl4v1u5 wrote: ↑
Tue Jun 14, 2022 19:35
LCDev wrote: ↑
Sun May 15, 2022 20:11
Thank you so much, Fl4v1u5, for explaining these concepts! Now I also finally understand how they work and how to use them correctly and effectively.

There are however still 2 values in the tool definition, which are very mysterious to me:
tool_capabilities = {
full_punch_interval = 1.3,
max_drop_level=0,

Can you or anyone else (LMD?) please explain what these are (full_punch_interval and max_drop_level) and how they are used? Most basic / low level tools seem to have a max_drop_level of 0 to 1, and then it increases as tools get more powerful...? But I still don't know what it really means. I tried to find info on these parameters, but there doesn't seem to be anything on them in the lua_api or Minetest Modding Book or anywhere else that I looked.
Hi!!
First of all, I am sorry to have taken such a long time to respond. I am currently going through a number of personal circumstances that need my attention and I can't spend as much time in minetest as before.

That being said, I am incredibly happy to learn that my tutorial has helped people understand more about Minetest. I feel useful :)

And to answer your question, full_punch_interval is the time you need to wait between punches to deal full damage when you hit enemies with it. That means, if you use that item as a weapon and start spam clicking it, it will do less damane than if you just click once, wait, in your example, 1.3 seconds, and then click again. It's sort of how the new fighting system in Minecraft works, only they have a nice UI bar that fills up with time to show you when you're ready to hit and us, we don't quite have such great graphics.

The max_drop_level is the maximum level that a node can have, such that "when you break it, it drops its useful item".
What this means is, if your tool can break nodes of level 3 but its max drop level is 2, you can break level 3 nodes with that tool but they won't drop stuff. I usually leave the max_drop_level with the same value as the max_level because I don't like the idea that you can break stuff and not get stuff in return, but you're free to do as you wish!

I'll now edit the tutorial and add these definitions.

Oh wait, one more thing, I recommend that, when viewing the API, you can press Ctrl+F, and that opes a window where you can put the text you're looking for and it'll search it for you and show you where it is.
As an example, open the API link I just gave you, press Ctrl+F and type "full_punch" I bet that before you even get to type "_interval" the finder tool will have already found what you were looking for in the API. Try it, trust me :)

Hi. Thanks a lot for your very clear explanation! Don't worry about taking time to respond - we all have things to deal with and I understand all too well that "life happens" :)

Hopefully the explanations added to your tutorial (resulting from questions and research by curious noobs like me) will help more people to get a better understanding of the Minetest mechanics and to make better mods.

Take care.

User avatar
sirrobzeroone
Member
Posts: 593
Joined: Mon Jul 16, 2018 07:56
GitHub: sirrobzeroone
Contact:

Re: [Tutorial] How to make sense of digging times and types.

by sirrobzeroone » Post

Adding a big thanks as well, I read over this to refresh myself on tools and node dig times much easier :)

Icalasari
Member
Posts: 166
Joined: Tue Sep 23, 2014 05:29
IRC: Icalasari
In-game: Icalasari

Re: [Tutorial] How to make sense of digging times and types.

by Icalasari » Post

If there's a max_drop_level function, isn't it technically possible to have tiers of items? e.g. If you break a level 3 node with a level 2 tool, you may get diamond shards, but if you break it with a level 3 tool you will get diamonds? Or is it not geared for that?

User avatar
sirrobzeroone
Member
Posts: 593
Joined: Mon Jul 16, 2018 07:56
GitHub: sirrobzeroone
Contact:

Re: [Tutorial] How to make sense of digging times and types.

by sirrobzeroone » Post

Icalasari wrote: ↑
Tue Jul 12, 2022 19:47
If there's a max_drop_level function, isn't it technically possible to have tiers of items? e.g. If you break a level 3 node with a level 2 tool, you may get diamond shards, but if you break it with a level 3 tool you will get diamonds? Or is it not geared for that?
Sorry bit of a slow reply.....

Theres a section in node drops that can be configured to do that (see the drop block):
https://minetest.gitlab.io/minetest/def ... definition

Theres also minetest.handle_node_drops(pos, drops, digger) - ethereal implements crystal shovel special drops this way (https://notabug.org/TenPlus1/ethereal/s ... l.lua#L223):
https://minetest.gitlab.io/minetest/min ... m-handling

Theres other ways but I think for what you want to do the above two are the easiest and the 1st may be exactly what your after.

User avatar
Noriel_Sylvire
Member
Posts: 72
Joined: Mon Dec 24, 2018 02:14
GitHub: NorielSylvire
In-game: Noriel_Sylvire
Contact:

Re: [Tutorial] How to make sense of digging times and types.

by Noriel_Sylvire » Post

Hello everyone!

I have a few things to say:

  1. This tutorial will get a do-over as soon as I can, because it was written in broken English and I think I can do a much better job, and because I believe the examples used were confusing.

  2. Take a look at my mod NSMC, which is an API that makes creating new minerals with any tier you want easier. How? It comes with a number of pre-installed textures, and you can color them with code very easily. All the boring configuration like the noise your tools/nodes make when they break is set up automatically for you, so you can focus on what you wanna do. I made that mod using what I learned from my tests from this tutorial, so if you wanna see an example do check NSMC's code out!

  3. Icalasari wrote: ↑
    Tue Jul 12, 2022 19:47
    Hey! That is a very original and interesting idea: having a node drop different items depending on the tier of tool you use.

    When I get the time, I may attempt to add this feature to my API to make it easier for anyone to make a mod that does this.

Much love, keep playing/coding open source games! πŸ‰πŸ”§
My Games πŸ‘ΎπŸ‰ | My Mods πŸ”§πŸ§ͺπŸŽ„πŸŽƒ | My GitHub πŸ’»πŸ“š

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests