Compare commits

...

63 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
49 changed files with 2358 additions and 520 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]

26
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
@ -600,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
@ -864,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
@ -77,7 +92,7 @@ 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"
@ -360,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",""}
}
@ -369,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
@ -541,6 +484,7 @@ 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"
@ -550,11 +494,17 @@ if industrialtest.mclAvailable then
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"
@ -639,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,
@ -665,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"
@ -770,6 +720,7 @@ 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"
@ -779,8 +730,14 @@ elseif industrialtest.mtgAvailable then
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,55 @@ 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"),
@ -449,6 +502,12 @@ minetest.register_craft({
}
}
})
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"),
@ -495,6 +554,13 @@ industrialtest.api.registerPlate("tin_plate",S("Tin Plate"),{
}
},"#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"),

View File

@ -34,18 +34,21 @@ 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")
@ -59,6 +62,7 @@ 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")
@ -74,3 +78,11 @@ dofile(modpath.."/cables.lua")
dofile(modpath.."/mapgen.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

@ -85,15 +85,7 @@ canningMachine.onTimer=function(pos,elapsed,meta,inv)
local powerStorageSlot=inv:get_stack("powerStorage",1)
local targetMeta=targetSlot:get_meta()
if not powerStorageSlot:is_empty() then
local stackMeta=powerStorageSlot:get_meta()
if industrialtest.api.transferPower(stackMeta,meta,stackMeta:get_int("industrialtest.powerFlow"))>0 then
shouldUpdateFormspec=true
shouldRerunTimer=true
industrialtest.api.updateItemPowerText(powerStorageSlot)
inv:set_stack("powerStorage",1,powerStorageSlot)
end
end
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
@ -170,14 +162,7 @@ canningMachine.activeOnTimer=function(pos,elapsed,meta,inv)
local targetSlot=inv:get_stack("target",1)
local powerStorageSlot=inv:get_stack("powerStorage",1)
if not powerStorageSlot:is_empty() then
local stackMeta=powerStorageSlot:get_meta()
if industrialtest.api.transferPower(stackMeta,meta,stackMeta:get_int("industrialtest.powerFlow"))>0 then
shouldUpdateFormspec=true
industrialtest.api.updateItemPowerText(powerStorageSlot)
inv:set_stack("powerStorage",1,powerStorageSlot)
end
end
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

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)
@ -270,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
@ -304,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
@ -559,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
@ -628,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
@ -644,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
@ -656,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
@ -765,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: 607 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 607 B

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

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)

View File

@ -14,6 +14,10 @@
-- 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)