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 0000000..e86ad35 Binary files /dev/null and b/textures/techage_appl_arrow2.png differ diff --git a/textures/techage_server2_back.png b/textures/techage_server2_back.png index c8c3da3..c91583d 100644 Binary files a/textures/techage_server2_back.png and b/textures/techage_server2_back.png differ diff --git a/textures/techage_server2_front.png b/textures/techage_server2_front.png index 0240dc0..973849e 100644 Binary files a/textures/techage_server2_front.png and b/textures/techage_server2_front.png differ diff --git a/textures/techage_tube_junction.png b/textures/techage_tube_junction.png new file mode 100644 index 0000000..b94402a Binary files /dev/null and b/textures/techage_tube_junction.png differ diff --git a/textures/techage_tubeta4_junction.png b/textures/techage_tubeta4_junction.png new file mode 100644 index 0000000..0c27a9d Binary files /dev/null and b/textures/techage_tubeta4_junction.png differ