From 57c82c55a3b0ffecca7cb151061de46506985b8a Mon Sep 17 00:00:00 2001 From: Joachim Stolberg Date: Thu, 13 May 2021 17:24:02 +0200 Subject: [PATCH] Add ta2 + ta4 concentrator tubes, add grinder farming recipes --- basic_machines/concentrator.lua | 125 ++++++++++++++++++++++++++ basic_machines/grinder.lua | 13 +++ init.lua | 1 + power/junction.lua | 29 +++++- textures/techage_appl_arrow2.png | Bin 0 -> 116 bytes textures/techage_server2_back.png | Bin 283 -> 272 bytes textures/techage_server2_front.png | Bin 283 -> 269 bytes textures/techage_tube_junction.png | Bin 0 -> 413 bytes textures/techage_tubeta4_junction.png | Bin 0 -> 404 bytes 9 files changed, 164 insertions(+), 4 deletions(-) create mode 100644 basic_machines/concentrator.lua create mode 100644 textures/techage_appl_arrow2.png create mode 100644 textures/techage_tube_junction.png create mode 100644 textures/techage_tubeta4_junction.png diff --git a/basic_machines/concentrator.lua b/basic_machines/concentrator.lua new file mode 100644 index 0000000..5f5f1cf --- /dev/null +++ b/basic_machines/concentrator.lua @@ -0,0 +1,125 @@ +--[[ + + TechAge + ======= + + Copyright (C) 2019-2021 Joachim Stolberg + + AGPL v3 + See LICENSE.txt for more information + + Tube Concentrator + +]]-- + +-- for lazy programmers +local M = minetest.get_meta +local S = techage.S + +local networks = techage.networks +local Tube = techage.Tube + +local size = 2/8 +local Boxes = { + {{-size, -size, size, size, size, 0.5 }}, -- z+ + {{-size, -size, -size, 0.5, size, size}}, -- x+ + {{-size, -size, -0.5, size, size, size}}, -- z- + {{-0.5, -size, -size, size, size, size}}, -- x- + {{-size, -0.5, -size, size, size, size}}, -- y- + {{-size, -size, -size, size, 0.5, size}}, -- y+ +} + +local names = techage.register_junction("techage:concentrator", 2/8, Boxes, Tube, { + description = S("Tube Concentrator"), + tiles = { + "techage_tube_junction.png^techage_appl_arrow2.png^[transformR270", + "techage_tube_junction.png^techage_appl_arrow2.png^[transformR270", + "techage_tube_junction.png^techage_tube_hole.png", + "techage_tube_junction.png", + "techage_tube_junction.png^techage_appl_arrow2.png^[transformR90", + "techage_tube_junction.png^techage_appl_arrow2.png^[transformR270", + }, + paramtype2 = "facedir", -- important! + groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 3, techage_trowel = 1}, + sounds = default.node_sound_defaults(), + + after_place_node = function(pos, placer, itemstack, pointed_thing) + local node = minetest.get_node(pos) + local name = "techage:concentrator"..techage.junction_type(pos, Tube, "R", node.param2) + minetest.swap_node(pos, {name = name, param2 = node.param2}) + M(pos):set_int("push_dir", techage.side_to_outdir("R", node.param2)) + Tube:after_place_node(pos) + end, + tubelib2_on_update2 = function(pos, dir1, tlib2, node) + local name = "techage:concentrator"..techage.junction_type(pos, Tube, "R", node.param2) + minetest.swap_node(pos, {name = name, param2 = node.param2}) + end, + after_dig_node = function(pos, oldnode, oldmetadata, digger) + Tube:after_dig_node(pos) + end, +}, 2) + +techage.register_node(names, { + on_push_item = function(pos, in_dir, stack) + local push_dir = M(pos):get_int("push_dir") + return techage.push_items(pos, push_dir, stack) + end, + is_pusher = true, -- is a pulling/pushing node +}) + +names = techage.register_junction("techage:ta4_concentrator", 2/8, Boxes, Tube, { + description = S("Tube Concentrator"), + tiles = { + "techage_tubeta4_junction.png^techage_appl_arrow2.png^[transformR270", + "techage_tubeta4_junction.png^techage_appl_arrow2.png^[transformR270", + "techage_tubeta4_junction.png^techage_tube_hole.png", + "techage_tubeta4_junction.png", + "techage_tubeta4_junction.png^techage_appl_arrow2.png^[transformR90", + "techage_tubeta4_junction.png^techage_appl_arrow2.png^[transformR270", + }, + paramtype2 = "facedir", -- important! + groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 3, techage_trowel = 1}, + sounds = default.node_sound_defaults(), + + after_place_node = function(pos, placer, itemstack, pointed_thing) + local node = minetest.get_node(pos) + local name = "techage:ta4_concentrator"..techage.junction_type(pos, Tube, "R", node.param2) + minetest.swap_node(pos, {name = name, param2 = node.param2}) + M(pos):set_int("push_dir", techage.side_to_outdir("R", node.param2)) + Tube:after_place_node(pos) + end, + tubelib2_on_update2 = function(pos, dir1, tlib2, node) + local name = "techage:ta4_concentrator"..techage.junction_type(pos, Tube, "R", node.param2) + minetest.swap_node(pos, {name = name, param2 = node.param2}) + end, + after_dig_node = function(pos, oldnode, oldmetadata, digger) + Tube:after_dig_node(pos) + end, +}, 2) + +techage.register_node(names, { + on_push_item = function(pos, in_dir, stack) + local push_dir = M(pos):get_int("push_dir") + return techage.push_items(pos, push_dir, stack) + end, + is_pusher = true, -- is a pulling/pushing node +}) + + +minetest.register_craft({ + output = "techage:electric_concentrator2", + recipe = { + {"", "techage:tubeS", ""}, + {"techage:tubeS", "", "techage:tubeS"}, + {"", "techage:tubeS", ""}, + }, +}) + +minetest.register_craft({ + output = "techage:electric_ta4_concentrator2", + recipe = { + {"", "techage:ta4_tubeS", ""}, + {"ta4_techage:tubeS", "", "ta4_techage:tubeS"}, + {"", "ta4_techage:tubeS", ""}, + }, +}) diff --git a/basic_machines/grinder.lua b/basic_machines/grinder.lua index c406ba2..1094a6c 100644 --- a/basic_machines/grinder.lua +++ b/basic_machines/grinder.lua @@ -299,3 +299,16 @@ techage.add_grinder_recipe({input="default:jungletree", output="default:junglele techage.add_grinder_recipe({input="default:pine_tree", output="default:pine_needles 8"}) techage.add_grinder_recipe({input="default:acacia_tree", output="default:acacia_leaves 8"}) techage.add_grinder_recipe({input="default:aspen_tree", output="default:aspen_leaves 8"}) + +if minetest.global_exists("farming") then + techage.add_grinder_recipe({input="farming:wheat 3", output="farming:flour"}) + techage.add_grinder_recipe({input="farming:seed_wheat 6", output="farming:flour"}) + techage.add_grinder_recipe({input="farming:barley 3", output="farming:flour"}) + techage.add_grinder_recipe({input="farming:seed_barley 6", output="farming:flour"}) + techage.add_grinder_recipe({input="farming:rye 3", output="farming:flour"}) + techage.add_grinder_recipe({input="farming:seed_rye 6", output="farming:flour"}) + techage.add_grinder_recipe({input="farming:rice 3", output="farming:rice_flour"}) + techage.add_grinder_recipe({input="farming:seed_rice 6", output="farming:rice_flour"}) + techage.add_grinder_recipe({input="farming:oat 3", output="farming:flour"}) + techage.add_grinder_recipe({input="farming:seed_oat 6", output="farming:flour"}) +end diff --git a/init.lua b/init.lua index 6b08220..d09930c 100644 --- a/init.lua +++ b/init.lua @@ -167,6 +167,7 @@ dofile(MP.."/basic_machines/ta4_chest.lua") dofile(MP.."/basic_machines/ta4_injector.lua") dofile(MP.."/basic_machines/itemsource.lua") dofile(MP.."/basic_machines/recycler.lua") +dofile(MP.."/basic_machines/concentrator.lua") -- Liquids II dofile(MP.."/liquids/tank.lua") diff --git a/power/junction.lua b/power/junction.lua index 9252e2c..e14c3ef 100644 --- a/power/junction.lua +++ b/power/junction.lua @@ -52,6 +52,7 @@ end -- 'node' is the node definition with tiles, callback functions, and so on -- 'index' number for the inventory node (default 0) function techage.register_junction(name, size, boxes, tlib2, node, index) + local names = {} for idx = 0,63 do local ndef = table.copy(node) if idx == (index or 0) then @@ -73,21 +74,41 @@ function techage.register_junction(name, size, boxes, tlib2, node, index) tlib2:add_secondary_node_names({name..idx}) -- for the case that 'tlib2.force_to_use_tubes' is set tlib2:add_special_node_names({name..idx}) + names[#names + 1] = name..idx end + return names end -function techage.junction_type(pos, network) +local SideToDir = {B=1, R=2, F=3, L=4} +local function dir_to_dir2(dir, param2) + if param2 == 0 then + return dir + elseif param2 == 1 then + return ({4,1,2,3,5,6})[dir] + elseif param2 == 2 then + return ({3,4,1,2,5,6})[dir] + elseif param2 == 3 then + return ({2,3,4,1,5,6})[dir] + end + return dir +end + +function techage.junction_type(pos, network, default_side, param2) local val = 0 + if default_side then + val = setbit(val, bit(SideToDir[default_side])) + end for dir = 1,6 do + local dir2 = dir_to_dir2(dir, param2) if network.force_to_use_tubes then if network:friendly_primary_node(pos, dir) then - val = setbit(val, bit(dir)) + val = setbit(val, bit(dir2)) elseif network:is_special_node(pos, dir) then - val = setbit(val, bit(dir)) + val = setbit(val, bit(dir2)) end else if network:connected(pos, dir) then - val = setbit(val, bit(dir)) + val = setbit(val, bit(dir2)) end end end diff --git a/textures/techage_appl_arrow2.png b/textures/techage_appl_arrow2.png new file mode 100644 index 0000000000000000000000000000000000000000..e86ad35de6cbaac5e4a0c255d4df0ac13ca393a7 GIT binary patch literal 116 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnL3?x0byx0z;*aCb)T-^(NfXw+?ErCFau_VYZ zn8D%MjWi%f#?!?ygyVX0f&+68uS3&Mh6xGv3@ShD4R|yd7?$}nYnv>b76(+v;OXk; Jvd$@?2>_7_8|eT5 literal 0 HcmV?d00001 diff --git a/textures/techage_server2_back.png b/textures/techage_server2_back.png index c8c3da38fb329a83b3fc5ce4175aacbe942460e1..c91583d0c4f3474cfa682f16c22b100a23e617e8 100644 GIT binary patch delta 244 zcmVfitYWzC5fo?Drm#a}bo(h_Aw}hgD<>ffKAqrLn-LOeB&S8dqYli=JoQ!%o uFc=?*N$?5vmvJxu!LUl92ZAzg|MdZ-jau0unm&a90000%S_Tseg*Up64_C{nON zE-QG-h~RMfxX3S5JRUlMu%0O|G+>1=01|@)!@wND?L3nax}n3=|N2wHLR`1g1#8v9zDzlRKpZn6LX diff --git a/textures/techage_server2_front.png b/textures/techage_server2_front.png index 0240dc08cace3e502e16d3a6b301171d4e154a54..973849e58587d6d7287a367ca82389a5e1782fa1 100644 GIT binary patch delta 241 zcmV~R;(#20qF~>@^YXm$%Zs2JXp-f~~tbdR8 rU(SIt(EhU<@Wy{X?zbPyefHx61fJL z5WSdkg1|~Rpa?5c$C47^S@9K+;*o!#DVqUJ$(XfRWj0Bh5|FeMqa>_6Wvxp2whTji z97Vs^=>F4DOt5Yr!b_F|ATS91XYarh|NA)KecaA-A8+%CoCh>5h1UQ8002ovPDHLk FV1m_PZ{q*} diff --git a/textures/techage_tube_junction.png b/textures/techage_tube_junction.png new file mode 100644 index 0000000000000000000000000000000000000000..b94402aa80652c61ef66af8bba8fe7fcf9504b57 GIT binary patch literal 413 zcmV;O0b>4%P)E1SYrLN8h5!Hn0d!JMQvg8b*k%9#0V+vE zK~yNuO_9H9#4rrT{R(Oz$Bi|pO>YYh&3q)>0|*3K)4}^)pr&geaO-s`Ui+k#lje^@ z%*T&U_>*Le9*YCt?O@GvPL>&&epg^$`|=RKHwT5@K@7BlG4`c`adX7pm0{=LN8c#m zt>i0#!(3tu5@8Y2Ur@80GyoE(50NyBeFoqhs_G03@MH}E04iwDfGXLH06F^!s3R{7 zwQVaikR%Q3y*N~o8TBrFmq4KsQ%S=*@eAxL6hST8>(r97UqU700000NkvXX Hu0mjf?%cAG literal 0 HcmV?d00001 diff --git a/textures/techage_tubeta4_junction.png b/textures/techage_tubeta4_junction.png new file mode 100644 index 0000000000000000000000000000000000000000..0c27a9dd5dd7e8cf6bdfb07e2e58e14cbef1e94f GIT binary patch literal 404 zcmV;F0c-w=P)Ix$HpIQZyD2ZQ%g)Nh#>20%uIcOOIzO_Vo}44D0!07-00DGTPE!Ct z=GbNc009_DL_t(2&t=jvOT;h~2k`e5(m=)Wnx%(R5)ivLn`2ZE9g5hqZZ0a0Culo* z1!+Hk3WpBonpGF6ql@@qd}%po+BcN&h!h!9sU8RB#68`6*C0@0000