Implement wrench and electric wrench
This commit is contained in:
parent
f532a0b4ac
commit
ce96b0166e
@ -178,6 +178,7 @@ elseif industrialtest.mclAvailable then
|
||||
definition._mcl_hardness=3.9
|
||||
end
|
||||
definition.groups._industrialtest_hasPowerOutput=1
|
||||
definition.groups._industrialtest_wrenchUnmountable=1
|
||||
minetest.register_node("industrialtest:generator",definition)
|
||||
definition=table.copy(definition)
|
||||
definition.description=nil
|
||||
@ -398,6 +399,7 @@ local function registerSimpleElectricItemProcessor(config)
|
||||
},
|
||||
paramtype2="facedir",
|
||||
legacy_facedir_simple=true,
|
||||
drop=(config.requiresWrench and "industrialtest:machine_block" or "industrialtest:"..config.name),
|
||||
on_construct=function(pos)
|
||||
local meta=minetest.get_meta(pos)
|
||||
local inv=meta:get_inventory()
|
||||
@ -538,6 +540,7 @@ local function registerSimpleElectricItemProcessor(config)
|
||||
definition._mcl_hardness=3.5
|
||||
end
|
||||
definition.groups._industrialtest_hasPowerInput=1
|
||||
definition.groups._industrialtest_wrenchUnmountable=1
|
||||
minetest.register_node("industrialtest:"..config.name,definition)
|
||||
definition=table.copy(definition)
|
||||
definition.description=nil
|
||||
@ -549,7 +552,6 @@ local function registerSimpleElectricItemProcessor(config)
|
||||
"industrialtest_machine_block.png"..(config.customBackTexture and "^industrialtest_"..config.name.."_back_active.png" or ""),
|
||||
"industrialtest_machine_block.png"..(config.customFrontTexture and "^industrialtest_"..config.name.."_front_active.png" or "")
|
||||
}
|
||||
definition.drop="industrialtest:"..config.name
|
||||
definition.on_timer=function(pos,elapsed)
|
||||
local meta=minetest.get_meta(pos)
|
||||
local inv=meta:get_inventory()
|
||||
@ -944,6 +946,7 @@ registerSimpleElectricItemProcessor({
|
||||
name="macerator",
|
||||
displayName="Macerator",
|
||||
customFrontTexture=true,
|
||||
requiresWrench=true,
|
||||
capacity=1200,
|
||||
flow=industrialtest.api.lvPowerFlow,
|
||||
opPower=100,
|
||||
@ -964,6 +967,7 @@ registerSimpleElectricItemProcessor({
|
||||
name="compressor",
|
||||
displayName="Compressor",
|
||||
customFrontTexture=true,
|
||||
requiresWrench=true,
|
||||
capacity=1400,
|
||||
flow=industrialtest.api.lvPowerFlow,
|
||||
opPower=120,
|
||||
@ -984,6 +988,7 @@ registerSimpleElectricItemProcessor({
|
||||
name="extractor",
|
||||
displayName="Extractor",
|
||||
customFrontTexture=true,
|
||||
requiresWrench=true,
|
||||
capacity=900,
|
||||
flow=industrialtest.api.lvPowerFlow,
|
||||
opPower=100,
|
||||
@ -1003,6 +1008,7 @@ registerSimpleElectricItemProcessor({
|
||||
name="recycler",
|
||||
displayName="Recycler",
|
||||
customTopTexture=true,
|
||||
requiresWrench=true,
|
||||
capacity=80,
|
||||
flow=industrialtest.api.lvPowerFlow,
|
||||
opPower=40,
|
||||
|
87
tools.lua
87
tools.lua
@ -98,4 +98,89 @@ minetest.register_craft({
|
||||
"industrialtest:electronic_circuit",
|
||||
"industrialtest:re_battery"
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
local function onWrenchUse(user,pointed)
|
||||
local node=minetest.get_node_or_nil(pointed.under)
|
||||
if not node then
|
||||
return false
|
||||
end
|
||||
local def=minetest.registered_nodes[node.name]
|
||||
if not def or not def.groups or not def.groups._industrialtest_wrenchUnmountable or (def.can_dig and not def.can_dig(pointed.under)) then
|
||||
return false
|
||||
end
|
||||
local inv=user:get_inventory()
|
||||
if def.after_dig_node then
|
||||
def.after_dig_node(pointed.under,node,minetest.get_meta(pointed.under):to_table())
|
||||
end
|
||||
minetest.remove_node(pointed.under)
|
||||
local name=node.name
|
||||
if string.sub(name,-7)=="_active" then
|
||||
name=string.sub(name,1,-8)
|
||||
end
|
||||
inv:add_item("main",ItemStack(name))
|
||||
return true
|
||||
end
|
||||
definition={
|
||||
description=S("Wrench"),
|
||||
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
|
||||
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",
|
||||
recipe={
|
||||
{industrialtest.elementKeys.bronzeIngot,"",industrialtest.elementKeys.bronzeIngot},
|
||||
{industrialtest.elementKeys.bronzeIngot,industrialtest.elementKeys.bronzeIngot,industrialtest.elementKeys.bronzeIngot},
|
||||
{"",industrialtest.elementKeys.bronzeIngot,""}
|
||||
}
|
||||
})
|
||||
definition={
|
||||
description=S("Electric Wrench"),
|
||||
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
|
||||
return nil
|
||||
end,
|
||||
_industrialtest_powerStorage=true,
|
||||
_industrialtest_powerCapacity=7000,
|
||||
_industrialtest_powerFlow=industrialtest.api.lvPowerFlow
|
||||
}
|
||||
if industrialtest.mclAvailable then
|
||||
definition.groups={
|
||||
tool=1
|
||||
}
|
||||
definition._mcl_toollike_wield=true
|
||||
end
|
||||
minetest.register_tool("industrialtest:electric_wrench",definition)
|
||||
minetest.register_craft({
|
||||
type="shapeless",
|
||||
output="industrialtest:electric_wrench",
|
||||
recipe={
|
||||
"industrialtest:wrench",
|
||||
"industrialtest:electronic_circuit",
|
||||
"industrialtest:re_battery"
|
||||
}
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user