diff --git a/elepower_machines/nodes.lua b/elepower_machines/nodes.lua index 7abaf48..0903d0b 100644 --- a/elepower_machines/nodes.lua +++ b/elepower_machines/nodes.lua @@ -5,3 +5,9 @@ minetest.register_node("elepower_machines:machine_block", { tiles = {"elepower_machine_top.png", "elepower_machine_base.png", "elepower_machine_side.png"}, 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}, +}) diff --git a/elepower_machines/textures/elepower_advblock.png b/elepower_machines/textures/elepower_advblock.png new file mode 100644 index 0000000..91cf71d Binary files /dev/null and b/elepower_machines/textures/elepower_advblock.png differ diff --git a/elepower_machines/textures/elepower_advblock_combined.png b/elepower_machines/textures/elepower_advblock_combined.png new file mode 100644 index 0000000..85a3d41 Binary files /dev/null and b/elepower_machines/textures/elepower_advblock_combined.png differ diff --git a/elepower_machines/textures/elepower_advblock_frame.png b/elepower_machines/textures/elepower_advblock_frame.png new file mode 100644 index 0000000..a7cb291 Binary files /dev/null and b/elepower_machines/textures/elepower_advblock_frame.png differ diff --git a/elepower_nuclear/machines/fusion_reactor.lua b/elepower_nuclear/machines/fusion_reactor.lua new file mode 100644 index 0000000..26d9598 --- /dev/null +++ b/elepower_nuclear/machines/fusion_reactor.lua @@ -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, + } +} diff --git a/elepower_nuclear/machines/init.lua b/elepower_nuclear/machines/init.lua index f3af94d..4e599dd 100644 --- a/elepower_nuclear/machines/init.lua +++ b/elepower_nuclear/machines/init.lua @@ -3,5 +3,6 @@ local mp = elenuclear.modpath .. "/machines/" dofile(mp.."enrichment_plant.lua") dofile(mp.."fission_reactor.lua") +dofile(mp.."fusion_reactor.lua") dofile(mp.."heat_exchanger.lua") diff --git a/elepower_nuclear/nodes.lua b/elepower_nuclear/nodes.lua index db924ee..89f9db6 100644 --- a/elepower_nuclear/nodes.lua +++ b/elepower_nuclear/nodes.lua @@ -1,6 +1,4 @@ -dofile(elenuclear.modpath.."/machines/init.lua") - minetest.register_node("elepower_nuclear:machine_block", { description = "Radiation-shielded Lead Machine Chassis\nContains dangerous ionizing radiation", tiles = { @@ -17,3 +15,11 @@ minetest.register_node("elepower_nuclear:stone_with_uranium", { drop = 'elepower_nuclear:uranium_lump', 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") diff --git a/elepower_nuclear/textures/elenuclear_fluid_port.png b/elepower_nuclear/textures/elenuclear_fluid_port.png new file mode 100644 index 0000000..a3193d0 Binary files /dev/null and b/elepower_nuclear/textures/elenuclear_fluid_port.png differ diff --git a/elepower_nuclear/textures/elenuclear_fluid_port_out.png b/elepower_nuclear/textures/elenuclear_fluid_port_out.png new file mode 100644 index 0000000..9ce0ae6 Binary files /dev/null and b/elepower_nuclear/textures/elenuclear_fluid_port_out.png differ diff --git a/elepower_nuclear/textures/elenuclear_fusion_coil_side.png b/elepower_nuclear/textures/elenuclear_fusion_coil_side.png new file mode 100644 index 0000000..3ccd207 Binary files /dev/null and b/elepower_nuclear/textures/elenuclear_fusion_coil_side.png differ diff --git a/elepower_nuclear/textures/elenuclear_fusion_coil_top.png b/elepower_nuclear/textures/elenuclear_fusion_coil_top.png new file mode 100644 index 0000000..e1aac6b Binary files /dev/null and b/elepower_nuclear/textures/elenuclear_fusion_coil_top.png differ diff --git a/elepower_nuclear/textures/elenuclear_fusion_controller.png b/elepower_nuclear/textures/elenuclear_fusion_controller.png new file mode 100644 index 0000000..15d9c8f Binary files /dev/null and b/elepower_nuclear/textures/elenuclear_fusion_controller.png differ diff --git a/elepower_nuclear/textures/elenuclear_power_port.png b/elepower_nuclear/textures/elenuclear_power_port.png new file mode 100644 index 0000000..4e93e40 Binary files /dev/null and b/elepower_nuclear/textures/elenuclear_power_port.png differ