From bea3f617d5f650d5e59f142cccf7c78501003a2d Mon Sep 17 00:00:00 2001 From: Joachim Stolberg Date: Fri, 7 Jan 2022 17:25:28 +0100 Subject: [PATCH] Add ta5 gas pipes --- fusion_reactor/gas_pipe.lua | 204 ++++++++++++++++++++++ init.lua | 1 + move_controller/flycontroller.lua | 2 +- textures/techage_appl_hole_ta5_pipe.png | Bin 0 -> 120 bytes textures/techage_ta5_gaspipe.png | Bin 0 -> 132 bytes textures/techage_ta5_gaspipe_hole.png | Bin 0 -> 129 bytes textures/techage_ta5_gaspipe_hole2.png | Bin 0 -> 185 bytes textures/techage_ta5_gaspipe_junction.png | Bin 0 -> 243 bytes textures/techage_ta5_gaspipe_knee.png | Bin 0 -> 193 bytes textures/techage_ta5_gaspipe_knee2.png | Bin 0 -> 175 bytes 10 files changed, 206 insertions(+), 1 deletion(-) create mode 100644 fusion_reactor/gas_pipe.lua create mode 100644 textures/techage_appl_hole_ta5_pipe.png create mode 100644 textures/techage_ta5_gaspipe.png create mode 100644 textures/techage_ta5_gaspipe_hole.png create mode 100644 textures/techage_ta5_gaspipe_hole2.png create mode 100644 textures/techage_ta5_gaspipe_junction.png create mode 100644 textures/techage_ta5_gaspipe_knee.png create mode 100644 textures/techage_ta5_gaspipe_knee2.png diff --git a/fusion_reactor/gas_pipe.lua b/fusion_reactor/gas_pipe.lua new file mode 100644 index 0000000..60cdcd6 --- /dev/null +++ b/fusion_reactor/gas_pipe.lua @@ -0,0 +1,204 @@ +--[[ + + TechAge + ======= + + Copyright (C) 2019-2021 Joachim Stolberg + + AGPL v3 + See LICENSE.txt for more information + + TA5 Gas Pipes + +]]-- + +-- for lazy programmers +local S2P = minetest.string_to_pos +local P2S = minetest.pos_to_string +local M = minetest.get_meta +local S = techage.S + +local MAX_PIPE_LENGHT = 100 + +local power = networks.power + +local Pipe = tubelib2.Tube:new({ + dirs_to_check = {1,2,3,4,5,6}, + max_tube_length = MAX_PIPE_LENGHT, + show_infotext = false, + force_to_use_tubes = false, + tube_type = "pipe3", + primary_node_names = { + "techage:ta5_pipeS", "techage:ta5_pipeA", + }, + secondary_node_names = {}, + after_place_tube = function(pos, param2, tube_type, num_tubes) + local name = minetest.get_node(pos).name + if not networks.hidden_name(pos) then + minetest.swap_node(pos, {name = "techage:ta5_pipe"..tube_type, param2 = param2 % 32}) + end + M(pos):set_int("netw_param2", param2) + end, +}) + +-- Enable hidden cables +networks.use_metadata(Pipe) + +-- Use global callback instead of node related functions +Pipe:register_on_tube_update2(function(pos, outdir, tlib2, node) + power.update_network(pos, outdir, tlib2, node) +end) + +minetest.register_node("techage:ta5_pipeS", { + description = S("TA5 Pipe"), + tiles = { + "techage_ta5_gaspipe.png^[transformR90", + "techage_ta5_gaspipe.png^[transformR90", + "techage_ta5_gaspipe.png", + "techage_ta5_gaspipe.png", + "techage_ta5_gaspipe_hole2.png", + "techage_ta5_gaspipe_hole2.png", + }, + + after_place_node = function(pos, placer, itemstack, pointed_thing) + if not Pipe:after_place_tube(pos, placer, pointed_thing) then + minetest.remove_node(pos) + return true + end + return false + end, + + after_dig_node = function(pos, oldnode, oldmetadata, digger) + Pipe:after_dig_tube(pos, oldnode, oldmetadata) + end, + + paramtype2 = "facedir", -- important! + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-1/16, -1/16, -8/16, 1/16, 1/16, 8/16}, + }, + }, + on_rotate = screwdriver.disallow, -- important! + paramtype = "light", + use_texture_alpha = techage.CLIP, + sunlight_propagates = true, + is_ground_content = false, + groups = {crumbly = 2, cracky = 2, snappy = 2, techage_trowel = 1}, + sounds = default.node_sound_metal_defaults(), +}) + +minetest.register_node("techage:ta5_pipeA", { + description = S("TA5 Pipe"), + tiles = { + "techage_ta5_gaspipe_knee2.png", + "techage_ta5_gaspipe_hole2.png^[transformR180", + "techage_ta5_gaspipe_knee.png^[transformR270", + "techage_ta5_gaspipe_knee.png", + "techage_ta5_gaspipe_knee2.png", + "techage_ta5_gaspipe_hole2.png", + }, + + after_dig_node = function(pos, oldnode, oldmetadata, digger) + Pipe:after_dig_tube(pos, oldnode, oldmetadata) + end, + + paramtype2 = "facedir", -- important! + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-1/16, -8/16, -1/16, 1/16, 1/16, 1/16}, + {-2/16, -0.5, -2/16, 2/16, -13/32, 2/16}, + {-1/16, -1/16, -8/16, 1/16, 1/16, -1/16}, + {-2/16, -2/16, -0.5, 2/16, 2/16, -13/32}, + }, + }, + on_rotate = screwdriver.disallow, -- important! + paramtype = "light", + use_texture_alpha = techage.CLIP, + sunlight_propagates = true, + is_ground_content = false, + groups = {crumbly = 2, cracky = 2, snappy = 2, + not_in_creative_inventory=1, techage_trowel = 1}, + sounds = default.node_sound_metal_defaults(), + drop = "techage:ta5_pipeS", +}) + +local size1 = 1/16 +local size2 = 2/16 +local size3 = 13/32 +local Boxes = { + { + {-size1, -size1, size1, size1, size1, 0.5 }, -- z+ + {-size2, -size2, size3, size2, size2, 0.5 }, -- z+ + }, + { + {-size1, -size1, -size1, 0.5, size1, size1}, -- x+ + { size3, -size2, -size2, 0.5, size2, size2}, -- x+ + }, + { + {-size1, -size1, -0.5, size1, size1, size1}, -- z- 2d5627 + {-size2, -size2, -0.5, size2, size2, -size3}, -- z- + }, + { + {-0.5, -size1, -size1, size1, size1, size1}, -- x- + {-0.5, -size2, -size2, -size3, size2, size2}, -- x- + }, + { + {-size1, -0.5, -size1, size1, size1, size1}, -- y- + {-size2, -0.5, -size2, size2, -size3, size2}, -- y- + }, + { + {-size1, -size1, -size1, size1, 0.5, size1}, -- y+ + {-size2, size3, -size2, size2, 0.5, size2}, -- y+ + } +} + +local names = networks.register_junction("techage:ta5_junctionpipe", 1/8, Boxes, Pipe, { + description = S("TA5 Junction Pipe"), + tiles = {"techage_ta5_gaspipe_junction.png"}, + use_texture_alpha = techage.CLIP, + is_ground_content = false, + groups = {crumbly = 2, cracky = 2, snappy = 2, techage_trowel = 1}, + sounds = default.node_sound_metal_defaults(), + + after_place_node = function(pos, placer, itemstack, pointed_thing) + local name = "techage:ta5_junctionpipe" .. networks.junction_type(pos, Pipe) + minetest.swap_node(pos, {name = name, param2 = 0}) + Pipe:after_place_node(pos) + end, + tubelib2_on_update2 = function(pos, dir1, tlib2, node) + if not networks.hidden_name(pos) then + local name = "techage:ta5_junctionpipe" .. networks.junction_type(pos, Pipe) + minetest.swap_node(pos, {name = name, param2 = 0}) + end + power.update_network(pos, 0, tlib2, node) + end, + after_dig_node = function(pos, oldnode, oldmetadata, digger) + Pipe:after_dig_node(pos) + end, +}, 25) + +power.register_nodes(names, Pipe, "junc") + +--minetest.register_craft({ +-- output = "techage:ta3_junctionpipe25 2", +-- recipe = { +-- {"", "techage:ta3_pipeS", ""}, +-- {"techage:ta3_pipeS", "", "techage:ta3_pipeS"}, +-- {"", "techage:ta3_pipeS", ""}, +-- }, +--}) + +--minetest.register_craft({ +-- output = "techage:ta3_pipeS 6", +-- recipe = { +-- {'', '', "techage:iron_ingot"}, +-- {'dye:yellow', 'default:steel_ingot', ''}, +-- {"techage:iron_ingot", '', ''}, +-- }, +--}) + +techage.GasPipe = Pipe diff --git a/init.lua b/init.lua index fe7b60c..accd883 100644 --- a/init.lua +++ b/init.lua @@ -398,6 +398,7 @@ dofile(MP.."/collider/worker.lua") dofile(MP.."/teleport/teleport_tube.lua") dofile(MP.."/teleport/teleport_pipe.lua") +dofile(MP.."/fusion_reactor/gas_pipe.lua") -- Prevent other mods from using IE techage.IE = nil diff --git a/move_controller/flycontroller.lua b/move_controller/flycontroller.lua index ca12aa1..2db7300 100644 --- a/move_controller/flycontroller.lua +++ b/move_controller/flycontroller.lua @@ -133,7 +133,7 @@ minetest.register_node("techage:ta5_flycontroller", { local path, err = fly.to_path(fields.path, MAX_DIST) if err then meta:set_string("status", err) - elseif path and nvm.lpos1 then + elseif path and nvm.lpos1 and nvm.lpos1[1] then local pos = table.copy(nvm.lpos1[1]) if pos then for _, offs in ipairs(path) do diff --git a/textures/techage_appl_hole_ta5_pipe.png b/textures/techage_appl_hole_ta5_pipe.png new file mode 100644 index 0000000000000000000000000000000000000000..e9ec6f84b55d873e806aa3a81b8979dede972885 GIT binary patch literal 120 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnH3?%tPCZz)@&H$efSN8%RAQMO$zkW6w$YLxB z@(X5gcy=QV$dUDQaSV~ToSd*gzaXK-XiJ!bFVdQ&MBb@01Gc3+yDRo literal 0 HcmV?d00001 diff --git a/textures/techage_ta5_gaspipe.png b/textures/techage_ta5_gaspipe.png new file mode 100644 index 0000000000000000000000000000000000000000..ab99682bf4264187839365de784c48b443d5944f GIT binary patch literal 132 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnH3?%tPCZz)@o&cW^SN8%R?|w(uW*f&^%Nbv; zO$CZGmIV0)GdMiEkp|?bdAc};NL)@%kOmdKI;Vst0PT?~#Q*>R literal 0 HcmV?d00001 diff --git a/textures/techage_ta5_gaspipe_hole.png b/textures/techage_ta5_gaspipe_hole.png new file mode 100644 index 0000000000000000000000000000000000000000..821059dd473e7eb885e2186fdad774e3f6c06546 GIT binary patch literal 129 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnH3?%tPCZz)@o&cW^SN8%R=SC~<364O47gBYe zK#H*>$S;_|;n|HeAV=BL#W6(Ua&p1~{TW+%PI2(I8a=B&e6pk6(CP4ko)t?=%Jdnk XtTbP0l+XkKR(d0{ literal 0 HcmV?d00001 diff --git a/textures/techage_ta5_gaspipe_hole2.png b/textures/techage_ta5_gaspipe_hole2.png new file mode 100644 index 0000000000000000000000000000000000000000..1491d8607c0db40cb8d219a4f125aab51ae56ba1 GIT binary patch literal 185 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnF3?v&v(vJfvp#Yx{SN8%R*A^SEJ_pBY3!s>$ zzlvByOE{3lSQ6wH%;50sMjDV4>gnPbqH+H2IYYq%0URy|^B+1eIx;3Oa(~QM)x0Fb zTdPr?cdy{wd%bl`j6OXFc1bRYR<|(UWjV`k(FKhD}WX-c)I$ztaD0e0sy`UI#>Vz literal 0 HcmV?d00001 diff --git a/textures/techage_ta5_gaspipe_junction.png b/textures/techage_ta5_gaspipe_junction.png new file mode 100644 index 0000000000000000000000000000000000000000..f5c44adfdb3ec0b3f9e54a3ffbb73d9921782911 GIT binary patch literal 243 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnF3?v&v(vJfv{s5m4SN8%Rmu744366H~ae%Vi}fm?|AvoSTxvm zRkZ6I`5DabbZ)yankN4`cG^&o>x}FXtLH3#gtS$a|GQXSI%oQBdx2?=a@@R-br%D& zx9H5}O4wxi@Zxp9rIiyUdtP1ezopr0HcXpga7~l literal 0 HcmV?d00001 diff --git a/textures/techage_ta5_gaspipe_knee.png b/textures/techage_ta5_gaspipe_knee.png new file mode 100644 index 0000000000000000000000000000000000000000..b0620924680af1eb10a2c48a6f145daa34db660e GIT binary patch literal 193 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnF3?v&v(vJfv{s5m4SN8%R*A^S^en;neD@}iu z*K=KW0Hqj9g8YIR9G=}s19B2PT^vI+&fh(ETChQZhb3T3Gp}gQ3WgO9$NyzF75oe0_|e(boFyt=akR{0G|v+@&Et; literal 0 HcmV?d00001 diff --git a/textures/techage_ta5_gaspipe_knee2.png b/textures/techage_ta5_gaspipe_knee2.png new file mode 100644 index 0000000000000000000000000000000000000000..f352736b61b93bb6736e0bfa999a614e72288d4d GIT binary patch literal 175 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnF3?v&v(vJfv{s5m4SN8%RmlkWUJ_q{>GfjV$ z?2yG*fl`bmL4Lsu4$p3+0Xcr2E{-7@=kNAz6m4+eaoWsuhvf+88J>6clQnZrh>Dd3 z{rle7ai3L|dFm9#ruOEuCrSbq^#?89boZD=rYmzn)1ldoUn`xTFKS%P literal 0 HcmV?d00001