Refactor treetaps

This commit is contained in:
mrkubax10 2025-04-06 22:08:43 +02:00
parent ae123446ad
commit 6147074e05

View File

@ -18,8 +18,6 @@ if industrialtest.mods.mclRubber then
return
end
local S=minetest.get_translator("industrialtest")
local function onTreetapUse(user,pointed)
local node=minetest.get_node_or_nil(pointed.under)
if not node then
@ -36,34 +34,23 @@ local function onTreetapUse(user,pointed)
return false
end
local definition={
local S=minetest.get_translator("industrialtest")
industrialtest.Treetap=table.copy(industrialtest.Tool)
industrialtest.internal.unpackTableInto(industrialtest.Treetap,{
name="industrialtest:treetap",
description=S("Treetap"),
inventory_image="industrialtest_treetap.png",
tool_capabilities={
full_punch_interval=1,
uses=50
},
on_place=function(itemstack,user,pointed)
if pointed.type=="node" and user and user:is_player() and onTreetapUse(user,pointed) then
industrialtest.api.afterToolUse(itemstack)
return itemstack
inventoryImage="industrialtest_treetap.png",
uses=50,
flammable=2,
repairMaterial="group:wood"
})
function industrialtest.Treetap.use(self,itemstack,user,pointed)
return pointed.type=="node" and user and user:is_player() and onTreetapUse(user,pointed)
end
return nil
end,
_industrialtest_tool=true
}
if industrialtest.mtgAvailable then
definition.groups={
flammable=2
}
elseif industrialtest.mclAvailable then
definition.groups={
tool=1
}
definition._repair_material="group:wood"
definition._mcl_toollike_wield=true
end
minetest.register_tool("industrialtest:treetap",definition)
industrialtest.Treetap:register()
minetest.register_craft({
type="shaped",
output="industrialtest:treetap",
@ -74,28 +61,25 @@ minetest.register_craft({
}
})
definition={
industrialtest.ElectricTreetap=table.copy(industrialtest.ElectricTool)
industrialtest.internal.unpackTableInto(industrialtest.ElectricTreetap,{
name="industrialtest:electric_treetap",
description=S("Electric Treetap"),
inventory_image="industrialtest_electric_treetap.png",
on_place=function(itemstack,user,pointed)
local meta=itemstack:get_meta()
if meta:get_int("industrialtest.powerAmount")>=50 and user and user:is_player() and onTreetapUse(user,pointed) then
industrialtest.api.addPowerToItem(itemstack,-50)
return itemstack
inventoryImage="industrialtest_electric_treetap.png",
capacity=10000,
flow=industrialtest.api.lvPowerFlow
})
function industrialtest.ElectricTreetap.use(self,itemstack,user,pointed)
return user and user:is_player() and onTreetapUse(user,pointed)
end
return nil
end,
_industrialtest_powerStorage=true,
_industrialtest_powerCapacity=10000,
_industrialtest_powerFlow=industrialtest.api.lvPowerFlow
}
if industrialtest.mclAvailable then
definition.groups={
tool=1
}
definition._mcl_toollike_wield=true
function industrialtest.ElectricTreetap.getOpPower(self,itemstack)
return 50
end
minetest.register_tool("industrialtest:electric_treetap",definition)
industrialtest.ElectricTreetap:register()
minetest.register_craft({
type="shapeless",
output="industrialtest:electric_treetap",