Add ta2 + ta4 concentrator tubes, add grinder farming recipes

This commit is contained in:
Joachim Stolberg 2021-05-13 17:24:02 +02:00
parent 555166d58e
commit 57c82c55a3
9 changed files with 164 additions and 4 deletions

View File

@ -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", ""},
},
})

View File

@ -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

View File

@ -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")

View File

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 283 B

After

Width:  |  Height:  |  Size: 272 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 283 B

After

Width:  |  Height:  |  Size: 269 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 413 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 404 B