Page 1 of 1

register_tool uses

PostPosted: Fri Apr 11, 2014 18:08
by Kilarin
Pardon my extreme ignorance, but I've got a very basic modding question.

The wiki says that a pickaxe is good for:
wooden: uses=30
stone: uses=60
steel: uses=180
bronze: uses=270
mese: uses=580
diamond: uses=810

But when I look in minetest\games\minetest_game\mods\default\tools.lua I see:
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_tool("default:pick_wood", {
    description = "Wooden Pickaxe",
    inventory_image = "default_tool_woodpick.png",
    tool_capabilities = {
        full_punch_interval = 1.2,
        max_drop_level=0,
        groupcaps={
            cracky = {times={[3]=1.60}, uses=10, maxlevel=1},
        },
        damage_groups = {fleshy=2},
    },
})

With
wood: uses=10
stone: uses=20
steel: uses=20
bronze: uses=30
mese: uses=20
diamond: uses=30

Which... confuses me.

I found this: http://c55.me/minetest2/wiki/doku.php?id=roadmap:digging_time_groups

which indicates that there is a maxwear option that could be set, but I don't find it anywhere in the lua files.

So how do I translate (or set) the uses value in tool_capabilities into number of blocks dug?

Thanks,

PostPosted: Fri Apr 11, 2014 19:43
by PilzAdam
The wiki you linked is very old and outdated.

The uses of a tool are multiplied by 3^leveldiff (https://github.com/minetest/minetest/blob/142e2d3b74ad886eed83b0fc9d6cfea100dae10a/doc/lua_api.txt#L736).

PostPosted: Fri Apr 11, 2014 20:17
by Kilarin
PilzAdam wrote:The uses of a tool are multiplied by 3^leveldiff

Thank you for the link!
So, am I understanding correctly that this means a pickaxe is used up more quickly when digging "harder" nodes? So that your pickaxe would wear out a lot faster digging obsidian than digging stone?

PostPosted: Fri Apr 11, 2014 20:18
by PilzAdam
Kilarin wrote:
PilzAdam wrote:The uses of a tool are multiplied by 3^leveldiff

Thank you for the link!
So, am I understanding correctly that this means a pickaxe is used up more quickly when digging "harder" nodes? So that your pickaxe would wear out a lot faster digging obsidian than digging stone?

Yes.

PostPosted: Fri Apr 11, 2014 20:21
by stu
Kilarin wrote:
PilzAdam wrote:The uses of a tool are multiplied by 3^leveldiff

Thank you for the link!
So, am I understanding correctly that this means a pickaxe is used up more quickly when digging "harder" nodes? So that your pickaxe would wear out a lot faster digging obsidian than digging stone?


If you want to override this default behaviour then you can add item wear explicitly in the on_use callback.

PostPosted: Fri Apr 11, 2014 20:50
by Kilarin
stu wrote:If you want to override this default behaviour then you can add item wear explicitly in the on_use callback.

Not my intention, but nice to know, thanks!