Compare commits
No commits in common. "62246bf91b1413b6beab88c0b513038208faa368" and "089550cc28c0812d400c1edb3fb6d1a2bf4024f3" have entirely different histories.
62246bf91b
...
089550cc28
@ -53,29 +53,6 @@ function industrialtest.Tool.onPlace(self,itemstack,user,pointed)
|
||||
return false
|
||||
end
|
||||
|
||||
function industrialtest.Tool.onUse(self,itemstack,user,pointed)
|
||||
if self:hitUse(itemstack,user,pointed) then
|
||||
local meta=itemstack:get_meta()
|
||||
if not meta:contains("industrialtest.uses") then
|
||||
self:prepare(itemstack)
|
||||
end
|
||||
local uses=meta:get_int("industrialtest.uses")-1
|
||||
if uses==0 then
|
||||
itemstack:set_count(0)
|
||||
minetest.sound_play({name="default_tool_breaks"},{
|
||||
gain=1,
|
||||
fade=0,
|
||||
pitch=1
|
||||
},true)
|
||||
return true
|
||||
end
|
||||
meta:set_int("industrialtest.uses",uses)
|
||||
itemstack:set_wear(65535-uses/self.uses*65535)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function industrialtest.Tool.prepare(self,itemstack)
|
||||
local meta=itemstack:get_meta()
|
||||
meta:set_int("industrialtest.uses",self.uses)
|
||||
|
@ -19,9 +19,6 @@ if industrialtest.mods.mclRubber then
|
||||
end
|
||||
|
||||
local function onTreetapUse(user,pointed)
|
||||
if pointed.type~="node" or not user or not user:is_player() then
|
||||
return false
|
||||
end
|
||||
local node=minetest.get_node_or_nil(pointed.under)
|
||||
if not node then
|
||||
return false
|
||||
@ -50,7 +47,7 @@ industrialtest.internal.unpackTableInto(industrialtest.Treetap,{
|
||||
})
|
||||
|
||||
function industrialtest.Treetap.use(self,itemstack,user,pointed)
|
||||
return onTreetapUse(user,pointed)
|
||||
return pointed.type=="node" and user and user:is_player() and onTreetapUse(user,pointed)
|
||||
end
|
||||
|
||||
industrialtest.Treetap:register()
|
||||
@ -76,7 +73,7 @@ industrialtest.internal.unpackTableInto(industrialtest.ElectricTreetap,{
|
||||
})
|
||||
|
||||
function industrialtest.ElectricTreetap.use(self,itemstack,user,pointed)
|
||||
return onTreetapUse(user,pointed)
|
||||
return user and user:is_player() and onTreetapUse(user,pointed)
|
||||
end
|
||||
|
||||
function industrialtest.ElectricTreetap.getOpPower(self,itemstack)
|
||||
|
@ -16,9 +16,6 @@
|
||||
local S=minetest.get_translator("industrialtest")
|
||||
|
||||
local function onWrenchUse(user,pointed)
|
||||
if pointed.type~="node" or not user or not user:is_player() then
|
||||
return false
|
||||
end
|
||||
local node=minetest.get_node_or_nil(pointed.under)
|
||||
if not node then
|
||||
return false
|
||||
@ -40,22 +37,29 @@ local function onWrenchUse(user,pointed)
|
||||
return true
|
||||
end
|
||||
|
||||
industrialtest.Wrench=table.copy(industrialtest.Tool)
|
||||
industrialtest.internal.unpackTableInto(industrialtest.Wrench,{
|
||||
name="industrialtest:wrench",
|
||||
define={onUse=true},
|
||||
local definition={
|
||||
description=S("Wrench"),
|
||||
inventoryImage="industrialtest_wrench.png",
|
||||
uses=200,
|
||||
repairMaterial=industrialtest.elementKeys.bronzeIngot
|
||||
})
|
||||
|
||||
function industrialtest.Wrench.hitUse(self,itemstack,user,pointed)
|
||||
return onWrenchUse(user,pointed)
|
||||
inventory_image="industrialtest_wrench.png",
|
||||
tool_capabilities={
|
||||
full_punch_interval=1,
|
||||
uses=200
|
||||
},
|
||||
on_use=function(itemstack,user,pointed)
|
||||
if pointed.type=="node" and user and user:is_player() and onWrenchUse(user,pointed) then
|
||||
industrialtest.api.afterToolUse(itemstack)
|
||||
return itemstack
|
||||
end
|
||||
|
||||
industrialtest.Wrench:register()
|
||||
|
||||
return nil
|
||||
end,
|
||||
_industrialtest_tool=true
|
||||
}
|
||||
if industrialtest.mclAvailable then
|
||||
definition.groups={
|
||||
tool=1
|
||||
}
|
||||
definition._mcl_toollike_wield=true
|
||||
end
|
||||
minetest.register_tool("industrialtest:wrench",definition)
|
||||
minetest.register_craft({
|
||||
type="shaped",
|
||||
output="industrialtest:wrench",
|
||||
@ -66,26 +70,28 @@ minetest.register_craft({
|
||||
}
|
||||
})
|
||||
|
||||
industrialtest.ElectricWrench=table.copy(industrialtest.ElectricTool)
|
||||
industrialtest.internal.unpackTableInto(industrialtest.ElectricWrench,{
|
||||
name="industrialtest:electric_wrench",
|
||||
define={onUse=true},
|
||||
definition={
|
||||
description=S("Electric Wrench"),
|
||||
inventoryImage="industrialtest_electric_wrench.png",
|
||||
capacity=10000,
|
||||
flow=industrialtest.api.lvPowerFlow
|
||||
})
|
||||
|
||||
function industrialtest.ElectricWrench.getOpPower(self,itemstack)
|
||||
return 50
|
||||
inventory_image="industrialtest_electric_wrench.png",
|
||||
on_use=function(itemstack,user,pointed)
|
||||
local meta=itemstack:get_meta()
|
||||
if meta:get_int("industrialtest.powerAmount")>=20 and user and user:is_player() and onWrenchUse(user,pointed) then
|
||||
industrialtest.api.addPowerToItem(itemstack,-20)
|
||||
return itemstack
|
||||
end
|
||||
|
||||
function industrialtest.ElectricWrench.hitUse(self,itemstack,user,pointed)
|
||||
return onWrenchUse(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
|
||||
|
||||
industrialtest.ElectricWrench:register()
|
||||
|
||||
minetest.register_tool("industrialtest:electric_wrench",definition)
|
||||
minetest.register_craft({
|
||||
type="shapeless",
|
||||
output="industrialtest:electric_wrench",
|
||||
|
Loading…
x
Reference in New Issue
Block a user