Compare commits
24 Commits
e11747c34e
...
1.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
| b91e3a882e | |||
| dc62ef6217 | |||
| ca78a0b4c2 | |||
| 993dc5733c | |||
| a678973814 | |||
| e5a917860a | |||
| 8bfff9ec52 | |||
| 5ad62134c8 | |||
| 42823b9dcc | |||
| 4749f31d12 | |||
| a8f788d4d9 | |||
| be0caaa284 | |||
| b0de104227 | |||
| 9b4d4be94d | |||
| 960b2e5b45 | |||
| c8be496afe | |||
| 96c9fe164a | |||
| 28040db868 | |||
| f561048339 | |||
| e3e00e59a1 | |||
| ab367b4f29 | |||
| 42fb3be910 | |||
| a126010274 | |||
| 443497b7b6 |
@@ -15,6 +15,7 @@ Currently IndustrialTest supports following games:
|
|||||||
## Optional dependencies
|
## Optional dependencies
|
||||||
- [Rubber Addon for MineClone](https://content.minetest.net/packages/biochemist/mcl_rubber)
|
- [Rubber Addon for MineClone](https://content.minetest.net/packages/biochemist/mcl_rubber)
|
||||||
- [Pipeworks](https://content.minetest.net/packages/VanessaE/pipeworks)
|
- [Pipeworks](https://content.minetest.net/packages/VanessaE/pipeworks)
|
||||||
|
- [Mesecons](https://content.minetest.net/packages/Jeija/mesecons)
|
||||||
|
|
||||||
## Contributors
|
## Contributors
|
||||||
- mrkubax10 <mrkubax10@onet.pl or mrkubax10 at irc.libera.chat> [programming, some graphics]
|
- mrkubax10 <mrkubax10@onet.pl or mrkubax10 at irc.libera.chat> [programming, some graphics]
|
||||||
|
|||||||
124
compat/mesecons.lua
Normal 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)
|
||||||
@@ -157,6 +157,7 @@ local override={
|
|||||||
local meta=minetest.get_meta(pos)
|
local meta=minetest.get_meta(pos)
|
||||||
local inv=meta:get_inventory()
|
local inv=meta:get_inventory()
|
||||||
local result=inv:add_item(listname,stack)
|
local result=inv:add_item(listname,stack)
|
||||||
|
minetest.registered_nodes["industrialtest:nuclear_reactor"].on_metadata_inventory_put(pos)
|
||||||
return result
|
return result
|
||||||
end,
|
end,
|
||||||
can_insert=function(pos,node,stack,direction)
|
can_insert=function(pos,node,stack,direction)
|
||||||
@@ -188,6 +189,36 @@ local override={
|
|||||||
minetest.override_item("industrialtest:nuclear_reactor",override)
|
minetest.override_item("industrialtest:nuclear_reactor",override)
|
||||||
minetest.override_item("industrialtest:nuclear_reactor_active",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
|
-- BatBox
|
||||||
addPipeworksCompatibility("industrialtest:batbox",{
|
addPipeworksCompatibility("industrialtest:batbox",{
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ elseif industrialtest.mclAvailable then
|
|||||||
industrialtest.mods.mclRubber=minetest.get_modpath("mcl_rubber")
|
industrialtest.mods.mclRubber=minetest.get_modpath("mcl_rubber")
|
||||||
end
|
end
|
||||||
industrialtest.mods.pipeworks=minetest.get_modpath("pipeworks")
|
industrialtest.mods.pipeworks=minetest.get_modpath("pipeworks")
|
||||||
|
industrialtest.mods.mesecons=minetest.get_modpath("mesecons")
|
||||||
|
|
||||||
if industrialtest.mtgAvailable and not industrialtest.mods._3dArmor then
|
if industrialtest.mtgAvailable and not industrialtest.mods._3dArmor then
|
||||||
error("IndustrialTest requires 3D Armor when used with Minetest Game")
|
error("IndustrialTest requires 3D Armor when used with Minetest Game")
|
||||||
@@ -252,7 +253,7 @@ if industrialtest.mclAvailable then
|
|||||||
return itemstack
|
return itemstack
|
||||||
end,
|
end,
|
||||||
sound={breaks="default_tool_breaks"},
|
sound={breaks="default_tool_breaks"},
|
||||||
_repair_material="industrialtest:"..material,
|
_repair_material="industrialtest:"..materialItem,
|
||||||
_mcl_toollike_wield=true,
|
_mcl_toollike_wield=true,
|
||||||
_mcl_diggroups={
|
_mcl_diggroups={
|
||||||
shovely={speed=config.speed,level=config.level,uses=config.uses}
|
shovely={speed=config.speed,level=config.level,uses=config.uses}
|
||||||
@@ -269,7 +270,7 @@ if industrialtest.mclAvailable then
|
|||||||
},
|
},
|
||||||
on_place=industrialtest.internal.mclMakeStrippedTrunk,
|
on_place=industrialtest.internal.mclMakeStrippedTrunk,
|
||||||
sound={breaks="default_tool_breaks"},
|
sound={breaks="default_tool_breaks"},
|
||||||
_repair_material="industrialtest:"..material,
|
_repair_material="industrialtest:"..materialItem,
|
||||||
_mcl_toollike_wield=true,
|
_mcl_toollike_wield=true,
|
||||||
_mcl_diggroups={
|
_mcl_diggroups={
|
||||||
axey={speed=config.speed,level=config.level,uses=config.uses}
|
axey={speed=config.speed,level=config.level,uses=config.uses}
|
||||||
@@ -285,7 +286,7 @@ if industrialtest.mclAvailable then
|
|||||||
damage_groups={fleshy=config.damage+2},
|
damage_groups={fleshy=config.damage+2},
|
||||||
},
|
},
|
||||||
sound={breaks="default_tool_breaks"},
|
sound={breaks="default_tool_breaks"},
|
||||||
_repair_material="industrialtest:"..material,
|
_repair_material="industrialtest:"..materialItem,
|
||||||
_mcl_toollike_wield=true,
|
_mcl_toollike_wield=true,
|
||||||
_mcl_diggroups={
|
_mcl_diggroups={
|
||||||
swordy={speed=config.speed,level=config.level,uses=config.uses},
|
swordy={speed=config.speed,level=config.level,uses=config.uses},
|
||||||
@@ -348,7 +349,7 @@ if industrialtest.mclAvailable then
|
|||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
_repair_material="industrialtest:"..material,
|
_repair_material="industrialtest:"..materialItem,
|
||||||
_mcl_toollike_wield=true,
|
_mcl_toollike_wield=true,
|
||||||
_mcl_diggroups={
|
_mcl_diggroups={
|
||||||
hoey={speed=config.speed,level=config.level,uses=config.uses}
|
hoey={speed=config.speed,level=config.level,uses=config.uses}
|
||||||
@@ -359,7 +360,7 @@ if industrialtest.mclAvailable then
|
|||||||
description=materialDisplayName,
|
description=materialDisplayName,
|
||||||
durability=config.uses,
|
durability=config.uses,
|
||||||
points=config.armorPoints,
|
points=config.armorPoints,
|
||||||
craft_material="industrialtest:"..material,
|
craft_material="industrialtest:"..materialItem,
|
||||||
cook_material=config.armorCookMaterial,
|
cook_material=config.armorCookMaterial,
|
||||||
sound_equip=config.armorEquipSound,
|
sound_equip=config.armorEquipSound,
|
||||||
sound_unequip=config.armorUnequipSound,
|
sound_unequip=config.armorUnequipSound,
|
||||||
|
|||||||
@@ -554,6 +554,24 @@ industrialtest.api.registerPlate("tin_plate",S("Tin Plate"),{
|
|||||||
}
|
}
|
||||||
},"#e0e0e0ff",true)
|
},"#e0e0e0ff",true)
|
||||||
|
|
||||||
|
industrialtest.api.registerPlate("lead_plate",S("Lead Plate"),{
|
||||||
|
{
|
||||||
|
resource="industrialtest:lead_ingot",
|
||||||
|
count=1
|
||||||
|
}
|
||||||
|
},"#eafef8ff",true)
|
||||||
|
|
||||||
|
industrialtest.api.registerPlate("iridium_plate",S("Iridium Plate"),{},false,"#ffffffff")
|
||||||
|
minetest.register_craft({
|
||||||
|
type="shaped",
|
||||||
|
output="industrialtest:iridium_plate",
|
||||||
|
recipe={
|
||||||
|
{"industrialtest:iridium_ingot","industrialtest:advanced_alloy","industrialtest:iridium_ingot"},
|
||||||
|
{"industrialtest:advanced_alloy",industrialtest.elementKeys.diamond,"industrialtest:advanced_alloy"},
|
||||||
|
{"industrialtest:iridium_ingot","industrialtest:advanced_alloy","industrialtest:iridium_ingot"}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
-- Cells
|
-- Cells
|
||||||
minetest.register_craftitem("industrialtest:empty_cell",{
|
minetest.register_craftitem("industrialtest:empty_cell",{
|
||||||
description=S("Empty Cell"),
|
description=S("Empty Cell"),
|
||||||
|
|||||||
4
init.lua
@@ -66,6 +66,7 @@ dofile(modpath.."/tools/nano_suit.lua")
|
|||||||
dofile(modpath.."/tools/solar_helmet.lua")
|
dofile(modpath.."/tools/solar_helmet.lua")
|
||||||
dofile(modpath.."/tools/static_boots.lua")
|
dofile(modpath.."/tools/static_boots.lua")
|
||||||
dofile(modpath.."/tools/treetap.lua")
|
dofile(modpath.."/tools/treetap.lua")
|
||||||
|
dofile(modpath.."/tools/quantum_suit.lua")
|
||||||
dofile(modpath.."/tools/wrench.lua")
|
dofile(modpath.."/tools/wrench.lua")
|
||||||
|
|
||||||
dofile(modpath.."/upgrades.lua")
|
dofile(modpath.."/upgrades.lua")
|
||||||
@@ -83,3 +84,6 @@ dofile(modpath.."/crafts.lua")
|
|||||||
if industrialtest.mods.pipeworks then
|
if industrialtest.mods.pipeworks then
|
||||||
dofile(modpath.."/compat/pipeworks.lua")
|
dofile(modpath.."/compat/pipeworks.lua")
|
||||||
end
|
end
|
||||||
|
if industrialtest.mods.mesecons then
|
||||||
|
dofile(modpath.."/compat/mesecons.lua")
|
||||||
|
end
|
||||||
|
|||||||
@@ -95,9 +95,6 @@ machine.onConstruct=function(pos,config)
|
|||||||
local inv=meta:get_inventory()
|
local inv=meta:get_inventory()
|
||||||
|
|
||||||
industrialtest.api.addPowerStorage(meta,config.capacity,config.flow,config.ioConfig)
|
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 then
|
||||||
if config.groups._industrialtest_hasPowerInput then
|
if config.groups._industrialtest_hasPowerInput then
|
||||||
@@ -130,10 +127,14 @@ machine.onConstruct=function(pos,config)
|
|||||||
config.onConstruct(pos,meta,inv)
|
config.onConstruct(pos,meta,inv)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not config.withoutFormspec then
|
||||||
|
meta:set_string("formspec",machine.getFormspec(pos,config))
|
||||||
|
end
|
||||||
|
|
||||||
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
|
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
|
||||||
end
|
end
|
||||||
|
|
||||||
machine.onDestruct=function(pos)
|
machine.onDestruct=function(pos,config)
|
||||||
local meta=minetest.get_meta(pos)
|
local meta=minetest.get_meta(pos)
|
||||||
if industrialtest.api.isNetworkMaster(meta) then
|
if industrialtest.api.isNetworkMaster(meta) then
|
||||||
local network=industrialtest.api.createNetworkMap(pos,true)
|
local network=industrialtest.api.createNetworkMap(pos,true)
|
||||||
@@ -155,6 +156,9 @@ machine.onDestruct=function(pos)
|
|||||||
industrialtest.api.removeNodeFromNetwork(network,pos)
|
industrialtest.api.removeNodeFromNetwork(network,pos)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if config.onDestruct then
|
||||||
|
config.onDestruct(pos)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
machine.onTimer=function(pos,elapsed,config)
|
machine.onTimer=function(pos,elapsed,config)
|
||||||
@@ -287,7 +291,9 @@ function industrialtest.internal.registerMachine(config)
|
|||||||
on_construct=function(pos)
|
on_construct=function(pos)
|
||||||
machine.onConstruct(pos,config)
|
machine.onConstruct(pos,config)
|
||||||
end,
|
end,
|
||||||
on_destruct=machine.onDestruct,
|
on_destruct=function(pos)
|
||||||
|
machine.onDestruct(pos,config)
|
||||||
|
end,
|
||||||
on_timer=function(pos,elapsed)
|
on_timer=function(pos,elapsed)
|
||||||
local shouldRerunTimer,_=machine.onTimer(pos,elapsed,config)
|
local shouldRerunTimer,_=machine.onTimer(pos,elapsed,config)
|
||||||
return shouldRerunTimer
|
return shouldRerunTimer
|
||||||
@@ -321,6 +327,12 @@ function industrialtest.internal.registerMachine(config)
|
|||||||
end,
|
end,
|
||||||
_industrialtest_updateFormspec=function(pos)
|
_industrialtest_updateFormspec=function(pos)
|
||||||
machine.updateFormspec(pos,config)
|
machine.updateFormspec(pos,config)
|
||||||
|
end,
|
||||||
|
_industrialtest_getFormspec=function(pos)
|
||||||
|
if config.withoutFormspec then
|
||||||
|
return ""
|
||||||
|
end
|
||||||
|
return machine.getFormspec(pos,config)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
if industrialtest.mtgAvailable then
|
if industrialtest.mtgAvailable then
|
||||||
|
|||||||
@@ -16,15 +16,17 @@
|
|||||||
|
|
||||||
local S=minetest.get_translator("industrialtest")
|
local S=minetest.get_translator("industrialtest")
|
||||||
local reactor={}
|
local reactor={}
|
||||||
|
local reactorChamber={}
|
||||||
|
|
||||||
reactor.getFormspec=function(pos)
|
reactor.getFormspec=function(pos)
|
||||||
local meta=minetest.get_meta(pos)
|
local meta=minetest.get_meta(pos)
|
||||||
local charged=meta:get_int("industrialtest.powerAmount")/meta:get_int("industrialtest.powerCapacity")
|
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 switchText=(meta:get_int("enabled")==0 and S("Start") or S("Stop"))
|
||||||
local formspec
|
local formspec
|
||||||
if industrialtest.mtgAvailable then
|
if industrialtest.mtgAvailable then
|
||||||
formspec={
|
formspec={
|
||||||
"list[context;fuel;1,1;5,4]",
|
"list[context;fuel;1,1;"..size..","..size.."]",
|
||||||
"listring[context;fuel]",
|
"listring[context;fuel]",
|
||||||
"list[context;charged;7.7,2.8;1,1]",
|
"list[context;charged;7.7,2.8;1,1]",
|
||||||
"listring[context;charged]",
|
"listring[context;charged]",
|
||||||
@@ -34,8 +36,8 @@ reactor.getFormspec=function(pos)
|
|||||||
}
|
}
|
||||||
elseif industrialtest.mclAvailable then
|
elseif industrialtest.mclAvailable then
|
||||||
formspec={
|
formspec={
|
||||||
"list[context;fuel;1,1;5,4]",
|
"list[context;fuel;1,1;"..size..","..size.."]",
|
||||||
mcl_formspec.get_itemslot_bg(1,1,5,4),
|
mcl_formspec.get_itemslot_bg(1,1,size,size),
|
||||||
"listring[context;fuel]",
|
"listring[context;fuel]",
|
||||||
"list[context;charged;7,2.8;1,1]",
|
"list[context;charged;7,2.8;1,1]",
|
||||||
mcl_formspec.get_itemslot_bg(7.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
|
end
|
||||||
|
|
||||||
reactor.onConstruct=function(pos,meta,inv)
|
reactor.onConstruct=function(pos,meta,inv)
|
||||||
inv:set_size("fuel",20)
|
inv:set_size("fuel",4)
|
||||||
inv:set_size("charged",1)
|
inv:set_size("charged",1)
|
||||||
meta:set_int("heat",0)
|
meta:set_int("heat",0)
|
||||||
|
meta:set_int("size",6)
|
||||||
meta:set_int("enabled",0)
|
meta:set_int("enabled",0)
|
||||||
meta:set_int("stateChanged",0)
|
meta:set_int("stateChanged",0)
|
||||||
end
|
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)
|
local function hasFuel(fuelList)
|
||||||
for _,stack in ipairs(fuelList) do
|
for _,stack in ipairs(fuelList) do
|
||||||
if stack:get_name()=="industrialtest:uranium_cell" then
|
if stack:get_name()=="industrialtest:uranium_cell" then
|
||||||
@@ -65,12 +77,12 @@ local function hasFuel(fuelList)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local function findMaxFuelCluster(fuelList)
|
local function findMaxFuelCluster(size,fuelList)
|
||||||
local maxCluster={}
|
local maxCluster={}
|
||||||
for y=1,4 do
|
for y=1,size do
|
||||||
for x=1,5 do
|
for x=1,size do
|
||||||
local iy=y-1
|
local iy=y-1
|
||||||
local stack=fuelList[iy*5+x]
|
local stack=fuelList[iy*size+x]
|
||||||
local def=minetest.registered_tools[stack:get_name()]
|
local def=minetest.registered_tools[stack:get_name()]
|
||||||
if def and def.groups._industrialtest_nuclearReactorFuel then
|
if def and def.groups._industrialtest_nuclearReactorFuel then
|
||||||
local cluster={
|
local cluster={
|
||||||
@@ -79,49 +91,49 @@ local function findMaxFuelCluster(fuelList)
|
|||||||
y=iy
|
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,{
|
table.insert(cluster,{
|
||||||
x=x-1,
|
x=x-1,
|
||||||
y=iy
|
y=iy
|
||||||
})
|
})
|
||||||
end
|
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,{
|
table.insert(cluster,{
|
||||||
x=x+1,
|
x=x+1,
|
||||||
y=iy
|
y=iy
|
||||||
})
|
})
|
||||||
end
|
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,{
|
table.insert(cluster,{
|
||||||
x=x,
|
x=x,
|
||||||
y=iy-1
|
y=iy-1
|
||||||
})
|
})
|
||||||
end
|
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,{
|
table.insert(cluster,{
|
||||||
x=x,
|
x=x,
|
||||||
y=iy+1
|
y=iy+1
|
||||||
})
|
})
|
||||||
end
|
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,{
|
table.insert(cluster,{
|
||||||
x=x-1,
|
x=x-1,
|
||||||
y=iy-1
|
y=iy-1
|
||||||
})
|
})
|
||||||
end
|
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,{
|
table.insert(cluster,{
|
||||||
x=x+1,
|
x=x+1,
|
||||||
y=iy-1
|
y=iy-1
|
||||||
})
|
})
|
||||||
end
|
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,{
|
table.insert(cluster,{
|
||||||
x=x-1,
|
x=x-1,
|
||||||
y=iy+1
|
y=iy+1
|
||||||
})
|
})
|
||||||
end
|
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,{
|
table.insert(cluster,{
|
||||||
x=x+1,
|
x=x+1,
|
||||||
y=iy+1
|
y=iy+1
|
||||||
@@ -140,7 +152,7 @@ local function findMaxFuelCluster(fuelList)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function findCoolant(fuelList)
|
local function findCoolant(fuelList)
|
||||||
for i=1,20 do
|
for i=1,#fuelList do
|
||||||
local stack=fuelList[i]
|
local stack=fuelList[i]
|
||||||
local def=minetest.registered_tools[stack:get_name()]
|
local def=minetest.registered_tools[stack:get_name()]
|
||||||
if def and def.groups._industrialtest_nuclearReactorCoolant then
|
if def and def.groups._industrialtest_nuclearReactorCoolant then
|
||||||
@@ -189,11 +201,14 @@ reactor.onTimer=function(pos,elapsed,meta,inv)
|
|||||||
shouldRerunTimer=false
|
shouldRerunTimer=false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
reactor.synchronizeChambers(pos)
|
||||||
|
|
||||||
return shouldRerunTimer,shouldUpdateFormspec
|
return shouldRerunTimer,shouldUpdateFormspec
|
||||||
end
|
end
|
||||||
|
|
||||||
reactor.activeOnTimer=function(pos,elapsed,meta,inv)
|
reactor.activeOnTimer=function(pos,elapsed,meta,inv)
|
||||||
local powerFlow=meta:get_int("industrialtest.powerFlow")
|
local powerFlow=meta:get_int("industrialtest.powerFlow")
|
||||||
|
local size=math.floor(meta:get_int("size")/3)
|
||||||
local chargedSlot=inv:get_stack("charged",1)
|
local chargedSlot=inv:get_stack("charged",1)
|
||||||
local fuelList=inv:get_list("fuel")
|
local fuelList=inv:get_list("fuel")
|
||||||
local afterFlow,flowTransferred=industrialtest.api.powerFlow(pos)
|
local afterFlow,flowTransferred=industrialtest.api.powerFlow(pos)
|
||||||
@@ -218,13 +233,14 @@ reactor.activeOnTimer=function(pos,elapsed,meta,inv)
|
|||||||
param2=minetest.get_node(pos).param2
|
param2=minetest.get_node(pos).param2
|
||||||
})
|
})
|
||||||
meta:set_int("enabled",0)
|
meta:set_int("enabled",0)
|
||||||
|
reactor.synchronizeChambers(pos)
|
||||||
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
|
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
|
||||||
return false,shouldUpdateFormspec
|
return false,shouldUpdateFormspec
|
||||||
end
|
end
|
||||||
|
|
||||||
local maxCluster=findMaxFuelCluster(fuelList)
|
local maxCluster=findMaxFuelCluster(size,fuelList)
|
||||||
for _,stack in ipairs(maxCluster) do
|
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)
|
local usedStack,_=useFuel(fuelList[index],5)
|
||||||
inv:set_stack("fuel",index,usedStack)
|
inv:set_stack("fuel",index,usedStack)
|
||||||
end
|
end
|
||||||
@@ -237,7 +253,7 @@ reactor.activeOnTimer=function(pos,elapsed,meta,inv)
|
|||||||
local coolant=findCoolant(fuelList)
|
local coolant=findCoolant(fuelList)
|
||||||
if coolant>0 then
|
if coolant>0 then
|
||||||
local coolantStack,used=useFuel(fuelList[coolant],#maxCluster*50)
|
local coolantStack,used=useFuel(fuelList[coolant],#maxCluster*50)
|
||||||
heat=heat-used
|
heat=math.max(0,heat-used)
|
||||||
inv:set_stack("fuel",coolant,coolantStack)
|
inv:set_stack("fuel",coolant,coolantStack)
|
||||||
end
|
end
|
||||||
if heat>200 then
|
if heat>200 then
|
||||||
@@ -247,6 +263,8 @@ reactor.activeOnTimer=function(pos,elapsed,meta,inv)
|
|||||||
end
|
end
|
||||||
meta:set_int("heat",heat)
|
meta:set_int("heat",heat)
|
||||||
|
|
||||||
|
reactor.synchronizeChambers(pos)
|
||||||
|
|
||||||
return shouldRerunTimer,shouldUpdateFormspec
|
return shouldRerunTimer,shouldUpdateFormspec
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -271,6 +289,7 @@ end
|
|||||||
|
|
||||||
reactor.metadataChange=function(pos)
|
reactor.metadataChange=function(pos)
|
||||||
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
|
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
|
||||||
|
reactor.synchronizeChambers(pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
reactor.handleFormspecFields=function(pos,formname,fields)
|
reactor.handleFormspecFields=function(pos,formname,fields)
|
||||||
@@ -292,33 +311,121 @@ reactor.handleFormspecFields=function(pos,formname,fields)
|
|||||||
reactor.metadataChange(pos)
|
reactor.metadataChange(pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
local definition={
|
reactor.synchronizeToChamber=function(pos)
|
||||||
description=S("Nuclear Reactor Chamber"),
|
local meta=minetest.get_meta(pos)
|
||||||
tiles={"industrialtest_machine_block.png^industrialtest_nuclear_reactor_top.png"},
|
local inv=meta:get_inventory()
|
||||||
drop="industrialtest:machine_block",
|
local fuelList=inv:get_list("fuel")
|
||||||
groups={
|
local chargedList=inv:get_list("charged")
|
||||||
_industrialtest_wrenchUnmountable=1
|
|
||||||
}
|
local reactorPos=minetest.deserialize(meta:get_string("reactor"))
|
||||||
}
|
local reactorMeta=minetest.get_meta(reactorPos)
|
||||||
if industrialtest.mtgAvailable then
|
local reactorInv=reactorMeta:get_inventory()
|
||||||
definition.sounds=default.node_sound_metal_defaults()
|
reactorInv:set_list("fuel",fuelList)
|
||||||
definition.groups.cracky=1
|
reactorInv:set_list("charged",chargedList)
|
||||||
definition.groups.level=2
|
|
||||||
elseif industrialtest.mclAvailable then
|
reactor.synchronizeChambers(reactorPos)
|
||||||
definition.sounds=mcl_sounds.node_sound_metal_defaults()
|
|
||||||
definition._mcl_blast_resistance=6
|
|
||||||
definition._mcl_hardness=5
|
|
||||||
end
|
end
|
||||||
minetest.register_node("industrialtest:nuclear_reactor_chamber",definition)
|
|
||||||
minetest.register_craft({
|
reactor.synchronizeChambers=function(pos)
|
||||||
type="shaped",
|
local meta=minetest.get_meta(pos)
|
||||||
output="industrialtest:nuclear_reactor_chamber",
|
local chambers=meta:contains("chambers") and minetest.deserialize(meta:get_string("chambers")) or {}
|
||||||
recipe={
|
for _,chamber in ipairs(chambers) do
|
||||||
{"","industrialtest:copper_plate",""},
|
reactorChamber.synchronize(chamber,pos)
|
||||||
{"industrialtest:copper_plate","industrialtest:machine_block","industrialtest:copper_plate"},
|
end
|
||||||
{"","industrialtest:copper_plate",""}
|
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({
|
industrialtest.internal.registerMachine({
|
||||||
name="nuclear_reactor",
|
name="nuclear_reactor",
|
||||||
@@ -347,7 +454,8 @@ industrialtest.internal.registerMachine({
|
|||||||
},
|
},
|
||||||
paramtype2="facedir",
|
paramtype2="facedir",
|
||||||
legacy_facedir_simple=true,
|
legacy_facedir_simple=true,
|
||||||
on_receive_fields=reactor.handleFormspecFields
|
on_receive_fields=reactor.handleFormspecFields,
|
||||||
|
_industrialtest_synchronizeToChamber=reactor.synchronizeToChamber
|
||||||
},
|
},
|
||||||
activeCustomKeys={
|
activeCustomKeys={
|
||||||
tiles={
|
tiles={
|
||||||
@@ -363,12 +471,14 @@ industrialtest.internal.registerMachine({
|
|||||||
on_receive_fields=reactor.handleFormspecFields
|
on_receive_fields=reactor.handleFormspecFields
|
||||||
},
|
},
|
||||||
onConstruct=reactor.onConstruct,
|
onConstruct=reactor.onConstruct,
|
||||||
|
onDestruct=reactor.onDestruct,
|
||||||
onTimer=reactor.onTimer,
|
onTimer=reactor.onTimer,
|
||||||
activeOnTimer=reactor.activeOnTimer,
|
activeOnTimer=reactor.activeOnTimer,
|
||||||
allowMetadataInventoryMove=reactor.allowMetadataInventoryMove,
|
allowMetadataInventoryMove=reactor.allowMetadataInventoryMove,
|
||||||
allowMetadataInventoryPut=reactor.allowMetadataInventoryPut,
|
allowMetadataInventoryPut=reactor.allowMetadataInventoryPut,
|
||||||
onMetadataInventoryMove=reactor.metadataChange,
|
onMetadataInventoryMove=reactor.metadataChange,
|
||||||
onMetadataInventoryPut=reactor.metadataChange
|
onMetadataInventoryPut=reactor.metadataChange,
|
||||||
|
onMetadataInventoryTake=reactor.metadataChange
|
||||||
})
|
})
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
type="shaped",
|
type="shaped",
|
||||||
@@ -379,3 +489,42 @@ minetest.register_craft({
|
|||||||
{"","industrialtest:generator",""}
|
{"","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",""}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ local S=minetest.get_translator("industrialtest")
|
|||||||
|
|
||||||
local rotaryMacerator={}
|
local rotaryMacerator={}
|
||||||
rotaryMacerator.opPower=60
|
rotaryMacerator.opPower=60
|
||||||
|
rotaryMacerator.maintainSpeedOpPower=10
|
||||||
|
|
||||||
rotaryMacerator.getFormspec=function(pos)
|
rotaryMacerator.getFormspec=function(pos)
|
||||||
local meta=minetest.get_meta(pos)
|
local meta=minetest.get_meta(pos)
|
||||||
@@ -25,6 +26,7 @@ rotaryMacerator.getFormspec=function(pos)
|
|||||||
local maxSrcTime=meta:get_float("maxSrcTime")
|
local maxSrcTime=meta:get_float("maxSrcTime")
|
||||||
local srcPercent=maxSrcTime>0 and meta:get_float("srcTime")/maxSrcTime*100 or 0
|
local srcPercent=maxSrcTime>0 and meta:get_float("srcTime")/maxSrcTime*100 or 0
|
||||||
local rpm=meta:get_int("rpm")
|
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
|
local formspec
|
||||||
if industrialtest.mtgAvailable then
|
if industrialtest.mtgAvailable then
|
||||||
formspec={
|
formspec={
|
||||||
@@ -38,6 +40,7 @@ rotaryMacerator.getFormspec=function(pos)
|
|||||||
"list[context;dst;6,2.8;1,1;]",
|
"list[context;dst;6,2.8;1,1;]",
|
||||||
"list[context;upgrades;9,0.9;1,4]",
|
"list[context;upgrades;9,0.9;1,4]",
|
||||||
"label[0.5,2.8;"..minetest.formspec_escape(S("Speed: @1",rpm)).."]",
|
"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;src]",
|
||||||
"listring[context;modifier]",
|
"listring[context;modifier]",
|
||||||
"listring[context;powerStorage]",
|
"listring[context;powerStorage]",
|
||||||
@@ -61,6 +64,7 @@ rotaryMacerator.getFormspec=function(pos)
|
|||||||
"list[context;upgrades;9,0.9;1,4]",
|
"list[context;upgrades;9,0.9;1,4]",
|
||||||
mcl_formspec.get_itemslot_bg(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)).."]",
|
"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;src]",
|
||||||
"listring[context;modifier]",
|
"listring[context;modifier]",
|
||||||
"listring[context;powerStorage]",
|
"listring[context;powerStorage]",
|
||||||
@@ -80,6 +84,7 @@ rotaryMacerator.onConstruct=function(pos,meta,inv)
|
|||||||
meta:set_int("rpm",0)
|
meta:set_int("rpm",0)
|
||||||
meta:set_float("srcTime",0)
|
meta:set_float("srcTime",0)
|
||||||
meta:set_float("maxSrcTime",0)
|
meta:set_float("maxSrcTime",0)
|
||||||
|
meta:set_int("maintainSpeed",0)
|
||||||
end
|
end
|
||||||
|
|
||||||
rotaryMacerator.onTimer=function(pos,elapsed,meta,inv)
|
rotaryMacerator.onTimer=function(pos,elapsed,meta,inv)
|
||||||
@@ -88,12 +93,21 @@ rotaryMacerator.onTimer=function(pos,elapsed,meta,inv)
|
|||||||
local srcSlot=inv:get_stack("src",1)
|
local srcSlot=inv:get_stack("src",1)
|
||||||
local modifierSlot=inv:get_stack("modifier",1)
|
local modifierSlot=inv:get_stack("modifier",1)
|
||||||
local dstSlot=inv:get_stack("dst",1)
|
local dstSlot=inv:get_stack("dst",1)
|
||||||
local powerAmount=meta:get_int("industrialtest.powerAmount")
|
|
||||||
local rpm=meta:get_int("rpm")
|
local rpm=meta:get_int("rpm")
|
||||||
|
local maintainSpeed=meta:get_int("maintainSpeed")
|
||||||
|
|
||||||
shouldRerunTimer,shouldUpdateFormspec=industrialtest.internal.chargeFromPowerStorageItem(meta,inv)
|
shouldRerunTimer,shouldUpdateFormspec=industrialtest.internal.chargeFromPowerStorageItem(meta,inv)
|
||||||
|
local powerAmount=meta:get_int("industrialtest.powerAmount")
|
||||||
|
|
||||||
if rpm>0 then
|
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))
|
meta:set_int("rpm",math.max(rpm-1000*elapsed,0))
|
||||||
shouldRerunTimer=shouldRerunTimer or rpm>0
|
shouldRerunTimer=shouldRerunTimer or rpm>0
|
||||||
shouldUpdateFormspec=true
|
shouldUpdateFormspec=true
|
||||||
|
|||||||
51
minerals.lua
@@ -20,32 +20,46 @@ if industrialtest.mtgAvailable then
|
|||||||
ore_type="scatter",
|
ore_type="scatter",
|
||||||
ore="industrialtest:stone_with_uranium",
|
ore="industrialtest:stone_with_uranium",
|
||||||
wherein="default:stone",
|
wherein="default:stone",
|
||||||
clust_scarcity=7*7*7,
|
clust_scarcity=15*15*15,
|
||||||
clust_num_ores=3,
|
clust_num_ores=3,
|
||||||
clust_size=3,
|
clust_size=3,
|
||||||
y_max=-128,
|
y_max=-128,
|
||||||
y_min=-31000
|
y_min=-31000
|
||||||
})
|
})
|
||||||
|
|
||||||
industrialtest.internal.registerMetal("lead","Lead",2)
|
industrialtest.internal.registerMetal("lead","Lead",2)
|
||||||
minetest.register_ore({
|
minetest.register_ore({
|
||||||
ore_type="scatter",
|
ore_type="scatter",
|
||||||
ore="industrialtest:stone_with_lead",
|
ore="industrialtest:stone_with_lead",
|
||||||
wherein="default:stone",
|
wherein="default:stone",
|
||||||
clust_scarcity=7*7*7,
|
clust_scarcity=11*11*11,
|
||||||
clust_num_ores=3,
|
clust_num_ores=3,
|
||||||
clust_size=3,
|
clust_size=3,
|
||||||
y_max=-48,
|
y_max=-48,
|
||||||
y_min=-31000
|
y_min=-31000
|
||||||
})
|
})
|
||||||
|
|
||||||
|
industrialtest.internal.registerMetal("iridium","Iridium",3)
|
||||||
|
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
|
elseif industrialtest.mclAvailable then
|
||||||
industrialtest.internal.registerMetal("uranium","Uranium",4,4,4,4,5,5)
|
|
||||||
local stonelike={"mcl_core:stone","mcl_core:diorite","mcl_core:andesite","mcl_core:granite"}
|
local stonelike={"mcl_core:stone","mcl_core:diorite","mcl_core:andesite","mcl_core:granite"}
|
||||||
local deepslatelike={"mcl_deepslate:deepslate","mcl_deepslate:tuff"}
|
local deepslatelike={"mcl_deepslate:deepslate","mcl_deepslate:tuff"}
|
||||||
|
|
||||||
|
industrialtest.internal.registerMetal("uranium","Uranium",4,4,4,4,5,5)
|
||||||
minetest.register_ore({
|
minetest.register_ore({
|
||||||
ore_type="scatter",
|
ore_type="scatter",
|
||||||
ore="industrialtest:stone_with_uranium",
|
ore="industrialtest:stone_with_uranium",
|
||||||
wherein=stonelike,
|
wherein=stonelike,
|
||||||
clust_scarcity=7*7*7,
|
clust_scarcity=15*15*15,
|
||||||
clust_num_ores=3,
|
clust_num_ores=3,
|
||||||
clust_size=3,
|
clust_size=3,
|
||||||
y_max=mcl_worlds.layer_to_y(20),
|
y_max=mcl_worlds.layer_to_y(20),
|
||||||
@@ -55,18 +69,19 @@ elseif industrialtest.mclAvailable then
|
|||||||
ore_type="scatter",
|
ore_type="scatter",
|
||||||
ore="industrialtest:deepslate_with_uranium",
|
ore="industrialtest:deepslate_with_uranium",
|
||||||
wherein=deepslatelike,
|
wherein=deepslatelike,
|
||||||
clust_scarcity=7*7*7,
|
clust_scarcity=15*15*15,
|
||||||
clust_num_ores=3,
|
clust_num_ores=3,
|
||||||
clust_size=3,
|
clust_size=3,
|
||||||
y_max=mcl_worlds.layer_to_y(15),
|
y_max=mcl_worlds.layer_to_y(15),
|
||||||
y_min=mcl_vars.mg_overworld_min
|
y_min=mcl_vars.mg_overworld_min
|
||||||
})
|
})
|
||||||
|
|
||||||
industrialtest.internal.registerMetal("lead","Lead",4,4,4,4,6,5)
|
industrialtest.internal.registerMetal("lead","Lead",4,4,4,4,6,5)
|
||||||
minetest.register_ore({
|
minetest.register_ore({
|
||||||
ore_type="scatter",
|
ore_type="scatter",
|
||||||
ore="industrialtest:stone_with_lead",
|
ore="industrialtest:stone_with_lead",
|
||||||
wherein=stonelike,
|
wherein=stonelike,
|
||||||
clust_scarcity=7*7*7,
|
clust_scarcity=11*11*11,
|
||||||
clust_num_ores=3,
|
clust_num_ores=3,
|
||||||
clust_size=3,
|
clust_size=3,
|
||||||
y_max=mcl_worlds.layer_to_y(30),
|
y_max=mcl_worlds.layer_to_y(30),
|
||||||
@@ -76,7 +91,29 @@ elseif industrialtest.mclAvailable then
|
|||||||
ore_type="scatter",
|
ore_type="scatter",
|
||||||
ore="industrialtest:deepslate_with_lead",
|
ore="industrialtest:deepslate_with_lead",
|
||||||
wherein=deepslatelike,
|
wherein=deepslatelike,
|
||||||
clust_scarcity=7*7*7,
|
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_num_ores=3,
|
||||||
clust_size=3,
|
clust_size=3,
|
||||||
y_max=mcl_worlds.layer_to_y(15),
|
y_max=mcl_worlds.layer_to_y(15),
|
||||||
|
|||||||
2
mod.conf
@@ -1,5 +1,5 @@
|
|||||||
name=industrialtest
|
name=industrialtest
|
||||||
description=Adds various machinery
|
description=Adds various machinery
|
||||||
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
|
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
|
author=IndustrialTest Team
|
||||||
title=IndustrialTest
|
title=IndustrialTest
|
||||||
|
|||||||
82
nodes.lua
@@ -411,3 +411,85 @@ if not industrialtest.mods.mclRubber then
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
definition={
|
||||||
|
description=S("Reinforced Stone"),
|
||||||
|
tiles={"industrialtest_reinforced_stone.png"}
|
||||||
|
}
|
||||||
|
if industrialtest.mtgAvailable then
|
||||||
|
definition.groups={cracky=3}
|
||||||
|
definition.sounds=default.node_sound_stone_defaults()
|
||||||
|
definition.on_blast=function(pos,intensity)
|
||||||
|
if intensity>20 then
|
||||||
|
minetest.remove_node(pos)
|
||||||
|
minetest.add_item(pos,ItemStack("industrialtest:reinforced_stone"))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif industrialtest.mclAvailable then
|
||||||
|
definition.groups={
|
||||||
|
pickaxey=1,
|
||||||
|
stone=1,
|
||||||
|
building_block=1,
|
||||||
|
material_stone=1
|
||||||
|
}
|
||||||
|
definition.sounds=mcl_sounds.node_sound_stone_defaults()
|
||||||
|
definition._mcl_blast_resistance=1200
|
||||||
|
definition._mcl_hardness=5
|
||||||
|
end
|
||||||
|
minetest.register_node("industrialtest:reinforced_stone",definition)
|
||||||
|
minetest.register_craft({
|
||||||
|
type="shaped",
|
||||||
|
output="industrialtest:reinforced_stone 8",
|
||||||
|
recipe={
|
||||||
|
{industrialtest.elementKeys.stone,industrialtest.elementKeys.stone,industrialtest.elementKeys.stone},
|
||||||
|
{industrialtest.elementKeys.stone,"industrialtest:advanced_alloy",industrialtest.elementKeys.stone},
|
||||||
|
{industrialtest.elementKeys.stone,industrialtest.elementKeys.stone,industrialtest.elementKeys.stone}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
definition={
|
||||||
|
description=S("Reinforced Glass"),
|
||||||
|
drawtype="glasslike_framed_optional",
|
||||||
|
tiles={"industrialtest_reinforced_glass.png"},
|
||||||
|
use_texture_alpha="clip",
|
||||||
|
paramtype="light",
|
||||||
|
sunlight_propagates=true
|
||||||
|
}
|
||||||
|
if industrialtest.mtgAvailable then
|
||||||
|
definition.groups={cracky=3}
|
||||||
|
definition.sounds=default.node_sound_glass_defaults()
|
||||||
|
definition.on_blast=function(pos,intensity)
|
||||||
|
if intensity>10 then
|
||||||
|
minetest.remove_node(pos)
|
||||||
|
minetest.add_item(pos,ItemStack("industrialtest:reinforced_glass"))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif industrialtest.mclAvailable then
|
||||||
|
definition.groups={
|
||||||
|
glass=1,
|
||||||
|
building_block=1,
|
||||||
|
material_glass=1
|
||||||
|
}
|
||||||
|
definition.sounds=mcl_sounds.node_sound_glass_defaults()
|
||||||
|
definition._mcl_blast_resistance=15
|
||||||
|
definition._mcl_hardness=1.5
|
||||||
|
end
|
||||||
|
minetest.register_node("industrialtest:reinforced_glass",definition)
|
||||||
|
minetest.register_craft({
|
||||||
|
type="shaped",
|
||||||
|
output="industrialtest:reinforced_glass 7",
|
||||||
|
recipe={
|
||||||
|
{industrialtest.elementKeys.glass,industrialtest.elementKeys.glass,industrialtest.elementKeys.glass},
|
||||||
|
{"industrialtest:advanced_alloy",industrialtest.elementKeys.glass,"industrialtest:advanced_alloy"},
|
||||||
|
{industrialtest.elementKeys.glass,industrialtest.elementKeys.glass,industrialtest.elementKeys.glass}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
minetest.register_craft({
|
||||||
|
type="shaped",
|
||||||
|
output="industrialtest:reinforced_glass 7",
|
||||||
|
recipe={
|
||||||
|
{industrialtest.elementKeys.glass,"industrialtest:advanced_alloy",industrialtest.elementKeys.glass},
|
||||||
|
{industrialtest.elementKeys.glass,industrialtest.elementKeys.glass,industrialtest.elementKeys.glass},
|
||||||
|
{industrialtest.elementKeys.glass,"industrialtest:advanced_alloy",industrialtest.elementKeys.glass}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|||||||
BIN
textures/industrialtest_iridium_block.png
Normal file
|
After Width: | Height: | Size: 771 B |
BIN
textures/industrialtest_mcl_iridium_ingot.png
Normal file
|
After Width: | Height: | Size: 858 B |
BIN
textures/industrialtest_mcl_nano_boots.png
Normal file
|
After Width: | Height: | Size: 700 B |
BIN
textures/industrialtest_mcl_quantum_boots.png
Normal file
|
After Width: | Height: | Size: 720 B |
BIN
textures/industrialtest_mcl_raw_iridium.png
Normal file
|
After Width: | Height: | Size: 963 B |
BIN
textures/industrialtest_mcl_raw_iridium_block.png
Normal file
|
After Width: | Height: | Size: 960 B |
BIN
textures/industrialtest_mcl_stone_with_iridium.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
textures/industrialtest_mtg_iridium_ingot.png
Normal file
|
After Width: | Height: | Size: 682 B |
BIN
textures/industrialtest_mtg_iridium_lump.png
Normal file
|
After Width: | Height: | Size: 641 B |
BIN
textures/industrialtest_mtg_stone_with_iridium.png
Normal file
|
After Width: | Height: | Size: 667 B |
BIN
textures/industrialtest_quantum_bodyarmor.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
textures/industrialtest_quantum_bodyarmor_inv.png
Normal file
|
After Width: | Height: | Size: 424 B |
BIN
textures/industrialtest_quantum_bodyarmor_preview.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
textures/industrialtest_quantum_boots.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
textures/industrialtest_quantum_boots_inv.png
Normal file
|
After Width: | Height: | Size: 359 B |
BIN
textures/industrialtest_quantum_boots_preview.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
textures/industrialtest_quantum_helmet.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
textures/industrialtest_quantum_helmet_inv.png
Normal file
|
After Width: | Height: | Size: 377 B |
BIN
textures/industrialtest_quantum_helmet_preview.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
textures/industrialtest_quantum_leggings.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
textures/industrialtest_quantum_leggings_inv.png
Normal file
|
After Width: | Height: | Size: 356 B |
BIN
textures/industrialtest_quantum_leggings_preview.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
textures/industrialtest_reinforced_glass.png
Normal file
|
After Width: | Height: | Size: 654 B |
BIN
textures/industrialtest_reinforced_stone.png
Normal file
|
After Width: | Height: | Size: 869 B |
@@ -38,7 +38,8 @@ local function registerNanoSuitPart(config)
|
|||||||
_industrialtest_powerStorage=true,
|
_industrialtest_powerStorage=true,
|
||||||
_industrialtest_powerCapacity=1000000,
|
_industrialtest_powerCapacity=1000000,
|
||||||
_industrialtest_powerFlow=industrialtest.api.evPowerFlow,
|
_industrialtest_powerFlow=industrialtest.api.evPowerFlow,
|
||||||
_industrialtest_damageReduction=config.damageReduction
|
_industrialtest_damageReduction=config.damageReduction,
|
||||||
|
industrialtest_powerPerDamage=5000
|
||||||
})
|
})
|
||||||
elseif industrialtest.mclAvailable then
|
elseif industrialtest.mclAvailable then
|
||||||
groups.armor=1
|
groups.armor=1
|
||||||
@@ -54,11 +55,12 @@ local function registerNanoSuitPart(config)
|
|||||||
on_place=mcl_armor.equip_on_use,
|
on_place=mcl_armor.equip_on_use,
|
||||||
on_secondary_use=mcl_armor.equip_on_use,
|
on_secondary_use=mcl_armor.equip_on_use,
|
||||||
_mcl_armor_element=config.element,
|
_mcl_armor_element=config.element,
|
||||||
_mcl_armor_texture="industrialtest_"..config.name..".png",
|
_mcl_armor_texture=(config.element=="feet" and "industrialtest_mcl_" or "industrialtest_")..config.name..".png",
|
||||||
_industrialtest_powerStorage=true,
|
_industrialtest_powerStorage=true,
|
||||||
_industrialtest_powerCapacity=1000000,
|
_industrialtest_powerCapacity=1000000,
|
||||||
_industrialtest_powerFlow=industrialtest.api.evPowerFlow,
|
_industrialtest_powerFlow=industrialtest.api.evPowerFlow,
|
||||||
_industrialtest_damageReduction=config.damageReduction
|
_industrialtest_damageReduction=config.damageReduction,
|
||||||
|
_industrialtest_powerPerDamage=5000
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -149,12 +151,12 @@ minetest.register_on_player_hpchange(function(player,hpChange)
|
|||||||
if def.groups and def.groups._industrialtest_nanoSuit then
|
if def.groups and def.groups._industrialtest_nanoSuit then
|
||||||
local meta=stack:get_meta()
|
local meta=stack:get_meta()
|
||||||
local targetReducedDamage=math.floor(math.abs(hpChange)*def._industrialtest_damageReduction)
|
local targetReducedDamage=math.floor(math.abs(hpChange)*def._industrialtest_damageReduction)
|
||||||
local requiredPower=targetReducedDamage*5000
|
local requiredPower=targetReducedDamage*def._industrialtest_powerPerDamage
|
||||||
local availablePower=math.min(meta:get_int("industrialtest.powerAmount"),requiredPower)
|
local availablePower=math.min(meta:get_int("industrialtest.powerAmount"),requiredPower)
|
||||||
local reducedDamage=math.floor(availablePower/5000)
|
local reducedDamage=math.floor(availablePower/def._industrialtest_powerPerDamage)
|
||||||
if reducedDamage>0 then
|
if reducedDamage>0 then
|
||||||
result=result+reducedDamage
|
result=result+reducedDamage
|
||||||
industrialtest.api.addPowerToItem(stack,-reducedDamage*5000)
|
industrialtest.api.addPowerToItem(stack,-reducedDamage*def._industrialtest_powerPerDamage)
|
||||||
inv:set_stack("armor",i,stack)
|
inv:set_stack("armor",i,stack)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
275
tools/quantum_suit.lua
Normal file
@@ -0,0 +1,275 @@
|
|||||||
|
-- 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 quantumSuit={}
|
||||||
|
quantumSuit.helmetBreathRefillOpPower=1000
|
||||||
|
quantumSuit.leggingsSpeedOpPower=125
|
||||||
|
quantumSuit.leggingsSpeedMaxVel=4
|
||||||
|
quantumSuit.bootsJumpOpPower=50
|
||||||
|
quantumSuit.bootsFallDamageReductionOpPower=900
|
||||||
|
|
||||||
|
local playerPositions={}
|
||||||
|
local playerLeggingsSpeedEnabled={}
|
||||||
|
local playerBootsJumpEnabled={}
|
||||||
|
|
||||||
|
local function registerQuantumSuitPart(config)
|
||||||
|
config.groups=config.groups or {}
|
||||||
|
config.groups._industrialtest_nanoSuit=1
|
||||||
|
if config.element=="head" then
|
||||||
|
config.groups.armor_head=1
|
||||||
|
elseif config.element=="torso" then
|
||||||
|
config.groups.armor_torso=1
|
||||||
|
elseif config.element=="legs" then
|
||||||
|
config.groups.armor_legs=1
|
||||||
|
elseif config.element=="feet" then
|
||||||
|
config.groups.armor_feet=1
|
||||||
|
end
|
||||||
|
local definition={
|
||||||
|
description=config.displayName,
|
||||||
|
inventory_image="industrialtest_"..config.name.."_inv.png",
|
||||||
|
groups=config.groups,
|
||||||
|
_industrialtest_powerStorage=true,
|
||||||
|
_industrialtest_powerCapacity=10000000,
|
||||||
|
_industrialtest_powerFlow=industrialtest.api.ivPowerFlow,
|
||||||
|
_industrialtest_damageReduction=config.damageReduction,
|
||||||
|
_industrialtest_powerPerDamage=30
|
||||||
|
}
|
||||||
|
if config.customKeys then
|
||||||
|
for k,v in pairs(config.customKeys) do
|
||||||
|
definition[k]=v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if industrialtest.mtgAvailable then
|
||||||
|
definition.groups.armor_heal=0
|
||||||
|
armor:register_armor("industrialtest:"..config.name,definition)
|
||||||
|
elseif industrialtest.mclAvailable then
|
||||||
|
definition.groups.armor=1
|
||||||
|
definition.groups.non_combat_armor=1
|
||||||
|
definition.sounds={
|
||||||
|
_mcl_armor_equip="mcl_armor_equip_iron",
|
||||||
|
_mcl_armor_unequip="mcl_armor_unequip_iron"
|
||||||
|
}
|
||||||
|
definition.on_place=mcl_armor.equip_on_use
|
||||||
|
definition.on_secondary_use=mcl_armor.equip_on_use
|
||||||
|
definition._mcl_armor_element=config.element
|
||||||
|
definition._mcl_armor_texture=(config.element=="feet" and "industrialtest_mcl_" or "industrialtest_")..config.name..".png"
|
||||||
|
minetest.register_tool("industrialtest:"..config.name,definition)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function findInPlayerArmorList(player,itemname)
|
||||||
|
local inv
|
||||||
|
if industrialtest.mclAvailable then
|
||||||
|
inv=player:get_inventory()
|
||||||
|
elseif industrialtest.mtgAvailable then
|
||||||
|
_,inv=armor:get_valid_player(player,"")
|
||||||
|
end
|
||||||
|
local armorList=inv:get_list("armor")
|
||||||
|
for i,stack in ipairs(armorList) do
|
||||||
|
if stack:get_name()==itemname then
|
||||||
|
return i,stack,inv
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
quantumSuit.tryFly=function(itemstack)
|
||||||
|
local meta=itemstack:get_meta()
|
||||||
|
if meta:get_int("industrialtest.powerAmount")<10 then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
industrialtest.api.addPowerToItem(itemstack,-10)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
registerQuantumSuitPart({
|
||||||
|
name="quantum_helmet",
|
||||||
|
displayName=S("Quantum Helmet"),
|
||||||
|
element="head",
|
||||||
|
damageReduction=0.15
|
||||||
|
})
|
||||||
|
minetest.register_craft({
|
||||||
|
type="shaped",
|
||||||
|
output="industrialtest:quantum_helmet",
|
||||||
|
recipe={
|
||||||
|
{"industrialtest:reinforced_glass","industrialtest:nano_helmet","industrialtest:reinforced_glass"},
|
||||||
|
{"industrialtest:iridium_plate","industrialtest:lapotron_crystal","industrialtest:iridium_plate"},
|
||||||
|
{"industrialtest:advanced_electronic_circuit","industrialtest:empty_cell","industrialtest:advanced_electronic_circuit"}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
registerQuantumSuitPart({
|
||||||
|
name="quantum_bodyarmor",
|
||||||
|
displayName=S("Quantum Bodyarmor"),
|
||||||
|
element="torso",
|
||||||
|
damageReduction=0.4,
|
||||||
|
groups={
|
||||||
|
_industrialtest_jetpack=1
|
||||||
|
},
|
||||||
|
customKeys={
|
||||||
|
_industrialtest_tryFly=quantumSuit.tryFly
|
||||||
|
}
|
||||||
|
})
|
||||||
|
minetest.register_craft({
|
||||||
|
type="shaped",
|
||||||
|
output="industrialtest:quantum_bodyarmor",
|
||||||
|
recipe={
|
||||||
|
{"industrialtest:advanced_alloy","industrialtest:nano_bodyarmor","industrialtest:advanced_alloy"},
|
||||||
|
{"industrialtest:iridium_plate","industrialtest:lapotron_crystal","industrialtest:iridium_plate"},
|
||||||
|
{"industrialtest:iridium_plate","industrialtest:electric_jetpack","industrialtest:iridium_plate"}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
registerQuantumSuitPart({
|
||||||
|
name="quantum_leggings",
|
||||||
|
displayName=S("Quantum Leggings"),
|
||||||
|
element="legs",
|
||||||
|
damageReduction=0.30
|
||||||
|
})
|
||||||
|
minetest.register_craft({
|
||||||
|
type="shaped",
|
||||||
|
output="industrialtest:quantum_leggings",
|
||||||
|
recipe={
|
||||||
|
{"industrialtest:machine_block","industrialtest:lapotron_crystal","industrialtest:machine_block"},
|
||||||
|
{"industrialtest:iridium_plate","industrialtest:nano_leggings","industrialtest:iridium_plate"},
|
||||||
|
{industrialtest.elementKeys.yellowDust,"",industrialtest.elementKeys.yellowDust}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
registerQuantumSuitPart({
|
||||||
|
name="quantum_boots",
|
||||||
|
displayName=S("Quantum Boots"),
|
||||||
|
element="feet",
|
||||||
|
damageReduction=0.15
|
||||||
|
})
|
||||||
|
minetest.register_craft({
|
||||||
|
type="shaped",
|
||||||
|
output="industrialtest:quantum_boots",
|
||||||
|
recipe={
|
||||||
|
{"industrialtest:iridium_plate","industrialtest:nano_boots","industrialtest:iridium_plate"},
|
||||||
|
{industrialtest.elementKeys.ironBoots,"industrialtest:lapotron_crystal",industrialtest.elementKeys.ironBoots}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_globalstep(function(dtime)
|
||||||
|
local players=minetest.get_connected_players()
|
||||||
|
for _,player in ipairs(players) do
|
||||||
|
local control=player:get_player_control()
|
||||||
|
local playerName=player:get_player_name()
|
||||||
|
if playerLeggingsSpeedEnabled[playerName] then
|
||||||
|
local shouldStopSpeed=true
|
||||||
|
if control.up and control.aux1 then
|
||||||
|
local index,stack,inv=findInPlayerArmorList(player,"industrialtest:quantum_leggings")
|
||||||
|
if index and stack and inv then
|
||||||
|
local meta=stack:get_meta()
|
||||||
|
local requiredPower=vector.distance(player:get_pos(),playerPositions[playerName])*quantumSuit.leggingsSpeedOpPower
|
||||||
|
if meta:get_int("industrialtest.powerAmount")>=requiredPower then
|
||||||
|
industrialtest.api.addPowerToItem(stack,-requiredPower)
|
||||||
|
inv:set_stack("armor",index,stack)
|
||||||
|
shouldStopSpeed=false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if shouldStopSpeed then
|
||||||
|
player:set_physics_override({
|
||||||
|
speed=1
|
||||||
|
})
|
||||||
|
playerLeggingsSpeedEnabled[playerName]=false
|
||||||
|
end
|
||||||
|
elseif control.up and control.aux1 then
|
||||||
|
local index,stack,inv=findInPlayerArmorList(player,"industrialtest:quantum_leggings")
|
||||||
|
if index and stack and inv then
|
||||||
|
local meta=stack:get_meta()
|
||||||
|
local requiredPower=vector.distance(player:get_pos(),playerPositions[playerName])*quantumSuit.leggingsSpeedOpPower
|
||||||
|
if meta:get_int("industrialtest.powerAmount")>=requiredPower then
|
||||||
|
player:set_physics_override({
|
||||||
|
speed=quantumSuit.leggingsSpeedMaxVel
|
||||||
|
})
|
||||||
|
playerLeggingsSpeedEnabled[playerName]=true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if playerBootsJumpEnabled[playerName] then
|
||||||
|
local shouldStopJump=not control.aux1
|
||||||
|
if control.jump and control.aux1 then
|
||||||
|
local index,stack,inv=findInPlayerArmorList(player,"industrialtest:quantum_boots")
|
||||||
|
if index and stack and inv then
|
||||||
|
local meta=stack:get_meta()
|
||||||
|
if meta:get_int("industrialtest.powerAmount")>=quantumSuit.bootsJumpOpPower then
|
||||||
|
industrialtest.api.addPowerToItem(stack,-quantumSuit.bootsJumpOpPower)
|
||||||
|
inv:set_stack("armor",index,stack)
|
||||||
|
shouldStopJump=false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if shouldStopJump then
|
||||||
|
player:set_physics_override({
|
||||||
|
jump=1
|
||||||
|
})
|
||||||
|
playerBootsJumpEnabled[playerName]=false
|
||||||
|
end
|
||||||
|
elseif control.aux1 then
|
||||||
|
local index,stack,inv=findInPlayerArmorList(player,"industrialtest:quantum_boots")
|
||||||
|
if index and stack and inv then
|
||||||
|
local meta=stack:get_meta()
|
||||||
|
local requiredPower=vector.distance(player:get_pos(),playerPositions[playerName])*quantumSuit.leggingsSpeedOpPower
|
||||||
|
if meta:get_int("industrialtest.powerAmount")>=quantumSuit.bootsJumpOpPower then
|
||||||
|
player:set_physics_override({
|
||||||
|
jump=2
|
||||||
|
})
|
||||||
|
playerBootsJumpEnabled[playerName]=true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if player:get_breath()<10 then
|
||||||
|
local index,stack,inv=findInPlayerArmorList(player,"industrialtest:quantum_helmet")
|
||||||
|
if index and stack and inv then
|
||||||
|
local meta=stack:get_meta()
|
||||||
|
local refilled=math.min(9-player:get_breath(),math.floor(meta:get_int("industrialtest.powerAmount")/quantumSuit.helmetBreathRefillOpPower))
|
||||||
|
if refilled>0 then
|
||||||
|
player:set_breath(player:get_breath()+refilled)
|
||||||
|
industrialtest.api.addPowerToItem(stack,-refilled*quantumSuit.helmetBreathRefillOpPower)
|
||||||
|
inv:set_stack("armor",index,stack)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
playerPositions[playerName]=player:get_pos()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
minetest.register_on_player_hpchange(function(player,hpChange,reason)
|
||||||
|
if reason.type~="fall" then
|
||||||
|
return hpChange
|
||||||
|
end
|
||||||
|
|
||||||
|
local index,stack,inv=findInPlayerArmorList(player,"industrialtest:quantum_boots")
|
||||||
|
if not index or not stack or not inv then
|
||||||
|
return hpChange
|
||||||
|
end
|
||||||
|
|
||||||
|
local damage=math.abs(hpChange)
|
||||||
|
local meta=stack:get_meta()
|
||||||
|
local reducedDamage=math.min(damage,math.floor(meta:get_int("industrialtest.powerAmount")/(damage*quantumSuit.bootsFallDamageReductionOpPower)))
|
||||||
|
industrialtest.api.addPowerToItem(stack,-reducedDamage*quantumSuit.bootsFallDamageReductionOpPower)
|
||||||
|
inv:set_stack("armor",index,stack)
|
||||||
|
|
||||||
|
return hpChange+reducedDamage
|
||||||
|
end,true)
|
||||||