Compare commits

...

108 Commits

Author SHA1 Message Date
mrkubax10 960b2e5b45 Don't try to check if other reactor chambers are powered if Nuclear Reactor wasn't initialized
Fixes #7
2024-03-28 07:13:32 +01:00
mrkubax10 c8be496afe Add Iridium metal 2024-03-24 20:56:43 +01:00
mrkubax10 96c9fe164a Mesecons compatibility: Nuclear Reactor and Nuclear Reactor Chamber 2024-03-24 15:54:24 +01:00
mrkubax10 28040db868 Add Mesecons as optional dependency to README.md 2024-03-24 11:06:27 +01:00
mrkubax10 f561048339 Mesecons compatibility: Rotary Macerator 2024-03-24 11:04:07 +01:00
mrkubax10 e3e00e59a1 Pipeworks compatibility: Nuclear Reactor Chamber 2024-03-23 20:00:12 +01:00
mrkubax10 ab367b4f29 Balance ore generation 2024-03-23 18:57:08 +01:00
mrkubax10 42fb3be910 Change Nuclear Reactor Chamber craft to use Lead Plate 2024-03-23 18:40:52 +01:00
mrkubax10 a126010274 Nuclear Reactor Chamber can be used to expand Nuclear Reactor storage capacity 2024-03-23 13:34:18 +01:00
mrkubax10 443497b7b6 Add Nano Boots model texture specific to MCL 2024-03-21 22:10:16 +01:00
mrkubax10 e11747c34e Add Nano Boots textures by me and LuanHawk 2024-03-21 22:00:59 +01:00
mrkubax10 ad5b541b60 Add Nano Leggings textures by me and LuanHawk 2024-03-21 19:53:12 +01:00
mrkubax10 84b853b39d Fix two issues with network map handling 2024-03-21 19:33:35 +01:00
mrkubax10 b1fc8b104f Fix Chargepad formspec not updating 2024-03-21 11:39:57 +01:00
mrkubax10 3c52a3e6f4 Pipeworks compatibility: Chargepads 2024-03-21 09:36:47 +01:00
mrkubax10 bc3283be7c Add active Chargepad top texture 2024-03-19 16:44:45 +01:00
mrkubax10 ff1c30a516 Add Chargepad top texture 2024-03-19 16:44:24 +01:00
mrkubax10 d65705d457 Implement Chargepads
Chargepad charges all electric armor parts and wielded item of player that stands on top of it
2024-03-19 16:43:33 +01:00
mrkubax10 362b318cb2 Fix bronze toolset craft in MCL 2024-03-18 20:03:20 +01:00
mrkubax10 5bae710a69 Fix simple electric item processors not resuming after removing items from dst slot 2024-03-18 15:34:08 +01:00
mrkubax10 5e40904081 Make cables breakable with hand in MCL 2024-03-18 08:03:36 +01:00
mrkubax10 e17fcf1d27 Fix oversight in tools/nano_suit.lua 2024-03-17 18:56:54 +01:00
mrkubax10 022d6c1f08 Add Nano Bodyarmor textures by LuanHawk and me 2024-03-17 18:50:20 +01:00
mrkubax10 8d0df04e8f Add Nano Helmet textures by LuanHawk and me 2024-03-17 18:49:35 +01:00
mrkubax10 1d56e59725 Implement Nano Suit
Basically a rechargeable armor
2024-03-14 16:04:22 +01:00
mrkubax10 8d93030db3 Pipeworks compatibility: Induction Furnace 2024-03-12 11:07:09 +01:00
mrkubax10 4d99b06299 Deduplicate Pipeworks compatibility code 2024-03-12 11:02:43 +01:00
mrkubax10 21d4a3a014 Rotary Macerator fixes 2024-03-11 19:43:40 +01:00
mrkubax10 1e9a2e645e Implement Induction Furnace
Induction Furnace allows for faster smelting via double input and output slots.
Additionaly it features heat storage which makes it smelt faster when heated.
2024-03-11 19:31:21 +01:00
mrkubax10 4b2b0e4836 Make speed indicator in Rotary Macerator formspec translatable 2024-03-11 18:46:50 +01:00
mrkubax10 a3e17ea5a1 Add Lead Ingot cooking craft from Lead Dust 2024-03-10 21:54:32 +01:00
mrkubax10 d66a418349 Use elapsed time to properly calcuate RPM difference in Rotary Macerator 2024-03-10 21:35:10 +01:00
mrkubax10 a197d1c2aa Add Sulfur Dust craft 2024-03-10 16:39:16 +01:00
mrkubax10 37de5770a5 Add MTG stone with lead texture 2024-03-10 14:05:15 +01:00
mrkubax10 5f79d0fadc Add MTG Lead Lump texture 2024-03-10 14:05:01 +01:00
mrkubax10 688e5636f0 Add MTG Lead Ingot texture 2024-03-10 14:04:43 +01:00
mrkubax10 a9c2f864fe Add stone with lead texture by LuanHawk 2024-03-10 13:50:52 +01:00
mrkubax10 6be362b354 Add Raw Lead Block texture by LuanHawk 2024-03-10 13:50:38 +01:00
mrkubax10 aad5388956 Add Raw Lead texture by LuanHawk 2024-03-10 13:50:22 +01:00
mrkubax10 7d64d8d654 Add Lead Ingot texture by LuanHawk 2024-03-10 13:49:57 +01:00
mrkubax10 df3cfc487f Add Lead Block texture by LuanHawk 2024-03-10 13:49:35 +01:00
mrkubax10 514e8cf5f1 Add lead ore (finally!) 2024-03-10 13:49:03 +01:00
mrkubax10 e60e43a702 Add mcl_rubber as optional dependency to README.md 2024-03-09 10:35:08 +01:00
mrkubax10 6a636099b3 Pipeworks compatibility: Rotary Macerator 2024-03-09 10:23:56 +01:00
mrkubax10 a90b4f8cfe Implement Rotary Macerator
It's a more advanced version of regular Macerator.
It introduces RPM which makes machine faster the longer it
works.
2024-03-08 22:41:02 +01:00
mrkubax10 3041d0982f Deduplicate machine charging from power storage item code 2024-03-08 08:56:56 +01:00
mrkubax10 664b11fe33 Add MCL bronze helmet model texture by LuanHawk 2024-03-08 08:39:54 +01:00
mrkubax10 e76fa7f65a Add MCL bronze chestplate model texture by LuanHawk 2024-03-08 08:39:28 +01:00
mrkubax10 de703009b7 Add MCL bronze leggings model texture by LuanHawk 2024-03-08 08:38:33 +01:00
mrkubax10 1dccd0724c Add MCL bronze boots model texture by LuanHawk 2024-03-08 08:38:03 +01:00
mrkubax10 62a3e2aa40 Fix Rubber Sapling not growing in MCL 2024-03-06 19:21:36 +01:00
mrkubax10 8a29704f5f Fix Stone with tin generation in MCL 2024-03-05 11:02:29 +01:00
mrkubax10 7f1efd3472 Pipeworks compatibility: Simple electric item processors 2024-03-01 09:01:43 +01:00
mrkubax10 e890a2002f Pipeworks compatibility: Canning Machine 2024-02-29 21:57:38 +01:00
mrkubax10 73232db9a0 Pipeworks compatibility: Power storage 2024-02-29 20:52:34 +01:00
mrkubax10 a8b625f782 Pipeworks compatibility: Nuclear Reactor 2024-02-29 20:39:26 +01:00
mrkubax10 64cdff6139 Pipeworks compatibility: Solar Panel 2024-02-29 19:24:24 +01:00
mrkubax10 d337e2a0f5 Pipeworks compatiblity: Wind Mill 2024-02-29 19:04:41 +01:00
mrkubax10 29f6bd2852 Pipeworks compatibility: Geothermal Generator and Water Mill 2024-02-29 18:53:12 +01:00
mrkubax10 3bc3dab88c Pipeworks compatibility: Generator 2024-02-28 18:37:20 +01:00
mrkubax10 d800a22fe0 Begin implementing compatibility with Pipeworks mod 2024-02-27 21:04:25 +01:00
mrkubax10 a5ef9eca00 Fix two issues with Iron Furnace 2024-02-27 12:41:54 +01:00
mrkubax10 d2346f65aa Introduce compatibility with mcl_rubber mod
Closes #1
2024-02-26 17:06:11 +01:00
mrkubax10 7df191097d Change registeredElectricSabers to industrialtest.internal.registeredElectricSabers to prevent nil indexing
Fixes #2
2024-02-07 14:26:30 +01:00
mrkubax10 9743217703 Add Hydrated Coal texture 2024-01-21 21:16:35 +01:00
mrkubax10 b6c5283ab8 Add some recipes involving UU-Matter 2024-01-21 11:48:37 +01:00
mrkubax10 80578576b6 Add Mining Laser beam texture 2024-01-20 14:37:17 +01:00
mrkubax10 a8a20078f2 Add Mining Laser texture by LuanHawk 2024-01-20 14:37:01 +01:00
mrkubax10 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
mrkubax10 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
mrkubax10 752731972c Add Coalfuel Cell texture 2024-01-17 19:22:27 +01:00
mrkubax10 0da54bb7ab Add Hydrated Coal Cell texture 2024-01-17 19:22:10 +01:00
mrkubax10 152eab80d5 Add Hydrated Coal Dust texture 2024-01-17 19:21:48 +01:00
mrkubax10 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
mrkubax10 1e72f07df1 Add preview Solar Helmet texture 2024-01-16 19:33:53 +01:00
mrkubax10 f072b0d599 Add model Solar Helmet texture 2024-01-16 19:31:30 +01:00
mrkubax10 8e1c648f99 Add inventory Solar Helmet texture by LuanHawk 2024-01-16 18:39:17 +01:00
mrkubax10 eed94c4853 Implement Solar Helmet
It can charge equipped electric tools from environment light.
2024-01-16 18:38:24 +01:00
mrkubax10 b4e6b826ef Add MCL model Static Boots texture 2024-01-16 18:37:32 +01:00
mrkubax10 6ffa856b44 Add preview Static Boots texture 2024-01-15 17:04:01 +01:00
mrkubax10 10fd3eab66 Add MTG model Static Boots texture 2024-01-15 17:03:24 +01:00
mrkubax10 c4ba8aac20 Add inventory Static Boots texture by LuanHawk 2024-01-15 16:31:27 +01:00
mrkubax10 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
mrkubax10 8446793413 Add preview BatPack and LapPack textures 2024-01-13 14:49:35 +01:00
mrkubax10 567d0b3971 Add model BatPack and LapPack textures 2024-01-13 14:49:15 +01:00
mrkubax10 3eb8b1e576 Add inventory BatPack and LapPack textures by LuanHawk 2024-01-13 14:48:25 +01:00
mrkubax10 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
mrkubax10 4674f3b396 Fix MCL crash during loading in jetpack.lua 2024-01-13 13:15:46 +01:00
mrkubax10 3db5fa322e Add active Canning Machine front texture 2024-01-12 20:18:17 +01:00
mrkubax10 ee27e3f432 Add Canning Machine front texture by LuanHawk 2024-01-12 20:18:00 +01:00
mrkubax10 6cf004ff0e Implement Canning Machine 2024-01-12 20:17:36 +01:00
mrkubax10 eaff4a9065 Optimize some electric tools and fix Electric Saber not discharging after digging node 2024-01-11 22:25:14 +01:00
mrkubax10 e69d16aeb0 Add simple item fluid storage API 2024-01-11 19:48:09 +01:00
mrkubax10 0895cb42ea Add preview Electric Jetpack texture 2024-01-10 19:00:12 +01:00
mrkubax10 4171e6da7a Add model Electric Jetpack texture 2024-01-10 18:59:53 +01:00
mrkubax10 d9d4396034 Add inventory Electric Jetpack texture 2024-01-10 18:59:32 +01:00
mrkubax10 5cef554c9e Implement Electric Jetpack 2024-01-10 18:59:07 +01:00
mrkubax10 536cd978ed Add 3D Armor preview Jetpack texture 2024-01-09 11:08:46 +01:00
mrkubax10 45bd28ef4c Add model Jetpack texture 2024-01-09 11:08:24 +01:00
mrkubax10 b06ef3bb98 Add Fuel Can texture by LuanHawk 2024-01-09 11:07:57 +01:00
mrkubax10 eed2c73911 Add inventory Jetpack texture by LuanHawk 2024-01-09 11:07:33 +01:00
mrkubax10 6da4aef854 Implement Jetpack 2024-01-09 11:07:00 +01:00
mrkubax10 3a7ba72571 Add Compressed Plantball texture by Migdyn 2024-01-07 19:57:53 +01:00
mrkubax10 5d28015b3e Add Plantball texture by Migdyn 2024-01-07 19:57:36 +01:00
mrkubax10 5acd9477fb Add Biofuel Cell texture 2024-01-07 14:31:10 +01:00
mrkubax10 880ad0c99c Add Bio Cell texture 2024-01-07 14:30:57 +01:00
mrkubax10 d973f97916 Add Biofuel Cell and some items required to produce it 2024-01-07 14:30:33 +01:00
mrkubax10 0b27efd756 Split tools.lua to separate files 2024-01-06 21:55:06 +01:00
94 changed files with 4782 additions and 1342 deletions

View File

@ -12,6 +12,11 @@ Currently IndustrialTest supports following games:
- MineClone2
- none
## Optional dependencies
- [Rubber Addon for MineClone](https://content.minetest.net/packages/biochemist/mcl_rubber)
- [Pipeworks](https://content.minetest.net/packages/VanessaE/pipeworks)
- [Mesecons](https://content.minetest.net/packages/Jeija/mesecons)
## Contributors
- mrkubax10 <mrkubax10@onet.pl or mrkubax10 at irc.libera.chat> [programming, some graphics]
- LuanHawk <Discord: LuanHawk#8733> [lead graphics]

119
api.lua
View File

@ -23,6 +23,7 @@ industrialtest.api.extractorRecipes={}
industrialtest.api.cableFormerRecipes={}
industrialtest.api.geothermalGeneratorFuels={}
industrialtest.api.waterMillFuels={}
industrialtest.api.rotaryMaceratorModifiers={}
industrialtest.api.storageCells={}
industrialtest.api.lvPowerFlow=600
@ -92,7 +93,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 +115,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 +153,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 +275,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)
@ -517,7 +601,7 @@ industrialtest.api.getConnections=function(pos,direction)
local powerOutput=(sourceDef.groups._industrialtest_cable or industrialtest.api.isPowerOutput(sourceMeta,normalizedKey))
local powerInput=(sourceDef.groups._industrialtest_cable or industrialtest.api.isPowerInput(sourceMeta,normalizedKey))
if def.groups._industrialtest_cable or industrialtest.api.hasPowerStorage(meta) then
local side=industrialtest.api.getOppositeSide(normalizedKey)
local side=industrialtest.api.normalizeSide(conn,industrialtest.api.getOppositeSide(normalizedKey))
if (powerOutput and directionInput and (def.groups._industrialtest_cable or industrialtest.api.isPowerInput(meta,side))) or ((def.groups._industrialtest_cable or industrialtest.api.isPowerOutput(meta,side)) and powerInput and directionOutput) then
table.insert(result,conn)
end
@ -781,6 +865,29 @@ industrialtest.api.getWaterMillFuelByItem=function(name)
return nil
end
-- \brief Registers Rotary Macerator recipe modifier
-- \param config table
-- \returns nil
industrialtest.api.registerRotaryMaceratorModifier=function(config)
local definition={
name=config.name or "",
modifier=config.modifier or "",
output=config.output or "",
time=config.time or 2,
uses=config.uses or 1,
modifierLeftover=config.modifierLeftover
}
industrialtest.api.rotaryMaceratorModifiers[definition.name.." "..config.modifier]=definition
end
-- \brief Returns modified Rotary Macerator recipe by item and modifier
-- \param name string
-- \param modifier string
-- \returns table
industrialtest.api.getRotaryMaceratorModifier=function(name,modifier)
return industrialtest.api.rotaryMaceratorModifiers[name.." "..modifier]
end
-- \brief Returns machine speed in items per operation
-- \param meta MetaDataRef
-- \returns number

View File

@ -130,7 +130,10 @@ local function registerCable(name,displayName,size,flow,registerInsulated)
}
definition.sound=default.node_sound_metal_defaults()
elseif industrialtest.mclAvailable then
definition.groups={pickaxey=1}
definition.groups={
handy=1,
pickaxey=1
}
definition._mcl_blast_resistance=1
definition._mcl_hardness=0.5
definition.sound=mcl_sounds.node_sound_metal_defaults()
@ -160,16 +163,16 @@ minetest.register_craft({
output="industrialtest:insulated_tin_cable",
recipe={
"industrialtest:tin_cable",
"industrialtest:rubber"
industrialtest.elementKeys.rubber
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:insulated_tin_cable 6",
recipe={
{"industrialtest:rubber","industrialtest:rubber","industrialtest:rubber"},
{industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber},
{industrialtest.elementKeys.tinIngot,industrialtest.elementKeys.tinIngot,industrialtest.elementKeys.tinIngot},
{"industrialtest:rubber","industrialtest:rubber","industrialtest:rubber"}
{industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber}
}
})
industrialtest.api.registerCableFormerRecipe({
@ -191,16 +194,16 @@ minetest.register_craft({
output="industrialtest:insulated_copper_cable",
recipe={
"industrialtest:copper_cable",
"industrialtest:rubber"
industrialtest.elementKeys.rubber
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:insulated_copper_cable 6",
recipe={
{"industrialtest:rubber","industrialtest:rubber","industrialtest:rubber"},
{industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber},
{industrialtest.elementKeys.copperIngot,industrialtest.elementKeys.copperIngot,industrialtest.elementKeys.copperIngot},
{"industrialtest:rubber","industrialtest:rubber","industrialtest:rubber"}
{industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber}
}
})
industrialtest.api.registerCableFormerRecipe({
@ -221,16 +224,16 @@ minetest.register_craft({
output="industrialtest:insulated_gold_cable",
recipe={
"industrialtest:gold_cable",
"industrialtest:rubber"
industrialtest.elementKeys.rubber
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:insulated_gold_cable 6",
recipe={
{"industrialtest:rubber","industrialtest:rubber","industrialtest:rubber"},
{industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber},
{industrialtest.elementKeys.goldIngot,industrialtest.elementKeys.goldIngot,industrialtest.elementKeys.goldIngot},
{"industrialtest:rubber","industrialtest:rubber","industrialtest:rubber"}
{industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber}
}
})
industrialtest.api.registerCableFormerRecipe({
@ -251,16 +254,16 @@ minetest.register_craft({
output="industrialtest:insulated_iron_cable",
recipe={
"industrialtest:iron_cable",
"industrialtest:rubber"
industrialtest.elementKeys.rubber
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:insulated_iron_cable 6",
recipe={
{"industrialtest:rubber","industrialtest:rubber","industrialtest:rubber"},
{industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber},
{"industrialtest:refined_iron_ingot","industrialtest:refined_iron_ingot","industrialtest:refined_iron_ingot"},
{"industrialtest:rubber","industrialtest:rubber","industrialtest:rubber"}
{industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber}
}
})
industrialtest.api.registerCableFormerRecipe({

124
compat/mesecons.lua Normal file
View File

@ -0,0 +1,124 @@
-- 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/>.
-- Rotary Macerator
local override={
mesecons={
effector={
action_on=function(pos,node)
if node.name~="industrialtest:rotary_macerator" then
return
end
local meta=minetest.get_meta(pos)
meta:set_int("maintainSpeed",1)
local def=minetest.registered_nodes[node.name]
def._industrialtest_updateFormspec(pos)
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
end,
action_off=function(pos,node)
local meta=minetest.get_meta(pos)
meta:set_int("maintainSpeed",0)
local def=minetest.registered_nodes[node.name]
def._industrialtest_updateFormspec(pos)
end
}
}
}
minetest.override_item("industrialtest:rotary_macerator",override)
minetest.override_item("industrialtest:rotary_macerator_active",override)
-- Nuclear Reactor
override={
mesecons={
effector={
action_on=function(pos,node)
local isChamber=node.name=="industrialtest:nuclear_reactor_chamber"
if node.name~="industrialtest:nuclear_reactor" and not isChamber then
return
end
local originalPos
local meta=minetest.get_meta(pos)
meta:set_int("meseconPowered",1)
if isChamber then
originalPos=pos
pos=minetest.deserialize(meta:get_string("reactor"))
node=minetest.get_node(pos)
meta=minetest.get_meta(pos)
end
meta:set_int("enabled",1)
meta:set_int("stateChanged",1)
local def=minetest.registered_nodes[node.name]
def._industrialtest_updateFormspec(pos)
if isChamber then
def._industrialtest_synchronizeToChamber(originalPos)
end
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
end,
action_off=function(pos,node)
local isChamber=node.name=="industrialtest:nuclear_reactor_chamber"
local originalPos
local meta=minetest.get_meta(pos)
meta:set_int("meseconPowered",0)
if isChamber then
originalPos=pos
pos=minetest.deserialize(meta:get_string("reactor"))
node=minetest.get_node(pos)
meta=minetest.get_meta(pos)
end
if meta:get_int("meseconPowered")==1 then
return
end
if meta:contains("chambers") then
local chambers=minetest.deserialize(meta:get_string("chambers"))
for _,chamber in ipairs(chambers) do
local chamberMeta=minetest.get_meta(chamber)
if chamberMeta:get_int("meseconPowered")==1 then
return
end
end
end
meta:set_int("enabled",0)
meta:set_int("stateChanged",1)
local def=minetest.registered_nodes[node.name]
def._industrialtest_updateFormspec(pos)
if isChamber then
def._industrialtest_synchronizeToChamber(originalPos)
end
end
}
}
}
minetest.override_item("industrialtest:nuclear_reactor",override)
minetest.override_item("industrialtest:nuclear_reactor_active",override)
-- Nuclear Reactor Chamber
minetest.override_item("industrialtest:nuclear_reactor_chamber",override)

365
compat/pipeworks.lua Normal file
View File

@ -0,0 +1,365 @@
-- 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 function getListnameBySide(sides,direction)
local listname
for _,side in ipairs(sides) do
if (not side.x or side.x==direction.x) and (not side.y or side.y==direction.y) and (not side.z or side.z==direction.z) then
listname=side.listname
break
end
end
return listname
end
local function addPipeworksCompatibility(name,sides,inputInventory)
local groups=table.copy(minetest.registered_nodes[name].groups)
groups.tubedevice=1
groups.tubedevice_receiver=1
local override={
groups=groups,
tube={
insert_object=function(pos,node,stack,direction)
local meta=minetest.get_meta(pos)
local inv=meta:get_inventory()
local listname=getListnameBySide(sides,direction)
if (listname=="charged" or listname=="discharged" or listname=="powerStorage") and not industrialtest.api.hasPowerStorage(stack:get_meta()) then
return nil
end
local result=inv:add_item(listname,stack)
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
return result
end,
can_insert=function(pos,node,stack,direction)
local meta=minetest.get_meta(pos)
local inv=meta:get_inventory()
local listname=getListnameBySide(sides,direction)
if (listname=="charged" or listname=="discharged" or listname=="powerStorage") and not industrialtest.api.hasPowerStorage(stack:get_meta()) then
return false
end
return inv:room_for_item(listname,stack)
end,
input_inventory=inputInventory,
connect_sides={
left=1,
right=1,
back=1,
front=1,
bottom=1,
top=1
}
},
after_place_node=pipeworks.after_place,
after_dig_node=pipeworks.after_dig,
on_rotate=pipeworks.on_rotate
}
minetest.override_item(name,override)
local activeName=name.."_active"
if minetest.registered_nodes[activeName] then
minetest.override_item(activeName,override)
end
end
-- Iron Furnace
addPipeworksCompatibility("industrialtest:iron_furnace",{
{
y=1,
listname="fuel"
},
{listname="src"}
},"dst")
-- Generator
addPipeworksCompatibility("industrialtest:generator",{
{
y=1,
listname="fuel",
},
{listname="charged"}
},"charged")
-- Geothermal Generator
addPipeworksCompatibility("industrialtest:geothermal_generator",{
{
y=1,
listname="leftover",
},
{
y=-1,
listname="fluid"
},
{listname="charged"}
},"leftover")
-- Water Mill
addPipeworksCompatibility("industrialtest:water_mill",{
{
y=1,
listname="leftover",
},
{
y=-1,
listname="fluid"
},
{listname="charged"}
},"leftover")
-- Wind Mill
addPipeworksCompatibility("industrialtest:wind_mill",{
{listname="charged"}
},"charged")
-- Solar Panel
addPipeworksCompatibility("industrialtest:solar_panel",{
{listname="charged"}
},"charged")
addPipeworksCompatibility("industrialtest:lv_solar_array",{
{listname="charged"}
},"charged")
addPipeworksCompatibility("industrialtest:mv_solar_array",{
{listname="charged"}
},"charged")
addPipeworksCompatibility("industrialtest:hv_solar_array",{
{listname="charged"}
},"charged")
-- Nuclear Reactor
local def=table.copy(minetest.registered_nodes["industrialtest:nuclear_reactor"])
def.groups.tubedevice=1
def.groups.tubedevice_receiver=1
local override={
groups=def.groups,
tube={
insert_object=function(pos,node,stack,direction)
local listname=direction.y==0 and "charged" or "fuel"
local def=stack:get_definition()
if (listname=="charged" and not industrialtest.api.hasPowerStorage(stack:get_meta())) or
(listname=="fuel" and (not def.groups or not def.groups._industrialtest_placedInNuclearReactor)) then
return nil
end
local meta=minetest.get_meta(pos)
local inv=meta:get_inventory()
local result=inv:add_item(listname,stack)
minetest.registered_nodes["industrialtest:nuclear_reactor"].on_metadata_inventory_put(pos)
return result
end,
can_insert=function(pos,node,stack,direction)
local listname=direction.y==0 and "charged" or "fuel"
local def=stack:get_definition()
if (listname=="charged" and not industrialtest.api.hasPowerStorage(stack:get_meta())) or
(listname=="fuel" and (not def.groups or not def.groups._industrialtest_placedInNuclearReactor)) then
return false
end
local meta=minetest.get_meta(pos)
local inv=meta:get_inventory()
return inv:room_for_item(listname,stack)
end,
input_inventory="fuel",
connect_sides={
left=1,
right=1,
back=1,
front=1,
bottom=1,
top=1
}
},
after_place_node=pipeworks.after_place,
after_dig_node=pipeworks.after_dig,
on_rotate=pipeworks.on_rotate
}
minetest.override_item("industrialtest:nuclear_reactor",override)
minetest.override_item("industrialtest:nuclear_reactor_active",override)
-- Nuclear Reactor Chamber
override=table.copy(override)
def=table.copy(minetest.registered_nodes["industrialtest:nuclear_reactor_chamber"])
override.groups=def.groups
override.groups.tubedevice=1
override.groups.tubedevice_receiver=1
override.tube.insert_object=function(pos,node,stack,direction)
local listname=direction.y==0 and "charged" or "fuel"
local def=stack:get_definition()
if (listname=="charged" and not industrialtest.api.hasPowerStorage(stack:get_meta())) or
(listname=="fuel" and (not def.groups or not def.groups._industrialtest_placedInNuclearReactor)) then
return nil
end
local meta=minetest.get_meta(pos)
local inv=meta:get_inventory()
local result=inv:add_item(listname,stack)
minetest.registered_nodes["industrialtest:nuclear_reactor_chamber"].on_metadata_inventory_put(pos)
return result
end
override.after_place_node_old=def.after_place_node
override.after_place_node=function(pos)
minetest.registered_nodes["industrialtest:nuclear_reactor_chamber"].after_place_node_old(pos)
pipeworks.after_place(pos)
end
minetest.override_item("industrialtest:nuclear_reactor_chamber",override)
-- BatBox
addPipeworksCompatibility("industrialtest:batbox",{
{
y=1,
listname="discharged"
},
{listname="charged"}
},"charged")
-- CESU
addPipeworksCompatibility("industrialtest:cesu",{
{
y=1,
listname="discharged"
},
{listname="charged"}
},"charged")
-- MFE
addPipeworksCompatibility("industrialtest:mfe",{
{
y=1,
listname="discharged"
},
{listname="charged"}
},"charged")
-- MFSU
addPipeworksCompatibility("industrialtest:mfsu",{
{
y=1,
listname="discharged"
},
{listname="charged"}
},"charged")
-- Canning Machine
def=table.copy(minetest.registered_nodes["industrialtest:canning_machine"])
def.groups.tubedevice=1
def.groups.tubedevice_receiver=1
override={
groups=def.groups,
tube={
insert_object=function(pos,node,stack,direction)
local listname
if direction.y==1 then
listname="powerStorage"
elseif direction.y==-1 then
listname="fuel"
else
listname="target"
end
local def=stack:get_definition()
if (listname=="powerStorage" and not industrialtest.api.hasPowerStorage(stack:get_meta())) or
(listname=="fuel" and (not def.groups or not def.groups._industrialtest_fuel)) or
(listname=="target" and (not def.groups or not def.groups._industrialtest_fueled)) then
return nil
end
local meta=minetest.get_meta(pos)
local inv=meta:get_inventory()
local result=inv:add_item(listname,stack)
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
return result
end,
can_insert=function(pos,node,stack,direction)
local listname
if direction.y==1 then
listname="powerStorage"
elseif direction.y==-1 then
listname="fuel"
else
listname="target"
end
local def=stack:get_definition()
if (listname=="powerStorage" and not industrialtest.api.hasPowerStorage(stack:get_meta())) or
(listname=="fuel" and (not def.groups or not def.groups._industrialtest_fuel)) or
(listname=="target" and (not def.groups or not def.groups._industrialtest_fueled)) then
return false
end
local meta=minetest.get_meta(pos)
local inv=meta:get_inventory()
return inv:room_for_item(listname,stack)
end,
input_inventory="target",
connect_sides={
left=1,
right=1,
back=1,
bottom=1,
top=1
}
},
after_place_node=pipeworks.after_place,
after_dig_node=pipeworks.after_dig,
on_rotate=pipeworks.on_rotate
}
minetest.override_item("industrialtest:canning_machine",override)
minetest.override_item("industrialtest:canning_machine_active",override)
-- Rotary Macerator
addPipeworksCompatibility("industrialtest:rotary_macerator",{
{
y=1,
listname="powerStorage"
},
{
y=-1,
listname="src"
},
{listname="modifier"}
},"dst")
-- Induction Furnace
addPipeworksCompatibility("industrialtest:induction_furnace",{
{
y=1,
listname="powerStorage"
},
{listname="src"}
},"dst")
-- Simple electric item processors
for _,name in ipairs(industrialtest.internal.simpleElectricItemProcessors) do
addPipeworksCompatibility(name,{
{
y=1,
listname="powerStorage"
},
{listname="src"}
},"dst")
end
for _,name in ipairs(industrialtest.internal.chargepads) do
addPipeworksCompatibility(name,{
{
y=1,
listname="discharged"
},
{listname="charged"}
},"charged")
end

View File

@ -33,7 +33,22 @@ for _,mod in ipairs(requiredMclModules) do
end
end
if industrialtest.mtgAvailable and not minetest.get_modpath("3d_armor") then
if industrialtest.mtgAvailable then
industrialtest.stackMax=99
elseif industrialtest.mclAvailable then
industrialtest.stackMax=64
end
industrialtest.mods={}
if industrialtest.mtgAvailable then
industrialtest.mods._3dArmor=minetest.get_modpath("3d_armor")
elseif industrialtest.mclAvailable then
industrialtest.mods.mclRubber=minetest.get_modpath("mcl_rubber")
end
industrialtest.mods.pipeworks=minetest.get_modpath("pipeworks")
industrialtest.mods.mesecons=minetest.get_modpath("mesecons")
if industrialtest.mtgAvailable and not industrialtest.mods._3dArmor then
error("IndustrialTest requires 3D Armor when used with Minetest Game")
end
@ -70,12 +85,14 @@ 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
if industrialtest.mclAvailable then
industrialtest.registerMetal=function(name,displayName,oreBlastResistance,oreHardness,rawBlockBlastResistance,rawBlockHardness,blockBlastResistance,blockHardness)
industrialtest.internal.registerMetal=function(name,displayName,oreBlastResistance,oreHardness,rawBlockBlastResistance,rawBlockHardness,blockBlastResistance,blockHardness)
minetest.register_craftitem("industrialtest:raw_"..name,{
description=S("Raw "..displayName),
inventory_image="industrialtest_mcl_raw_"..name..".png"
@ -358,7 +375,7 @@ if industrialtest.mclAvailable then
type="shaped",
output="industrialtest:"..material.."_pickaxe",
recipe={
{"industrialtest:"..material,"industrialtest:"..material,"industrialtest:"..material},
{"industrialtest:"..materialItem,"industrialtest:"..materialItem,"industrialtest:"..materialItem},
{"","mcl_core:stick",""},
{"","mcl_core:stick",""}
}
@ -367,126 +384,54 @@ if industrialtest.mclAvailable then
type="shaped",
output="industrialtest:"..material.."_shovel",
recipe={
{"","industrialtest:"..material,""},
{"","mcl_core:stick",""},
{"","mcl_core:stick",""}
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:"..material.."_shovel",
recipe={
{"industrialtest:"..material,"",""},
{"mcl_core:stick","",""},
{"mcl_core:stick","",""}
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:"..material.."_shovel",
recipe={
{"","","industrialtest:"..material},
{"","","mcl_core:stick"},
{"","","mcl_core:stick"}
{"industrialtest:"..materialItem},
{"mcl_core:stick"},
{"mcl_core:stick"}
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:"..material.."_axe",
recipe={
{"industrialtest:"..material,"industrialtest:"..material,""},
{"industrialtest:"..material,"mcl_core:stick",""},
{"","mcl_core:stick",""}
{"industrialtest:"..materialItem,"industrialtest:"..materialItem},
{"industrialtest:"..materialItem,"mcl_core:stick"},
{"","mcl_core:stick"}
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:"..material.."_axe",
recipe={
{"","industrialtest:"..material,"industrialtest:"..material},
{"","mcl_core:stick","industrialtest:"..material},
{"","mcl_core:stick",""}
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:"..material.."_axe",
recipe={
{"industrialtest:"..material,"industrialtest:"..material,""},
{"mcl_core:stick","industrialtest:"..material,""},
{"mcl_core:stick","",""}
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:"..material.."_axe",
recipe={
{"","industrialtest:"..material,"industrialtest:"..material},
{"","mcl_core:stick","industrialtest:"..material},
{"","","mcl_core:stick"}
{"industrialtest:"..materialItem,"industrialtest:"..materialItem},
{"mcl_core:stick","industrialtest:"..materialItem},
{"mcl_core:stick",""}
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:"..material.."_sword",
recipe={
{"industrialtest:"..material,"",""},
{"industrialtest:"..material,"",""},
{"mcl_core:stick","",""}
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:"..material.."_sword",
recipe={
{"","industrialtest:"..material,""},
{"","industrialtest:"..material,""},
{"","mcl_core:stick",""}
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:"..material.."_sword",
recipe={
{"","","industrialtest:"..material},
{"","","industrialtest:"..material},
{"","","mcl_core:stick"}
{"industrialtest:"..materialItem},
{"industrialtest:"..materialItem},
{"mcl_core:stick"}
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:"..material.."_hoe",
recipe={
{"industrialtest:"..material,"industrialtest:"..material,""},
{"","mcl_core:stick",""},
{"","mcl_core:stick",""}
{"industrialtest:"..materialItem,"industrialtest:"..materialItem},
{"","mcl_core:stick"},
{"","mcl_core:stick"}
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:"..material.."_hoe",
recipe={
{"","industrialtest:"..material,"industrialtest:"..material},
{"","","mcl_core:stick"},
{"","","mcl_core:stick"}
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:"..material.."_hoe",
recipe={
{"","industrialtest:"..material,"industrialtest:"..material},
{"","mcl_core:stick",""},
{"","mcl_core:stick",""}
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:"..material.."_hoe",
recipe={
{"industrialtest:"..material,"industrialtest:"..material,""},
{"mcl_core:stick","",""},
{"mcl_core:stick","",""}
{"industrialtest:"..materialItem,"industrialtest:"..materialItem},
{"mcl_core:stick",""},
{"mcl_core:stick",""}
}
})
end
@ -497,6 +442,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 +464,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"
@ -537,12 +484,27 @@ if industrialtest.mclAvailable then
industrialtest.elementKeys.stoneWithGold="mcl_core:stone_with_gold"
industrialtest.elementKeys.copperBlock="mcl_copper:block"
industrialtest.elementKeys.stoneWithCopper="mcl_copper:stone_with_copper"
industrialtest.elementKeys.leadLump="industrialtest:raw_lead"
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.gunpowder="mcl_mobitems:gunpowder"
industrialtest.elementKeys.groupSapling="group:sapling"
industrialtest.elementKeys.groupLeaves="group:leaves"
industrialtest.elementKeys.stickyResin=(industrialtest.mods.mclRubber and "mcl_rubber:rubber_raw" or "industrialtest:sticky_resin")
industrialtest.elementKeys.rubber=(industrialtest.mods.mclRubber and "mcl_rubber:rubber" or "industrialtest:rubber")
industrialtest.elementKeys.rubberWood=(industrialtest.mods.mclRubber and "mcl_rubber:rubbertree" or "industrialtest:rubber_wood")
industrialtest.elementKeys.rubberSapling=(industrialtest.mods.mclRubber and "mcl_rubber:rubbersapling" or "industrialtest:rubber_sapling")
industrialtest.elementKeys.treetap=(industrialtest.mods.mclRubber and "mcl_rubber:treetap" or "industrialtest:treetap")
-- register required minerals that are not available in MCL
industrialtest.registerMetal("tin","Tin",3,3)
industrialtest.internal.registerMetal("tin","Tin",3,3)
industrialtest.elementKeys.tinIngot="industrialtest:tin_ingot"
industrialtest.elementKeys.tinBlock="industrialtest:tin_block"
industrialtest.elementKeys.stoneWithTin="industrialtest:stone_with_tin"
@ -627,11 +589,11 @@ if industrialtest.mclAvailable then
{"industrialtest:bronze_ingot","industrialtest:bronze_ingot","industrialtest:bronze_ingot"}
}
})
minetest.register_ore({
ore_type="scatter",
ore="industrialtest:stone_with_tin",
wherein=stonelike,
wherein={"mcl_core:stone","mcl_core:diorite","mcl_core:andesite","mcl_core:granite"},
clust_scarcity=10*10*10,
clust_num_ores=5,
clust_size=3,
@ -653,7 +615,7 @@ elseif industrialtest.mtgAvailable then
tnt.boom(pos,{radius=radius})
end
industrialtest.registerMetal=function(name,displayName,hardness)
industrialtest.internal.registerMetal=function(name,displayName,hardness)
minetest.register_craftitem("industrialtest:"..name.."_lump",{
description=S(displayName.." Lump"),
inventory_image="industrialtest_mtg_"..name.."_lump.png"
@ -728,12 +690,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"
@ -756,9 +720,24 @@ elseif industrialtest.mtgAvailable then
industrialtest.elementKeys.tinBlock="default:tinblock"
industrialtest.elementKeys.stoneWithTin="default:stone_with_tin"
industrialtest.elementKeys.bronzeBlock="default:bronzeblock"
industrialtest.elementKeys.leadLump="industrialtest:lead_lump"
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.gunpowder="tnt:gunpowder"
industrialtest.elementKeys.groupSapling="group:sapling"
industrialtest.elementKeys.groupLeaves="group:leaves"
industrialtest.elementKeys.stickyResin="industrialtest:sticky_resin"
industrialtest.elementKeys.rubber="industrialtest:rubber"
industrialtest.elementKeys.rubberWood="industrialtest:rubber_wood"
industrialtest.elementKeys.rubberSapling="industrialtest:rubber_sapling"
industrialtest.elementKeys.treetap="industrialtest:treetap"
else
error("No compatible games found!")
end

View File

@ -95,6 +95,11 @@ minetest.register_craft({
output="industrialtest:refined_iron_ingot",
recipe=industrialtest.elementKeys.ironIngot
})
minetest.register_craft({
type="cooking",
output="industrialtest:refined_iron_ingot",
recipe="industrialtest:refined_iron_dust"
})
minetest.register_craft({
type="shapeless",
output="industrialtest:refined_iron_ingot 8",
@ -117,31 +122,33 @@ minetest.register_craft({
}
})
minetest.register_craftitem("industrialtest:sticky_resin",{
description=S("Sticky Resin"),
inventory_image="industrialtest_sticky_resin.png"
})
if not industrialtest.mods.mclRubber then
minetest.register_craftitem("industrialtest:sticky_resin",{
description=S("Sticky Resin"),
inventory_image="industrialtest_sticky_resin.png"
})
minetest.register_craftitem("industrialtest:rubber",{
description=S("Rubber"),
inventory_image="industrialtest_rubber.png"
})
minetest.register_craft({
type="cooking",
output="industrialtest:rubber",
recipe="industrialtest:sticky_resin"
minetest.register_craftitem("industrialtest:rubber",{
description=S("Rubber"),
inventory_image="industrialtest_rubber.png"
})
minetest.register_craft({
type="cooking",
output="industrialtest:rubber",
recipe="industrialtest:sticky_resin"
})
end
industrialtest.api.registerExtractorRecipe({
output=industrialtest.elementKeys.rubber,
recipe=industrialtest.elementKeys.rubberWood
})
industrialtest.api.registerExtractorRecipe({
output="industrialtest:rubber",
recipe="industrialtest:rubber_wood"
output=industrialtest.elementKeys.rubber,
recipe=industrialtest.elementKeys.rubberSapling
})
industrialtest.api.registerExtractorRecipe({
output="industrialtest:rubber",
recipe="industrialtest:rubber_sapling"
})
industrialtest.api.registerExtractorRecipe({
output="industrialtest:rubber 3",
recipe="industrialtest:sticky_resin"
output=industrialtest.elementKeys.rubber.." 3",
recipe=industrialtest.elementKeys.stickyResin
})
minetest.register_craftitem("industrialtest:raw_carbon_fibre",{
@ -412,9 +419,104 @@ minetest.register_craft({
output=industrialtest.elementKeys.bronzeIngot,
recipe="industrialtest:bronze_dust"
})
industrialtest.api.registerRotaryMaceratorModifier({
name=industrialtest.elementKeys.copperLump,
modifier=industrialtest.elementKeys.tinLump,
output="industrialtest:bronze_dust 2",
uses=4
})
industrialtest.api.registerRotaryMaceratorModifier({
name=industrialtest.elementKeys.copperIngot,
modifier=industrialtest.elementKeys.tinIngot,
output="industrialtest:bronze_dust",
uses=4
})
industrialtest.api.registerResourceDust("sulfur","Sulfur",{},"#e3ff33ff",false)
industrialtest.api.registerResourceDust("lead","Lead",{},"#eafef8ff",false)
-- TODO: Add lead ore
industrialtest.api.registerExtractorRecipe({
output="industrialtest:sulfur_dust",
recipe=industrialtest.elementKeys.gunpowder
})
industrialtest.api.registerResourceDust("lead","Lead",{
{
resource="industrialtest:lead_block",
count=9
},
{
resource="industrialtest:lead_ore",
count=2
},
{
resource=industrialtest.elementKeys.leadLump,
count=2
},
{resource="industrialtest:lead_ingot"}
},"#eafef8ff",true)
minetest.register_craft({
type="cooking",
output="industrialtest:lead_ingot",
recipe="industrialtest:lead_dust"
})
industrialtest.api.registerResourceDust("refined_iron","Refined Iron",{
{
resource="industrialtest:refined_iron_ingot",
count=1
}
},"#7c8588ff",true)
industrialtest.api.registerRotaryMaceratorModifier({
name=industrialtest.elementKeys.ironLump,
modifier=industrialtest.elementKeys.coal,
output="industrialtest:refined_iron_dust 2",
uses=industrialtest.stackMax
})
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
}
}
})
industrialtest.api.registerRotaryMaceratorModifier({
name=industrialtest.elementKeys.coal,
modifier="industrialtest:water_cell",
output="industrialtest:hydrated_coal_dust",
uses=8
})
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 +547,20 @@ 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)
industrialtest.api.registerPlate("lead_plate",S("Lead Plate"),{
{
resource="industrialtest:lead_ingot",
count=1
}
},"#eafef8ff",true)
-- Cells
minetest.register_craftitem("industrialtest:empty_cell",{
description=S("Empty Cell"),
@ -535,6 +651,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 +755,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,23 +33,41 @@ dofile(modpath.."/api.lua")
dofile(modpath.."/minerals.lua")
dofile(modpath.."/machines/common.lua")
dofile(modpath.."/machines/canning_machine.lua")
dofile(modpath.."/machines/chargepad.lua")
dofile(modpath.."/machines/compressor.lua")
dofile(modpath.."/machines/cable_former.lua")
dofile(modpath.."/machines/electric_furnace.lua")
dofile(modpath.."/machines/extractor.lua")
dofile(modpath.."/machines/fluid_generator.lua")
dofile(modpath.."/machines/generator.lua")
dofile(modpath.."/machines/induction_furnace.lua")
dofile(modpath.."/machines/iron_furnace.lua")
dofile(modpath.."/machines/macerator.lua")
dofile(modpath.."/machines/mass_fabricator.lua")
dofile(modpath.."/machines/nuclear_reactor.lua")
dofile(modpath.."/machines/power_storage.lua")
dofile(modpath.."/machines/recycler.lua")
dofile(modpath.."/machines/rotary_macerator.lua")
dofile(modpath.."/machines/tool_workshop.lua")
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/nano_suit.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 +76,13 @@ 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")
-- compatibility with other mods
if industrialtest.mods.pipeworks then
dofile(modpath.."/compat/pipeworks.lua")
end
if industrialtest.mods.mesecons then
dofile(modpath.."/compat/mesecons.lua")
end

View File

@ -0,0 +1,279 @@
-- 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()
shouldRerunTimer,shouldUpdateFormspec=industrialtest.internal.chargeFromPowerStorageItem(meta,inv)
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)
shouldRerunTimer,shouldUpdateFormspec=industrialtest.internal.chargeFromPowerStorageItem(meta,inv)
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}
}
})

267
machines/chargepad.lua Normal file
View File

@ -0,0 +1,267 @@
-- 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 chargepad={}
industrialtest.internal.chargepads={}
local function chargePlayer(meta,player,flow)
local inv
if industrialtest.mtgAvailable then
_,inv=armor:get_valid_player(player,"")
if not inv then
return false
end
elseif industrialtest.mclAvailable then
inv=player:get_inventory()
end
local armorList=inv:get_list("armor")
local chargedSlots={}
for i,stack in ipairs(armorList) do
local stackMeta=stack:get_meta()
if industrialtest.api.hasPowerStorage(stackMeta) and not industrialtest.api.isFullyCharged(stackMeta) then
table.insert(chargedSlots,{
index=i,
stack=stack
})
end
end
local wielded=player:get_wielded_item()
if not wielded:is_empty() then
local wieldedMeta=wielded:get_meta()
if industrialtest.api.hasPowerStorage(wieldedMeta) and not industrialtest.api.isFullyCharged(wieldedMeta) then
table.insert(chargedSlots,{
stack=wielded
})
end
end
if #chargedSlots==0 then
return false
end
local distribution=math.min(flow,meta:get_int("industrialtest.powerAmount"))/#chargedSlots
for _,chargedSlot in ipairs(chargedSlots) do
industrialtest.api.transferPowerToItem(meta,chargedSlot.stack,distribution)
if chargedSlot.index then
inv:set_stack("armor",chargedSlot.index,chargedSlot.stack)
else
player:set_wielded_item(chargedSlot.stack)
end
end
return true
end
chargepad.getFormspec=function(pos)
local meta=minetest.get_meta(pos)
local charged=meta:get_int("industrialtest.powerAmount")/meta:get_int("industrialtest.powerCapacity")
local formspec
if industrialtest.mtgAvailable then
formspec={
"list[context;charged;1,2.5;1,1]",
"listring[context;charged]",
"label[0.9,3.9;"..S("Charge").."]",
"list[context;discharged;3,2.5;1,1]",
"listring[context;discharged]",
"label[2.7,3.9;"..S("Discharge").."]",
"box[9,1;0.3,4.8;#202020]",
(charged>0 and "box[9,"..(1+4.8-(charged*4.8))..";0.3,"..(charged*4.8)..";#FF1010]" or "")
}
elseif industrialtest.mclAvailable then
formspec={
"list[context;charged;1,2.5;1,1]",
"listring[context;charged]",
mcl_formspec.get_itemslot_bg(1,2.5,1,1),
"label[0.9,3.9;"..S("Charge").."]",
"list[context;discharged;3,2.5;1,1]",
"listring[context;discharged]",
mcl_formspec.get_itemslot_bg(3,2.5,1,1),
"label[2.7,3.9;"..S("Discharge").."]",
"box[9,1;0.3,4.8;#202020]",
(charged>0 and "box[9,"..(1+4.8-(charged*4.8))..";0.3,"..(charged*4.8)..";#FF1010]" or "")
}
end
return table.concat(formspec,"")
end
chargepad.onConstruct=function(pos,meta,inv)
inv:set_size("charged",1)
inv:set_size("discharged",1)
meta:set_int("active",0)
end
chargepad.action=function(pos,node)
local meta=minetest.get_meta(pos)
local inv=meta:get_inventory()
local chargedSlot=inv:get_stack("charged",1)
local dischargedSlot=inv:get_stack("discharged",1)
local _,shouldUpdateFormspec=industrialtest.api.powerFlow(pos)
local flow=meta:get_int("industrialtest.powerFlow")
if chargedSlot:get_count()>0 and meta:get_int("industrialtest.powerAmount")>0 and industrialtest.api.transferPowerToItem(meta,chargedSlot,flow)>0 then
inv:set_stack("charged",1,chargedSlot)
shouldUpdateFormspec=true
end
if dischargedSlot:get_count()>0 and not industrialtest.api.isFullyCharged(meta) and industrialtest.api.transferPowerFromItem(dischargedSlot,meta,flow)>0 then
inv:set_stack("discharged",1,dischargedSlot)
shouldUpdateFormspec=true
end
local players=minetest.get_connected_players()
local p1=vector.offset(pos,-0.5,0,-0.5)
local p2=vector.offset(pos,0.5,2,0.5)
local playerFound=false
for _,player in ipairs(players) do
if vector.in_area(player:get_pos(),p1,p2) then
playerFound=true
shouldUpdateFormspec=shouldUpdateFormspec or chargePlayer(meta,player,flow)
break
end
end
local active=meta:get_int("active")==1
if playerFound and not active then
minetest.swap_node(pos,{
name=node.name.."_active",
param2=node.param2
})
meta:set_int("active",1)
elseif (not playerFound or meta:get_int("industrialtest.powerAmount")==0) and active then
local def=minetest.registered_nodes[node.name]
minetest.swap_node(pos,{
name=def._industrialtest_baseNodeName,
param2=node.param2
})
meta:set_int("active",0)
end
if shouldUpdateFormspec then
local def=minetest.registered_nodes[node.name]
def._industrialtest_updateFormspec(pos)
end
end
local function registerChargepad(config)
industrialtest.internal.registerMachine({
name=config.name,
displayName=config.displayName,
capacity=config.capacity,
flow=config.flow,
ioConfig="iiiioi",
sounds=config.sounds,
powerSlots={"charged","discharged"},
storageSlots={"charged","discharged"},
requiresWrench=config.requiresWrench,
registerActiveVariant=true,
groups={
_industrialtest_hasPowerOutput=1,
_industrialtest_hasPowerInput=1
},
customKeys={
tiles={
config.machineBlockTexture.."^industrialtest_chargepad_top.png",
config.machineBlockTexture,
config.machineBlockTexture,
config.machineBlockTexture,
config.machineBlockTexture,
config.machineBlockTexture.."^"..config.frontTexture
},
paramtype2="facedir",
legacy_facedir_simple=true
},
activeCustomKeys={
tiles={
config.machineBlockTexture.."^industrialtest_chargepad_top_active.png",
config.machineBlockTexture,
config.machineBlockTexture,
config.machineBlockTexture,
config.machineBlockTexture,
config.machineBlockTexture.."^"..config.frontTexture
},
_industrialtest_baseNodeName="industrialtest:"..config.name
},
getFormspec=chargepad.getFormspec,
onConstruct=chargepad.onConstruct
})
minetest.register_craft({
type="shaped",
output="industrialtest:"..config.name,
recipe={
{"industrialtest:electronic_circuit",industrialtest.elementKeys.stoneSlab,"industrialtest:electronic_circuit"},
{industrialtest.elementKeys.rubber,"industrialtest:"..config.basePowerStorage,industrialtest.elementKeys.rubber}
}
})
table.insert(industrialtest.internal.chargepads,"industrialtest:"..config.name)
table.insert(industrialtest.internal.chargepads,"industrialtest:"..config.name.."_active")
end
registerChargepad({
name="batbox_chargepad",
displayName=S("BatBox Chargepad"),
capacity=25000,
flow=industrialtest.api.lvPowerFlow,
sounds="wood",
machineBlockTexture="industrialtest_wood_machine_block.png",
frontTexture="industrialtest_batbox_front.png",
requiresWrench=false,
basePowerStorage="batbox"
})
registerChargepad({
name="cesu_chargepad",
displayName=S("CESU Chargepad"),
capacity=400000,
flow=industrialtest.api.mvPowerFlow,
sounds="metal",
machineBlockTexture="industrialtest_bronze_machine_block.png",
frontTexture="industrialtest_cesu_front.png",
requiresWrench=false,
basePowerStorage="cesu"
})
registerChargepad({
name="mfe_chargepad",
displayName=S("MFE Chargepad"),
capacity=3000000,
flow=industrialtest.api.hvPowerFlow,
sounds="metal",
machineBlockTexture="industrialtest_machine_block.png",
frontTexture="industrialtest_mfe_front.png",
requiresWrench=true,
basePowerStorage="mfe"
})
registerChargepad({
name="mfsu_chargepad",
displayName=S("MFSU Chargepad"),
capacity=30000000,
flow=industrialtest.api.evPowerFlow,
sounds="metal",
machineBlockTexture="industrialtest_advanced_machine_block.png",
frontTexture="industrialtest_mfsu_front.png",
requiresWrench=true,
basePowerStorage="mfsu"
})
minetest.register_abm({
label="Chargepad updating",
nodenames=industrialtest.internal.chargepads,
interval=industrialtest.updateDelay,
chance=1,
action=chargepad.action
})

View File

@ -17,6 +17,8 @@
local machine={}
local simpleElectricItemProcessor={}
industrialtest.internal.simpleElectricItemProcessors={}
industrialtest.internal.mclAfterDigNode=function(pos,oldmeta,lists)
-- Taken from https://git.minetest.land/MineClone2/MineClone2/src/branch/master/mods/ITEMS/mcl_furnaces/init.lua#L538
local meta=minetest.get_meta(pos)
@ -47,6 +49,22 @@ industrialtest.internal.allowMoveToUpgradeSlot=function(pos,toIndex,stack)
return stack:get_count()
end
industrialtest.internal.chargeFromPowerStorageItem=function(meta,inv)
local shouldRerunTimer=false
local shouldUpdateFormspec=false
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
shouldRerunTimer=stackMeta:get_int("industrialtest.powerAmount")>0 and not industrialtest.api.isFullyCharged(meta)
industrialtest.api.updateItemPowerText(powerStorageSlot)
inv:set_stack("powerStorage",1,powerStorageSlot)
end
end
return shouldRerunTimer,shouldUpdateFormspec
end
machine.getFormspec=function(pos,config)
local formspec
if industrialtest.mtgAvailable then
@ -77,9 +95,6 @@ machine.onConstruct=function(pos,config)
local inv=meta:get_inventory()
industrialtest.api.addPowerStorage(meta,config.capacity,config.flow,config.ioConfig)
if not config.withoutFormspec then
meta:set_string("formspec",machine.getFormspec(pos,config))
end
if config.groups then
if config.groups._industrialtest_hasPowerInput then
@ -112,10 +127,14 @@ machine.onConstruct=function(pos,config)
config.onConstruct(pos,meta,inv)
end
if not config.withoutFormspec then
meta:set_string("formspec",machine.getFormspec(pos,config))
end
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
end
machine.onDestruct=function(pos)
machine.onDestruct=function(pos,config)
local meta=minetest.get_meta(pos)
if industrialtest.api.isNetworkMaster(meta) then
local network=industrialtest.api.createNetworkMap(pos,true)
@ -130,14 +149,16 @@ machine.onDestruct=function(pos)
end
endpointMeta:set_string("industrialtest.networks",minetest.serialize(networks))
end
else
local networks=industrialtest.api.isAttachedToNetwork(meta)
if networks then
for _,network in ipairs(networks) do
industrialtest.api.removeNodeFromNetwork(network,pos)
end
end
local networks=industrialtest.api.isAttachedToNetwork(meta)
if networks then
for _,network in ipairs(networks) do
industrialtest.api.removeNodeFromNetwork(network,pos)
end
end
if config.onDestruct then
config.onDestruct(pos)
end
end
machine.onTimer=function(pos,elapsed,config)
@ -221,6 +242,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)
@ -263,7 +291,9 @@ function industrialtest.internal.registerMachine(config)
on_construct=function(pos)
machine.onConstruct(pos,config)
end,
on_destruct=machine.onDestruct,
on_destruct=function(pos)
machine.onDestruct(pos,config)
end,
on_timer=function(pos,elapsed)
local shouldRerunTimer,_=machine.onTimer(pos,elapsed,config)
return shouldRerunTimer
@ -274,6 +304,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
@ -294,6 +327,12 @@ function industrialtest.internal.registerMachine(config)
end,
_industrialtest_updateFormspec=function(pos)
machine.updateFormspec(pos,config)
end,
_industrialtest_getFormspec=function(pos)
if config.withoutFormspec then
return ""
end
return machine.getFormspec(pos,config)
end
}
if industrialtest.mtgAvailable then
@ -549,15 +588,9 @@ simpleElectricItemProcessor.onTimer=function(pos,elapsed,meta,inv,config)
local shouldUpdateFormspec=false
local shouldRerunTimer=false
local requiredPower=elapsed*config.opPower*industrialtest.api.getMachineSpeed(meta)
if powerStorageSlot:get_count()>0 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
shouldRerunTimer,shouldUpdateFormspec=industrialtest.internal.chargeFromPowerStorageItem(meta,inv)
if srcSlot:get_count()>0 and meta:get_int("industrialtest.powerAmount")>=requiredPower then
local output=craftResultProxy(config.method,srcSlot)
if output.time>0 and inv:room_for_item("dst",output.item) then
@ -618,7 +651,7 @@ simpleElectricItemProcessor.onMetadataInventoryMove=function(pos,fromList,fromIn
if meta:get_int("industrialtest.powerAmount")>0 then
meta:set_string("formspec",simpleElectricItemProcessor.getFormspec(pos))
end
elseif fromList=="dst" and dstSlot:get_free_space()==0 then
elseif fromList=="dst" and dstSlot:get_free_space()>0 then
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
end
end
@ -634,7 +667,7 @@ simpleElectricItemProcessor.onMetadataInventoryTake=function(pos,listname,index,
if meta:get_int("industrialtest.powerAmount")>0 then
meta:set_string("formspec",simpleElectricItemProcessor.getFormspec(pos))
end
elseif listname=="dst" and dstSlot:get_free_space()==0 then
elseif listname=="dst" and dstSlot:get_free_space()>0 then
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
end
end
@ -646,15 +679,8 @@ simpleElectricItemProcessor.activeOnTimer=function(pos,elapsed,meta,inv,config)
local shouldRerunTimer=false
local requiredPower=elapsed*config.opPower*industrialtest.api.getMachineSpeed(meta)
if powerStorageSlot:get_count()>0 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
shouldRerunTimer,shouldUpdateFormspec=industrialtest.internal.chargeFromPowerStorageItem(meta,inv)
if srcSlot:get_count()>0 and meta:get_float("maxSrcTime")<=0 and meta:get_int("industrialtest.powerAmount")>=requiredPower then
local output=craftResultProxy(config.method,srcSlot)
if output.time>0 and inv:room_for_item("dst",output.item) then
@ -755,4 +781,5 @@ function industrialtest.internal.registerSimpleElectricItemProcessor(config)
return simpleElectricItemProcessor.activeOnTimer(pos,elapsed,meta,inv,config)
end
})
table.insert(industrialtest.internal.simpleElectricItemProcessors,"industrialtest:"..config.name)
end

View File

@ -31,7 +31,7 @@ minetest.register_craft({
type="shaped",
output="industrialtest:extractor",
recipe={
{"industrialtest:treetap","industrialtest:machine_block","industrialtest:treetap"},
{"industrialtest:treetap","industrialtest:electronic_circuit","industrialtest:treetap"}
{industrialtest.elementKeys.treetap,"industrialtest:machine_block",industrialtest.elementKeys.treetap},
{industrialtest.elementKeys.treetap,"industrialtest:electronic_circuit",industrialtest.elementKeys.treetap}
}
})

View File

@ -0,0 +1,287 @@
-- 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 inductionFurnace={}
inductionFurnace.opPower=60
inductionFurnace.efficiency=0.5
local function calculateMaxSrcTime(pos)
local meta=minetest.get_meta(pos)
local inv=meta:get_inventory()
local srcList=inv:get_list("src")
local maxSrcTime=0
for _,slot in ipairs(srcList) do
local result,_=minetest.get_craft_result({
method="cooking",
width=1,
items={slot}
})
maxSrcTime=math.max(maxSrcTime,result.time*inductionFurnace.efficiency)
end
meta:set_float("maxSrcTime",maxSrcTime)
end
inductionFurnace.getFormspec=function(pos)
local meta=minetest.get_meta(pos)
local powerPercent=meta:get_int("industrialtest.powerAmount")/meta:get_int("industrialtest.powerCapacity")*100
local maxSrcTime=meta:get_float("maxSrcTime")
local srcPercent=maxSrcTime>0 and meta:get_float("srcTime")/maxSrcTime*100 or 0
local heat=meta:get_int("heat")
local formspec
if industrialtest.mtgAvailable then
formspec={
"list[context;src;3.7,1.8;2,1]",
(powerPercent>0 and "image[3.7,2.8;1,1;industrialtest_gui_electricity_bg.png^[lowpart:"..powerPercent..":industrialtest_gui_electricity_fg.png]"
or "image[3.7,2.8;1,1;industrialtest_gui_electricity_bg.png]"),
"list[context;powerStorage;3.7,3.9;1,1]",
(srcPercent>0 and "image[4.9,2.8;1,1;gui_furnace_arrow_bg.png^[lowpart:"..srcPercent..":gui_furnace_arrow_fg.png^[transformR270]"
or "image[4.9,2.8;1,1;gui_furnace_arrow_bg.png^[transformR270]"),
"list[context;dst;6,2.8;2,1;]",
"list[context;upgrades;9,0.9;1,4]",
"label[0.5,2.8;"..minetest.formspec_escape(S("Heat: @1 %",heat)).."]",
"listring[context;src]",
"listring[context;powerStorage]",
"listring[context;dst]",
"listring[context;upgrades]"
}
elseif industrialtest.mclAvailable then
formspec={
"list[context;src;3.7,1.8;2,1]",
mcl_formspec.get_itemslot_bg(3.7,1.8,2,1),
(powerPercent>0 and "image[3.7,2.8;1,1;industrialtest_gui_electricity_bg.png^[lowpart:"..powerPercent..":industrialtest_gui_electricity_fg.png]"
or "image[3.7,2.8;1,1;industrialtest_gui_electricity_bg.png]"),
"list[context;powerStorage;3.7,3.9;1,1]",
mcl_formspec.get_itemslot_bg(3.7,3.9,1,1),
(srcPercent>0 and "image[4.9,2.8;1,1;gui_furnace_arrow_bg.png^[lowpart:"..srcPercent..":gui_furnace_arrow_fg.png^[transformR270]"
or "image[4.9,2.8;1,1;gui_furnace_arrow_bg.png^[transformR270]"),
"list[context;dst;6,2.8;2,1;]",
mcl_formspec.get_itemslot_bg(6,2.8,2,1),
"list[context;upgrades;9,0.9;1,4]",
mcl_formspec.get_itemslot_bg(9,0.9,1,4),
"label[0.5,2.8;"..minetest.formspec_escape(S("Heat: @1 %",heat)).."]",
"listring[context;src]",
"listring[context;powerStorage]",
"listring[context;dst]",
"listring[context;upgrades]"
}
end
return table.concat(formspec,"")
end
inductionFurnace.onConstruct=function(pos,meta,inv)
inv:set_size("src",2)
inv:set_size("dst",2)
inv:set_size("powerStorage",1)
inv:set_size("upgrades",4)
meta:set_int("heat",0)
meta:set_float("srcTime",0)
end
inductionFurnace.onTimer=function(pos,elapsed,meta,inv)
local shouldRerunTimer=false
local shouldUpdateFormspec=false
local srcList=inv:get_list("src")
local heat=meta:get_int("heat")
shouldRerunTimer,shouldUpdateFormspec=industrialtest.internal.chargeFromPowerStorageItem(meta,inv)
if heat>0 then
meta:set_int("heat",math.max(heat-math.max(2*elapsed,1),0))
shouldRerunTimer=shouldRerunTimer or heat>0
shouldUpdateFormspec=true
end
for _,slot in ipairs(srcList) do
if not slot:is_empty() then
local result,after=minetest.get_craft_result({
method="cooking",
width=1,
items={slot}
})
if result.time>0 and inv:room_for_item("dst",result.item) then
minetest.swap_node(pos,{
name="industrialtest:induction_furnace_active",
param2=minetest.get_node(pos).param2
})
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
return false,shouldUpdateFormspec
end
end
end
return shouldRerunTimer,shouldUpdateFormspec
end
inductionFurnace.allowMetadataInventoryMove=function(pos,fromList,fromIndex,toList,toIndex,count)
if toList=="dst" then
return 0
end
return count
end
inductionFurnace.allowMetadataInventoryPut=function(pos,listname,index,stack)
if listname=="dst" then
return 0
end
return stack:get_count()
end
inductionFurnace.onMetadataInventoryPut=function(pos,listname)
if listname=="src" then
calculateMaxSrcTime(pos)
end
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
end
inductionFurnace.onMetadataInventoryMove=function(pos,fromList,fromIndex,toList)
if fromList=="src" or toList=="src" then
calculateMaxSrcTime(pos)
end
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
end
inductionFurnace.onMetadataInventoryTake=function(pos,listname)
if listname=="src" then
calculateMaxSrcTime(pos)
end
if listname=="dst" then
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
end
end
inductionFurnace.activeOnTimer=function(pos,elapsed,meta,inv)
local srcList=inv:get_list("src")
local powerAmount=meta:get_int("industrialtest.powerAmount")
local srcTime=meta:get_float("srcTime")
local maxSrcTime=meta:get_float("maxSrcTime")
local heat=meta:get_int("heat")
local speed=industrialtest.api.getMachineSpeed(meta)
local requiredPower=elapsed*inductionFurnace.opPower*speed
industrialtest.internal.chargeFromPowerStorageItem(meta,inv)
local shouldContinue=false
local results={}
for _,slot in ipairs(srcList) do
if slot:is_empty() then
table.insert(results,false)
else
local result,after=minetest.get_craft_result({
method="cooking",
width=1,
items={slot}
})
if result.time>0 and inv:room_for_item("dst",result.item) then
table.insert(results,result.item)
shouldContinue=true
else
table.insert(results,false)
end
end
end
if not shouldContinue or powerAmount<requiredPower then
meta:set_float("srcTime",0)
minetest.swap_node(pos,{
name="industrialtest:induction_furnace",
param2=minetest.get_node(pos).param2
})
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
return false,true
end
srcTime=srcTime+elapsed*(1+heat/100)
if srcTime>=maxSrcTime then
for i,result in ipairs(results) do
if result then
local multiplier=math.min(srcList[i]:get_count(),speed)
local prevCount=result:get_count()
result:set_count(result:get_count()*multiplier)
local leftover=inv:add_item("dst",result)
srcList[i]:take_item(multiplier-leftover:get_count()/prevCount)
inv:set_stack("src",i,srcList[i])
end
end
srcTime=0
end
meta:set_float("srcTime",srcTime)
if heat<100 then
meta:set_int("heat",math.min(100,heat+speed))
end
industrialtest.api.addPower(meta,-requiredPower)
return true,true
end
industrialtest.internal.registerMachine({
name="induction_furnace",
displayName=S("Induction Furnace"),
capacity=industrialtest.api.mvPowerFlow*2,
getFormspec=inductionFurnace.getFormspec,
flow=industrialtest.api.mvPowerFlow,
ioConfig="iiiiii",
requiresWrench=true,
registerActiveVariant=true,
sounds="metal",
powerSlots={"powerStorage"},
storageSlots={"src","dst","powerStorage","upgrades"},
groups={
_industrialtest_hasPowerInput=1
},
customKeys={
tiles={
"industrialtest_advanced_machine_block.png",
"industrialtest_advanced_machine_block.png",
"industrialtest_advanced_machine_block.png",
"industrialtest_advanced_machine_block.png",
"industrialtest_advanced_machine_block.png",
"industrialtest_advanced_machine_block.png^industrialtest_electric_furnace_front.png"
},
paramtype2="facedir",
legacy_facedir_simple=true
},
activeCustomKeys={
tiles={
"industrialtest_advanced_machine_block.png",
"industrialtest_advanced_machine_block.png",
"industrialtest_advanced_machine_block.png",
"industrialtest_advanced_machine_block.png",
"industrialtest_advanced_machine_block.png",
"industrialtest_advanced_machine_block.png^industrialtest_electric_furnace_front_active.png"
}
},
onConstruct=inductionFurnace.onConstruct,
onTimer=inductionFurnace.onTimer,
allowMetadataInventoryMove=inductionFurnace.allowMetadataInventoryMove,
allowMetadataInventoryPut=inductionFurnace.allowMetadataInventoryPut,
onMetadataInventoryPut=inductionFurnace.onMetadataInventoryPut,
onMetadataInventoryMove=inductionFurnace.onMetadataInventoryMove,
onMetadataInventoryTake=inductionFurnace.onMetadataInventoryTake,
activeOnTimer=inductionFurnace.activeOnTimer
})
minetest.register_craft({
type="shaped",
output="industrialtest:induction_furnace",
recipe={
{industrialtest.elementKeys.copperIngot,industrialtest.elementKeys.copperIngot,industrialtest.elementKeys.copperIngot},
{industrialtest.elementKeys.copperIngot,"industrialtest:electric_furnace",industrialtest.elementKeys.copperIngot},
{industrialtest.elementKeys.copperIngot,"industrialtest:advanced_machine_block",industrialtest.elementKeys.copperIngot}
}
})

View File

@ -173,7 +173,7 @@ ironFurnace.activeOnTimer=function(pos,elapsed)
end
shouldUpdateFormspec=true
shouldRerunTimer=true
else
elseif meta:get_float("fuelTime")<=0 then
minetest.swap_node(pos,{
name="industrialtest:iron_furnace",
param2=minetest.get_node(pos).param2
@ -252,7 +252,7 @@ ironFurnace.onMetadataInventoryTake=function(pos,listname,index,stack)
meta:set_float("srcTime",-1)
meta:set_float("maxSrcTime",0)
if meta:get_float("maxFuelTime")>0 then
meta:set_string("formspec",ironFurnaceFormspec(meta:get_float("fuelTime")/meta:get_float("maxFuelTime")*100,0))
meta:set_string("formspec",ironFurnace.getFormspec(meta:get_float("fuelTime")/meta:get_float("maxFuelTime")*100,0))
end
elseif listname=="dst" and dstSlot:get_free_space()==0 then
minetest.get_node_timer(pos):start(industrialtest.updateDelay)

View File

@ -16,15 +16,17 @@
local S=minetest.get_translator("industrialtest")
local reactor={}
local reactorChamber={}
reactor.getFormspec=function(pos)
local meta=minetest.get_meta(pos)
local charged=meta:get_int("industrialtest.powerAmount")/meta:get_int("industrialtest.powerCapacity")
local size=math.floor(meta:get_int("size")/3)
local switchText=(meta:get_int("enabled")==0 and S("Start") or S("Stop"))
local formspec
if industrialtest.mtgAvailable then
formspec={
"list[context;fuel;1,1;5,4]",
"list[context;fuel;1,1;"..size..","..size.."]",
"listring[context;fuel]",
"list[context;charged;7.7,2.8;1,1]",
"listring[context;charged]",
@ -34,8 +36,8 @@ reactor.getFormspec=function(pos)
}
elseif industrialtest.mclAvailable then
formspec={
"list[context;fuel;1,1;5,4]",
mcl_formspec.get_itemslot_bg(1,1,5,4),
"list[context;fuel;1,1;"..size..","..size.."]",
mcl_formspec.get_itemslot_bg(1,1,size,size),
"listring[context;fuel]",
"list[context;charged;7,2.8;1,1]",
mcl_formspec.get_itemslot_bg(7.7,2.8,1,1),
@ -49,13 +51,23 @@ reactor.getFormspec=function(pos)
end
reactor.onConstruct=function(pos,meta,inv)
inv:set_size("fuel",20)
inv:set_size("fuel",4)
inv:set_size("charged",1)
meta:set_int("heat",0)
meta:set_int("size",6)
meta:set_int("enabled",0)
meta:set_int("stateChanged",0)
end
reactor.onDestruct=function(pos)
local meta=minetest.get_meta(pos)
local chambers=minetest.deserialize(meta:get_string("chambers")) or {}
for _,chamber in ipairs(chambers) do
minetest.remove_node(chamber)
minetest.add_item(chamber,"industrialtest:nuclear_reactor_chamber")
end
end
local function hasFuel(fuelList)
for _,stack in ipairs(fuelList) do
if stack:get_name()=="industrialtest:uranium_cell" then
@ -65,12 +77,12 @@ local function hasFuel(fuelList)
return false
end
local function findMaxFuelCluster(fuelList)
local function findMaxFuelCluster(size,fuelList)
local maxCluster={}
for y=1,4 do
for x=1,5 do
for y=1,size do
for x=1,size do
local iy=y-1
local stack=fuelList[iy*5+x]
local stack=fuelList[iy*size+x]
local def=minetest.registered_tools[stack:get_name()]
if def and def.groups._industrialtest_nuclearReactorFuel then
local cluster={
@ -79,49 +91,49 @@ local function findMaxFuelCluster(fuelList)
y=iy
}
}
if x>1 and fuelList[iy*5+x-1]:get_name()==stack:get_name() then
if x>1 and fuelList[iy*size+x-1]:get_name()==stack:get_name() then
table.insert(cluster,{
x=x-1,
y=iy
})
end
if x<5 and fuelList[iy*5+x+1]:get_name()==stack:get_name() then
if x<size and fuelList[iy*size+x+1]:get_name()==stack:get_name() then
table.insert(cluster,{
x=x+1,
y=iy
})
end
if y>1 and fuelList[(iy-1)*5+x]:get_name()==stack:get_name() then
if y>1 and fuelList[(iy-1)*size+x]:get_name()==stack:get_name() then
table.insert(cluster,{
x=x,
y=iy-1
})
end
if y<4 and fuelList[(iy+1)*5+x]:get_name()==stack:get_name() then
if y<size and fuelList[(iy+1)*size+x]:get_name()==stack:get_name() then
table.insert(cluster,{
x=x,
y=iy+1
})
end
if x>1 and y>1 and fuelList[(iy-1)*5+x-1]:get_name()==stack:get_name() then
if x>1 and y>1 and fuelList[(iy-1)*size+x-1]:get_name()==stack:get_name() then
table.insert(cluster,{
x=x-1,
y=iy-1
})
end
if x<5 and y>1 and fuelList[(iy-1)*5+x+1]:get_name()==stack:get_name() then
if x<size and y>1 and fuelList[(iy-1)*size+x+1]:get_name()==stack:get_name() then
table.insert(cluster,{
x=x+1,
y=iy-1
})
end
if x>1 and y<4 and fuelList[(iy+1)*5+x-1]:get_name()==stack:get_name() then
if x>1 and y<size and fuelList[(iy+1)*size+x-1]:get_name()==stack:get_name() then
table.insert(cluster,{
x=x-1,
y=iy+1
})
end
if x<5 and y<4 and fuelList[(iy+1)*5+x+1]:get_name()==stack:get_name() then
if x<size and y<size and fuelList[(iy+1)*size+x+1]:get_name()==stack:get_name() then
table.insert(cluster,{
x=x+1,
y=iy+1
@ -140,7 +152,7 @@ local function findMaxFuelCluster(fuelList)
end
local function findCoolant(fuelList)
for i=1,20 do
for i=1,#fuelList do
local stack=fuelList[i]
local def=minetest.registered_tools[stack:get_name()]
if def and def.groups._industrialtest_nuclearReactorCoolant then
@ -189,11 +201,14 @@ reactor.onTimer=function(pos,elapsed,meta,inv)
shouldRerunTimer=false
end
reactor.synchronizeChambers(pos)
return shouldRerunTimer,shouldUpdateFormspec
end
reactor.activeOnTimer=function(pos,elapsed,meta,inv)
local powerFlow=meta:get_int("industrialtest.powerFlow")
local size=math.floor(meta:get_int("size")/3)
local chargedSlot=inv:get_stack("charged",1)
local fuelList=inv:get_list("fuel")
local afterFlow,flowTransferred=industrialtest.api.powerFlow(pos)
@ -218,13 +233,14 @@ reactor.activeOnTimer=function(pos,elapsed,meta,inv)
param2=minetest.get_node(pos).param2
})
meta:set_int("enabled",0)
reactor.synchronizeChambers(pos)
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
return false,shouldUpdateFormspec
end
local maxCluster=findMaxFuelCluster(fuelList)
local maxCluster=findMaxFuelCluster(size,fuelList)
for _,stack in ipairs(maxCluster) do
local index=stack.y*5+stack.x
local index=stack.y*size+stack.x
local usedStack,_=useFuel(fuelList[index],5)
inv:set_stack("fuel",index,usedStack)
end
@ -237,7 +253,7 @@ reactor.activeOnTimer=function(pos,elapsed,meta,inv)
local coolant=findCoolant(fuelList)
if coolant>0 then
local coolantStack,used=useFuel(fuelList[coolant],#maxCluster*50)
heat=heat-used
heat=math.max(0,heat-used)
inv:set_stack("fuel",coolant,coolantStack)
end
if heat>200 then
@ -247,6 +263,8 @@ reactor.activeOnTimer=function(pos,elapsed,meta,inv)
end
meta:set_int("heat",heat)
reactor.synchronizeChambers(pos)
return shouldRerunTimer,shouldUpdateFormspec
end
@ -271,6 +289,7 @@ end
reactor.metadataChange=function(pos)
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
reactor.synchronizeChambers(pos)
end
reactor.handleFormspecFields=function(pos,formname,fields)
@ -292,33 +311,121 @@ reactor.handleFormspecFields=function(pos,formname,fields)
reactor.metadataChange(pos)
end
local definition={
description=S("Nuclear Reactor Chamber"),
tiles={"industrialtest_machine_block.png^industrialtest_nuclear_reactor_top.png"},
drop="industrialtest:machine_block",
groups={
_industrialtest_wrenchUnmountable=1
}
}
if industrialtest.mtgAvailable then
definition.sounds=default.node_sound_metal_defaults()
definition.groups.cracky=1
definition.groups.level=2
elseif industrialtest.mclAvailable then
definition.sounds=mcl_sounds.node_sound_metal_defaults()
definition._mcl_blast_resistance=6
definition._mcl_hardness=5
reactor.synchronizeToChamber=function(pos)
local meta=minetest.get_meta(pos)
local inv=meta:get_inventory()
local fuelList=inv:get_list("fuel")
local chargedList=inv:get_list("charged")
local reactorPos=minetest.deserialize(meta:get_string("reactor"))
local reactorMeta=minetest.get_meta(reactorPos)
local reactorInv=reactorMeta:get_inventory()
reactorInv:set_list("fuel",fuelList)
reactorInv:set_list("charged",chargedList)
reactor.synchronizeChambers(reactorPos)
end
minetest.register_node("industrialtest:nuclear_reactor_chamber",definition)
minetest.register_craft({
type="shaped",
output="industrialtest:nuclear_reactor_chamber",
recipe={
{"","industrialtest:copper_plate",""},
{"industrialtest:copper_plate","industrialtest:machine_block","industrialtest:copper_plate"},
{"","industrialtest:copper_plate",""}
reactor.synchronizeChambers=function(pos)
local meta=minetest.get_meta(pos)
local chambers=meta:contains("chambers") and minetest.deserialize(meta:get_string("chambers")) or {}
for _,chamber in ipairs(chambers) do
reactorChamber.synchronize(chamber,pos)
end
end
reactor.changeSize=function(pos,diff)
local meta=minetest.get_meta(pos)
local inv=meta:get_inventory()
local size=meta:get_int("size")+diff
local actualSize=math.floor(size/3)
meta:set_int("size",size)
inv:set_size("fuel",actualSize*actualSize)
local def=minetest.registered_nodes[minetest.get_node(pos).name]
def._industrialtest_updateFormspec(pos)
end
reactorChamber.synchronize=function(pos,reactor)
local meta=minetest.get_meta(pos)
local inv=meta:get_inventory()
local reactorDef=minetest.registered_nodes[minetest.get_node(reactor).name]
meta:set_string("formspec",reactorDef._industrialtest_getFormspec(reactor))
local reactorMeta=minetest.get_meta(reactor)
local reactorInv=reactorMeta:get_inventory()
local fuelList=reactorInv:get_list("fuel")
local chargedList=reactorInv:get_list("charged")
inv:set_size("fuel",#fuelList)
inv:set_size("charged",#chargedList)
inv:set_list("fuel",fuelList)
inv:set_list("charged",chargedList)
end
reactorChamber.afterPlaceNode=function(pos)
local neighbours={
vector.offset(pos,-1,0,0),
vector.offset(pos,1,0,0),
vector.offset(pos,0,-1,0),
vector.offset(pos,0,1,0),
vector.offset(pos,0,0,-1),
vector.offset(pos,0,0,1)
}
})
local reactorPos=nil
for _,neighbour in ipairs(neighbours) do
local node=minetest.get_node(neighbour)
if node.name=="industrialtest:nuclear_reactor" or node.name=="industrialtest:nuclear_reactor_active" then
reactorPos=neighbour
end
end
if not reactorPos then
minetest.remove_node(pos)
return true
end
local meta=minetest.get_meta(pos)
meta:set_string("reactor",minetest.serialize(reactorPos))
reactor.changeSize(reactorPos,1)
reactor.synchronizeChambers(reactorPos)
local reactorMeta=minetest.get_meta(reactorPos)
local chambers=reactorMeta:contains("chambers") and minetest.deserialize(reactorMeta:get_string("chambers")) or {}
table.insert(chambers,pos)
reactorMeta:set_string("chambers",minetest.serialize(chambers))
industrialtest.api.createNetworkMapForNode(reactorPos)
reactorChamber.synchronize(pos,reactorPos)
end
reactorChamber.onDestruct=function(pos)
local meta=minetest.get_meta(pos)
if not meta:contains("reactor") then
return
end
local reactorPos=minetest.deserialize(meta:get_string("reactor"))
local reactorMeta=minetest.get_meta(reactorPos)
if not reactorMeta or not reactorMeta:contains("chambers") then
return
end
local chambers=minetest.deserialize(reactorMeta:get_string("chambers"))
for i,chamber in ipairs(chambers) do
if chamber.x==pos.x and chamber.y==pos.y and chamber.z==pos.z then
table.remove(chambers,i)
break
end
end
reactorMeta:set_string("chambers",minetest.serialize(chambers))
reactor.changeSize(reactorPos,-1)
reactor.synchronizeChambers(reactorPos)
end
reactorChamber.handleFormspecFields=function(pos,formname,fields)
local meta=minetest.get_meta(pos)
local reactorPos=minetest.deserialize(meta:get_string("reactor"))
reactor.handleFormspecFields(reactorPos,formname,fields)
end
industrialtest.internal.registerMachine({
name="nuclear_reactor",
@ -347,7 +454,8 @@ industrialtest.internal.registerMachine({
},
paramtype2="facedir",
legacy_facedir_simple=true,
on_receive_fields=reactor.handleFormspecFields
on_receive_fields=reactor.handleFormspecFields,
_industrialtest_synchronizeToChamber=reactor.synchronizeToChamber
},
activeCustomKeys={
tiles={
@ -363,12 +471,14 @@ industrialtest.internal.registerMachine({
on_receive_fields=reactor.handleFormspecFields
},
onConstruct=reactor.onConstruct,
onDestruct=reactor.onDestruct,
onTimer=reactor.onTimer,
activeOnTimer=reactor.activeOnTimer,
allowMetadataInventoryMove=reactor.allowMetadataInventoryMove,
allowMetadataInventoryPut=reactor.allowMetadataInventoryPut,
onMetadataInventoryMove=reactor.metadataChange,
onMetadataInventoryPut=reactor.metadataChange
onMetadataInventoryPut=reactor.metadataChange,
onMetadataInventoryTake=reactor.metadataChange
})
minetest.register_craft({
type="shaped",
@ -379,3 +489,42 @@ minetest.register_craft({
{"","industrialtest:generator",""}
}
})
local definition={
description=S("Nuclear Reactor Chamber"),
tiles={"industrialtest_machine_block.png^industrialtest_nuclear_reactor_top.png"},
drop="industrialtest:machine_block",
groups={
_industrialtest_wrenchUnmountable=1,
_industrialtest_cable=1
},
on_destruct=reactorChamber.onDestruct,
after_place_node=reactorChamber.afterPlaceNode,
can_dig=minetest.registered_nodes["industrialtest:nuclear_reactor"].can_dig,
on_receive_fields=reactorChamber.handleFormspecFields,
allow_metadata_inventory_move=minetest.registered_nodes["industrialtest:nuclear_reactor"].allow_metadata_inventory_move,
allow_metadata_inventory_put=minetest.registered_nodes["industrialtest:nuclear_reactor"].allow_metadata_inventory_put,
on_metadata_inventory_move=reactor.synchronizeToChamber,
on_metadata_inventory_put=reactor.synchronizeToChamber,
on_metadata_inventory_take=reactor.synchronizeToChamber,
_industrialtest_cableFlow=industrialtest.api.evPowerFlow
}
if industrialtest.mtgAvailable then
definition.sounds=default.node_sound_metal_defaults()
definition.groups.cracky=1
definition.groups.level=2
elseif industrialtest.mclAvailable then
definition.sounds=mcl_sounds.node_sound_metal_defaults()
definition._mcl_blast_resistance=6
definition._mcl_hardness=5
end
minetest.register_node("industrialtest:nuclear_reactor_chamber",definition)
minetest.register_craft({
type="shaped",
output="industrialtest:nuclear_reactor_chamber",
recipe={
{"","industrialtest:lead_plate",""},
{"industrialtest:lead_plate","industrialtest:machine_block","industrialtest:lead_plate"},
{"","industrialtest:lead_plate",""}
}
})

View File

@ -0,0 +1,300 @@
-- 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 rotaryMacerator={}
rotaryMacerator.opPower=60
rotaryMacerator.maintainSpeedOpPower=10
rotaryMacerator.getFormspec=function(pos)
local meta=minetest.get_meta(pos)
local powerPercent=meta:get_int("industrialtest.powerAmount")/meta:get_int("industrialtest.powerCapacity")*100
local maxSrcTime=meta:get_float("maxSrcTime")
local srcPercent=maxSrcTime>0 and meta:get_float("srcTime")/maxSrcTime*100 or 0
local rpm=meta:get_int("rpm")
local buttonMaintainSpeedText=meta:get_int("maintainSpeed")==1 and S("Don't maintain speed") or S("Maintain speed")
local formspec
if industrialtest.mtgAvailable then
formspec={
"list[context;src;3.8,1.8;1,1]",
"list[context;modifier;4.9,1.8;1,1]",
(powerPercent>0 and "image[3.8,2.8;1,1;industrialtest_gui_electricity_bg.png^[lowpart:"..powerPercent..":industrialtest_gui_electricity_fg.png]"
or "image[3.8,2.8;1,1;industrialtest_gui_electricity_bg.png]"),
"list[context;powerStorage;3.8,3.9;1,1]",
(srcPercent>0 and "image[4.9,2.8;1,1;gui_furnace_arrow_bg.png^[lowpart:"..srcPercent..":gui_furnace_arrow_fg.png^[transformR270]"
or "image[4.9,2.8;1,1;gui_furnace_arrow_bg.png^[transformR270]"),
"list[context;dst;6,2.8;1,1;]",
"list[context;upgrades;9,0.9;1,4]",
"label[0.5,2.8;"..minetest.formspec_escape(S("Speed: @1",rpm)).."]",
"button[0.5,3.4;3,0.8;maintainSpeed;"..minetest.formspec_escape(buttonMaintainSpeedText).."]",
"listring[context;src]",
"listring[context;modifier]",
"listring[context;powerStorage]",
"listring[context;dst]",
"listring[context;upgrades]"
}
elseif industrialtest.mclAvailable then
formspec={
"list[context;src;3.8,1.8;1,1]",
mcl_formspec.get_itemslot_bg(3.8,1.8,1,1),
"list[context;modifier;4.9,1.8;1,1]",
mcl_formspec.get_itemslot_bg(4.9,1.8,1,1),
(powerPercent>0 and "image[3.8,2.8;1,1;industrialtest_gui_electricity_bg.png^[lowpart:"..powerPercent..":industrialtest_gui_electricity_fg.png]"
or "image[3.8,2.8;1,1;industrialtest_gui_electricity_bg.png]"),
"list[context;powerStorage;3.8,3.9;1,1]",
mcl_formspec.get_itemslot_bg(3.8,3.9,1,1),
(srcPercent>0 and "image[4.9,2.8;1,1;gui_furnace_arrow_bg.png^[lowpart:"..srcPercent..":gui_furnace_arrow_fg.png^[transformR270]"
or "image[4.9,2.8;1,1;gui_furnace_arrow_bg.png^[transformR270]"),
"list[context;dst;6,2.8;1,1;]",
mcl_formspec.get_itemslot_bg(6,2.8,1,1),
"list[context;upgrades;9,0.9;1,4]",
mcl_formspec.get_itemslot_bg(9,0.9,1,4),
"label[0.5,2.8;"..minetest.formspec_escape(S("Speed: @1",rpm)).."]",
"button[0.5,3.4;3,0.8;maintainSpeed;"..minetest.formspec_escape(buttonMaintainSpeedText).."]",
"listring[context;src]",
"listring[context;modifier]",
"listring[context;powerStorage]",
"listring[context;dst]",
"listring[context;upgrades]"
}
end
return table.concat(formspec,"")
end
rotaryMacerator.onConstruct=function(pos,meta,inv)
inv:set_size("src",1)
inv:set_size("modifier",1)
inv:set_size("powerStorage",1)
inv:set_size("dst",1)
inv:set_size("upgrades",4)
meta:set_int("rpm",0)
meta:set_float("srcTime",0)
meta:set_float("maxSrcTime",0)
meta:set_int("maintainSpeed",0)
end
rotaryMacerator.onTimer=function(pos,elapsed,meta,inv)
local shouldRerunTimer=false
local shouldUpdateFormspec=false
local srcSlot=inv:get_stack("src",1)
local modifierSlot=inv:get_stack("modifier",1)
local dstSlot=inv:get_stack("dst",1)
local rpm=meta:get_int("rpm")
local maintainSpeed=meta:get_int("maintainSpeed")
shouldRerunTimer,shouldUpdateFormspec=industrialtest.internal.chargeFromPowerStorageItem(meta,inv)
local powerAmount=meta:get_int("industrialtest.powerAmount")
if maintainSpeed==1 and powerAmount>=rotaryMacerator.maintainSpeedOpPower then
local newRpm=math.max(rpm+10*elapsed,0)
if newRpm>rpm then
meta:set_int("rpm",newRpm)
shouldUpdateFormspec=true
end
industrialtest.api.addPower(meta,-rotaryMacerator.maintainSpeedOpPower)
shouldRerunTimer=true
elseif rpm>0 then
meta:set_int("rpm",math.max(rpm-1000*elapsed,0))
shouldRerunTimer=shouldRerunTimer or rpm>0
shouldUpdateFormspec=true
end
if powerAmount>=rotaryMacerator.opPower and not srcSlot:is_empty() then
local result=industrialtest.api.getMaceratorRecipeResult(srcSlot:get_name())
if result then
meta:set_float("srcTime",0)
meta:set_float("maxSrcTime",result.time)
minetest.swap_node(pos,{
name="industrialtest:rotary_macerator_active",
param2=minetest.get_node(pos).param2
})
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
return false,shouldUpdateFormspec
end
end
return shouldRerunTimer,shouldUpdateFormspec
end
rotaryMacerator.allowMetadataInventoryMove=function(pos,fromList,fromIndex,toList,count)
if toList=="dst" then
return 0
end
return count
end
rotaryMacerator.allowMetadataInventoryPut=function(pos,listname,index,stack)
if listname=="dst" then
return 0
end
return stack:get_count()
end
rotaryMacerator.onMetadataInventoryMove=function(pos)
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
end
rotaryMacerator.onMetadataInventoryPut=function(pos)
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
end
rotaryMacerator.onMetadataInventoryTake=function(pos,listname)
if listname=="dst" then
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
end
end
rotaryMacerator.activeOnTimer=function(pos,elapsed,meta,inv)
local srcSlot=inv:get_stack("src",1)
local modifierSlot=inv:get_stack("modifier",1)
local dstSlot=inv:get_stack("dst",1)
local powerAmount=meta:get_int("industrialtest.powerAmount")
local rpm=meta:get_int("rpm")
local speed=industrialtest.api.getMachineSpeed(meta)
local requiredPower=elapsed*rotaryMacerator.opPower*speed
industrialtest.internal.chargeFromPowerStorageItem(meta,inv)
if srcSlot:is_empty() or powerAmount<requiredPower then
meta:set_float("srcTime",0)
meta:set_float("maxSrcTime",0)
minetest.swap_node(pos,{
name="industrialtest:rotary_macerator",
param2=minetest.get_node(pos).param2
})
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
return false,true
end
local result
local modified=false
if not modifierSlot:is_empty() then
result=industrialtest.api.getRotaryMaceratorModifier(srcSlot:get_name(),modifierSlot:get_name())
end
if result then
modified=true
else
result=industrialtest.api.getMaceratorRecipeResult(srcSlot:get_name())
end
local resultStack=ItemStack(result.output)
if not dstSlot:item_fits(resultStack) then
meta:set_float("srcTime",0)
meta:set_float("maxSrcTime",0)
minetest.swap_node(pos,{
name="industrialtest:rotary_macerator",
param2=minetest.get_node(pos).param2
})
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
return false,true
end
meta:set_float("maxSrcTime",result.time)
local srcTime=meta:get_float("srcTime")+elapsed*(1+rpm/7500)
if srcTime>=meta:get_float("maxSrcTime") then
local multiplier=math.min(srcSlot:get_count(),speed)
local prevCount=resultStack:get_count()
resultStack:set_count(resultStack:get_count()*multiplier)
local leftover=inv:add_item("dst",resultStack)
meta:set_float("srcTime",0)
meta:set_float("maxSrcTime",0)
srcSlot:take_item(multiplier-leftover:get_count()/prevCount)
inv:set_stack("src",1,srcSlot)
meta:set_int("rpm",math.min(rpm+750*elapsed,7500))
if modified then
local modifierMeta=modifierSlot:get_meta()
local uses=result.uses
if modifierMeta:contains("uses") then
uses=modifierMeta:get_int("uses")
end
uses=math.max(uses-1,0)
if uses==0 then
if result.modifierLeftover then
modifierSlot:set_name(result.modifierLeftover)
else
modifierSlot:take_item(1)
end
uses=result.uses
end
if not modifierSlot:is_empty() and not result.modifierLeftover then
modifierMeta:set_int("uses",uses)
end
inv:set_stack("modifier",1,modifierSlot)
end
else
meta:set_float("srcTime",srcTime)
end
industrialtest.api.addPower(meta,-requiredPower)
return true,true
end
industrialtest.internal.registerMachine({
name="rotary_macerator",
displayName=S("Rotary Macerator"),
capacity=industrialtest.api.lvPowerFlow*2,
getFormspec=rotaryMacerator.getFormspec,
flow=industrialtest.api.lvPowerFlow,
ioConfig="iiiiii",
requiresWrench=true,
registerActiveVariant=true,
sounds="metal",
powerSlots={"powerStorage"},
storageSlots={"src","modifier","powerStorage","dst","upgrades"},
groups={
_industrialtest_hasPowerInput=1
},
customKeys={
tiles={
"industrialtest_advanced_machine_block.png",
"industrialtest_advanced_machine_block.png",
"industrialtest_advanced_machine_block.png",
"industrialtest_advanced_machine_block.png",
"industrialtest_advanced_machine_block.png",
"industrialtest_advanced_machine_block.png^industrialtest_macerator_front.png"
},
paramtype2="facedir",
legacy_facedir_simple=true
},
activeCustomKeys={
tiles={
"industrialtest_advanced_machine_block.png",
"industrialtest_advanced_machine_block.png",
"industrialtest_advanced_machine_block.png",
"industrialtest_advanced_machine_block.png",
"industrialtest_advanced_machine_block.png",
"industrialtest_advanced_machine_block.png^industrialtest_macerator_front_active.png"
}
},
onConstruct=rotaryMacerator.onConstruct,
onTimer=rotaryMacerator.onTimer,
allowMetadataInventoryMove=rotaryMacerator.allowMetadataInventoryMove,
allowMetadataInventoryPut=rotaryMacerator.allowMetadataInventoryPut,
onMetadataInventoryPut=rotaryMacerator.onMetadataInventoryPut,
onMetadataInventoryMove=rotaryMacerator.onMetadataInventoryMove,
onMetadataInventoryTake=rotaryMacerator.onMetadataInventoryTake,
activeOnTimer=rotaryMacerator.activeOnTimer
})
minetest.register_craft({
type="shaped",
output="industrialtest:rotary_macerator",
recipe={
{"industrialtest:refined_iron_ingot","industrialtest:refined_iron_ingot","industrialtest:refined_iron_ingot"},
{"industrialtest:refined_iron_ingot","industrialtest:macerator","industrialtest:refined_iron_ingot"},
{"industrialtest:refined_iron_ingot","industrialtest:advanced_machine_block","industrialtest:refined_iron_ingot"}
}
})

View File

@ -15,12 +15,12 @@
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
minetest.register_on_generated(function(minp,maxp,seed)
if industrialtest.random:next(1,100)>40 then
if industrialtest.mods.mclRubber or industrialtest.random:next(1,100)>40 then
return
end
local center=vector.new((maxp.x-minp.x)/2+ minp.x,(maxp.y-minp.y)/2+minp.y,(maxp.z-minp.z)/2+minp.z)
local pos=minetest.find_node_near(center,maxp.x-minp.x,{industrialtest.elementKeys.grassBlock})
if pos then
industrialtest.makeRubberTree(pos)
industrialtest.internal.makeRubberTree(pos)
end
end)

View File

@ -15,25 +15,51 @@
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
if industrialtest.mtgAvailable then
industrialtest.registerMetal("uranium","Uranium",3)
industrialtest.internal.registerMetal("uranium","Uranium",3)
minetest.register_ore({
ore_type="scatter",
ore="industrialtest:stone_with_uranium",
wherein="default:stone",
clust_scarcity=7*7*7,
clust_scarcity=15*15*15,
clust_num_ores=3,
clust_size=3,
y_max=-128,
y_min=-31000
})
industrialtest.internal.registerMetal("lead","Lead",2)
minetest.register_ore({
ore_type="scatter",
ore="industrialtest:stone_with_lead",
wherein="default:stone",
clust_scarcity=11*11*11,
clust_num_ores=3,
clust_size=3,
y_max=-48,
y_min=-31000
})
industrialtest.internal.registerMetal("iridium","Iridium",4)
minetest.register_ore({
ore_type="scatter",
ore="industrialtest:stone_with_iridium",
wherein="default:stone",
clust_scarcity=40*40*40,
clust_num_ores=3,
clust_size=3,
y_max=-512,
y_min=-31000
})
elseif industrialtest.mclAvailable then
industrialtest.registerMetal("uranium","Uranium",4,4,4,4,5,5)
local stonelike={"mcl_core:stone","mcl_core:diorite","mcl_core:andesite","mcl_core:granite"}
local deepslatelike={"mcl_deepslate:deepslate","mcl_deepslate:tuff"}
industrialtest.internal.registerMetal("uranium","Uranium",4,4,4,4,5,5)
minetest.register_ore({
ore_type="scatter",
ore="industrialtest:stone_with_uranium",
wherein=stonelike,
clust_scarcity=7*7*7,
clust_scarcity=15*15*15,
clust_num_ores=3,
clust_size=3,
y_max=mcl_worlds.layer_to_y(20),
@ -42,8 +68,52 @@ elseif industrialtest.mclAvailable then
minetest.register_ore({
ore_type="scatter",
ore="industrialtest:deepslate_with_uranium",
wherein={"mcl_deepslate:deepslate","mcl_deepslate:tuff"},
clust_scarcity=7*7*7,
wherein=deepslatelike,
clust_scarcity=15*15*15,
clust_num_ores=3,
clust_size=3,
y_max=mcl_worlds.layer_to_y(15),
y_min=mcl_vars.mg_overworld_min
})
industrialtest.internal.registerMetal("lead","Lead",4,4,4,4,6,5)
minetest.register_ore({
ore_type="scatter",
ore="industrialtest:stone_with_lead",
wherein=stonelike,
clust_scarcity=11*11*11,
clust_num_ores=3,
clust_size=3,
y_max=mcl_worlds.layer_to_y(30),
y_min=mcl_vars.mg_overworld_min
})
minetest.register_ore({
ore_type="scatter",
ore="industrialtest:deepslate_with_lead",
wherein=deepslatelike,
clust_scarcity=11*11*11,
clust_num_ores=3,
clust_size=3,
y_max=mcl_worlds.layer_to_y(15),
y_min=mcl_vars.mg_overworld_min
})
industrialtest.internal.registerMetal("iridium","Iridium",4,5,4,4,5,5)
minetest.register_ore({
ore_type="scatter",
ore="industrialtest:stone_with_iridium",
wherein=stonelike,
clust_scarcity=40*40*40,
clust_num_ores=3,
clust_size=3,
y_max=mcl_worlds.layer_to_y(20),
y_min=mcl_vars.mg_overworld_min
})
minetest.register_ore({
ore_type="scatter",
ore="industrialtest:deepslate_with_iridium",
wherein=deepslatelike,
clust_scarcity=40*40*40,
clust_num_ores=3,
clust_size=3,
y_max=mcl_worlds.layer_to_y(15),

View File

@ -1,5 +1,5 @@
name=industrialtest
description=Adds various machinery
optional_depends=default,bucket,3d_armor,mcl_core,mcl_copper,mcl_armor,mcl_deepslate,mcl_nether,mcl_buckets
optional_depends=default,bucket,3d_armor,mcl_core,mcl_copper,mcl_armor,mcl_deepslate,mcl_nether,mcl_buckets,mcl_util,mcl_dye,mcl_rubber,pipeworks,mesecons
author=IndustrialTest Team
title=IndustrialTest
title=IndustrialTest

595
nodes.lua
View File

@ -66,309 +66,348 @@ minetest.register_craft({
}
})
definition={
description=S("Rubber Wood"),
tiles={
"industrialtest_rubber_wood_top.png",
"industrialtest_rubber_wood_top.png",
"industrialtest_rubber_wood_side.png"
},
paramtype2="4dir"
}
if industrialtest.mtgAvailable then
definition.sounds=default.node_sound_wood_defaults()
definition.groups={
tree=1,
choppy=2,
oddly_breakable_by_hand=1,
flammable=2
if not industrialtest.mods.mclRubber then
definition={
description=S("Rubber Wood"),
tiles={
"industrialtest_rubber_wood_top.png",
"industrialtest_rubber_wood_top.png",
"industrialtest_rubber_wood_side.png"
},
paramtype2="4dir"
}
elseif industrialtest.mclAvailable then
definition.sounds=mcl_sounds.node_sound_wood_defaults()
definition.groups={
handy=1,
axey=1,
tree=1,
flammable=2,
building_block=1,
material_wood=1,
fire_encouragement=5,
fire_flammability=5
}
definition.after_destruct=mcl_core.update_leaves
definition._mcl_blast_resistance=1.8
definition._mcl_hardness=1.8
end
definition.groups._industrialtest_rubberWood=1
minetest.register_node("industrialtest:rubber_wood",definition)
definition=table.copy(definition)
definition.description=nil
definition.tiles={
"industrialtest_rubber_wood_top.png",
"industrialtest_rubber_wood_top.png",
"industrialtest_rubber_wood_side.png",
"industrialtest_rubber_wood_side.png",
"industrialtest_rubber_wood_side_with_rubber.png",
"industrialtest_rubber_wood_side.png"
}
definition.drop="industrialtest:rubber_wood"
if industrialtest.mclAvailable then
definition.groups.not_in_creative_inventory=1
definition._doc_items_create_entry=false
end
minetest.register_node("industrialtest:rubber_wood_with_rubber",definition)
minetest.register_abm({
label="Rubber forming",
nodenames={"industrialtest:rubber_wood"},
interval=120,
chance=2,
action=function(pos)
local neighbourPositions={
vector.offset(pos,-1,0,0),
vector.offset(pos,1,0,0),
vector.offset(pos,0,-1,0),
vector.offset(pos,0,1,0),
vector.offset(pos,0,0,-1),
vector.offset(pos,0,0,1)
if industrialtest.mtgAvailable then
definition.sounds=default.node_sound_wood_defaults()
definition.groups={
tree=1,
choppy=2,
oddly_breakable_by_hand=1,
flammable=2
}
for _,value in ipairs(neighbourPositions) do
if minetest.get_node(value).name=="industrialtest:rubber_wood_with_rubber" then
return
end
end
minetest.set_node(pos,{
name="industrialtest:rubber_wood_with_rubber",
param2=industrialtest.random:next(0,3)
})
elseif industrialtest.mclAvailable then
definition.sounds=mcl_sounds.node_sound_wood_defaults()
definition.groups={
handy=1,
axey=1,
tree=1,
flammable=2,
building_block=1,
material_wood=1,
fire_encouragement=5,
fire_flammability=5
}
definition.after_destruct=mcl_core.update_leaves
definition._mcl_blast_resistance=1.8
definition._mcl_hardness=1.8
end
})
minetest.register_craft({
type="shapeless",
output=industrialtest.elementKeys.junglePlanks.." 3",
recipe={"group:_industrialtest_rubberWood"}
})
definition={
description=S("Rubber Leaves"),
drawtype="allfaces_optional",
tiles={"industrialtest_rubber_leaves.png"},
special_tiles={"industrialtest_rubber_leaves_simple.png"},
paramtype="light",
sunlight_propagates=true,
waving=1
}
if industrialtest.mtgAvailable then
definition.sounds=default.node_sound_leaves_defaults()
definition.groups={
snappy=3,
leafdecay=3,
flammable=2,
leaves=1
definition.groups._industrialtest_rubberWood=1
minetest.register_node("industrialtest:rubber_wood",definition)
definition=table.copy(definition)
definition.description=nil
definition.tiles={
"industrialtest_rubber_wood_top.png",
"industrialtest_rubber_wood_top.png",
"industrialtest_rubber_wood_side.png",
"industrialtest_rubber_wood_side.png",
"industrialtest_rubber_wood_side_with_rubber.png",
"industrialtest_rubber_wood_side.png"
}
definition.drop={
max_items=1,
items={
{
items={"industrialtest:rubber_sapling"},
rarity=20
},
{items={"industrialtest:rubber_leaves"}}
definition.drop="industrialtest:rubber_wood"
if industrialtest.mclAvailable then
definition.groups.not_in_creative_inventory=1
definition._doc_items_create_entry=false
end
minetest.register_node("industrialtest:rubber_wood_with_rubber",definition)
minetest.register_abm({
label="Rubber forming",
nodenames={"industrialtest:rubber_wood"},
interval=120,
chance=2,
action=function(pos)
local neighbourPositions={
vector.offset(pos,-1,0,0),
vector.offset(pos,1,0,0),
vector.offset(pos,0,-1,0),
vector.offset(pos,0,1,0),
vector.offset(pos,0,0,-1),
vector.offset(pos,0,0,1)
}
for _,value in ipairs(neighbourPositions) do
if minetest.get_node(value).name=="industrialtest:rubber_wood_with_rubber" then
return
end
end
minetest.set_node(pos,{
name="industrialtest:rubber_wood_with_rubber",
param2=industrialtest.random:next(0,3)
})
end
})
minetest.register_craft({
type="shapeless",
output=industrialtest.elementKeys.junglePlanks.." 3",
recipe={"group:_industrialtest_rubberWood"}
})
definition={
description=S("Rubber Leaves"),
drawtype="allfaces_optional",
tiles={"industrialtest_rubber_leaves.png"},
special_tiles={"industrialtest_rubber_leaves_simple.png"},
paramtype="light",
sunlight_propagates=true,
waving=1
}
if industrialtest.mtgAvailable then
definition.sounds=default.node_sound_leaves_defaults()
definition.groups={
snappy=3,
leafdecay=3,
flammable=2,
leaves=1
}
}
definition.after_place_node=default.after_place_leaves
elseif industrialtest.mclAvailable then
local saplingChances={20,16,12,10}
local stickChances={50,45,30,35,10}
-- Taken and adapted from https://git.minetest.land/MineClone2/MineClone2/src/branch/master/mods/ITEMS/mcl_core/nodes_trees.lua#L157
local function getDrops(fortuneLevel)
local drop = {
definition.drop={
max_items=1,
items = {
items={
{
items = {"industrialtest:rubber_sapling"},
rarity = saplingChances[fortuneLevel+1] or saplingChances[fortuneLevel]
},
{
items = {"mcl_core:stick 1"},
rarity = stickChances[fortuneLevel+1]
},
{
items = {"mcl_core:stick 2"},
rarity = stickChances[fortuneLevel+1]
items={"industrialtest:rubber_sapling"},
rarity=20
},
{items={"industrialtest:rubber_leaves"}}
}
}
return drop
definition.after_place_node=default.after_place_leaves
elseif industrialtest.mclAvailable then
local saplingChances={20,16,12,10}
local stickChances={50,45,30,35,10}
-- Taken and adapted from https://git.minetest.land/MineClone2/MineClone2/src/branch/master/mods/ITEMS/mcl_core/nodes_trees.lua#L157
local function getDrops(fortuneLevel)
local drop = {
max_items=1,
items = {
{
items = {"industrialtest:rubber_sapling"},
rarity = saplingChances[fortuneLevel+1] or saplingChances[fortuneLevel]
},
{
items = {"mcl_core:stick 1"},
rarity = stickChances[fortuneLevel+1]
},
{
items = {"mcl_core:stick 2"},
rarity = stickChances[fortuneLevel+1]
},
}
}
return drop
end
definition.sounds=mcl_sounds.node_sound_leaves_defaults()
definition.groups={
handy=1,
hoey=1,
shearsy=1,
swordy=1,
dig_by_piston=1,
flammable=2,
fire_encouragement=30,
fire_flammability=60,
leaves=1,
deco_block=1,
compostability=30
}
definition.drop=getDrops(0)
definition.after_place_node=mcl_core.make_player_leaves
definition._mcl_shears_drop=true
definition._mcl_blast_resistance=0.2
definition._mcl_hardness=0.2
definition._mcl_silk_touch_drop=true
definition._mcl_fortune_drop={getDrops(1),getDrops(2),getDrops(3),getDrops(4)}
end
definition.sounds=mcl_sounds.node_sound_leaves_defaults()
definition.groups={
handy=1,
hoey=1,
shearsy=1,
swordy=1,
dig_by_piston=1,
flammable=2,
fire_encouragement=30,
fire_flammability=60,
leaves=1,
deco_block=1,
compostability=30
}
definition.drop=getDrops(0)
definition.after_place_node=mcl_core.make_player_leaves
definition._mcl_shears_drop=true
definition._mcl_blast_resistance=0.2
definition._mcl_hardness=0.2
definition._mcl_silk_touch_drop=true
definition._mcl_fortune_drop={getDrops(1),getDrops(2),getDrops(3),getDrops(4)}
end
minetest.register_node("industrialtest:rubber_leaves",definition)
if industrialtest.mtgAvailable then
default.register_leafdecay({
trunks={"industrialtest:rubber_wood"},
leaves={"industrialtest:rubber_leaves"},
radius=2
})
end
if industrialtest.mclAvailable then
definition=table.copy(definition)
definition._doc_items_create_entry=false
definition.groups.not_in_creative_inventory=1
definition.groups.orphan_leaves=1
definition._mcl_shears_drop={"industrialtest:rubber_leaves"}
definition._mcl_silk_touch_drop={"industrialtest:rubber_leaves"}
minetest.register_node("industrialtest:rubber_leaves_orphan",definition)
end
industrialtest.makeRubberTree=function(pos)
-- FIXME: Replace this with placing schematic
-- Taken and adapted from https://github.com/minetest/minetest_game/blob/master/mods/default/trees.lua#L182
local height=industrialtest.random:next(4,5)
local tree=minetest.get_content_id("industrialtest:rubber_wood")
local treeWithRubber=minetest.get_content_id("industrialtest:rubber_wood_with_rubber")
local leaves=minetest.get_content_id("industrialtest:rubber_leaves")
local air=minetest.get_content_id("air")
local ignore=minetest.get_content_id("ignore")
minetest.register_node("industrialtest:rubber_leaves",definition)
if industrialtest.mtgAvailable then
default.register_leafdecay({
trunks={"industrialtest:rubber_wood"},
leaves={"industrialtest:rubber_leaves"},
radius=2
})
end
if industrialtest.mclAvailable then
definition=table.copy(definition)
definition._doc_items_create_entry=false
definition.groups.not_in_creative_inventory=1
definition.groups.orphan_leaves=1
definition._mcl_shears_drop={"industrialtest:rubber_leaves"}
definition._mcl_silk_touch_drop={"industrialtest:rubber_leaves"}
minetest.register_node("industrialtest:rubber_leaves_orphan",definition)
end
industrialtest.internal.makeRubberTree=function(pos)
-- FIXME: Replace this with placing schematic
-- Taken and adapted from https://github.com/minetest/minetest_game/blob/master/mods/default/trees.lua#L182
local height=industrialtest.random:next(4,5)
local tree=minetest.get_content_id("industrialtest:rubber_wood")
local treeWithRubber=minetest.get_content_id("industrialtest:rubber_wood_with_rubber")
local leaves=minetest.get_content_id("industrialtest:rubber_leaves")
local air=minetest.get_content_id("air")
local ignore=minetest.get_content_id("ignore")
local manip=minetest.get_voxel_manip()
local minp,maxp=manip:read_from_map(vector.new(pos.x-2,pos.y,pos.z),vector.new(pos.x+2,pos.y+height+1,pos.z+2))
local area=VoxelArea:new({
local manip=minetest.get_voxel_manip()
local minp,maxp=manip:read_from_map(vector.new(pos.x-2,pos.y,pos.z),vector.new(pos.x+2,pos.y+height+1,pos.z+2))
local area=VoxelArea:new({
MinEdge=minp,
MaxEdge=maxp
})
local data=manip:get_data()
})
local data=manip:get_data()
-- Trunk
data[area:index(pos.x,pos.y,pos.z)]=tree
for y=pos.y+1,pos.y+height-1 do
local index=area:index(pos.x,y,pos.z)
local id=data[index]
if id==air or id==ignore or id==leaves then
data[index]=(industrialtest.random:next(0,5)==1 and treeWithRubber or tree)
end
end
-- Force leaves near the trunk
for dz=-1,1 do
for dy=-2,1 do
local index=area:index(pos.x-1,pos.y+height+dy,pos.z+dz)
for dx=-1,1 do
if data[index]==air or data[index]==ignore then
data[index]=leaves
end
index=index+1
-- Trunk
data[area:index(pos.x,pos.y,pos.z)]=tree
for y=pos.y+1,pos.y+height-1 do
local index=area:index(pos.x,y,pos.z)
local id=data[index]
if id==air or id==ignore or id==leaves then
data[index]=(industrialtest.random:next(0,5)==1 and treeWithRubber or tree)
end
end
end
-- Randomly add leaves in 2x2x2 clusters.
for i=1,8 do
local x=pos.x+industrialtest.random:next(-2,1)
local y=pos.y+height+industrialtest.random:next(-2,0)
local z=pos.z+industrialtest.random:next(-2,1)
for dx=0,1 do
for dy=0,1 do
for dz=0,1 do
local index=area:index(x+dx,y+dy,z+dz)
-- Force leaves near the trunk
for dz=-1,1 do
for dy=-2,1 do
local index=area:index(pos.x-1,pos.y+height+dy,pos.z+dz)
for dx=-1,1 do
if data[index]==air or data[index]==ignore then
data[index]=leaves
end
index=index+1
end
end
end
-- Randomly add leaves in 2x2x2 clusters.
for i=1,8 do
local x=pos.x+industrialtest.random:next(-2,1)
local y=pos.y+height+industrialtest.random:next(-2,0)
local z=pos.z+industrialtest.random:next(-2,1)
for dx=0,1 do
for dy=0,1 do
for dz=0,1 do
local index=area:index(x+dx,y+dy,z+dz)
if data[index]==air or data[index]==ignore then
data[index]=leaves
end
end
end
end
end
manip:set_data(data)
manip:write_to_map()
manip:update_map()
end
manip:set_data(data)
manip:write_to_map()
manip:update_map()
end
definition={
description=S("Rubber Sapling"),
inventory_image="industrialtest_rubber_sapling.png",
wield_image="industrialtest_rubber_sapling.png",
drawtype="plantlike",
tiles={"industrialtest_rubber_sapling.png"},
paramtype="light",
sunlight_propagates=true,
walkable=false,
waving=1,
on_timer=function(pos)
-- Use MTG can_grow function if available
local canGrow
if industrialtest.mtgAvailable then
canGrow=default.can_grow
elseif industrialtest.mclAvailable then
canGrow=function(pos)
local under=minetest.get_node_or_nil(vector.offset(pos,0,-1,0))
if not under then
return false
end
local lightLevel=minetest.get_node_light(pos)
return (minetest.get_item_group(under.name,"soil")>0 and lightLevel and lightLevel>=13)
end
end
if not canGrow(pos) then
minetest.get_node_timer(pos):start(300)
return false
end
industrialtest.makeRubberTree(pos)
return false
end
}
if industrialtest.mtgAvailable then
definition.sounds=default.node_sound_leaves_defaults()
definition.groups={
snappy=2,
flammable=2
definition={
description=S("Rubber Sapling"),
inventory_image="industrialtest_rubber_sapling.png",
wield_image="industrialtest_rubber_sapling.png",
drawtype="plantlike",
tiles={"industrialtest_rubber_sapling.png"},
paramtype="light",
sunlight_propagates=true,
walkable=false,
waving=1
}
definition.on_construct=function(pos)
minetest.get_node_timer(pos):start(industrialtest.random:next(300,1500))
end
elseif industrialtest.mclAvailable then
definition.sounds=mcl_sounds.node_sound_leaves_defaults()
definition.groups={
plant=1,
non_mycelium_plant=1,
deco_block=1,
dig_by_water=1,
dig_by_piston=1,
destroy_by_lava_flow=1,
compostability=40
}
definition.on_construct=function(pos)
local meta=minetest.get_meta(pos)
meta:set_int("stage",0)
end
end
definition.groups.attached_node=1
definition.groups.dig_immediate=3
definition.groups.sapling=1
minetest.register_node("industrialtest:rubber_sapling",definition)
if industrialtest.mtgAvailable then
minetest.register_lbm({
name="industrialtest:rubber_sapling_lbm",
nodenames={"industrialtest:rubber_sapling"},
action=function(pos)
if industrialtest.mtgAvailable then
definition.sounds=default.node_sound_leaves_defaults()
definition.groups={
snappy=2,
flammable=2
}
definition.on_construct=function(pos)
minetest.get_node_timer(pos):start(industrialtest.random:next(300,1500))
end
})
definition.on_timer=function(pos)
if not default.can_grow(pos) then
minetest.get_node_timer(pos):start(300)
return false
end
industrialtest.internal.makeRubberTree(pos)
return false
end
elseif industrialtest.mclAvailable then
definition.sounds=mcl_sounds.node_sound_leaves_defaults()
definition.groups={
plant=1,
non_mycelium_plant=1,
deco_block=1,
dig_by_water=1,
dig_by_piston=1,
destroy_by_lava_flow=1,
compostability=40
}
definition.on_construct=function(pos)
local meta=minetest.get_meta(pos)
meta:set_int("stage",0)
end
definition.on_place=mcl_util.generate_on_place_plant_function(function(pos,node)
local nodeBelow = minetest.get_node_or_nil(vector.new(pos.x,pos.y-1,pos.z))
if not nodeBelow then
return false
end
local name = nodeBelow.name
return minetest.get_item_group(name,"grass_block")==1 or
name=="mcl_core:podzol" or name=="mcl_core:podzol_snow" or
name=="mcl_core:dirt" or name=="mcl_core:mycelium" or name=="mcl_core:coarse_dirt"
end)
minetest.register_abm({
label="Rubber sapling growing",
nodenames={"industrialtest:rubber_sapling"},
interval=120,
chance=1,
catch_up=false,
action=function(pos)
local under=minetest.get_node_or_nil(vector.offset(pos,0,-1,0))
if not under or minetest.get_item_group(under.name,"soil")==0 then
return
end
local lightLevel=minetest.get_node_light(pos)
if not lightLevel or lightLevel<13 then
return
end
local meta=minetest.get_meta(pos)
local stage=meta:get_int("stage") or 0
stage=stage+1
if stage>=3 then
industrialtest.internal.makeRubberTree(pos)
else
meta:set_int("stage",stage)
end
end
})
mcl_dye.register_on_bone_meal_apply(function(pointed)
local node=minetest.get_node(pointed.under)
if node.name~="industrialtest:rubber_sapling" then
return
end
if industrialtest.random:next(1,100)>45 then
return
end
local meta=minetest.get_meta(pointed.under)
local stage=meta:get_int("stage") or 0
stage=stage+1
if stage>=3 then
industrialtest.internal.makeRubberTree(pointed.under)
else
meta:set_int("stage",stage)
end
end)
end
definition.groups.attached_node=1
definition.groups.dig_immediate=3
definition.groups.sapling=1
minetest.register_node("industrialtest:rubber_sapling",definition)
if industrialtest.mtgAvailable then
minetest.register_lbm({
name="industrialtest:rubber_sapling_lbm",
nodenames={"industrialtest:rubber_sapling"},
action=function(pos)
minetest.get_node_timer(pos):start(industrialtest.random:next(300,1500))
end
})
end
end

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: 607 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 607 B

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: 499 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 832 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 621 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 567 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 427 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 700 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 571 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 571 B

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: 348 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 546 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 770 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 725 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 708 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 474 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 356 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 341 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 453 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

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 industrialtest.internal.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"}
}
})

164
tools/nano_suit.lua Normal file
View File

@ -0,0 +1,164 @@
-- 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 registerNanoSuitPart(config)
local groups={
_industrialtest_nanoSuit=1
}
if config.element=="head" then
groups.armor_head=1
elseif config.element=="torso" then
groups.armor_torso=1
elseif config.element=="legs" then
groups.armor_legs=1
elseif config.element=="feet" then
groups.armor_feet=1
end
if industrialtest.mtgAvailable then
groups.armor_heal=0
armor:register_armor("industrialtest:"..config.name,{
description=config.displayName,
inventory_image="industrialtest_"..config.name.."_inv.png",
groups=groups,
_industrialtest_powerStorage=true,
_industrialtest_powerCapacity=1000000,
_industrialtest_powerFlow=industrialtest.api.evPowerFlow,
_industrialtest_damageReduction=config.damageReduction
})
elseif industrialtest.mclAvailable then
groups.armor=1
groups.non_combat_armor=1
minetest.register_tool("industrialtest:"..config.name,{
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=config.element,
_mcl_armor_texture=(config.element=="feet" and "industrialtest_mcl_" or "industrialtest_")..config.name..".png",
_industrialtest_powerStorage=true,
_industrialtest_powerCapacity=1000000,
_industrialtest_powerFlow=industrialtest.api.evPowerFlow,
_industrialtest_damageReduction=config.damageReduction
})
end
end
registerNanoSuitPart({
name="nano_helmet",
displayName=S("Nano Helmet"),
element="head",
damageReduction=0.12
})
minetest.register_craft({
type="shaped",
output="industrialtest:nano_helmet",
recipe={
{"industrialtest:carbon_plate","industrialtest:energy_crystal","industrialtest:carbon_plate"},
{"industrialtest:carbon_plate",industrialtest.elementKeys.glass,"industrialtest:carbon_plate"}
}
})
registerNanoSuitPart({
name="nano_bodyarmor",
displayName=S("Nano Bodyarmor"),
element="torso",
damageReduction=0.32
})
minetest.register_craft({
type="shaped",
output="industrialtest:nano_bodyarmor",
recipe={
{"industrialtest:carbon_plate","","industrialtest:carbon_plate"},
{"industrialtest:carbon_plate","industrialtest:energy_crystal","industrialtest:carbon_plate"},
{"industrialtest:carbon_plate","industrialtest:carbon_plate","industrialtest:carbon_plate"}
}
})
registerNanoSuitPart({
name="nano_leggings",
displayName=S("Nano Leggings"),
element="legs",
damageReduction=0.3
})
minetest.register_craft({
type="shaped",
output="industrialtest:nano_leggings",
recipe={
{"industrialtest:carbon_plate","industrialtest:energy_crystal","industrialtest:carbon_plate"},
{"industrialtest:carbon_plate","","industrialtest:carbon_plate"},
{"industrialtest:carbon_plate","","industrialtest:carbon_plate"}
}
})
registerNanoSuitPart({
name="nano_boots",
displayName=S("Nano Boots"),
element="feet",
damageReduction=0.24
})
minetest.register_craft({
type="shaped",
output="industrialtest:nano_boots",
recipe={
{"industrialtest:carbon_plate","","industrialtest:carbon_plate"},
{"industrialtest:carbon_plate","industrialtest:energy_crystal","industrialtest:carbon_plate"}
}
})
minetest.register_on_player_hpchange(function(player,hpChange)
if hpChange>0 or not player:is_player() then
return hpChange
end
local inv
if industrialtest.mtgAvailable then
_,inv=armor:get_valid_player(player,"")
if not inv then
return hpChange
end
elseif industrialtest.mclAvailable then
inv=player:get_inventory()
end
local armorList=inv:get_list("armor")
assert(armorList)
local result=hpChange
for i=1,#armorList do
local stack=armorList[i]
local def=stack:get_definition()
if def.groups and def.groups._industrialtest_nanoSuit then
local meta=stack:get_meta()
local targetReducedDamage=math.floor(math.abs(hpChange)*def._industrialtest_damageReduction)
local requiredPower=targetReducedDamage*5000
local availablePower=math.min(meta:get_int("industrialtest.powerAmount"),requiredPower)
local reducedDamage=math.floor(availablePower/5000)
if reducedDamage>0 then
result=result+reducedDamage
industrialtest.api.addPowerToItem(stack,-reducedDamage*5000)
inv:set_stack("armor",i,stack)
end
end
end
return result
end,true)

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)

107
tools/treetap.lua Normal file
View File

@ -0,0 +1,107 @@
-- 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/>.
if industrialtest.mods.mclRubber then
return
end
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