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
|
return false
|
||||||
end
|
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)
|
function industrialtest.Tool.prepare(self,itemstack)
|
||||||
local meta=itemstack:get_meta()
|
local meta=itemstack:get_meta()
|
||||||
meta:set_int("industrialtest.uses",self.uses)
|
meta:set_int("industrialtest.uses",self.uses)
|
||||||
|
@ -19,9 +19,6 @@ if industrialtest.mods.mclRubber then
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function onTreetapUse(user,pointed)
|
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)
|
local node=minetest.get_node_or_nil(pointed.under)
|
||||||
if not node then
|
if not node then
|
||||||
return false
|
return false
|
||||||
@ -50,7 +47,7 @@ industrialtest.internal.unpackTableInto(industrialtest.Treetap,{
|
|||||||
})
|
})
|
||||||
|
|
||||||
function industrialtest.Treetap.use(self,itemstack,user,pointed)
|
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
|
end
|
||||||
|
|
||||||
industrialtest.Treetap:register()
|
industrialtest.Treetap:register()
|
||||||
@ -76,7 +73,7 @@ industrialtest.internal.unpackTableInto(industrialtest.ElectricTreetap,{
|
|||||||
})
|
})
|
||||||
|
|
||||||
function industrialtest.ElectricTreetap.use(self,itemstack,user,pointed)
|
function industrialtest.ElectricTreetap.use(self,itemstack,user,pointed)
|
||||||
return onTreetapUse(user,pointed)
|
return user and user:is_player() and onTreetapUse(user,pointed)
|
||||||
end
|
end
|
||||||
|
|
||||||
function industrialtest.ElectricTreetap.getOpPower(self,itemstack)
|
function industrialtest.ElectricTreetap.getOpPower(self,itemstack)
|
||||||
|
@ -16,9 +16,6 @@
|
|||||||
local S=minetest.get_translator("industrialtest")
|
local S=minetest.get_translator("industrialtest")
|
||||||
|
|
||||||
local function onWrenchUse(user,pointed)
|
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)
|
local node=minetest.get_node_or_nil(pointed.under)
|
||||||
if not node then
|
if not node then
|
||||||
return false
|
return false
|
||||||
@ -40,22 +37,29 @@ local function onWrenchUse(user,pointed)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
industrialtest.Wrench=table.copy(industrialtest.Tool)
|
local definition={
|
||||||
industrialtest.internal.unpackTableInto(industrialtest.Wrench,{
|
|
||||||
name="industrialtest:wrench",
|
|
||||||
define={onUse=true},
|
|
||||||
description=S("Wrench"),
|
description=S("Wrench"),
|
||||||
inventoryImage="industrialtest_wrench.png",
|
inventory_image="industrialtest_wrench.png",
|
||||||
uses=200,
|
tool_capabilities={
|
||||||
repairMaterial=industrialtest.elementKeys.bronzeIngot
|
full_punch_interval=1,
|
||||||
})
|
uses=200
|
||||||
|
},
|
||||||
function industrialtest.Wrench.hitUse(self,itemstack,user,pointed)
|
on_use=function(itemstack,user,pointed)
|
||||||
return onWrenchUse(user,pointed)
|
if pointed.type=="node" and user and user:is_player() and onWrenchUse(user,pointed) then
|
||||||
|
industrialtest.api.afterToolUse(itemstack)
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end,
|
||||||
|
_industrialtest_tool=true
|
||||||
|
}
|
||||||
|
if industrialtest.mclAvailable then
|
||||||
|
definition.groups={
|
||||||
|
tool=1
|
||||||
|
}
|
||||||
|
definition._mcl_toollike_wield=true
|
||||||
end
|
end
|
||||||
|
minetest.register_tool("industrialtest:wrench",definition)
|
||||||
industrialtest.Wrench:register()
|
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
type="shaped",
|
type="shaped",
|
||||||
output="industrialtest:wrench",
|
output="industrialtest:wrench",
|
||||||
@ -66,26 +70,28 @@ minetest.register_craft({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
industrialtest.ElectricWrench=table.copy(industrialtest.ElectricTool)
|
definition={
|
||||||
industrialtest.internal.unpackTableInto(industrialtest.ElectricWrench,{
|
|
||||||
name="industrialtest:electric_wrench",
|
|
||||||
define={onUse=true},
|
|
||||||
description=S("Electric Wrench"),
|
description=S("Electric Wrench"),
|
||||||
inventoryImage="industrialtest_electric_wrench.png",
|
inventory_image="industrialtest_electric_wrench.png",
|
||||||
capacity=10000,
|
on_use=function(itemstack,user,pointed)
|
||||||
flow=industrialtest.api.lvPowerFlow
|
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)
|
||||||
function industrialtest.ElectricWrench.getOpPower(self,itemstack)
|
return itemstack
|
||||||
return 50
|
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
|
||||||
end
|
end
|
||||||
|
minetest.register_tool("industrialtest:electric_wrench",definition)
|
||||||
function industrialtest.ElectricWrench.hitUse(self,itemstack,user,pointed)
|
|
||||||
return onWrenchUse(user,pointed)
|
|
||||||
end
|
|
||||||
|
|
||||||
industrialtest.ElectricWrench:register()
|
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
type="shapeless",
|
type="shapeless",
|
||||||
output="industrialtest:electric_wrench",
|
output="industrialtest:electric_wrench",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user