44 Commits
0.2.0 ... 0.3.0

Author SHA1 Message Date
9743217703 Add Hydrated Coal texture 2024-01-21 21:16:35 +01:00
b6c5283ab8 Add some recipes involving UU-Matter 2024-01-21 11:48:37 +01:00
80578576b6 Add Mining Laser beam texture 2024-01-20 14:37:17 +01:00
a8a20078f2 Add Mining Laser texture by LuanHawk 2024-01-20 14:37:01 +01:00
359af1e57a Implement Mining Laser
Mining Laser allows for quick node mining via shooting the beam. It comes with following modes:
- normal range
- short range
- horizontal direction
- explosion
2024-01-20 14:35:14 +01:00
e95a2a7cc1 Prevent crash caused by nil in division returned by minetest.get_node_light in solar_helmet.lua 2024-01-18 18:20:23 +01:00
752731972c Add Coalfuel Cell texture 2024-01-17 19:22:27 +01:00
0da54bb7ab Add Hydrated Coal Cell texture 2024-01-17 19:22:10 +01:00
152eab80d5 Add Hydrated Coal Dust texture 2024-01-17 19:21:48 +01:00
87f0a65f21 Implement Coal Cell and items required to make it
Coal Fuel can be used to fill Fuel Can or Jetpack
2024-01-17 19:21:09 +01:00
1e72f07df1 Add preview Solar Helmet texture 2024-01-16 19:33:53 +01:00
f072b0d599 Add model Solar Helmet texture 2024-01-16 19:31:30 +01:00
8e1c648f99 Add inventory Solar Helmet texture by LuanHawk 2024-01-16 18:39:17 +01:00
eed94c4853 Implement Solar Helmet
It can charge equipped electric tools from environment light.
2024-01-16 18:38:24 +01:00
b4e6b826ef Add MCL model Static Boots texture 2024-01-16 18:37:32 +01:00
6ffa856b44 Add preview Static Boots texture 2024-01-15 17:04:01 +01:00
10fd3eab66 Add MTG model Static Boots texture 2024-01-15 17:03:24 +01:00
c4ba8aac20 Add inventory Static Boots texture by LuanHawk 2024-01-15 16:31:27 +01:00
56c08f1f76 Implement Static Boots
This item allows for charging equipped electric tools via walking. Walking
distance of 5 blocks charges 1 EU to first found tool in armor inventory.
2024-01-14 16:56:50 +01:00
8446793413 Add preview BatPack and LapPack textures 2024-01-13 14:49:35 +01:00
567d0b3971 Add model BatPack and LapPack textures 2024-01-13 14:49:15 +01:00
3eb8b1e576 Add inventory BatPack and LapPack textures by LuanHawk 2024-01-13 14:48:25 +01:00
870343f74b Implement BatPack and LapPack
When equipped they can charge currently wielded tool or item with power storage.
2024-01-13 13:16:41 +01:00
4674f3b396 Fix MCL crash during loading in jetpack.lua 2024-01-13 13:15:46 +01:00
3db5fa322e Add active Canning Machine front texture 2024-01-12 20:18:17 +01:00
ee27e3f432 Add Canning Machine front texture by LuanHawk 2024-01-12 20:18:00 +01:00
6cf004ff0e Implement Canning Machine 2024-01-12 20:17:36 +01:00
eaff4a9065 Optimize some electric tools and fix Electric Saber not discharging after digging node 2024-01-11 22:25:14 +01:00
e69d16aeb0 Add simple item fluid storage API 2024-01-11 19:48:09 +01:00
0895cb42ea Add preview Electric Jetpack texture 2024-01-10 19:00:12 +01:00
4171e6da7a Add model Electric Jetpack texture 2024-01-10 18:59:53 +01:00
d9d4396034 Add inventory Electric Jetpack texture 2024-01-10 18:59:32 +01:00
5cef554c9e Implement Electric Jetpack 2024-01-10 18:59:07 +01:00
536cd978ed Add 3D Armor preview Jetpack texture 2024-01-09 11:08:46 +01:00
45bd28ef4c Add model Jetpack texture 2024-01-09 11:08:24 +01:00
b06ef3bb98 Add Fuel Can texture by LuanHawk 2024-01-09 11:07:57 +01:00
eed2c73911 Add inventory Jetpack texture by LuanHawk 2024-01-09 11:07:33 +01:00
6da4aef854 Implement Jetpack 2024-01-09 11:07:00 +01:00
3a7ba72571 Add Compressed Plantball texture by Migdyn 2024-01-07 19:57:53 +01:00
5d28015b3e Add Plantball texture by Migdyn 2024-01-07 19:57:36 +01:00
5acd9477fb Add Biofuel Cell texture 2024-01-07 14:31:10 +01:00
880ad0c99c Add Bio Cell texture 2024-01-07 14:30:57 +01:00
d973f97916 Add Biofuel Cell and some items required to produce it 2024-01-07 14:30:33 +01:00
0b27efd756 Split tools.lua to separate files 2024-01-06 21:55:06 +01:00
52 changed files with 2441 additions and 839 deletions

93
api.lua
View File

@@ -92,7 +92,8 @@ end
industrialtest.api.updateItemPowerText=function(itemstack)
local meta=itemstack:get_meta()
local def=minetest.registered_tools[itemstack:get_name()]
meta:set_string("description",S("@1\n@2 / @3 EU",def.description,meta:get_int("industrialtest.powerAmount"),meta:get_int("industrialtest.powerCapacity")))
local desc=meta:contains("industrialtest.descriptionOverride") and meta:get_string("industrialtest.descriptionOverride") or def.description
meta:set_string("description",S("@1\n@2 / @3 EU",desc,meta:get_int("industrialtest.powerAmount"),meta:get_int("industrialtest.powerCapacity")))
itemstack:set_wear(65535-meta:get_int("industrialtest.powerAmount")/meta:get_int("industrialtest.powerCapacity")*65534)
end
-- \brief Adds power storage to item depending on it's definition
@@ -113,12 +114,18 @@ end
-- \returns true if value was successfully added, false otherwise
industrialtest.api.prepareToolItem=function(itemstack)
local def=minetest.registered_tools[itemstack:get_name()]
if not def or not def._industrialtest_tool or not def.tool_capabilities or not def.tool_capabilities.uses then
if not def then
return false
end
local meta=itemstack:get_meta()
meta:set_int("industrialtest.uses",def.tool_capabilities.uses)
return true
if def._industrialtest_tool and def.tool_capabilities and def.tool_capabilities.uses then
local meta=itemstack:get_meta()
meta:set_int("industrialtest.uses",def.tool_capabilities.uses)
return true
elseif def.groups and def.groups._industrialtest_emptyOnConstruct and itemstack:get_wear()==0 then
itemstack:set_wear(65534)
return true
end
return false
end
-- \brief Adds wear to item after it's use
-- \param itemstack ItemStack to which wear should be added
@@ -145,6 +152,81 @@ industrialtest.api.afterToolUse=function(itemstack)
meta:set_int("industrialtest.uses",uses)
itemstack:set_wear(65535-uses/def.tool_capabilities.uses*65535)
end
-- \brief Check if itemstack contains fluid storage
-- \param itemstack ItemStack
-- \returns bool
industrialtest.api.itemHasFluidStorage=function(itemstack)
local values={"industrialtest.fluidAmount","industrialtest.fluidCapacity"}
local meta=itemstack:get_meta()
for _,value in ipairs(values) do
if not meta:contains(value) then
return false
end
end
return true
end
-- \brief Updates itemstack description and wear depending on contained fluid
-- \param itemstack ItemStack
-- \returns nil
industrialtest.api.updateItemFluidText=function(itemstack)
local meta=itemstack:get_meta()
local def=itemstack:get_definition()
meta:set_string("description",S("@1\n@2 / @3 mB",def.description,meta:get_int("industrialtest.fluidAmount"),meta:get_int("industrialtest.fluidCapacity")))
itemstack:set_wear(65535-meta:get_int("industrialtest.fluidAmount")/meta:get_int("industrialtest.fluidCapacity")*65534)
end
-- \brief Prepares itemstack containing fluid storage
-- \param itemstack ItemStack
-- \returns bool
industrialtest.api.prepareFluidStorageItem=function(itemstack)
local meta=itemstack:get_meta()
local def=itemstack:get_definition()
if industrialtest.api.itemHasFluidStorage(itemstack) or not def.groups or not def.groups._industrialtest_fluidStorage or not def._industrialtest_fluidCapacity then
return false
end
meta:set_int("industrialtest.fluidAmount",0)
meta:set_int("industrialtest.fluidCapacity",def._industrialtest_fluidCapacity)
industrialtest.api.updateItemFluidText(itemstack)
return true
end
-- \brief Adds fluid amount to item fluid storage
-- \param itemstack ItemStack
-- \param amount number
-- \returns number
industrialtest.api.addFluidToItem=function(itemstack,amount)
local meta=itemstack:get_meta()
if not industrialtest.api.itemHasFluidStorage(itemstack) then
return 0
end
local fluidAmount=meta:get_int("industrialtest.fluidAmount")
local fluidCapacity=meta:get_int("industrialtest.fluidCapacity")
local prevFluidAmount=fluidAmount
fluidAmount=industrialtest.internal.clamp(fluidAmount+amount,0,fluidCapacity)
meta:set_int("industrialtest.fluidAmount",fluidAmount)
industrialtest.api.updateItemFluidText(itemstack)
return fluidAmount-prevFluidAmount
end
-- \brief Adds fluid to destination itemstack while subtracting it from source itemstack's metadata
-- \param srcItemstack ItemStack
-- \param itemstack ItemStack
-- \param amount number
-- \returns number
industrialtest.api.transferFluidToItem=function(srcItemstack,itemstack,amount)
local meta=srcItemstack:get_meta()
local flow=math.min(meta:get_int("industrialtest.fluidAmount"),amount)
if flow==0 then
return 0
end
local actualFlow=industrialtest.api.addFluidToItem(itemstack,flow)
meta:set_int("industrialtest.fluidAmount",meta:get_int("industrialtest.fluidAmount")-actualFlow)
industrialtest.api.updateItemFluidText(srcItemstack)
return actualFlow
end
-- \brief Checks if power storage is fully charged
-- \param meta MetaDataRef which should be checked
-- \returns true if power storage is fully charged, false otherwise
@@ -192,6 +274,7 @@ end
-- \brief Adds power to destination itemstack while subtracting it from source metadata
-- \param srcMeta MetaDataRef from which take power
-- \param itemstack ItemStack to which add power
-- \param amount number
-- \returns How much of power was actually transferred
industrialtest.api.transferPowerToItem=function(srcMeta,itemstack,amount)
local currentFlow=math.min(srcMeta:get_int("industrialtest.powerAmount"),amount)

View File

@@ -70,7 +70,9 @@ if industrialtest.mclAvailable then
end
return itemstack
end
industrialtest.internal.explode=mcl_explosions.explode
industrialtest.internal.explode=function(pos,radius,dropChance)
mcl_explosions.explode(pos,radius,{drop_chance=dropChance})
end
end
-- compatibilty that adds not existing elements
@@ -497,6 +499,7 @@ if industrialtest.mclAvailable then
industrialtest.elementKeys.snowball="mcl_throwing:snowball"
industrialtest.elementKeys.string="mcl_mobitems:string"
industrialtest.elementKeys.junglePlanks="mcl_core:junglewood"
industrialtest.elementKeys.wood="mcl_core:tree"
industrialtest.elementKeys.ironIngot="mcl_core:iron_ingot"
industrialtest.elementKeys.ironLump="mcl_raw_ores:raw_iron"
industrialtest.elementKeys.goldIngot="mcl_core:gold_ingot"
@@ -518,6 +521,7 @@ if industrialtest.mclAvailable then
industrialtest.elementKeys.stone="mcl_core:stone"
industrialtest.elementKeys.stoneSlab="mcl_stairs:slab_stone"
industrialtest.elementKeys.cobble="mcl_core:cobble"
industrialtest.elementKeys.mossCobble="mcl_core:mossycobble"
industrialtest.elementKeys.sand="mcl_core:sand"
industrialtest.elementKeys.gravel="mcl_core:gravel"
industrialtest.elementKeys.ice="mcl_core:ice"
@@ -538,8 +542,16 @@ if industrialtest.mclAvailable then
industrialtest.elementKeys.copperBlock="mcl_copper:block"
industrialtest.elementKeys.stoneWithCopper="mcl_copper:stone_with_copper"
industrialtest.elementKeys.ironPickaxe="mcl_tools:pick_iron"
industrialtest.elementKeys.ironHelmet="mcl_tools:helmet_iron"
industrialtest.elementKeys.ironBoots="mcl_armor:boots_iron"
industrialtest.elementKeys.lavaSource="mcl_core:lava_source"
industrialtest.elementKeys.waterSource="mcl_core:water_source"
industrialtest.elementKeys.sugarCane="mcl_core:reeds"
industrialtest.elementKeys.wheat="mcl_farming:wheat_item"
industrialtest.elementKeys.dryShrub="mcl_core:deadbush"
industrialtest.elementKeys.cactus="mcl_core:cactus"
industrialtest.elementKeys.groupSapling="group:sapling"
industrialtest.elementKeys.groupLeaves="group:leaves"
-- register required minerals that are not available in MCL
industrialtest.registerMetal("tin","Tin",3,3)
@@ -728,12 +740,14 @@ elseif industrialtest.mtgAvailable then
industrialtest.elementKeys.bucketWithWater="bucket:bucket_water"
industrialtest.elementKeys.string="farming:string"
industrialtest.elementKeys.junglePlanks="default:junglewood"
industrialtest.elementKeys.wood="default:tree"
industrialtest.elementKeys.glass="default:glass"
industrialtest.elementKeys.powerCarrier="default:mese_crystal_fragment"
industrialtest.elementKeys.furnace="default:furnace"
industrialtest.elementKeys.stone="default:stone"
industrialtest.elementKeys.stoneSlab="stairs:slab_stone"
industrialtest.elementKeys.cobble="default:cobble"
industrialtest.elementKeys.mossCobble="default:mossycobble"
industrialtest.elementKeys.sand="default:sand"
industrialtest.elementKeys.gravel="default:gravel"
industrialtest.elementKeys.ice="default:ice"
@@ -757,8 +771,16 @@ elseif industrialtest.mtgAvailable then
industrialtest.elementKeys.stoneWithTin="default:stone_with_tin"
industrialtest.elementKeys.bronzeBlock="default:bronzeblock"
industrialtest.elementKeys.ironPickaxe="default:pick_steel"
industrialtest.elementKeys.ironHelmet="3d_armor:helmet_steel"
industrialtest.elementKeys.ironBoots="3d_armor:boots_steel"
industrialtest.elementKeys.lavaSource="default:lava_source"
industrialtest.elementKeys.waterSource="default:water_source"
industrialtest.elementKeys.sugarCane="default:papyrus"
industrialtest.elementKeys.wheat="farming:wheat"
industrialtest.elementKeys.dryShrub="default:dry_shrub"
industrialtest.elementKeys.cactus="default:cactus"
industrialtest.elementKeys.groupSapling="group:sapling"
industrialtest.elementKeys.groupLeaves="group:leaves"
else
error("No compatible games found!")
end

View File

@@ -416,6 +416,49 @@ industrialtest.api.registerResourceDust("sulfur","Sulfur",{},"#e3ff33ff",false)
industrialtest.api.registerResourceDust("lead","Lead",{},"#eafef8ff",false)
-- TODO: Add lead ore
minetest.register_craftitem("industrialtest:hydrated_coal_dust",{
description=S("Hydrated Coal Dust"),
inventory_image="industrialtest_hydrated_coal_dust.png"
})
minetest.register_craft({
type="shaped",
output="industrialtest:hydrated_coal_dust 8",
recipe={
{"industrialtest:coal_dust","industrialtest:coal_dust","industrialtest:coal_dust"},
{"industrialtest:coal_dust",industrialtest.elementKeys.bucketWithWater,"industrialtest:coal_dust"},
{"industrialtest:coal_dust","industrialtest:coal_dust","industrialtest:coal_dust"}
},
replacements={
{
industrialtest.elementKeys.bucketWithWater,
industrialtest.elementKeys.bucket
}
}
})
minetest.register_craft({
type="shapeless",
output="industrialtest:hydrated_coal_dust",
recipe={
"industrialtest:coal_dust",
industrialtest.elementKeys.bucketWithWater
},
replacements={
{
industrialtest.elementKeys.bucketWithWater,
industrialtest.elementKeys.bucket
}
}
})
minetest.register_craftitem("industrialtest:hydrated_coal",{
description=S("Hydrated Coal"),
inventory_image="industrialtest_hydrated_coal.png"
})
industrialtest.api.registerCompressorRecipe({
output="industrialtest:hydrated_coal",
recipe="industrialtest:hydrated_coal_dust"
})
-- Plates
industrialtest.api.registerPlate("bronze_plate",S("Bronze Plate"),{
{
@@ -445,6 +488,13 @@ industrialtest.api.registerPlate("carbon_plate",S("Carbon Plate"),{
}
},"#272725ff",true)
industrialtest.api.registerPlate("tin_plate",S("Tin Plate"),{
{
resource=industrialtest.elementKeys.tinIngot,
count=1
}
},"#e0e0e0ff",true)
-- Cells
minetest.register_craftitem("industrialtest:empty_cell",{
description=S("Empty Cell"),
@@ -535,6 +585,62 @@ if industrialtest.mtgAvailable then
})
end
minetest.register_craftitem("industrialtest:bio_cell",{
description=S("Bio Cell"),
inventory_image="industrialtest_bio_cell.png"
})
minetest.register_craft({
type="shapeless",
output="industrialtest:bio_cell",
recipe={
"industrialtest:empty_cell",
"industrialtest:compressed_plantball"
}
})
minetest.register_craftitem("industrialtest:biofuel_cell",{
description=S("Biofuel Cell"),
inventory_image="industrialtest_bio_cell.png",
groups={
_industrialtest_fuel=1
},
_industrialtest_fuelAmount=500,
_industrialtest_emptyVariant="industrialtest:empty_cell"
})
industrialtest.api.registerExtractorRecipe({
output="industrialtest:biofuel_cell",
recipe="industrialtest:bio_cell",
time=4
})
minetest.register_craftitem("industrialtest:hydrated_coal_cell",{
description=S("Hydrated Coal Cell"),
inventory_image="industrialtest_hydrated_coal_cell.png"
})
minetest.register_craft({
type="shapeless",
output="industrialtest:hydrated_coal_cell",
recipe={
"industrialtest:empty_cell",
"industrialtest:hydrated_coal"
}
})
minetest.register_craftitem("industrialtest:coalfuel_cell",{
description=S("Coalfuel Cell"),
inventory_image="industrialtest_coalfuel_cell.png",
groups={
_industrialtest_fuel=1
},
_industrialtest_fuelAmount=1000,
_industrialtest_emptyVariant="industrialtest:empty_cell"
})
industrialtest.api.registerExtractorRecipe({
output="industrialtest:coal_cell",
recipe="industrialtest:hydrated_coal_cell",
time=4
})
-- Other items
minetest.register_craftitem("industrialtest:electronic_circuit",{
description=S("Electronic Circuit"),
@@ -583,17 +689,106 @@ minetest.register_craftitem("industrialtest:uu_matter",{
inventory_image="industrialtest_uu_matter.png"
})
minetest.register_craftitem("industrialtest:plantball",{
description=S("Plantball"),
inventory_image="industrialtest_plantball.png"
})
minetest.register_craft({
type="shaped",
output="industrialtest:plantball 2",
recipe={
{industrialtest.elementKeys.groupSapling,industrialtest.elementKeys.groupSapling,industrialtest.elementKeys.groupSapling},
{industrialtest.elementKeys.groupSapling,"",industrialtest.elementKeys.groupSapling},
{industrialtest.elementKeys.groupSapling,industrialtest.elementKeys.groupSapling,industrialtest.elementKeys.groupSapling}
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:plantball",
recipe={
{industrialtest.elementKeys.groupLeaves,industrialtest.elementKeys.groupLeaves,industrialtest.elementKeys.groupLeaves},
{industrialtest.elementKeys.groupLeaves,"",industrialtest.elementKeys.groupLeaves},
{industrialtest.elementKeys.groupLeaves,industrialtest.elementKeys.groupLeaves,industrialtest.elementKeys.groupLeaves}
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:plantball",
recipe={
{industrialtest.elementKeys.sugarCane,industrialtest.elementKeys.sugarCane,industrialtest.elementKeys.sugarCane},
{industrialtest.elementKeys.sugarCane,"",industrialtest.elementKeys.sugarCane},
{industrialtest.elementKeys.sugarCane,industrialtest.elementKeys.sugarCane,industrialtest.elementKeys.sugarCane}
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:plantball",
recipe={
{industrialtest.elementKeys.wheat,industrialtest.elementKeys.wheat,industrialtest.elementKeys.wheat},
{industrialtest.elementKeys.wheat,"",industrialtest.elementKeys.wheat},
{industrialtest.elementKeys.wheat,industrialtest.elementKeys.wheat,industrialtest.elementKeys.wheat}
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:plantball",
recipe={
{industrialtest.elementKeys.dryShrub,industrialtest.elementKeys.dryShrub,industrialtest.elementKeys.dryShrub},
{industrialtest.elementKeys.dryShrub,"",industrialtest.elementKeys.dryShrub},
{industrialtest.elementKeys.dryShrub,industrialtest.elementKeys.dryShrub,industrialtest.elementKeys.dryShrub}
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:plantball",
recipe={
{industrialtest.elementKeys.cactus,industrialtest.elementKeys.cactus,industrialtest.elementKeys.cactus},
{industrialtest.elementKeys.cactus,"",industrialtest.elementKeys.cactus},
{industrialtest.elementKeys.cactus,industrialtest.elementKeys.cactus,industrialtest.elementKeys.cactus}
}
})
minetest.register_craftitem("industrialtest:compressed_plantball",{
description=S("Compressed Plantball"),
inventory_image="industrialtest_compressed_plantball.png"
})
industrialtest.api.registerCompressorRecipe({
output="industrialtest:compressed_plantball",
recipe="industrialtest:plantball",
time=5
})
minetest.register_tool("industrialtest:fuel_can",{
description=S("Fuel Can"),
inventory_image="industrialtest_fuel_can.png",
groups={
_industrialtest_fueled=1,
_industrialtest_fuel=1,
_industrialtest_fluidStorage=1
},
_industrialtest_fluidCapacity=10000
})
minetest.register_craft({
type="shaped",
output="industrialtest:fuel_can",
recipe={
{"","industrialtest:tin_plate","industrialtest:tin_plate"},
{"industrialtest:tin_plate","","industrialtest:tin_plate"},
{"industrialtest:tin_plate","industrialtest:tin_plate","industrialtest:tin_plate"}
}
})
-- Item callbacks
minetest.register_on_player_inventory_action(function(player,action,inventory,info)
if action=="put" then
if industrialtest.api.preparePowerStorageItem(info.stack) or industrialtest.api.prepareToolItem(info.stack) then
if industrialtest.api.preparePowerStorageItem(info.stack) or industrialtest.api.prepareToolItem(info.stack) or industrialtest.api.prepareFluidStorageItem(info.stack) then
inventory:set_stack(info.listname,info.index,info.stack)
end
end
end)
minetest.register_on_craft(function(itemstack)
if industrialtest.api.preparePowerStorageItem(itemstack) then
if industrialtest.api.preparePowerStorageItem(itemstack) or industrialtest.api.prepareToolItem(itemstack) then
return
end
industrialtest.api.prepareToolItem(itemstack)
industrialtest.api.prepareFluidStorageItem(itemstack)
end)

View File

@@ -33,6 +33,7 @@ dofile(modpath.."/api.lua")
dofile(modpath.."/minerals.lua")
dofile(modpath.."/machines/common.lua")
dofile(modpath.."/machines/canning_machine.lua")
dofile(modpath.."/machines/compressor.lua")
dofile(modpath.."/machines/cable_former.lua")
dofile(modpath.."/machines/electric_furnace.lua")
@@ -50,6 +51,19 @@ dofile(modpath.."/machines/transformer.lua")
dofile(modpath.."/machines/solar_panel_generator.lua")
dofile(modpath.."/machines/wind_mill.lua")
dofile(modpath.."/tools/common.lua")
dofile(modpath.."/tools/batpack.lua")
dofile(modpath.."/tools/electric_chainsaw.lua")
dofile(modpath.."/tools/electric_drill.lua")
dofile(modpath.."/tools/electric_hoe.lua")
dofile(modpath.."/tools/electric_saber.lua")
dofile(modpath.."/tools/jetpack.lua")
dofile(modpath.."/tools/mining_laser.lua")
dofile(modpath.."/tools/solar_helmet.lua")
dofile(modpath.."/tools/static_boots.lua")
dofile(modpath.."/tools/treetap.lua")
dofile(modpath.."/tools/wrench.lua")
dofile(modpath.."/upgrades.lua")
dofile(modpath.."/craftitems.lua")
dofile(modpath.."/nodes.lua")
@@ -58,5 +72,5 @@ if industrialtest.developerMode then
end
dofile(modpath.."/cables.lua")
dofile(modpath.."/mapgen.lua")
dofile(modpath.."/tools.lua")
dofile(modpath.."/uu_matter_crafts.lua")
dofile(modpath.."/crafts.lua")

View File

@@ -0,0 +1,294 @@
-- IndustrialTest
-- Copyright (C) 2024 mrkubax10
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local S=minetest.get_translator("industrialtest")
local canningMachine={}
canningMachine.opPower=200
canningMachine.canningTime=5
canningMachine.getFormspec=function(pos)
local meta=minetest.get_meta(pos)
local powerPercent=meta:get_int("industrialtest.powerAmount")/meta:get_int("industrialtest.powerCapacity")*100
local srcPercent=meta:get_float("srcTime")/canningMachine.canningTime*100
local formspec
if industrialtest.mtgAvailable then
formspec={
"list[context;fuel;3.4,1.8;1,1]",
(powerPercent>0 and "image[3.4,2.8;1,1;industrialtest_gui_electricity_bg.png^[lowpart:"..powerPercent..":industrialtest_gui_electricity_fg.png]"
or "image[3.4,2.8;1,1;industrialtest_gui_electricity_bg.png]"),
"list[context;powerStorage;3.4,3.9;1,1]",
(srcPercent>0 and "image[4.9,1.8;1,1;gui_furnace_arrow_bg.png^[lowpart:"..srcPercent..":gui_furnace_arrow_fg.png^[transformR270]"
or "image[4.9,1.8;1,1;gui_furnace_arrow_bg.png^[transformR270]"),
"list[context;target;6.4,1.8;1,1]",
"list[context;leftover;6.4,2.8;1,1]",
"list[context;upgrades;9,0.9;1,4]",
"listring[context;fuel]",
"listring[context;powerStorage]",
"listring[context;target]",
"listring[context;leftover]",
"listring[context;upgrades]"
}
elseif industrialtest.mclAvailable then
formspec={
"list[context;fuel;3.4,1.8;1,1]",
mcl_formspec.get_itemslot_bg(3.4,1.8,1,1),
(powerPercent>0 and "image[3.4,2.8;1,1;industrialtest_gui_electricity_bg.png^[lowpart:"..powerPercent..":industrialtest_gui_electricity_fg.png]"
or "image[3.4,2.8;1,1;industrialtest_gui_electricity_bg.png]"),
"list[context;powerStorage;3.4,3.9;1,1]",
mcl_formspec.get_itemslot_bg(3.4,3.9,1,1),
(srcPercent>0 and "image[4.9,1.8;1,1;gui_furnace_arrow_bg.png^[lowpart:"..srcPercent..":gui_furnace_arrow_fg.png^[transformR270]"
or "image[4.9,1.8;1,1;gui_furnace_arrow_bg.png^[transformR270]"),
"list[context;target;6.4,1.8;1,1]",
mcl_formspec.get_itemslot_bg(6.4,1.8,1,1),
"list[context;leftover;6.4,2.8;1,1]",
mcl_formspec.get_itemslot_bg(6.4,2.8,1,1),
"list[context;upgrades;9,0.9;1,4]",
mcl_formspec.get_itemslot_bg(9,0.9,1,4),
"listring[context;fuel]",
"listring[context;powerStorage]",
"listring[context;target]",
"listring[context;upgrades]"
}
end
return table.concat(formspec,"")
end
canningMachine.onConstruct=function(pos,meta,inv)
inv:set_size("fuel",1)
inv:set_size("target",1)
inv:set_size("leftover",1)
inv:set_size("powerStorage",1)
inv:set_size("upgrades",4)
meta:set_float("srcTime",0)
end
canningMachine.onTimer=function(pos,elapsed,meta,inv)
local shouldRerunTimer=false
local shouldUpdateFormspec=false
local fuelSlot=inv:get_stack("fuel",1)
local targetSlot=inv:get_stack("target",1)
local leftoverSlot=inv:get_stack("leftover",1)
local powerStorageSlot=inv:get_stack("powerStorage",1)
local targetMeta=targetSlot:get_meta()
if not powerStorageSlot:is_empty() then
local stackMeta=powerStorageSlot:get_meta()
if industrialtest.api.transferPower(stackMeta,meta,stackMeta:get_int("industrialtest.powerFlow"))>0 then
shouldUpdateFormspec=true
shouldRerunTimer=true
industrialtest.api.updateItemPowerText(powerStorageSlot)
inv:set_stack("powerStorage",1,powerStorageSlot)
end
end
local def=fuelSlot:get_definition()
if not fuelSlot:is_empty() and not targetSlot:is_empty() and meta:get_int("industrialtest.powerAmount")>=canningMachine.opPower and (not def._industrialtest_emptyVariant or leftoverSlot:item_fits(ItemStack(def._industrialtest_emptyVariant))) and
(not industrialtest.api.itemHasFluidStorage(fuelSlot) or fuelSlot:get_meta():get_int("industrialtest.fluidAmount")>0) and targetMeta:get_int("industrialtest.fluidAmount")<targetMeta:get_int("industrialtest.fluidCapacity") then
minetest.swap_node(pos,{
name="industrialtest:canning_machine_active",
param2=minetest.get_node(pos).param2
})
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
return false,shouldUpdateFormspec
end
return shouldRerunTimer,true
end
canningMachine.allowMetadataInventoryMove=function(pos,fromList,fromIndex,toList,count)
if toList=="fuel" then
local inv=minetest.get_meta(pos):get_inventory()
local itemstack=inv:get_stack(fromList,fromIndex)
local def=itemstack:get_definition()
return (def.groups and def.groups._industrialtest_fuel) and count or 0
end
if toList=="target" then
local inv=minetest.get_meta(pos):get_inventory()
local itemstack=inv:get_stack(fromList,fromIndex)
local def=itemstack:get_definition()
return (def.groups and def.groups._industrialtest_fueled) and count or 0
end
return count
end
canningMachine.allowMetadataInventoryPut=function(pos,listname,index,stack)
if listname=="fuel" then
local def=stack:get_definition()
return (def.groups and def.groups._industrialtest_fuel) and stack:get_count() or 0
end
if listname=="target" then
local def=stack:get_definition()
return (def.groups and def.groups._industrialtest_fueled) and stack:get_count() or 0
end
return stack:get_count()
end
canningMachine.allowMetadataInventoryTake=function(pos,listname,index,stack)
local meta=minetest.get_meta(pos)
local inv=meta:get_inventory()
local fuelSlot=inv:get_stack("fuel",1)
local targetSlot=inv:get_stack("target",1)
if ((listname=="fuel" and stack:get_count()==fuelSlot:get_count()) or (listname=="target" and stack:get_count()==targetSlot:get_count())) and meta:get_float("srcTime")>0 then
meta:set_float("srcTime",0)
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
end
return stack:get_count()
end
canningMachine.onMetadataInventoryPut=function(pos)
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
end
canningMachine.onMetadataInventoryMove=function(pos,fromList,fromIndex,toList,toIndex,count)
local meta=minetest.get_meta(pos)
local inv=meta:get_inventory()
local fuelSlot=inv:get_stack("fuel",1)
local targetSlot=inv:get_stack("target",1)
if ((fromList=="fuel" and count==fuelSlot:get_count()) or (fromList=="target" and count==targetSlot:get_count())) and meta:get_float("srcTime")>0 then
meta:set_float("srcTime",0)
meta:set_string("formspec",canningMachine.getFormspec(pos))
end
end
canningMachine.activeOnTimer=function(pos,elapsed,meta,inv)
local shouldUpdateFormspec=false
local fuelSlot=inv:get_stack("fuel",1)
local targetSlot=inv:get_stack("target",1)
local powerStorageSlot=inv:get_stack("powerStorage",1)
if not powerStorageSlot:is_empty() then
local stackMeta=powerStorageSlot:get_meta()
if industrialtest.api.transferPower(stackMeta,meta,stackMeta:get_int("industrialtest.powerFlow"))>0 then
shouldUpdateFormspec=true
industrialtest.api.updateItemPowerText(powerStorageSlot)
inv:set_stack("powerStorage",1,powerStorageSlot)
end
end
if fuelSlot:is_empty() or targetSlot:is_empty() or meta:get_int("industrialtest.powerAmount")<canningMachine.opPower then
if meta:get_int("industrialtest.powerAmount")>=canningMachine.opPower then
meta:set_float("srcTime",0)
end
minetest.swap_node(pos,{
name="industrialtest:canning_machine",
param2=minetest.get_node(pos).param2
})
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
return false,true
end
local fuelMeta=fuelSlot:get_meta()
local targetMeta=targetSlot:get_meta()
if (industrialtest.api.itemHasFluidStorage(fuelSlot) and fuelMeta:get_int("industrialtest.fluidAmount")==0) or targetMeta:get_int("industrialtest.fluidAmount")==targetMeta:get_int("industrialtest.fluidCapacity") then
meta:set_float("srcTime",0)
minetest.swap_node(pos,{
name="industrialtest:canning_machine",
param2=minetest.get_node(pos).param2
})
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
return false,true
end
local srcTime=meta:get_float("srcTime")
srcTime=srcTime+elapsed*industrialtest.api.getMachineSpeed(meta)
if srcTime>=canningMachine.canningTime then
if industrialtest.api.itemHasFluidStorage(fuelSlot) then
industrialtest.api.transferFluidToItem(fuelSlot,targetSlot,fuelMeta:get_int("industrialtest.fluidAmount"))
inv:set_stack("fuel",1,fuelSlot)
inv:set_stack("target",1,targetSlot)
else
local def=fuelSlot:get_definition()
local leftoverSlot=inv:get_stack("leftover",1)
if targetMeta:get_int("industrialtest.fluidCapacity")-targetMeta:get_int("industrialtest.fluidAmount")<def._industrialtest_fuelAmount or (def._industrialtest_emptyVariant and not leftoverSlot:item_fits(ItemStack(def._industrialtest_emptyVariant))) then
minetest.swap_node(pos,{
name="industrialtest:canning_machine",
param2=minetest.get_node(pos).param2
})
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
return false,shouldUpdateFormspec
end
industrialtest.api.addFluidToItem(targetSlot,def._industrialtest_fuelAmount)
inv:set_stack("target",1,targetSlot)
fuelSlot:take_item(1)
inv:set_stack("fuel",1,fuelSlot)
leftoverSlot:add_item(ItemStack(def._industrialtest_emptyVariant))
inv:set_stack("leftover",1,leftoverSlot)
end
meta:set_float("srcTime",0)
else
meta:set_float("srcTime",srcTime)
end
industrialtest.api.addPower(meta,-canningMachine.opPower)
return true,true
end
industrialtest.internal.registerMachine({
name="canning_machine",
displayName=S("Canning Machine"),
capacity=industrialtest.api.lvPowerFlow*2,
getFormspec=canningMachine.getFormspec,
flow=industrialtest.api.lvPowerFlow,
ioConfig="iiiiii",
requiresWrench=true,
registerActiveVariant=true,
sounds="metal",
powerSlots={"powerStorage"},
storageSlots={"fuel","target","powerStorage","upgrades"},
groups={
_industrialtest_hasPowerInput=1
},
customKeys={
tiles={
"industrialtest_machine_block.png",
"industrialtest_machine_block.png",
"industrialtest_machine_block.png",
"industrialtest_machine_block.png",
"industrialtest_machine_block.png",
"industrialtest_machine_block.png^industrialtest_canning_machine_front.png"
},
paramtype2="facedir",
legacy_facedir_simple=true
},
activeCustomKeys={
tiles={
"industrialtest_machine_block.png",
"industrialtest_machine_block.png",
"industrialtest_machine_block.png",
"industrialtest_machine_block.png",
"industrialtest_machine_block.png",
"industrialtest_machine_block.png^industrialtest_canning_machine_front_active.png"
}
},
onConstruct=canningMachine.onConstruct,
onTimer=canningMachine.onTimer,
allowMetadataInventoryMove=canningMachine.allowMetadataInventoryMove,
allowMetadataInventoryPut=canningMachine.allowMetadataInventoryPut,
allowMetadataInventoryTake=canningMachine.allowMetadataInventoryTake,
onMetadataInventoryPut=canningMachine.onMetadataInventoryPut,
onMetadataInventoryMove=canningMachine.onMetadataInventoryMove,
activeOnTimer=canningMachine.activeOnTimer
})
minetest.register_craft({
type="shaped",
output="industrialtest:canning_machine",
recipe={
{industrialtest.elementKeys.tinIngot,"industrialtest:electronic_circuit",industrialtest.elementKeys.tinIngot},
{industrialtest.elementKeys.tinIngot,"industrialtest:machine_block",industrialtest.elementKeys.tinIngot},
{industrialtest.elementKeys.tinIngot,industrialtest.elementKeys.tinIngot,industrialtest.elementKeys.tinIngot}
}
})

View File

@@ -221,6 +221,13 @@ machine.allowMetadataInventoryPut=function(pos,listname,index,stack,player,confi
return stack:get_count()
end
machine.allowMetadataInventoryTake=function(pos,listname,index,stack,player,config)
if config.allowMetadataInventoryTake then
return config.allowMetadataInventoryTake(pos,listname,index,stack,player)
end
return stack:get_count()
end
machine.onMetadataInventoryMove=function(pos,fromList,fromIndex,toList,toIndex,count)
if toList=="upgrades" then
local meta=minetest.get_meta(pos)
@@ -274,6 +281,9 @@ function industrialtest.internal.registerMachine(config)
allow_metadata_inventory_put=function(pos,listname,index,stack,player)
return machine.allowMetadataInventoryPut(pos,listname,index,stack,player,config)
end,
allow_metadata_inventory_take=function(pos,listname,index,stack,player)
return machine.allowMetadataInventoryTake(pos,listname,index,stack,player,config)
end,
on_metadata_inventory_put=function(pos,listname,index,stack,player)
machine.onMetadataInventoryPut(pos,listname,index,stack)
if config.onMetadataInventoryPut then

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 354 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 679 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 383 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 348 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 546 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

829
tools.lua
View File

@@ -1,829 +0,0 @@
-- IndustrialTest
-- Copyright (C) 2023 mrkubax10
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local S=minetest.get_translator("industrialtest")
local function onTreetapUse(user,pointed)
local node=minetest.get_node_or_nil(pointed.under)
if not node then
return false
end
-- Note: if more nodes from which treetap can extract will be added then they shouldn't be added here
-- Instead they should have additional entry in definition which will denote that treetap can be used on them
if node.name=="industrialtest:rubber_wood_with_rubber" then
local inv=user:get_inventory()
inv:add_item("main",ItemStack("industrialtest:sticky_resin"))
minetest.set_node(pointed.under,{name="industrialtest:rubber_wood"})
return true
end
return false
end
local definition={
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
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)
minetest.register_craft({
type="shaped",
output="industrialtest:treetap",
recipe={
{"","group:wood",""},
{"group:wood","group:wood","group:wood"},
{"group:wood","",""}
}
})
definition={
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
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
minetest.register_tool("industrialtest:electric_treetap",definition)
minetest.register_craft({
type="shapeless",
output="industrialtest:electric_treetap",
recipe={
"industrialtest:treetap",
"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=10000,
_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"
}
})
local registeredElectricChainsaws={}
local function registerElectricChainsaw(config)
local definition={
description=S(config.displayName),
inventory_image="industrialtest_"..config.name..".png",
_industrialtest_powerStorage=true,
_industrialtest_powerCapacity=10000,
_industrialtest_powerFlow=industrialtest.api.lvPowerFlow
}
if industrialtest.mtgAvailable then
definition.tool_capabilities={
full_punch_interval=0.5,
max_drop_level=config.maxDropLevel,
groupcaps={
choppy={
times=config.inactiveTimes,
maxlevel=config.maxLevel
}
}
}
definition.groups={
axe=1
}
elseif industrialtest.mclAvailable then
definition.tool_capabilities={
full_punch_interval=0.5,
max_drop_level=config.maxDropLevel,
}
definition.groups={
tool=1,
dig_speed_class=config.digSpeedClass,
}
definition.on_place=function(itemstack,user,pointed)
local meta=itemstack:get_meta()
if meta:get_int("industrialtest.powerAmount")>=20 then
local itemstackCopy=itemstack
if itemstack:get_wear()~=industrialtest.internal.mclMakeStrippedTrunk(itemstackCopy,user,pointed,true):get_wear() then
industrialtest.api.addPowerToItem(itemstack,-20)
return itemstack
end
end
return nil
end
definition.after_use=function(itemstack)
-- Hack to make sure that chainsaw won't be destroyed when has 0 EU in MCL
return nil
end
definition._mcl_diggroups={
axey={
speed=config.inactiveDigSpeed,
level=config.digLevel,
uses=-1
}
}
definition._mcl_toollike_wield=true
end
minetest.register_tool("industrialtest:"..config.name,definition)
definition=table.copy(definition)
if industrialtest.mtgAvailable then
definition.tool_capabilities.groupcaps.choppy.times=config.activeTimes
elseif industrialtest.mclAvailable then
definition._mcl_diggroups.axey.speed=config.activeDigSpeed
end
definition.groups.not_in_creative_inventory=1
definition.on_use=nil
definition.after_use=function(itemstack,user,node,digparams)
industrialtest.api.addPowerToItem(itemstack,-20)
itemstack:set_name("industrialtest:"..config.name)
return itemstack
end
minetest.register_tool("industrialtest:"..config.name.."_active",definition)
registeredElectricChainsaws["industrialtest:"..config.name]=true
end
definition={
name="electric_chainsaw",
displayName="Electric Chainsaw"
}
if industrialtest.mtgAvailable then
definition.maxDropLevel=1
definition.inactiveTimes={[1]=10,[2]=5.6,[3]=4}
definition.maxLevel=2
definition.activeTimes={[1]=2.2,[2]=1.1,[3]=0.7}
elseif industrialtest.mclAvailable then
definition.digSpeedClass=4
definition.maxDropLevel=4
definition.inactiveDigSpeed=1
definition.digLevel=4
definition.activeDigSpeed=7
end
registerElectricChainsaw(definition)
minetest.register_craft({
type="shaped",
output="industrialtest:electric_chainsaw",
recipe={
{"","industrialtest:refined_iron_ingot","industrialtest:refined_iron_ingot"},
{"industrialtest:refined_iron_ingot","industrialtest:electronic_circuit","industrialtest:refined_iron_ingot"},
{"industrialtest:re_battery","industrialtest:refined_iron_ingot",""}
}
})
definition={
name="diamond_electric_chainsaw",
displayName="Diamond Electric Chainsaw"
}
if industrialtest.mtgAvailable then
definition.maxDropLevel=1
definition.inactiveTimes={[1]=10,[2]=5.6,[3]=4}
definition.maxLevel=3
definition.activeTimes={[1]=2.0,[2]=0.8,[3]=0.4}
elseif industrialtest.mclAvailable then
definition.digSpeedClass=5
definition.maxDropLevel=5
definition.inactiveDigSpeed=1
definition.digLevel=5
definition.activeDigSpeed=9
end
registerElectricChainsaw(definition)
minetest.register_craft({
type="shaped",
output="industrialtest:diamond_electric_chainsaw",
recipe={
{"",industrialtest.elementKeys.diamond,""},
{industrialtest.elementKeys.diamond,"industrialtest:electric_chainsaw",industrialtest.elementKeys.diamond}
}
})
local registeredElectricHoes={}
local function registerElectricHoe(config)
local definition={
description=S(config.displayName),
inventory_image="industrialtest_"..config.name..".png",
_industrialtest_powerStorage=true,
_industrialtest_powerCapacity=10000,
_industrialtest_powerFlow=industrialtest.api.lvPowerFlow
}
if industrialtest.mtgAvailable then
-- Taken and adapted from farming mod from Minetest Game
local function onUse(user,pointed)
local pt = pointed
-- check if pointing at a node
if not pt then
return false
end
if pt.type ~= "node" then
return false
end
local under = minetest.get_node(pt.under)
local p = {x=pt.under.x, y=pt.under.y+1, z=pt.under.z}
local above = minetest.get_node(p)
-- return if any of the nodes is not registered
if not minetest.registered_nodes[under.name] then
return false
end
if not minetest.registered_nodes[above.name] then
return false
end
-- check if the node above the pointed thing is air
if above.name ~= "air" then
return false
end
-- check if pointing at soil
if minetest.get_item_group(under.name, "soil") ~= 1 then
return false
end
-- check if (wet) soil defined
local regN = minetest.registered_nodes
if regN[under.name].soil == nil or regN[under.name].soil.wet == nil or regN[under.name].soil.dry == nil then
return false
end
local player_name = user and user:get_player_name() or ""
if minetest.is_protected(pt.under, player_name) then
minetest.record_protection_violation(pt.under, player_name)
return false
end
if minetest.is_protected(pt.above, player_name) then
minetest.record_protection_violation(pt.above, player_name)
return false
end
-- turn the node into soil and play sound
minetest.set_node(pt.under, {name = regN[under.name].soil.dry})
minetest.sound_play("default_dig_crumbly", {
pos = pt.under,
gain = 0.3,
}, true)
return true
end
definition.groups={
hoe=1
}
definition.on_use=function(itemstack,user,pointed)
local meta=itemstack:get_meta()
if meta:get_int("industrialtest.powerAmount")>=20 and onUse(user,pointed) then
industrialtest.api.addPowerToItem(itemstack,-20)
return itemstack
end
return nil
end
elseif industrialtest.mclAvailable then
-- Taken from https://git.minetest.land/MineClone2/MineClone2/src/branch/master/mods/ITEMS/mcl_farming/hoes.lua#L3
local function createSoil(pos)
if pos == nil then
return false
end
local node = minetest.get_node(pos)
local name = node.name
local above = minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z})
if minetest.get_item_group(name, "cultivatable") == 2 then
if above.name == "air" then
node.name = "mcl_farming:soil"
minetest.set_node(pos, node)
minetest.sound_play("default_dig_crumbly", { pos = pos, gain = 0.5 }, true)
return true
end
elseif minetest.get_item_group(name, "cultivatable") == 1 then
if above.name == "air" then
node.name = "mcl_core:dirt"
minetest.set_node(pos, node)
minetest.sound_play("default_dig_crumbly", { pos = pos, gain = 0.6 }, true)
return true
end
end
return false
end
definition.tool_capabilities={
full_punch_interval=0.5
}
definition.groups={
tool=1
}
definition.on_place=function(itemstack,user,pointed)
local node=minetest.get_node(pointed.under)
if user and not user:get_player_control().sneak then
if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then
return minetest.registered_nodes[node.name].on_rightclick(pointed.under,node,user,itemstack) or itemstack
end
end
if minetest.is_protected(pointed.under, user:get_player_name()) then
minetest.record_protection_violation(pointed.under,user:get_player_name())
return nil
end
local meta=itemstack:get_meta()
if meta:get_int("industrialtest.powerAmount")>=20 and createSoil(pointed.under) then
industrialtest.api.addPowerToItem(itemstack,-20)
return itemstack
end
return nil
end
definition.after_use=function(itemstack)
-- Hack to make sure that chainsaw won't be destroyed when has 0 EU in MCL
return nil
end
definition._mcl_toollike_wield=true
definition._mcl_diggroups={
hoey={
speed=config.inactiveDigSpeed,
level=config.digLevel,
uses=-1
}
}
end
minetest.register_tool("industrialtest:"..config.name,definition)
if industrialtest.mclAvailable then
definition=table.copy(definition)
definition._mcl_diggroups.hoey.speed=config.activeDigSpeed
definition.groups.not_in_creative_inventory=1
definition.after_use=function(itemstack)
industrialtest.api.addPowerToItem(itemstack,-20)
itemstack:set_name("industrialtest:"..config.name)
return itemstack
end
minetest.register_tool("industrialtest:"..config.name.."_active",definition)
end
registeredElectricHoes["industrialtest:"..config.name]=true
end
definition={
name="electric_hoe",
displayName="Electric Hoe"
}
if industrialtest.mclAvailable then
definition.inactiveDigSpeed=1
definition.digLevel=2
definition.activeDigSpeed=7
end
registerElectricHoe(definition)
minetest.register_craft({
type="shaped",
output="industrialtest:electric_hoe",
recipe={
{"industrialtest:refined_iron_ingot","industrialtest:refined_iron_ingot"},
{"","industrialtest:electronic_circuit"},
{"","industrialtest:re_battery"}
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:electric_hoe",
recipe={
{"industrialtest:refined_iron_ingot","industrialtest:refined_iron_ingot"},
{"industrialtest:electronic_circuit",""},
{"industrialtest:re_battery",""}
}
})
if industrialtest.mclAvailable then
registerElectricHoe({
name="diamond_electric_hoe",
displayName="Diamond Electric Hoe",
inactiveDigSpeed=1,
digLevel=5,
activeDigSpeed=9
})
minetest.register_craft({
type="shapeless",
output="industrialtest:diamond_electric_hoe",
recipe={
"industrialtest:electric_hoe",
industrialtest.elementKeys.diamond,
industrialtest.elementKeys.diamond
}
})
end
local registeredElectricDrills={}
local function registerElectricDrill(config)
local definition={
description=S(config.displayName),
inventory_image="industrialtest_"..config.name..".png",
_industrialtest_powerStorage=true,
_industrialtest_powerCapacity=10000,
_industrialtest_powerFlow=industrialtest.api.lvPowerFlow
}
if industrialtest.mtgAvailable then
definition.tool_capabilities={
full_punch_interval=0.5,
max_drop_level=config.maxDropLevel,
groupcaps={
cracky={
times=config.inactiveTimes,
maxlevel=config.maxLevel
},
crumbly={
times=config.inactiveTimes,
maxlevel=config.maxLevel
}
}
}
definition.groups={
pickaxe=1,
shovel=1
}
elseif industrialtest.mclAvailable then
definition.tool_capabilities={
full_punch_interval=0.5,
max_drop_level=config.maxDropLevel
}
definition.groups={
tool=1,
dig_speed_class=config.digSpeedClass
}
definition.after_use=function()
-- Hack to make sure that drill won't be destroyed when has 0 EU in MCL
return nil
end
definition._mcl_diggroups={
pickaxey={
speed=config.inactiveDigSpeed,
level=config.digLevel,
uses=-1
},
shovely={
speed=config.inactiveDigSpeed,
level=config.digLevel,
uses=-1
}
}
definition._mcl_toollike_wield=true
end
minetest.register_tool("industrialtest:"..config.name,definition)
definition=table.copy(definition)
if industrialtest.mtgAvailable then
definition.tool_capabilities.groupcaps.cracky.times=config.activeTimes
definition.tool_capabilities.groupcaps.crumbly.times=config.activeTimes
elseif industrialtest.mclAvailable then
definition._mcl_diggroups.pickaxey.speed=config.activeDigSpeed
definition._mcl_diggroups.shovely.speed=config.activeDigSpeed
end
definition.groups.not_in_creative_inventory=1
definition.after_use=function(itemstack)
industrialtest.api.addPowerToItem(itemstack,-20)
itemstack:set_name("industrialtest:"..config.name)
return itemstack
end
minetest.register_tool("industrialtest:"..config.name.."_active",definition)
registeredElectricDrills["industrialtest:"..config.name]=true
end
definition={
name="electric_drill",
displayName="Electric Drill"
}
if industrialtest.mtgAvailable then
definition.maxDropLevel=1
definition.inactiveTimes={[1]=10,[2]=5.6,[3]=4}
definition.maxLevel=2
definition.activeTimes={[1]=2.0,[2]=0.8,[3]=0.4}
elseif industrialtest.mclAvailable then
definition.digSpeedClass=4
definition.maxDropLevel=4
definition.inactiveDigSpeed=1
definition.digLevel=4
definition.activeDigSpeed=7
end
registerElectricDrill(definition)
minetest.register_craft({
type="shaped",
output="industrialtest:electric_drill",
recipe={
{"","industrialtest:refined_iron_ingot",""},
{"industrialtest:refined_iron_ingot","industrialtest:electronic_circuit","industrialtest:refined_iron_ingot"},
{"industrialtest:refined_iron_ingot","industrialtest:re_battery","industrialtest:refined_iron_ingot"}
}
})
definition={
name="diamond_electric_drill",
displayName="Diamond Electric Drill"
}
if industrialtest.mtgAvailable then
definition.maxDropLevel=1
definition.inactiveTimes={[1]=10,[2]=5.6,[3]=4}
definition.maxLevel=3
definition.activeTimes={[1]=2.0,[2]=0.8,[3]=0.4}
elseif industrialtest.mclAvailable then
definition.digSpeedClass=5
definition.maxDropLevel=5
definition.inactiveDigSpeed=1
definition.digLevel=5
definition.activeDigSpeed=9
end
registerElectricDrill(definition)
minetest.register_craft({
type="shaped",
output="industrialtest:diamond_electric_drill",
recipe={
{"",industrialtest.elementKeys.diamond,""},
{industrialtest.elementKeys.diamond,"industrialtest:electric_drill",industrialtest.elementKeys.diamond}
}
})
local registeredElectricSabers={}
local function registerElectricSaber(config)
local definition={
description=S(config.displayName),
inventory_image="industrialtest_"..config.name..".png",
_industrialtest_powerStorage=true,
_industrialtest_powerCapacity=10000,
_industrialtest_powerFlow=industrialtest.api.lvPowerFlow
}
if industrialtest.mtgAvailable then
definition.groups={
sword=1
}
definition.tool_capabilities={
full_punch_interval=0.5,
max_drop_level=config.maxDropLevel,
groupcaps={
snappy={
times=config.inactiveTimes,
maxlevel=config.maxLevel
}
},
damage_groups={fleshy=config.inactiveDamage}
}
elseif industrialtest.mclAvailable then
definition.groups={
weapon=1,
sword=1,
dig_speed_class=config.digSpeedClass
}
definition.tool_capabilities={
full_punch_interval=0.5,
max_drop_level=config.maxDropLevel,
damage_groups={fleshy=config.inactiveDamage}
}
definition.after_use=function()
-- Hack to make sure that saber won't be destroyed when has 0 EU in MCL
return nil
end
definition._mcl_toollike_wield=true
definition._mcl_diggroups={
swordy={
speed=config.inactiveDigSpeed,
level=config.digLevel,
uses=-1
},
swordy_cobweb={
speed=config.inactiveDigSpeed,
level=config.digLevel,
uses=-1
}
}
end
minetest.register_tool("industrialtest:"..config.name,definition)
definition=table.copy(definition)
if industrialtest.mtgAvailable then
definition.tool_capabilities.groupcaps.snappy.times=config.activeTimes
definition.tool_capabilities.damage_groups.fleshy=config.activeDamage
elseif industrialtest.mclAvailable then
definition.tool_capabilities.damage_groups.fleshy=config.activeDamage
definition._mcl_diggroups.swordy.speed=config.activeDigSpeed
definition._mcl_diggroups.swordy_cobweb.speed=config.activeDigSpeed
end
definition.groups.not_in_creative_inventory=1
definition.after_use=function()
return nil
end
minetest.register_tool("industrialtest:"..config.name.."_active",definition)
registeredElectricSabers["industrialtest:"..config.name]=true
end
definition={
name="electric_saber",
displayName="Electric Saber"
}
if industrialtest.mtgAvailable then
definition.maxDropLevel=1
definition.inactiveTimes={[1]=10,[2]=5.6,[3]=4}
definition.maxLevel=3
definition.inactiveDamage=1
definition.activeTimes={[1]=2.0,[2]=0.8,[3]=0.4}
definition.activeDamage=6
elseif industrialtest.mclAvailable then
definition.digSpeedClass=4
definition.maxDropLevel=4
definition.inactiveDamage=1
definition.inactiveDigSpeed=1
definition.digLevel=4
definition.activeDamage=6
definition.activeDigSpeed=7
end
registerElectricSaber(definition)
minetest.register_craft({
type="shaped",
output="industrialtest:electric_saber",
recipe={
{"industrialtest:refined_iron_ingot"},
{"industrialtest:refined_iron_ingot"},
{"industrialtest:re_battery"}
}
})
definition={
name="diamond_electric_saber",
displayName="Diamond Electric Saber"
}
if industrialtest.mtgAvailable then
definition.maxDropLevel=1
definition.inactiveTimes={[1]=10,[2]=5.6,[3]=4}
definition.maxLevel=3
definition.inactiveDamage=1
definition.activeTimes={[1]=2.0,[2]=0.8,[3]=0.4}
definition.activeDamage=9
elseif industrialtest.mclAvailable then
definition.digSpeedClass=5
definition.maxDropLevel=5
definition.inactiveDamage=1
definition.inactiveDigSpeed=1
definition.digLevel=5
definition.activeDamage=9
definition.activeDigSpeed=9
end
registerElectricSaber(definition)
minetest.register_craft({
type="shapeless",
output="industrialtest:diamond_electric_saber",
recipe={
"industrialtest:electric_saber",
industrialtest.elementKeys.diamond,
industrialtest.elementKeys.diamond
}
})
-- Tool callbacks
minetest.register_on_punchnode(function(pos,node,user,pointed)
if user then
local itemstack=user:get_wielded_item()
if registeredElectricChainsaws[itemstack:get_name()] then
local meta=itemstack:get_meta()
if meta:get_int("industrialtest.powerAmount")>=20 then
local def=minetest.registered_nodes[node.name]
if (industrialtest.mtgAvailable and def.groups and def.groups.choppy) or (industrialtest.mclAvailable and def.groups and def.groups.axey) then
itemstack:set_name(itemstack:get_name().."_active")
user:set_wielded_item(itemstack)
end
end
elseif industrialtest.mclAvailable and registeredElectricHoes[itemstack:get_name()] then
local meta=itemstack:get_meta()
if meta:get_int("industrialtest.powerAmount")>=20 then
local def=minetest.registered_nodes[node.name]
if def.groups and def.groups.hoey then
itemstack:set_name(itemstack:get_name().."_active")
user:set_wielded_item(itemstack)
end
end
elseif registeredElectricDrills[itemstack:get_name()] then
local meta=itemstack:get_meta()
if meta:get_int("industrialtest.powerAmount")>=20 then
local def=minetest.registered_nodes[node.name]
if (industrialtest.mtgAvailable and def.groups and (def.groups.cracky or def.groups.crumbly)) or (industrialtest.mclAvailable and def.groups and (def.groups.pickaxey or def.groups.shovely)) then
itemstack:set_name(itemstack:get_name().."_active")
user:set_wielded_item(itemstack)
end
end
elseif registeredElectricSabers[itemstack:get_name()] then
local meta=itemstack:get_meta()
if meta:get_int("industrialtest.powerAmount")>=20 then
local def=minetest.registered_nodes[node.name]
if (industrialtest.mtgAvailable and def.groups and def.groups.snappy) or (industrialtest.mclAvailable and def.groups and (def.groups.swordy or def.groups.swordy_cobweb)) then
itemstack:set_name(itemstack:get_name().."_active")
user:set_wielded_item(itemstack)
end
end
end
end
end)
minetest.register_on_punchplayer(function(player,hitter)
local itemstack=hitter:get_wielded_item()
if registeredElectricSabers[itemstack:get_name()] then
local meta=itemstack:get_meta()
if meta:get_int("industrialtest.powerAmount")>=20 then
industrialtest.api.addPowerToItem(itemstack,-20)
hitter:set_wielded_item(itemstack)
local def=minetest.registered_tools[itemstack:get_name().."_active"]
player:set_hp(player:get_hp()-def.tool_capabilites.damage_groups.fleshy)
return true
end
end
return false
end)

138
tools/batpack.lua Normal file
View File

@@ -0,0 +1,138 @@
-- IndustrialTest
-- Copyright (C) 2024 mrkubax10
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local S=minetest.get_translator("industrialtest")
local updateDelta=0
local function registerBatpack(config)
if industrialtest.mtgAvailable then
armor:register_armor("industrialtest:"..config.name,{
description=config.displayName,
inventory_image="industrialtest_"..config.name.."_inv.png",
groups={
armor_torso=1,
armor_heal=0,
_industrialtest_batpack=1
},
_industrialtest_powerStorage=true,
_industrialtest_powerCapacity=config.powerCapacity,
_industrialtest_powerFlow=config.powerFlow
})
elseif industrialtest.mclAvailable then
minetest.register_tool("industrialtest:"..config.name,{
description=config.displayName,
inventory_image="industrialtest_"..config.name.."_inv.png",
groups={
armor=1,
non_combat_armor=1,
armor_torso=1,
non_combat_torso=1,
_industrialtest_batpack=1
},
sounds={
_mcl_armor_equip="mcl_armor_equip_iron",
_mcl_armor_unequip="mcl_armor_unequip_iron"
},
on_place=mcl_armor.equip_on_use,
on_secondary_use=mcl_armor.equip_on_use,
_mcl_armor_element="torso",
_mcl_armor_texture="industrialtest_"..config.name..".png",
_industrialtest_powerStorage=true,
_industrialtest_powerCapacity=config.powerCapacity,
_industrialtest_powerFlow=config.powerFlow
})
end
end
local function onGlobalStep(player,inv,stack,index,def)
if not def.groups or not def.groups._industrialtest_batpack then
return false
end
local wielded=player:get_wielded_item()
local wieldedMeta=wielded:get_meta()
if not industrialtest.api.hasPowerStorage(wieldedMeta) or wieldedMeta:get_int("industrialtest.powerFlow")>def._industrialtest_powerFlow then
return true
end
if industrialtest.api.transferPowerFromItem(stack,wieldedMeta,def._industrialtest_powerFlow)>0 then
industrialtest.api.updateItemPowerText(wielded)
player:set_wielded_item(wielded)
inv:set_stack("armor",index,stack)
end
return true
end
registerBatpack({
name="batpack_v",
displayName=S("BatPack"),
powerCapacity=60000,
powerFlow=industrialtest.api.lvPowerFlow
})
minetest.register_craft({
type="shaped",
output="industrialtest:batpack_v",
recipe={
{"industrialtest:re_battery","industrialtest:electronic_circuit","industrialtest:re_battery"},
{"industrialtest:re_battery",industrialtest.elementKeys.tinIngot,"industrialtest:re_battery"},
{"industrialtest:re_battery","","industrialtest:re_battery"}
}
})
registerBatpack({
name="lappack_v",
displayName=S("LapPack"),
powerCapacity=300000,
powerFlow=industrialtest.api.hvPowerFlow
})
minetest.register_craft({
type="shaped",
output="industrialtest:lappack_v",
recipe={
{industrialtest.elementKeys.powerCarrier,"industrialtest:electronic_circuit",industrialtest.elementKeys.powerCarrier},
{industrialtest.elementKeys.powerCarrier,"industrialtest:batpack_v",industrialtest.elementKeys.powerCarrier},
{industrialtest.elementKeys.powerCarrier,"",industrialtest.elementKeys.powerCarrier}
}
})
minetest.register_globalstep(function(dtime)
updateDelta=updateDelta+dtime
if updateDelta<industrialtest.updateDelay then
return
end
updateDelta=0
local players=minetest.get_connected_players()
for _,player in ipairs(players) do
if industrialtest.mtgAvailable then
local _,inv=armor:get_valid_player(player,"")
if inv then
local armorList=inv:get_list("armor")
assert(armorList)
for i=1,#armorList do
local stack=armorList[i]
local def=stack:get_definition()
if onGlobalStep(player,inv,stack,i,def) then
break
end
end
end
elseif industrialtest.mclAvailable then
local inv=player:get_inventory()
local stack=inv:get_stack("armor",3)
local def=stack:get_definition()
onGlobalStep(player,inv,stack,3,def)
end
end
end)

55
tools/common.lua Normal file
View File

@@ -0,0 +1,55 @@
-- IndustrialTest
-- Copyright (C) 2024 mrkubax10
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
industrialtest.internal.registeredElectricChainsaws={}
industrialtest.internal.registeredElectricDrills={}
industrialtest.internal.registeredElectricHoes={}
industrialtest.internal.registeredElectricSabers={}
local function isActive(itemstack)
return string.sub(itemstack:get_name(),-string.len("_active"),-1)=="_active"
end
local function beforeUse(user,itemstack,canDig)
local meta=itemstack:get_meta()
local def=itemstack:get_definition()
if meta:get_int("industrialtest.powerAmount")>=20 and canDig then
if not isActive(itemstack) then
itemstack:set_name(itemstack:get_name().."_active")
end
else
itemstack:set_name(def._industrialtest_inactiveName)
end
user:set_wielded_item(itemstack)
end
minetest.register_on_punchnode(function(pos,node,user,pointed)
if not user then
return
end
local itemstack=user:get_wielded_item()
local meta=itemstack:get_meta()
local def=minetest.registered_nodes[node.name]
if industrialtest.internal.registeredElectricChainsaws[itemstack:get_name()] then
beforeUse(user,itemstack,(industrialtest.mtgAvailable and def.groups and def.groups.choppy) or (industrialtest.mclAvailable and def.groups and def.groups.axey))
elseif industrialtest.mclAvailable and industrialtest.internal.registeredElectricHoes[itemstack:get_name()] then
beforeUse(user,itemstack,def.groups and def.groups.hoey)
elseif industrialtest.internal.registeredElectricDrills[itemstack:get_name()] then
beforeUse(user,itemstack,(industrialtest.mtgAvailable and def.groups and (def.groups.cracky or def.groups.crumbly)) or (industrialtest.mclAvailable and def.groups and (def.groups.pickaxey or def.groups.shovely)))
elseif industrialtest.internal.registeredElectricSabers[itemstack:get_name()] then
beforeUse(user,itemstack,(industrialtest.mtgAvailable and def.groups and def.groups.snappy) or (industrialtest.mclAvailable and def.groups and (def.groups.swordy or def.groups.swordy_cobweb)))
end
end)

152
tools/electric_chainsaw.lua Normal file
View File

@@ -0,0 +1,152 @@
-- IndustrialTest
-- Copyright (C) 2024 mrkubax10
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local S=minetest.get_translator("industrialtest")
local electricChainsaw={}
electricChainsaw.afterUse=function(itemstack,config)
local meta=itemstack:get_meta()
industrialtest.api.addPowerToItem(itemstack,-20)
if meta:get_int("industrialtest.powerAmount")<20 then
itemstack:set_name("industrialtest:"..config.name)
end
return itemstack
end
local function registerElectricChainsaw(config)
local definition={
description=config.displayName,
inventory_image="industrialtest_"..config.name..".png",
_industrialtest_powerStorage=true,
_industrialtest_powerCapacity=10000,
_industrialtest_powerFlow=industrialtest.api.lvPowerFlow,
_industrialtest_inactiveName="industrialtest:"..config.name
}
if industrialtest.mtgAvailable then
definition.tool_capabilities={
full_punch_interval=0.5,
max_drop_level=config.maxDropLevel,
groupcaps={
choppy={
times=config.inactiveTimes,
maxlevel=config.maxLevel
}
}
}
definition.groups={
axe=1
}
elseif industrialtest.mclAvailable then
definition.tool_capabilities={
full_punch_interval=0.5,
max_drop_level=config.maxDropLevel,
}
definition.groups={
tool=1,
dig_speed_class=config.digSpeedClass,
}
definition.on_place=function(itemstack,user,pointed)
local meta=itemstack:get_meta()
if meta:get_int("industrialtest.powerAmount")>=20 then
local itemstackCopy=itemstack
if itemstack:get_wear()~=industrialtest.internal.mclMakeStrippedTrunk(itemstackCopy,user,pointed,true):get_wear() then
industrialtest.api.addPowerToItem(itemstack,-20)
return itemstack
end
end
return nil
end
definition.after_use=function(itemstack)
-- Hack to make sure that chainsaw won't be destroyed when has 0 EU in MCL
return nil
end
definition._mcl_diggroups={
axey={
speed=config.inactiveDigSpeed,
level=config.digLevel,
uses=-1
}
}
definition._mcl_toollike_wield=true
end
minetest.register_tool("industrialtest:"..config.name,definition)
definition=table.copy(definition)
if industrialtest.mtgAvailable then
definition.tool_capabilities.groupcaps.choppy.times=config.activeTimes
elseif industrialtest.mclAvailable then
definition._mcl_diggroups.axey.speed=config.activeDigSpeed
end
definition.groups.not_in_creative_inventory=1
definition.on_use=nil
definition.after_use=function(itemstack)
return electricChainsaw.afterUse(itemstack,config)
end
minetest.register_tool("industrialtest:"..config.name.."_active",definition)
industrialtest.internal.registeredElectricChainsaws["industrialtest:"..config.name]=true
industrialtest.internal.registeredElectricChainsaws["industrialtest:"..config.name.."_active"]=true
end
local definition={
name="electric_chainsaw",
displayName=S("Electric Chainsaw")
}
if industrialtest.mtgAvailable then
definition.maxDropLevel=1
definition.inactiveTimes={[1]=10,[2]=5.6,[3]=4}
definition.maxLevel=2
definition.activeTimes={[1]=2.2,[2]=1.1,[3]=0.7}
elseif industrialtest.mclAvailable then
definition.digSpeedClass=4
definition.maxDropLevel=4
definition.inactiveDigSpeed=1
definition.digLevel=4
definition.activeDigSpeed=7
end
registerElectricChainsaw(definition)
minetest.register_craft({
type="shaped",
output="industrialtest:electric_chainsaw",
recipe={
{"","industrialtest:refined_iron_ingot","industrialtest:refined_iron_ingot"},
{"industrialtest:refined_iron_ingot","industrialtest:electronic_circuit","industrialtest:refined_iron_ingot"},
{"industrialtest:re_battery","industrialtest:refined_iron_ingot",""}
}
})
definition={
name="diamond_electric_chainsaw",
displayName=S("Diamond Electric Chainsaw")
}
if industrialtest.mtgAvailable then
definition.maxDropLevel=1
definition.inactiveTimes={[1]=10,[2]=5.6,[3]=4}
definition.maxLevel=3
definition.activeTimes={[1]=2.0,[2]=0.8,[3]=0.4}
elseif industrialtest.mclAvailable then
definition.digSpeedClass=5
definition.maxDropLevel=5
definition.inactiveDigSpeed=1
definition.digLevel=5
definition.activeDigSpeed=9
end
registerElectricChainsaw(definition)
minetest.register_craft({
type="shaped",
output="industrialtest:diamond_electric_chainsaw",
recipe={
{"",industrialtest.elementKeys.diamond,""},
{industrialtest.elementKeys.diamond,"industrialtest:electric_chainsaw",industrialtest.elementKeys.diamond}
}
})

152
tools/electric_drill.lua Normal file
View File

@@ -0,0 +1,152 @@
-- IndustrialTest
-- Copyright (C) 2024 mrkubax10
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local S=minetest.get_translator("industrialtest")
local electricDrill={}
electricDrill.afterUse=function(itemstack,config)
local meta=itemstack:get_meta()
industrialtest.api.addPowerToItem(itemstack,-20)
if meta:get_int("industrialtest.powerAmount")<20 then
itemstack:set_name("industrialtest:"..config.name)
end
return itemstack
end
local function registerElectricDrill(config)
local definition={
description=config.displayName,
inventory_image="industrialtest_"..config.name..".png",
_industrialtest_powerStorage=true,
_industrialtest_powerCapacity=10000,
_industrialtest_powerFlow=industrialtest.api.lvPowerFlow,
_industrialtest_inactiveName="industrialtest:"..config.name
}
if industrialtest.mtgAvailable then
definition.tool_capabilities={
full_punch_interval=0.5,
max_drop_level=config.maxDropLevel,
groupcaps={
cracky={
times=config.inactiveTimes,
maxlevel=config.maxLevel
},
crumbly={
times=config.inactiveTimes,
maxlevel=config.maxLevel
}
}
}
definition.groups={
pickaxe=1,
shovel=1
}
elseif industrialtest.mclAvailable then
definition.tool_capabilities={
full_punch_interval=0.5,
max_drop_level=config.maxDropLevel
}
definition.groups={
tool=1,
dig_speed_class=config.digSpeedClass
}
definition.after_use=function()
-- Hack to make sure that drill won't be destroyed when has 0 EU in MCL
return nil
end
definition._mcl_diggroups={
pickaxey={
speed=config.inactiveDigSpeed,
level=config.digLevel,
uses=-1
},
shovely={
speed=config.inactiveDigSpeed,
level=config.digLevel,
uses=-1
}
}
definition._mcl_toollike_wield=true
end
minetest.register_tool("industrialtest:"..config.name,definition)
definition=table.copy(definition)
if industrialtest.mtgAvailable then
definition.tool_capabilities.groupcaps.cracky.times=config.activeTimes
definition.tool_capabilities.groupcaps.crumbly.times=config.activeTimes
elseif industrialtest.mclAvailable then
definition._mcl_diggroups.pickaxey.speed=config.activeDigSpeed
definition._mcl_diggroups.shovely.speed=config.activeDigSpeed
end
definition.groups.not_in_creative_inventory=1
definition.after_use=function(itemstack)
return electricDrill.afterUse(itemstack,config)
end
minetest.register_tool("industrialtest:"..config.name.."_active",definition)
industrialtest.internal.registeredElectricDrills["industrialtest:"..config.name]=true
industrialtest.internal.registeredElectricDrills["industrialtest:"..config.name.."_active"]=true
end
local definition={
name="electric_drill",
displayName=S("Electric Drill")
}
if industrialtest.mtgAvailable then
definition.maxDropLevel=1
definition.inactiveTimes={[1]=10,[2]=5.6,[3]=4}
definition.maxLevel=2
definition.activeTimes={[1]=2.0,[2]=0.8,[3]=0.4}
elseif industrialtest.mclAvailable then
definition.digSpeedClass=4
definition.maxDropLevel=4
definition.inactiveDigSpeed=1
definition.digLevel=4
definition.activeDigSpeed=7
end
registerElectricDrill(definition)
minetest.register_craft({
type="shaped",
output="industrialtest:electric_drill",
recipe={
{"","industrialtest:refined_iron_ingot",""},
{"industrialtest:refined_iron_ingot","industrialtest:electronic_circuit","industrialtest:refined_iron_ingot"},
{"industrialtest:refined_iron_ingot","industrialtest:re_battery","industrialtest:refined_iron_ingot"}
}
})
definition={
name="diamond_electric_drill",
displayName=S("Diamond Electric Drill")
}
if industrialtest.mtgAvailable then
definition.maxDropLevel=1
definition.inactiveTimes={[1]=10,[2]=5.6,[3]=4}
definition.maxLevel=3
definition.activeTimes={[1]=2.0,[2]=0.8,[3]=0.4}
elseif industrialtest.mclAvailable then
definition.digSpeedClass=5
definition.maxDropLevel=5
definition.inactiveDigSpeed=1
definition.digLevel=5
definition.activeDigSpeed=9
end
registerElectricDrill(definition)
minetest.register_craft({
type="shaped",
output="industrialtest:diamond_electric_drill",
recipe={
{"",industrialtest.elementKeys.diamond,""},
{industrialtest.elementKeys.diamond,"industrialtest:electric_drill",industrialtest.elementKeys.diamond}
}
})

231
tools/electric_hoe.lua Normal file
View File

@@ -0,0 +1,231 @@
-- IndustrialTest
-- Copyright (C) 2024 mrkubax10
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local S=minetest.get_translator("industrialtest")
local electricHoe={}
electricHoe.afterUse=function(itemstack,config)
local meta=itemstack:get_meta()
industrialtest.api.addPowerToItem(itemstack,-20)
if meta:get_int("industrialtest.powerAmount")<20 then
itemstack:set_name("industrialtest:"..config.name)
end
return itemstack
end
local function registerElectricHoe(config)
local definition={
description=config.displayName,
inventory_image="industrialtest_"..config.name..".png",
_industrialtest_powerStorage=true,
_industrialtest_powerCapacity=10000,
_industrialtest_powerFlow=industrialtest.api.lvPowerFlow,
_industrialtest_inactiveName="industrialtest:"..config.name
}
if industrialtest.mtgAvailable then
-- Taken and adapted from farming mod from Minetest Game
local function onUse(user,pointed)
local pt = pointed
-- check if pointing at a node
if not pt then
return false
end
if pt.type ~= "node" then
return false
end
local under = minetest.get_node(pt.under)
local p = {x=pt.under.x, y=pt.under.y+1, z=pt.under.z}
local above = minetest.get_node(p)
-- return if any of the nodes is not registered
if not minetest.registered_nodes[under.name] then
return false
end
if not minetest.registered_nodes[above.name] then
return false
end
-- check if the node above the pointed thing is air
if above.name ~= "air" then
return false
end
-- check if pointing at soil
if minetest.get_item_group(under.name, "soil") ~= 1 then
return false
end
-- check if (wet) soil defined
local regN = minetest.registered_nodes
if regN[under.name].soil == nil or regN[under.name].soil.wet == nil or regN[under.name].soil.dry == nil then
return false
end
local player_name = user and user:get_player_name() or ""
if minetest.is_protected(pt.under, player_name) then
minetest.record_protection_violation(pt.under, player_name)
return false
end
if minetest.is_protected(pt.above, player_name) then
minetest.record_protection_violation(pt.above, player_name)
return false
end
-- turn the node into soil and play sound
minetest.set_node(pt.under, {name = regN[under.name].soil.dry})
minetest.sound_play("default_dig_crumbly", {
pos = pt.under,
gain = 0.3,
}, true)
return true
end
definition.groups={
hoe=1
}
definition.on_use=function(itemstack,user,pointed)
local meta=itemstack:get_meta()
if meta:get_int("industrialtest.powerAmount")>=20 and onUse(user,pointed) then
industrialtest.api.addPowerToItem(itemstack,-20)
return itemstack
end
return nil
end
elseif industrialtest.mclAvailable then
-- Taken from https://git.minetest.land/MineClone2/MineClone2/src/branch/master/mods/ITEMS/mcl_farming/hoes.lua#L3
local function createSoil(pos)
if pos == nil then
return false
end
local node = minetest.get_node(pos)
local name = node.name
local above = minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z})
if minetest.get_item_group(name, "cultivatable") == 2 then
if above.name == "air" then
node.name = "mcl_farming:soil"
minetest.set_node(pos, node)
minetest.sound_play("default_dig_crumbly", { pos = pos, gain = 0.5 }, true)
return true
end
elseif minetest.get_item_group(name, "cultivatable") == 1 then
if above.name == "air" then
node.name = "mcl_core:dirt"
minetest.set_node(pos, node)
minetest.sound_play("default_dig_crumbly", { pos = pos, gain = 0.6 }, true)
return true
end
end
return false
end
definition.tool_capabilities={
full_punch_interval=0.5
}
definition.groups={
tool=1
}
definition.on_place=function(itemstack,user,pointed)
local node=minetest.get_node(pointed.under)
if user and not user:get_player_control().sneak then
if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then
return minetest.registered_nodes[node.name].on_rightclick(pointed.under,node,user,itemstack) or itemstack
end
end
if minetest.is_protected(pointed.under, user:get_player_name()) then
minetest.record_protection_violation(pointed.under,user:get_player_name())
return nil
end
local meta=itemstack:get_meta()
if meta:get_int("industrialtest.powerAmount")>=20 and createSoil(pointed.under) then
industrialtest.api.addPowerToItem(itemstack,-20)
return itemstack
end
return nil
end
definition.after_use=function(itemstack)
-- Hack to make sure that chainsaw won't be destroyed when has 0 EU in MCL
return nil
end
definition._mcl_toollike_wield=true
definition._mcl_diggroups={
hoey={
speed=config.inactiveDigSpeed,
level=config.digLevel,
uses=-1
}
}
end
minetest.register_tool("industrialtest:"..config.name,definition)
if industrialtest.mclAvailable then
definition=table.copy(definition)
definition._mcl_diggroups.hoey.speed=config.activeDigSpeed
definition.groups.not_in_creative_inventory=1
definition.after_use=function(itemstack)
return electricHoe.afterUse(itemstack,config)
end
minetest.register_tool("industrialtest:"..config.name.."_active",definition)
industrialtest.internal.registeredElectricHoes["industrialtest:"..config.name.."_active"]=true
end
industrialtest.internal.registeredElectricHoes["industrialtest:"..config.name]=true
end
local definition={
name="electric_hoe",
displayName=S("Electric Hoe")
}
if industrialtest.mclAvailable then
definition.inactiveDigSpeed=1
definition.digLevel=2
definition.activeDigSpeed=7
end
registerElectricHoe(definition)
minetest.register_craft({
type="shaped",
output="industrialtest:electric_hoe",
recipe={
{"industrialtest:refined_iron_ingot","industrialtest:refined_iron_ingot"},
{"","industrialtest:electronic_circuit"},
{"","industrialtest:re_battery"}
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:electric_hoe",
recipe={
{"industrialtest:refined_iron_ingot","industrialtest:refined_iron_ingot"},
{"industrialtest:electronic_circuit",""},
{"industrialtest:re_battery",""}
}
})
if industrialtest.mclAvailable then
registerElectricHoe({
name="diamond_electric_hoe",
displayName=S("Diamond Electric Hoe"),
inactiveDigSpeed=1,
digLevel=5,
activeDigSpeed=9
})
minetest.register_craft({
type="shapeless",
output="industrialtest:diamond_electric_hoe",
recipe={
"industrialtest:electric_hoe",
industrialtest.elementKeys.diamond,
industrialtest.elementKeys.diamond
}
})
end

175
tools/electric_saber.lua Normal file
View File

@@ -0,0 +1,175 @@
-- IndustrialTest
-- Copyright (C) 2024 mrkubax10
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local S=minetest.get_translator("industrialtest")
local electricSaber={}
electricSaber.afterUse=function(itemstack,config)
local meta=itemstack:get_meta()
industrialtest.api.addPowerToItem(itemstack,-20)
if meta:get_int("industrialtest.powerAmount")<20 then
itemstack:set_name("industrialtest:"..config.name)
end
return itemstack
end
local function registerElectricSaber(config)
local definition={
description=config.displayName,
inventory_image="industrialtest_"..config.name..".png",
_industrialtest_powerStorage=true,
_industrialtest_powerCapacity=10000,
_industrialtest_powerFlow=industrialtest.api.lvPowerFlow,
_industrialtest_inactiveName="industrialtest:"..config.name
}
if industrialtest.mtgAvailable then
definition.groups={
sword=1
}
definition.tool_capabilities={
full_punch_interval=0.5,
max_drop_level=config.maxDropLevel,
groupcaps={
snappy={
times=config.inactiveTimes,
maxlevel=config.maxLevel
}
},
damage_groups={fleshy=config.inactiveDamage}
}
elseif industrialtest.mclAvailable then
definition.groups={
weapon=1,
sword=1,
dig_speed_class=config.digSpeedClass
}
definition.tool_capabilities={
full_punch_interval=0.5,
max_drop_level=config.maxDropLevel,
damage_groups={fleshy=config.inactiveDamage}
}
definition.after_use=function()
-- Hack to make sure that saber won't be destroyed when has 0 EU in MCL
return nil
end
definition._mcl_toollike_wield=true
definition._mcl_diggroups={
swordy={
speed=config.inactiveDigSpeed,
level=config.digLevel,
uses=-1
},
swordy_cobweb={
speed=config.inactiveDigSpeed,
level=config.digLevel,
uses=-1
}
}
end
minetest.register_tool("industrialtest:"..config.name,definition)
definition=table.copy(definition)
if industrialtest.mtgAvailable then
definition.tool_capabilities.groupcaps.snappy.times=config.activeTimes
definition.tool_capabilities.damage_groups.fleshy=config.activeDamage
elseif industrialtest.mclAvailable then
definition.tool_capabilities.damage_groups.fleshy=config.activeDamage
definition._mcl_diggroups.swordy.speed=config.activeDigSpeed
definition._mcl_diggroups.swordy_cobweb.speed=config.activeDigSpeed
end
definition.groups.not_in_creative_inventory=1
definition.after_use=function(itemstack)
return electricSaber.afterUse(itemstack,config)
end
minetest.register_tool("industrialtest:"..config.name.."_active",definition)
industrialtest.internal.registeredElectricSabers["industrialtest:"..config.name]=true
industrialtest.internal.registeredElectricSabers["industrialtest:"..config.name.."_active"]=true
end
local definition={
name="electric_saber",
displayName=S("Electric Saber")
}
if industrialtest.mtgAvailable then
definition.maxDropLevel=1
definition.inactiveTimes={[1]=10,[2]=5.6,[3]=4}
definition.maxLevel=3
definition.inactiveDamage=1
definition.activeTimes={[1]=2.0,[2]=0.8,[3]=0.4}
definition.activeDamage=6
elseif industrialtest.mclAvailable then
definition.digSpeedClass=4
definition.maxDropLevel=4
definition.inactiveDamage=1
definition.inactiveDigSpeed=1
definition.digLevel=4
definition.activeDamage=6
definition.activeDigSpeed=7
end
registerElectricSaber(definition)
minetest.register_craft({
type="shaped",
output="industrialtest:electric_saber",
recipe={
{"industrialtest:refined_iron_ingot"},
{"industrialtest:refined_iron_ingot"},
{"industrialtest:re_battery"}
}
})
definition={
name="diamond_electric_saber",
displayName=S("Diamond Electric Saber")
}
if industrialtest.mtgAvailable then
definition.maxDropLevel=1
definition.inactiveTimes={[1]=10,[2]=5.6,[3]=4}
definition.maxLevel=3
definition.inactiveDamage=1
definition.activeTimes={[1]=2.0,[2]=0.8,[3]=0.4}
definition.activeDamage=9
elseif industrialtest.mclAvailable then
definition.digSpeedClass=5
definition.maxDropLevel=5
definition.inactiveDamage=1
definition.inactiveDigSpeed=1
definition.digLevel=5
definition.activeDamage=9
definition.activeDigSpeed=9
end
registerElectricSaber(definition)
minetest.register_craft({
type="shapeless",
output="industrialtest:diamond_electric_saber",
recipe={
"industrialtest:electric_saber",
industrialtest.elementKeys.diamond,
industrialtest.elementKeys.diamond
}
})
minetest.register_on_punchplayer(function(player,hitter)
local itemstack=hitter:get_wielded_item()
if registeredElectricSabers[itemstack:get_name()] then
local meta=itemstack:get_meta()
if meta:get_int("industrialtest.powerAmount")>=20 then
industrialtest.api.addPowerToItem(itemstack,-20)
hitter:set_wielded_item(itemstack)
local def=minetest.registered_tools[itemstack:get_name().."_active"]
player:set_hp(player:get_hp()-def.tool_capabilites.damage_groups.fleshy)
return true
end
end
return false
end)

190
tools/jetpack.lua Normal file
View File

@@ -0,0 +1,190 @@
-- IndustrialTest
-- Copyright (C) 2024 mrkubax10
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local S=minetest.get_translator("industrialtest")
local jetpack={}
local electricJetpack={}
local function registerJetpack(config)
if industrialtest.mclAvailable then
local groups={
armor=1,
non_combat_armor=1,
armor_torso=1,
non_combat_torso=1,
_industrialtest_jetpack=1
}
if config.groups then
for key,value in pairs(config.groups) do
groups[key]=value
end
end
local definition={
description=config.displayName,
inventory_image="industrialtest_"..config.name.."_inv.png",
groups=groups,
sounds={
_mcl_armor_equip="mcl_armor_equip_iron",
_mcl_armor_unequip="mcl_armor_unequip_iron"
},
on_place=mcl_armor.equip_on_use,
on_secondary_use=mcl_armor.equip_on_use,
_mcl_armor_element="torso",
_mcl_armor_texture="industrialtest_"..config.name..".png",
_industrialtest_tryFly=config.tryFly
}
if config.customKeys then
for key,value in pairs(config.customKeys) do
definition[key]=value
end
end
minetest.register_tool("industrialtest:"..config.name,definition)
elseif industrialtest.mtgAvailable then
local groups={
armor_torso=1,
armor_heal=0,
_industrialtest_jetpack=1
}
if config.groups then
for key,value in pairs(config.groups) do
groups[key]=value
end
end
local definition={
description=config.displayName,
inventory_image="industrialtest_"..config.name.."_inv.png",
groups=groups,
_industrialtest_tryFly=config.tryFly
}
if config.customKeys then
for key,value in pairs(config.customKeys) do
definition[key]=value
end
end
armor:register_armor("industrialtest:"..config.name,definition)
end
end
local function addYVelocityClamped(player,vel,max)
local playerVel=player:get_velocity()
if playerVel.y+vel>max then
player:add_velocity(vector.new(0,math.max(max-playerVel.y,0),0))
else
player:add_velocity(vector.new(0,vel,0))
end
end
local function onGlobalStep(player,inv,itemstack,index,def)
if def.groups and def.groups._industrialtest_jetpack then
if def._industrialtest_tryFly(itemstack) then
addYVelocityClamped(player,1,10)
inv:set_stack("armor",index,itemstack)
end
return true
end
return false
end
jetpack.tryFly=function(itemstack)
local meta=itemstack:get_meta()
if meta:get_int("industrialtest.fluidAmount")==0 then
return false
end
industrialtest.api.addFluidToItem(itemstack,-1)
return true
end
-- _v is hack to suppress "Registered armor doesn't have material at the end of registration name" warning from 3D Armor.
registerJetpack({
name="jetpack_v",
displayName=S("Jetpack"),
groups={
_industrialtest_fueled=1,
_industrialtest_fluidStorage=1
},
tryFly=jetpack.tryFly,
customKeys={
_industrialtest_fluidCapacity=5000
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:jetpack_v",
recipe={
{"industrialtest:refined_iron_ingot","industrialtest:electronic_circuit","industrialtest:refined_iron_ingot"},
{"industrialtest:refined_iron_ingot","industrialtest:fuel_can","industrialtest:refined_iron_ingot"},
{industrialtest.elementKeys.powerCarrier,"",industrialtest.elementKeys.powerCarrier}
}
})
electricJetpack.tryFly=function(itemstack)
local meta=itemstack:get_meta()
if meta:get_int("industrialtest.powerAmount")<10 then
return false
end
industrialtest.api.addPowerToItem(itemstack,-10)
return true
end
registerJetpack({
name="electric_jetpack",
displayName=S("Electric Jetpack"),
tryFly=electricJetpack.tryFly,
customKeys={
_industrialtest_powerStorage=true,
_industrialtest_powerCapacity=30000,
_industrialtest_powerFlow=industrialtest.api.lvPowerFlow
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:electric_jetpack",
recipe={
{"industrialtest:refined_iron_ingot","industrialtest:advanced_electronic_circuit","industrialtest:refined_iron_ingot"},
{"industrialtest:refined_iron_ingot","industrialtest:batbox","industrialtest:refined_iron_ingot"},
{industrialtest.elementKeys.yellowDust,"",industrialtest.elementKeys.yellowDust}
}
})
minetest.register_globalstep(function(dtime)
-- FIXME: Maybe this can be optimized?
local players=minetest.get_connected_players()
for _,player in ipairs(players) do
local control=player:get_player_control()
if control.jump then
if industrialtest.mclAvailable then
local inv=player:get_inventory()
local stack=inv:get_stack("armor",3)
local def=stack:get_definition()
onGlobalStep(player,inv,stack,3,def)
elseif industrialtest.mtgAvailable then
local _,inv=armor:get_valid_player(player,"")
if inv then
local armorList=inv:get_list("armor")
assert(armorList)
for i=1,#armorList do
local stack=armorList[i]
local def=stack:get_definition()
if onGlobalStep(player,inv,stack,i,def) then
break
end
end
end
end
end
end
end)

202
tools/mining_laser.lua Normal file
View File

@@ -0,0 +1,202 @@
-- IndustrialTest
-- Copyright (C) 2024 mrkubax10
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local S=minetest.get_translator("industrialtest")
local beam={}
beam.onActivate=function(self,staticdata)
local data=minetest.deserialize(staticdata)
self.direction=data.direction
self.energy=data.energy
self.distance=data.distance
self.startPos=self.object:get_pos()
self.mode=data.mode
self.user=data.user
end
beam.onPunch=function()
return true
end
beam.onNodeBreak=function(pos,node,user)
if industrialtest.mclAvailable then
local drops=minetest.get_node_drops(node.name,"")
for _, val in ipairs(drops) do
if type(val)~="string" then
val=val:get_name()..val:get_count()
end
minetest.add_item(pos,val)
end
end
minetest.node_dig(pos,node,user)
end
beam.onStep=function(self,dtime,moveresult)
local pos=self.object:get_pos()
if vector.distance(self.startPos,pos)>=self.distance or self.energy<=0 then
self.object:remove()
return
end
local speed=400*dtime
self.object:set_velocity(vector.multiply(self.direction,vector.new(speed,speed,speed)))
if moveresult.collides then
for _,val in ipairs(moveresult.collisions) do
if val.type=="node" then
if self.mode>=1 and self.mode<=3 then
local nodeUnbreakable=false
local node=minetest.get_node(val.node_pos)
local def=minetest.registered_nodes[node.name]
if industrialtest.mclAvailable then
nodeUnbreakable=def._mcl_hardness==-1
end
if nodeUnbreakable then
self.object:remove()
return
else
beam.onNodeBreak(val.node_pos,node,minetest.get_player_by_name(self.user))
self.energy=self.energy-1
end
elseif self.mode==4 then
industrialtest.internal.explode(pos,4,1)
self.object:remove()
return
end
end
end
end
end
minetest.register_entity("industrialtest:mining_laser_beam",{
initial_properties={
physical=true,
collide_with_objects=false,
collisionbox={
-0.25,-0.25,-0.25,
0.25,0.25,0.25
},
pointable=false,
visual="cube",
visual_size={x=0.25,y=0.25,z=0.25},
textures={
"industrialtest_mining_laser_beam.png",
"industrialtest_mining_laser_beam.png",
"industrialtest_mining_laser_beam.png",
"industrialtest_mining_laser_beam.png",
"industrialtest_mining_laser_beam.png",
"industrialtest_mining_laser_beam.png"
},
glow=-1,
static_save=false,
shaded=false,
},
on_activate=beam.onActivate,
on_punch=beam.onPunch,
on_step=beam.onStep
})
local miningLaser={}
miningLaser.mode1OpPower=1250
miningLaser.mode2OpPower=100
miningLaser.mode4OpPower=5000
miningLaser.modeCount=4
miningLaser.getMode=function(itemstack)
local meta=itemstack:get_meta()
if not meta:contains("mode") then
meta:set_int("mode",1)
return 1
end
return meta:get_int("mode")
end
miningLaser.setMode=function(itemstack,mode)
local meta=itemstack:get_meta()
meta:set_int("mode",mode)
meta:set_string("industrialtest.descriptionOverride",S("Mining Laser (Mode @1)",mode))
industrialtest.api.updateItemPowerText(itemstack)
end
miningLaser.spawnBeam=function(itemstack,user,pos,dir,opPower,energy,distance)
local meta=itemstack:get_meta()
if meta:get_int("industrialtest.powerAmount")<opPower then
return false
end
minetest.add_entity(pos+vector.new(0,1.5,0),"industrialtest:mining_laser_beam",minetest.serialize({
direction=dir,
energy=energy,
distance=distance,
mode=miningLaser.getMode(itemstack),
user=user:get_player_name()
}))
industrialtest.api.addPowerToItem(itemstack,-opPower)
return true
end
miningLaser.onUse=function(itemstack,user)
if not user:is_player() then
return nil
end
local mode=miningLaser.getMode(itemstack)
local control=user:get_player_control()
if control.sneak then
mode=mode+1
if mode>=miningLaser.modeCount+1 then
mode=1
end
miningLaser.setMode(itemstack,mode)
return itemstack
end
local meta=itemstack:get_meta()
if mode==1 then
if not miningLaser.spawnBeam(itemstack,user,user:get_pos(),user:get_look_dir(),miningLaser.mode1OpPower,10,64) then
return nil
end
elseif mode==2 then
if not miningLaser.spawnBeam(itemstack,user,user:get_pos(),user:get_look_dir(),miningLaser.mode2OpPower,3,2) then
return nil
end
elseif mode==3 then
local yaw=user:get_look_horizontal()
local dir=vector.new(-math.sin(yaw),0,math.cos(yaw))
if not miningLaser.spawnBeam(itemstack,user,user:get_pos(),dir,miningLaser.mode1OpPower,10,64) then
return nil
end
elseif mode==4 then
if not miningLaser.spawnBeam(itemstack,user,user:get_pos(),user:get_look_dir(),miningLaser.mode4OpPower,1,64) then
return nil
end
end
return itemstack
end
minetest.register_tool("industrialtest:mining_laser",{
description=S("Mining Laser (Mode 1)"),
inventory_image="industrialtest_mining_laser.png",
on_use=miningLaser.onUse,
_industrialtest_powerStorage=true,
_industrialtest_powerCapacity=300000,
_industrialtest_powerFlow=industrialtest.api.hvPowerFlow
})
minetest.register_craft({
type="shaped",
output="industrialtest:mining_laser",
recipe={
{industrialtest.elementKeys.powerCarrier,industrialtest.elementKeys.powerCarrier,"industrialtest:energy_crystal"},
{"industrialtest:advanced_alloy","industrialtest:advanced_alloy","industrialtest:advanced_electronic_circuit"},
{"","industrialtest:advanced_alloy","industrialtest:advanced_alloy"}
}
})

115
tools/solar_helmet.lua Normal file
View File

@@ -0,0 +1,115 @@
-- IndustrialTest
-- Copyright (C) 2024 mrkubax10
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local S=minetest.get_translator("industrialtest")
local updateDelta=0
local function onGlobalStep(player,inv,stack)
if stack:get_name()~="industrialtest:solar_helmet" then
return false
end
local amount=math.floor((minetest.get_node_light(player:get_pos()) or 0)/2)
if amount==0 then
return true
end
local armorList=inv:get_list("armor")
for i=1,#armorList do
local meta=armorList[i]:get_meta()
if industrialtest.api.hasPowerStorage(meta) and not industrialtest.api.isFullyCharged(meta) then
industrialtest.api.addPowerToItem(armorList[i],amount)
inv:set_stack("armor",i,armorList[i])
break
end
end
return true
end
if industrialtest.mtgAvailable then
armor:register_armor("industrialtest:solar_helmet",{
description=S("Solar Helmet"),
inventory_image="industrialtest_solar_helmet_inv.png",
groups={
armor_head=1,
armor_heal=0
}
})
elseif industrialtest.mclAvailable then
minetest.register_tool("industrialtest:solar_helmet",{
description=S("Solar Helmet"),
inventory_image="industrialtest_solar_helmet_inv.png",
groups={
armor=1,
non_combat_armor=1,
armor_head=1,
non_combat_feet=1
},
sounds={
_mcl_armor_equip="mcl_armor_equip_iron",
_mcl_armor_unequip="mcl_armor_unequip_iron"
},
on_place=mcl_armor.equip_on_use,
on_secondary_use=mcl_armor.equip_on_use,
_mcl_armor_element="head",
_mcl_armor_texture="industrialtest_solar_helmet.png"
})
end
minetest.register_craft({
type="shaped",
output="industrialtest:solar_helmet",
recipe={
{industrialtest.elementKeys.ironIngot,industrialtest.elementKeys.ironIngot,industrialtest.elementKeys.ironIngot},
{industrialtest.elementKeys.ironIngot,"industrialtest:solar_panel",industrialtest.elementKeys.ironIngot},
{"industrialtest:insulated_copper_cable","industrialtest:insulated_copper_cable","industrialtest:insulated_copper_cable"}
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:solar_helmet",
recipe={
{"",industrialtest.elementKeys.ironHelmet,""},
{"","industrialtest:solar_panel",""},
{"industrialtest:insulated_copper_cable","industrialtest:insulated_copper_cable","industrialtest:insulated_copper_cable"}
}
})
minetest.register_globalstep(function(dtime)
updateDelta=updateDelta+dtime
if updateDelta<industrialtest.updateDelay then
return
end
updateDelta=0
local players=minetest.get_connected_players()
for _,player in ipairs(players) do
if industrialtest.mtgAvailable then
local _,inv=armor:get_valid_player(player,"")
if inv then
local armorList=inv:get_list("armor")
assert(armorList)
for i=1,#armorList do
local stack=armorList[i]
if onGlobalStep(player,inv,stack) then
break
end
end
end
elseif industrialtest.mclAvailable then
local inv=player:get_inventory()
local stack=inv:get_stack("armor",1)
onGlobalStep(player,inv,stack)
end
end
end)

126
tools/static_boots.lua Normal file
View File

@@ -0,0 +1,126 @@
-- IndustrialTest
-- Copyright (C) 2024 mrkubax10
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local S=minetest.get_translator("industrialtest")
local updateDelta=0
local playerPositions={}
local function onGlobalStep(player,inv,stack)
if stack:get_name()~="industrialtest:static_boots" then
return false
end
local playerPos=player:get_pos()
playerPos.y=0
if not playerPositions[player:get_player_name()] then
playerPositions[player:get_player_name()]=playerPos
return true
end
if vector.distance(playerPos,playerPositions[player:get_player_name()])<5 then
return true
end
playerPositions[player:get_player_name()]=playerPos
local armorList=inv:get_list("armor")
for i=1,#armorList do
local meta=armorList[i]:get_meta()
if industrialtest.api.hasPowerStorage(meta) and not industrialtest.api.isFullyCharged(meta) then
industrialtest.api.addPowerToItem(armorList[i],1)
inv:set_stack("armor",i,armorList[i])
break
end
end
return true
end
if industrialtest.mtgAvailable then
armor:register_armor("industrialtest:static_boots",{
description=S("Static Boots"),
inventory_image="industrialtest_static_boots_inv.png",
groups={
armor_feet=1,
armor_heal=0
}
})
elseif industrialtest.mclAvailable then
minetest.register_tool("industrialtest:static_boots",{
description=S("Static Boots"),
inventory_image="industrialtest_static_boots_inv.png",
groups={
armor=1,
non_combat_armor=1,
armor_feet=1,
non_combat_feet=1
},
sounds={
_mcl_armor_equip="mcl_armor_equip_iron",
_mcl_armor_unequip="mcl_armor_unequip_iron"
},
on_place=mcl_armor.equip_on_use,
on_secondary_use=mcl_armor.equip_on_use,
_mcl_armor_element="feet",
_mcl_armor_texture="industrialtest_mcl_static_boots.png"
})
end
minetest.register_craft({
type="shaped",
output="industrialtest:static_boots",
recipe={
{industrialtest.elementKeys.ironIngot,"",industrialtest.elementKeys.ironIngot},
{industrialtest.elementKeys.ironIngot,industrialtest.elementKeys.whiteWool,industrialtest.elementKeys.ironIngot},
{"industrialtest:insulated_copper_cable","industrialtest:insulated_copper_cable","industrialtest:insulated_copper_cable"}
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:static_boots",
recipe={
{"",industrialtest.elementKeys.ironBoots,""},
{"",industrialtest.elementKeys.whiteWool,""},
{"industrialtest:insulated_copper_cable","industrialtest:insulated_copper_cable","industrialtest:insulated_copper_cable"}
}
})
minetest.register_on_leaveplayer(function(player)
playerPositions[player:get_player_name()]=nil
end)
minetest.register_globalstep(function(dtime)
updateDelta=updateDelta+dtime
if updateDelta<industrialtest.updateDelay then
return
end
updateDelta=0
local players=minetest.get_connected_players()
for _,player in ipairs(players) do
if industrialtest.mtgAvailable then
local _,inv=armor:get_valid_player(player,"")
if inv then
local armorList=inv:get_list("armor")
assert(armorList)
for i=1,#armorList do
local stack=armorList[i]
if onGlobalStep(player,inv,stack) then
break
end
end
end
elseif industrialtest.mclAvailable then
local inv=player:get_inventory()
local stack=inv:get_stack("armor",5)
onGlobalStep(player,inv,stack)
end
end
end)

103
tools/treetap.lua Normal file
View File

@@ -0,0 +1,103 @@
-- IndustrialTest
-- Copyright (C) 2024 mrkubax10
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local S=minetest.get_translator("industrialtest")
local function onTreetapUse(user,pointed)
local node=minetest.get_node_or_nil(pointed.under)
if not node then
return false
end
-- Note: if more nodes from which treetap can extract will be added then they shouldn't be added here
-- Instead they should have additional entry in definition which will denote that treetap can be used on them
if node.name=="industrialtest:rubber_wood_with_rubber" then
local inv=user:get_inventory()
inv:add_item("main",ItemStack("industrialtest:sticky_resin"))
minetest.set_node(pointed.under,{name="industrialtest:rubber_wood"})
return true
end
return false
end
local definition={
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
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)
minetest.register_craft({
type="shaped",
output="industrialtest:treetap",
recipe={
{"","group:wood",""},
{"group:wood","group:wood","group:wood"},
{"group:wood","",""}
}
})
definition={
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
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
minetest.register_tool("industrialtest:electric_treetap",definition)
minetest.register_craft({
type="shapeless",
output="industrialtest:electric_treetap",
recipe={
"industrialtest:treetap",
"industrialtest:electronic_circuit",
"industrialtest:re_battery"
}
})

103
tools/wrench.lua Normal file
View File

@@ -0,0 +1,103 @@
-- IndustrialTest
-- Copyright (C) 2024 mrkubax10
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
-- You should have received a copy of the GNU General Public License
local S=minetest.get_translator("industrialtest")
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
local 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=10000,
_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"
}
})

71
uu_matter_crafts.lua Normal file
View File

@@ -0,0 +1,71 @@
-- IndustrialTest
-- Copyright (C) 2024 mrkubax10
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
minetest.register_craft({
type="shapeless",
output=industrialtest.elementKeys.stone.." 16",
recipe={"industrialtest:uu_matter"}
})
minetest.register_craft({
type="shaped",
output=industrialtest.elementKeys.grassBlock.." 16",
recipe={
{"industrialtest:uu_matter"},
{"industrialtest:uu_matter"}
}
})
minetest.register_craft({
type="shaped",
output=industrialtest.elementKeys.wood.." 16",
recipe={
{"","industrialtest:uu_matter",""},
{"","",""},
{"industrialtest:uu_matter","",""}
}
})
minetest.register_craft({
type="shaped",
output=industrialtest.elementKeys.glass.." 32",
recipe={
{"","industrialtest:uu_matter",""},
{"industrialtest:uu_matter","","industrialtest:uu_matter"},
{"","industrialtest:uu_matter",""}
}
})
minetest.register_craft({
type="shaped",
output=industrialtest.elementKeys.mossCobble.." 16",
recipe={
{"","industrialtest:uu_matter",""},
{"industrialtest:uu_matter","","industrialtest:uu_matter"}
}
})
if industrialtest.mclAvailable then
minetest.register_craft({
type="shaped",
output="mcl_core:stonebrickcarved 48",
recipe={
{"industrialtest:uu_matter","industrialtest:uu_matter"},
{"industrialtest:uu_matter","industrialtest:uu_matter"},
{"industrialtest:uu_matter",""}
}
})
end