Merge pull request #1 from Treer/feature/toolranks-support

Feature/toolranks support
This commit is contained in:
Diablosxm 2023-06-01 21:32:21 -04:00 committed by GitHub
commit 0301d9f1ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 8 deletions

View File

@ -27,9 +27,12 @@ read_globals = {
"stairsplus", "stairsplus",
"string.split", "string.split",
table = { fields = { "copy", "getn" } }, table = { fields = { "copy", "getn" } },
"technic",
"toolranks",
"vector", "vector",
"VoxelArea", "VoxelArea",
"VoxelManip", "VoxelManip",
"walls",
xpanes = { fields = { "register_pane" } }, xpanes = { fields = { "register_pane" } },
} }

View File

@ -2,7 +2,7 @@ local S = minetest.get_translator("nether")
technic.register_recipe_type("compressing", { description = S("Compressing") }) technic.register_recipe_type("compressing", { description = S("Compressing") })
function technic.register_compressor_recipe(data) function register_compressor_recipe(data)
data.time = data.time or 4 data.time = data.time or 4
technic.register_recipe("compressing", data) technic.register_recipe("compressing", data)
end end
@ -46,7 +46,7 @@ minetest.clear_craft({
}) })
for _, data in pairs(recipes) do for _, data in pairs(recipes) do
technic.register_compressor_recipe({input = {data[1]}, output = data[2], time = data[3]}) register_compressor_recipe({input = {data[1]}, output = data[2], time = data[3]})
end end

View File

@ -153,6 +153,36 @@ minetest.register_craft({
}) })
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
--===========================-- --===========================--
@ -360,9 +390,3 @@ minetest.register_tool("nether:lightstaff_eternal", {
return itemstack return itemstack
end end
}) })
if minetest.get_modpath("toolranks") then
-- toolranks.add_tool("nether:pick_nether")
toolranks.add_tool("nether:shovel_nether")
toolranks.add_tool("nether:axe_nether")
toolranks.add_tool("nether:sword_nether")
end