Get started on a fusion reactor
@ -5,3 +5,9 @@ minetest.register_node("elepower_machines:machine_block", {
|
|||||||
tiles = {"elepower_machine_top.png", "elepower_machine_base.png", "elepower_machine_side.png"},
|
tiles = {"elepower_machine_top.png", "elepower_machine_base.png", "elepower_machine_side.png"},
|
||||||
groups = {oddly_breakable_by_hand = 1, cracky = 1},
|
groups = {oddly_breakable_by_hand = 1, cracky = 1},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_node("elepower_machines:advanced_machine_block", {
|
||||||
|
description = "Advanced Machine Block\nSafe for decoration",
|
||||||
|
tiles = {"elepower_advblock_combined.png"},
|
||||||
|
groups = {oddly_breakable_by_hand = 1, cracky = 1},
|
||||||
|
})
|
||||||
|
BIN
elepower_machines/textures/elepower_advblock.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
elepower_machines/textures/elepower_advblock_combined.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
elepower_machines/textures/elepower_advblock_frame.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
193
elepower_nuclear/machines/fusion_reactor.lua
Normal file
@ -0,0 +1,193 @@
|
|||||||
|
|
||||||
|
local iC = 1 -- Casing
|
||||||
|
local iR = 2 -- Controller
|
||||||
|
local iI = 3 -- Inputs
|
||||||
|
local iO = 4 -- Outputs
|
||||||
|
local iE = 5 -- Energy Inputs
|
||||||
|
local iX = 6 -- Center nodes
|
||||||
|
|
||||||
|
-- Width and Height of the structure
|
||||||
|
local structure_size = 15
|
||||||
|
|
||||||
|
-- This is the reactor structure (y 0 to 2)
|
||||||
|
local reactor_structure = {}
|
||||||
|
|
||||||
|
local controller_pos = {x = 7, z = 14}
|
||||||
|
|
||||||
|
-- Determine the validity of the structure from the position of the controller
|
||||||
|
local function determine_structure(pos, player)
|
||||||
|
local node = minetest.get_node_or_nil(pos)
|
||||||
|
if not node then return nil end
|
||||||
|
|
||||||
|
local hsize = math.floor(structure_size / 2)
|
||||||
|
local hindex = {x = hsize, y = 1, z = structure_size}
|
||||||
|
|
||||||
|
-- TODO: Determine build direction
|
||||||
|
--local front = ele.helpers.face_front(pos, node.param2)
|
||||||
|
|
||||||
|
-- Load appropriate map piece into memory for easier parsing
|
||||||
|
local manip = minetest.get_voxel_manip()
|
||||||
|
local e1, e2 = manip:read_from_map(vector.subtract(pos, hindex), vector.add(pos, hindex))
|
||||||
|
local area = VoxelArea:new{MinEdge=e1, MaxEdge=e2}
|
||||||
|
local data = manip:get_data()
|
||||||
|
local success = true
|
||||||
|
|
||||||
|
local inputs = {}
|
||||||
|
local outputs = {}
|
||||||
|
local power = {}
|
||||||
|
|
||||||
|
for y = -1, 1 do
|
||||||
|
if not success then break end
|
||||||
|
|
||||||
|
local arr = reactor_structure[(y + 2)]
|
||||||
|
|
||||||
|
for i = 1, #arr do
|
||||||
|
local ntype = arr[i]
|
||||||
|
local indx = i - 1
|
||||||
|
|
||||||
|
if ntype ~= 0 then
|
||||||
|
local z = math.floor(indx / structure_size)
|
||||||
|
local x = math.floor(indx % structure_size)
|
||||||
|
|
||||||
|
local relX = controller_pos.x - x
|
||||||
|
local relZ = controller_pos.z - z
|
||||||
|
|
||||||
|
local scan_pos = vector.add(pos, {x = relX, y = y, z = relZ})
|
||||||
|
local index = area:indexp(scan_pos)
|
||||||
|
if data[index] ~= ntype then
|
||||||
|
minetest.chat_send_player(player, ('Incorrect node at %d,%d,%d; expected %s, found %s'):format(
|
||||||
|
scan_pos.x,scan_pos.y,scan_pos.z,minetest.get_name_from_content_id(ntype),
|
||||||
|
minetest.get_name_from_content_id(data[index])))
|
||||||
|
success = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
|
||||||
|
if ntype == iI then
|
||||||
|
table.insert(inputs, scan_pos)
|
||||||
|
elseif ntype == iO then
|
||||||
|
table.insert(outputs, scan_pos)
|
||||||
|
elseif ntype == iE then
|
||||||
|
table.insert(power, scan_pos)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if success then
|
||||||
|
minetest.chat_send_player(player, "Multi-node structure complete!")
|
||||||
|
end
|
||||||
|
|
||||||
|
return success, inputs, outputs, power
|
||||||
|
end
|
||||||
|
|
||||||
|
-----------
|
||||||
|
-- Nodes --
|
||||||
|
-----------
|
||||||
|
|
||||||
|
minetest.register_node("elepower_nuclear:reactor_controller", {
|
||||||
|
description = "Fusion Reactor Controller",
|
||||||
|
tiles = {
|
||||||
|
"elepower_advblock_combined.png", "elepower_advblock_combined.png", "elepower_advblock_combined.png",
|
||||||
|
"elepower_advblock_combined.png", "elepower_advblock_combined.png", "elepower_advblock_combined.png^elenuclear_fusion_controller.png",
|
||||||
|
},
|
||||||
|
groups = {cracky = 2},
|
||||||
|
on_punch = function (pos, node, puncher, pointed_thing)
|
||||||
|
print(determine_structure(pos, puncher:get_player_name()))
|
||||||
|
minetest.node_punch(pos, node, puncher, pointed_thing)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("elepower_nuclear:reactor_power", {
|
||||||
|
description = "Fusion Reactor Power Port (Input)",
|
||||||
|
tiles = {
|
||||||
|
"elepower_advblock_combined.png", "elepower_advblock_combined.png", "elepower_advblock_combined.png",
|
||||||
|
"elepower_advblock_combined.png", "elepower_advblock_combined.png", "elepower_advblock_combined.png^elenuclear_power_port.png^elepower_power_port.png",
|
||||||
|
},
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = {cracky = 2},
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("elepower_nuclear:reactor_fluid", {
|
||||||
|
description = "Fusion Reactor Fluid Port (Input)",
|
||||||
|
tiles = {
|
||||||
|
"elepower_advblock_combined.png", "elepower_advblock_combined.png", "elepower_advblock_combined.png",
|
||||||
|
"elepower_advblock_combined.png", "elepower_advblock_combined.png",
|
||||||
|
"elepower_advblock_combined.png^elenuclear_fluid_port.png^elepower_power_port.png",
|
||||||
|
},
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = {cracky = 2},
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("elepower_nuclear:reactor_output", {
|
||||||
|
description = "Fusion Reactor Fluid Port (Output)",
|
||||||
|
tiles = {
|
||||||
|
"elepower_advblock_combined.png", "elepower_advblock_combined.png", "elepower_advblock_combined.png",
|
||||||
|
"elepower_advblock_combined.png", "elepower_advblock_combined.png",
|
||||||
|
"elepower_advblock_combined.png^elenuclear_fluid_port_out.png^elepower_power_port.png",
|
||||||
|
},
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = {cracky = 2},
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Define reactor structure with Content IDs
|
||||||
|
|
||||||
|
iC = minetest.get_content_id("elepower_machines:advanced_machine_block")
|
||||||
|
iR = minetest.get_content_id("elepower_nuclear:reactor_controller")
|
||||||
|
iI = minetest.get_content_id("elepower_nuclear:reactor_fluid")
|
||||||
|
iO = minetest.get_content_id("elepower_nuclear:reactor_output")
|
||||||
|
iE = minetest.get_content_id("elepower_nuclear:reactor_power")
|
||||||
|
iX = minetest.get_content_id("elepower_nuclear:fusion_coil")
|
||||||
|
|
||||||
|
reactor_structure = {
|
||||||
|
{
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, iC, iC, iC, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, iC, iC, 0, 0, 0, iC, iC, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, iC, 0, 0, 0, 0, 0, 0, 0, iC, 0, 0, 0,
|
||||||
|
0, 0, iC, 0, 0, 0, 0, 0, 0, 0, 0, 0, iC, 0, 0,
|
||||||
|
0, 0, iC, 0, 0, 0, 0, 0, 0, 0, 0, 0, iC, 0, 0,
|
||||||
|
0, iC, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, iC, 0,
|
||||||
|
0, iI, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, iI, 0,
|
||||||
|
0, iC, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, iC, 0,
|
||||||
|
0, 0, iC, 0, 0, 0, 0, 0, 0, 0, 0, 0, iC, 0, 0,
|
||||||
|
0, 0, iC, 0, 0, 0, 0, 0, 0, 0, 0, 0, iC, 0, 0,
|
||||||
|
0, 0, 0, iC, 0, 0, 0, 0, 0, 0, 0, iC, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, iC, iC, 0, 0, 0, iC, iC, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, iC, iC, iC, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
0, 0, 0, 0, 0, 0, iC, iE, iC, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, iC, iC, iX, iX, iX, iC, iC, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, iC, iX, iX, iC, iC, iC, iX, iX, iC, 0, 0, 0,
|
||||||
|
0, 0, iC, iX, iC, iC, 0, 0, 0, iC, iC, iX, iC, 0, 0,
|
||||||
|
0, iC, iX, iC, 0, 0, 0, 0, 0, 0, 0, iC, iX, iC, 0,
|
||||||
|
0, iC, iX, iC, 0, 0, 0, 0, 0, 0, 0, iC, iX, iC, 0,
|
||||||
|
iC, iX, iC, 0, 0, 0, 0, 0, 0, 0, 0, 0, iC, iX, iC,
|
||||||
|
iE, iX, iC, 0, 0, 0, 0, 0, 0, 0, 0, 0, iC, iX, iE,
|
||||||
|
iC, iX, iC, 0, 0, 0, 0, 0, 0, 0, 0, 0, iC, iX, iC,
|
||||||
|
0, iC, iX, iC, 0, 0, 0, 0, 0, 0, 0, iC, iX, iC, 0,
|
||||||
|
0, iC, iX, iC, 0, 0, 0, 0, 0, 0, 0, iC, iX, iC, 0,
|
||||||
|
0, 0, iC, iX, iC, iC, 0, 0, 0, iC, iC, iX, iC, 0, 0,
|
||||||
|
0, 0, 0, iC, iX, iX, iC, iC, iC, iX, iX, iC, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, iC, iC, iX, iX, iX, iC, iC, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, iC, iR, iC, 0, 0, 0, 0, 0, 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, iC, iC, iC, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, iC, iC, 0, 0, 0, iC, iC, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, iC, 0, 0, 0, 0, 0, 0, 0, iC, 0, 0, 0,
|
||||||
|
0, 0, iC, 0, 0, 0, 0, 0, 0, 0, 0, 0, iC, 0, 0,
|
||||||
|
0, 0, iC, 0, 0, 0, 0, 0, 0, 0, 0, 0, iC, 0, 0,
|
||||||
|
0, iC, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, iC, 0,
|
||||||
|
0, iO, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, iO, 0,
|
||||||
|
0, iC, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, iC, 0,
|
||||||
|
0, 0, iC, 0, 0, 0, 0, 0, 0, 0, 0, 0, iC, 0, 0,
|
||||||
|
0, 0, iC, 0, 0, 0, 0, 0, 0, 0, 0, 0, iC, 0, 0,
|
||||||
|
0, 0, 0, iC, 0, 0, 0, 0, 0, 0, 0, iC, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, iC, iC, 0, 0, 0, iC, iC, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, iC, iC, iC, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
}
|
||||||
|
}
|
@ -3,5 +3,6 @@ local mp = elenuclear.modpath .. "/machines/"
|
|||||||
|
|
||||||
dofile(mp.."enrichment_plant.lua")
|
dofile(mp.."enrichment_plant.lua")
|
||||||
dofile(mp.."fission_reactor.lua")
|
dofile(mp.."fission_reactor.lua")
|
||||||
|
dofile(mp.."fusion_reactor.lua")
|
||||||
dofile(mp.."heat_exchanger.lua")
|
dofile(mp.."heat_exchanger.lua")
|
||||||
|
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
|
|
||||||
dofile(elenuclear.modpath.."/machines/init.lua")
|
|
||||||
|
|
||||||
minetest.register_node("elepower_nuclear:machine_block", {
|
minetest.register_node("elepower_nuclear:machine_block", {
|
||||||
description = "Radiation-shielded Lead Machine Chassis\nContains dangerous ionizing radiation",
|
description = "Radiation-shielded Lead Machine Chassis\nContains dangerous ionizing radiation",
|
||||||
tiles = {
|
tiles = {
|
||||||
@ -17,3 +15,11 @@ minetest.register_node("elepower_nuclear:stone_with_uranium", {
|
|||||||
drop = 'elepower_nuclear:uranium_lump',
|
drop = 'elepower_nuclear:uranium_lump',
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_node("elepower_nuclear:fusion_coil", {
|
||||||
|
description = "Fusion Reactor Coil",
|
||||||
|
tiles = {"elenuclear_fusion_coil_top.png", "elenuclear_fusion_coil_top.png", "elenuclear_fusion_coil_side.png"},
|
||||||
|
groups = {cracky = 2},
|
||||||
|
})
|
||||||
|
|
||||||
|
dofile(elenuclear.modpath.."/machines/init.lua")
|
||||||
|
BIN
elepower_nuclear/textures/elenuclear_fluid_port.png
Normal file
After Width: | Height: | Size: 228 B |
BIN
elepower_nuclear/textures/elenuclear_fluid_port_out.png
Normal file
After Width: | Height: | Size: 278 B |
BIN
elepower_nuclear/textures/elenuclear_fusion_coil_side.png
Normal file
After Width: | Height: | Size: 911 B |
BIN
elepower_nuclear/textures/elenuclear_fusion_coil_top.png
Normal file
After Width: | Height: | Size: 1020 B |
BIN
elepower_nuclear/textures/elenuclear_fusion_controller.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
elepower_nuclear/textures/elenuclear_power_port.png
Normal file
After Width: | Height: | Size: 232 B |