Refactor treetaps
This commit is contained in:
parent
ae123446ad
commit
6147074e05
@ -18,8 +18,6 @@ if industrialtest.mods.mclRubber then
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local S=minetest.get_translator("industrialtest")
|
|
||||||
|
|
||||||
local function onTreetapUse(user,pointed)
|
local function onTreetapUse(user,pointed)
|
||||||
local node=minetest.get_node_or_nil(pointed.under)
|
local node=minetest.get_node_or_nil(pointed.under)
|
||||||
if not node then
|
if not node then
|
||||||
@ -36,34 +34,23 @@ local function onTreetapUse(user,pointed)
|
|||||||
return false
|
return false
|
||||||
end
|
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"),
|
description=S("Treetap"),
|
||||||
inventory_image="industrialtest_treetap.png",
|
inventoryImage="industrialtest_treetap.png",
|
||||||
tool_capabilities={
|
uses=50,
|
||||||
full_punch_interval=1,
|
flammable=2,
|
||||||
uses=50
|
repairMaterial="group:wood"
|
||||||
},
|
})
|
||||||
on_place=function(itemstack,user,pointed)
|
|
||||||
if pointed.type=="node" and user and user:is_player() and onTreetapUse(user,pointed) then
|
function industrialtest.Treetap.use(self,itemstack,user,pointed)
|
||||||
industrialtest.api.afterToolUse(itemstack)
|
return pointed.type=="node" and user and user:is_player() and onTreetapUse(user,pointed)
|
||||||
return itemstack
|
|
||||||
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
|
end
|
||||||
minetest.register_tool("industrialtest:treetap",definition)
|
|
||||||
|
industrialtest.Treetap:register()
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
type="shaped",
|
type="shaped",
|
||||||
output="industrialtest:treetap",
|
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"),
|
description=S("Electric Treetap"),
|
||||||
inventory_image="industrialtest_electric_treetap.png",
|
inventoryImage="industrialtest_electric_treetap.png",
|
||||||
on_place=function(itemstack,user,pointed)
|
capacity=10000,
|
||||||
local meta=itemstack:get_meta()
|
flow=industrialtest.api.lvPowerFlow
|
||||||
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
|
function industrialtest.ElectricTreetap.use(self,itemstack,user,pointed)
|
||||||
end
|
return user and user:is_player() and onTreetapUse(user,pointed)
|
||||||
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
|
|
||||||
end
|
end
|
||||||
minetest.register_tool("industrialtest:electric_treetap",definition)
|
|
||||||
|
function industrialtest.ElectricTreetap.getOpPower(self,itemstack)
|
||||||
|
return 50
|
||||||
|
end
|
||||||
|
|
||||||
|
industrialtest.ElectricTreetap:register()
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
type="shapeless",
|
type="shapeless",
|
||||||
output="industrialtest:electric_treetap",
|
output="industrialtest:electric_treetap",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user