Closed Diablosxm closed 6 months ago
Adding toolranks support , but pickaxe has conflict with function after_use of nether:pickaxe and toolranks_after_use. i m not a Dev, if anyone can help , pls
@Diablosxm - Nether Pick already has an after_use function in effect which will break compatibility if overwritten:
https://github.com/minetest-mods/nether/blob/master/tools.lua#L37
i saw that , any tricks to composing with that ? i ask in toolranks forum to. you think is a good adding any chance to be commited ?
At the risk of complicating and coupling the code, toolranks support could be added like:
if minetest.get_modpath("toolranks") then
function add_toolranks(name)
local nethertool_after_use = ItemStack(name):get_definition().after_use
toolranks.add_tool(name)
local toolranks_after_use = ItemStack(name):get_definition().after_use
if (nethertool_after_use ~= nil and nethertool_after_use ~= toolranks_after_use) then
minetest.override_item(name, {
after_use = function(itemstack, user, node, digparams)
-- combine nethertool_after_use and toolranks_after_use by allowing
-- nethertool_after_use() to calculate the wear...
local initialWear = itemstack:get_wear()
itemstack = nethertool_after_use(itemstack, user, node, digparams)
local wear = itemstack:get_wear() - initialWear
itemstack:set_wear(initialWear) -- restore/undo the wear
-- ...and have toolranks_after_use() apply the wear.
digparams.wear = wear
return toolranks_after_use(itemstack, user, node, digparams)
end
})
end
end
add_toolranks("nether:pick_nether")
add_toolranks("nether:shovel_nether")
add_toolranks("nether:axe_nether")
add_toolranks("nether:sword_nether")
end
"toolranks" and "technic" could also be added to the read_globals
in .luacheckrc
Hi , Treer. very kind of you for your help but unfortunately i try and itis not working.
but unfortunately i try and itis not working.
Could you give details about what's going wrong, or provide a screenshot.
(the code is supposed to replace the changes you made at the bottom of tools.lua
)
indeed....sorry,The toolranks works , counting dug and do leveling , but for the pickaxe nether normaly it suppose to be well with netherrack , digging 350 before breaking. it is only dig 35 .
It works for me - the pickaxe is digging way more that 35 netherrack, and the toolranks counts are shown.
Perhaps the toolranks.add_tool("nether:axe_nether")
call wasn't removed/replaced when you tried it? I've made a branch that contains the code I was running - https://github.com/Treer/nether/tree/feature/toolranks-support
(I can raise that change as a pull-request into your own nether repo if you want)
It also contains this unrelated change, which doesn't make any functional difference but removes a luacheck warning.
Sure you can pull-request and i really appreciate your help thank you very much.
adding some recipe to use with technic mod machine