2019-11-08 23:10:05 +03:00
|
|
|
--[[
|
|
|
|
|
|
|
|
TechAge
|
|
|
|
=======
|
|
|
|
|
2020-02-02 00:00:58 +03:00
|
|
|
Copyright (C) 2019-2020 Joachim Stolberg
|
2019-11-08 23:10:05 +03:00
|
|
|
|
|
|
|
GPL v3
|
|
|
|
See LICENSE.txt for more information
|
|
|
|
|
|
|
|
TA3 Distillation Tower
|
|
|
|
|
|
|
|
]]--
|
|
|
|
|
|
|
|
local S2P = minetest.string_to_pos
|
|
|
|
local P2S = minetest.pos_to_string
|
|
|
|
local M = minetest.get_meta
|
|
|
|
local S = techage.S
|
|
|
|
local Pipe = techage.LiquidPipe
|
|
|
|
local networks = techage.networks
|
|
|
|
local liquid = techage.liquid
|
|
|
|
|
|
|
|
|
|
|
|
local function orientation(pos, names)
|
|
|
|
local node = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z})
|
|
|
|
for _,name in ipairs(names) do
|
|
|
|
if node.name == name then
|
|
|
|
local param2 = node.param2
|
|
|
|
node = minetest.get_node(pos)
|
|
|
|
node.param2 = param2
|
|
|
|
minetest.swap_node(pos, node)
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
minetest.remove_node(pos)
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
local function after_place_node(pos, placer)
|
|
|
|
Pipe:after_place_node(pos)
|
|
|
|
end
|
|
|
|
|
|
|
|
local function tubelib2_on_update2(pos, dir, tlib2, node)
|
2020-02-09 23:09:09 +03:00
|
|
|
liquid.update_network(pos, dir, tlib2)
|
2019-11-08 23:10:05 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
local function after_dig_node(pos, oldnode, oldmetadata, digger)
|
|
|
|
Pipe:after_dig_node(pos)
|
|
|
|
end
|
|
|
|
|
|
|
|
minetest.register_node("techage:ta3_distiller_base", {
|
|
|
|
description = S("TA3 Distillation Tower Base"),
|
|
|
|
tiles = {
|
|
|
|
-- up, down, right, left, back, front
|
|
|
|
"techage_concrete.png^techage_appl_arrowXL.png^techage_appl_hole_pipe.png",
|
|
|
|
"techage_concrete.png",
|
|
|
|
"techage_concrete.png",
|
|
|
|
"techage_concrete.png",
|
|
|
|
"techage_concrete.png^techage_appl_hole_pipe.png",
|
|
|
|
"techage_concrete.png",
|
|
|
|
},
|
|
|
|
drawtype = "nodebox",
|
|
|
|
paramtype = "light",
|
|
|
|
node_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-6/8, -4/8, -6/8, 6/8, 4/8, 6/8},
|
|
|
|
},
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-1/2, -1/2, -1/2, 1/2, 1/2, 1/2},
|
|
|
|
},
|
|
|
|
collision_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-1/2, -1/2, -1/2, 1/2, 1/2, 1/2},
|
|
|
|
},
|
|
|
|
|
|
|
|
after_place_node = after_place_node,
|
|
|
|
tubelib2_on_update2 = tubelib2_on_update2,
|
|
|
|
after_dig_node = after_dig_node,
|
|
|
|
|
|
|
|
paramtype2 = "facedir",
|
|
|
|
on_rotate = screwdriver.disallow,
|
|
|
|
groups = {cracky=2},
|
|
|
|
is_ground_content = false,
|
2019-11-10 23:08:37 +03:00
|
|
|
sounds = default.node_sound_stone_defaults(),
|
2019-11-10 01:36:28 +03:00
|
|
|
|
|
|
|
networks = {
|
2020-01-31 21:55:10 +03:00
|
|
|
pipe2 = {
|
2019-11-10 01:36:28 +03:00
|
|
|
sides = {B=1}, -- Pipe connection sides
|
|
|
|
ntype = "pump",
|
|
|
|
},
|
|
|
|
},
|
2019-11-08 23:10:05 +03:00
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_node("techage:ta3_distiller1", {
|
|
|
|
description = S("TA3 Distillation Tower 1"),
|
|
|
|
tiles = {"techage_distiller1.png"},
|
|
|
|
drawtype = "mesh",
|
|
|
|
mesh = "techage_cylinder_14.obj",
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-1/2, -1/2, -1/2, 1/2, 1/2, 1/2},
|
|
|
|
},
|
|
|
|
collision_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-1/2, -1/2, -1/2, 1/2, 1/2, 1/2},
|
|
|
|
},
|
|
|
|
|
|
|
|
after_place_node = function(pos, placer)
|
|
|
|
local res = orientation(pos, {"techage:ta3_distiller_base"})
|
2019-11-10 01:36:28 +03:00
|
|
|
M(pos):set_int("outdir", networks.side_to_outdir(pos, "B"))
|
2019-11-08 23:10:05 +03:00
|
|
|
after_place_node(pos, placer)
|
|
|
|
return res
|
|
|
|
end,
|
|
|
|
|
|
|
|
tubelib2_on_update2 = tubelib2_on_update2,
|
|
|
|
after_dig_node = after_dig_node,
|
|
|
|
|
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "facedir",
|
|
|
|
on_rotate = screwdriver.disallow,
|
|
|
|
groups = {cracky=2},
|
|
|
|
is_ground_content = false,
|
|
|
|
sounds = default.node_sound_metal_defaults(),
|
2019-11-10 01:36:28 +03:00
|
|
|
|
|
|
|
networks = {
|
2020-01-31 21:55:10 +03:00
|
|
|
pipe2 = {
|
2019-11-10 01:36:28 +03:00
|
|
|
sides = {F=1}, -- Pipe connection sides
|
|
|
|
ntype = "tank",
|
|
|
|
},
|
|
|
|
},
|
2019-11-08 23:10:05 +03:00
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_node("techage:ta3_distiller2", {
|
|
|
|
description = S("TA3 Distillation Tower 2"),
|
|
|
|
tiles = {"techage_distiller2.png"},
|
|
|
|
drawtype = "mesh",
|
|
|
|
mesh = "techage_cylinder_14.obj",
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-1/2, -1/2, -1/2, 1/2, 1/2, 1/2},
|
|
|
|
},
|
|
|
|
collision_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-1/2, -1/2, -1/2, 1/2, 1/2, 1/2},
|
|
|
|
},
|
|
|
|
|
|
|
|
after_place_node = function(pos, placer)
|
|
|
|
return orientation(pos, {"techage:ta3_distiller1", "techage:ta3_distiller3"})
|
|
|
|
end,
|
|
|
|
|
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "facedir",
|
|
|
|
on_rotate = screwdriver.disallow,
|
|
|
|
groups = {cracky=2},
|
|
|
|
is_ground_content = false,
|
|
|
|
sounds = default.node_sound_metal_defaults(),
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_node("techage:ta3_distiller3", {
|
|
|
|
description = S("TA3 Distillation Tower 3"),
|
|
|
|
tiles = {"techage_distiller3.png"},
|
|
|
|
drawtype = "mesh",
|
|
|
|
mesh = "techage_cylinder_14.obj",
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-1/2, -1/2, -1/2, 1/2, 1/2, 1/2},
|
|
|
|
},
|
|
|
|
collision_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-1/2, -1/2, -1/2, 1/2, 1/2, 1/2},
|
|
|
|
},
|
|
|
|
|
|
|
|
after_place_node = function(pos, placer)
|
|
|
|
local res = orientation(pos, {"techage:ta3_distiller2"})
|
|
|
|
return res
|
|
|
|
end,
|
|
|
|
|
|
|
|
tubelib2_on_update2 = tubelib2_on_update2,
|
|
|
|
after_dig_node = after_dig_node,
|
|
|
|
|
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "facedir",
|
|
|
|
on_rotate = screwdriver.disallow,
|
|
|
|
groups = {cracky=2},
|
|
|
|
is_ground_content = false,
|
|
|
|
sounds = default.node_sound_metal_defaults(),
|
2019-11-10 01:36:28 +03:00
|
|
|
|
|
|
|
networks = {
|
2020-01-31 21:55:10 +03:00
|
|
|
pipe2 = {
|
2019-11-10 01:36:28 +03:00
|
|
|
sides = {B=1}, -- Pipe connection sides
|
|
|
|
ntype = "pump",
|
|
|
|
},
|
|
|
|
},
|
2019-11-08 23:10:05 +03:00
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_node("techage:ta3_distiller4", {
|
|
|
|
description = S("TA3 Distillation Tower 4"),
|
|
|
|
tiles = {"techage_distiller4.png"},
|
|
|
|
drawtype = "mesh",
|
|
|
|
mesh = "techage_cylinder_14.obj",
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-1/2, -1/2, -1/2, 1/2, 1/2, 1/2},
|
|
|
|
},
|
|
|
|
collision_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-1/2, -1/2, -1/2, 1/2, 1/2, 1/2},
|
|
|
|
},
|
|
|
|
|
|
|
|
after_place_node = function(pos, placer)
|
|
|
|
local res = orientation(pos, {"techage:ta3_distiller3"})
|
|
|
|
after_place_node(pos, placer)
|
|
|
|
return res
|
|
|
|
end,
|
|
|
|
|
|
|
|
tubelib2_on_update2 = tubelib2_on_update2,
|
|
|
|
after_dig_node = after_dig_node,
|
|
|
|
|
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "facedir",
|
|
|
|
on_rotate = screwdriver.disallow,
|
|
|
|
groups = {cracky=2},
|
|
|
|
is_ground_content = false,
|
|
|
|
sounds = default.node_sound_metal_defaults(),
|
2019-11-10 01:36:28 +03:00
|
|
|
|
|
|
|
networks = {
|
2020-01-31 21:55:10 +03:00
|
|
|
pipe2 = {
|
2019-11-10 01:36:28 +03:00
|
|
|
sides = {U=1}, -- Pipe connection sides
|
|
|
|
ntype = "pump",
|
|
|
|
},
|
|
|
|
},
|
2019-11-08 23:10:05 +03:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
Pipe:add_secondary_node_names({
|
2019-11-10 01:36:28 +03:00
|
|
|
"techage:ta3_distiller_base", "techage:ta3_distiller1",
|
2019-11-08 23:10:05 +03:00
|
|
|
"techage:ta3_distiller3", "techage:ta3_distiller4",
|
|
|
|
})
|
|
|
|
|
2019-11-10 01:36:28 +03:00
|
|
|
local Liquids = {
|
|
|
|
[-1] = "techage:bitumen",
|
|
|
|
[2] = "techage:fueloil",
|
|
|
|
[4] = "techage:naphtha",
|
|
|
|
[6] = "techage:gasoline",
|
|
|
|
[7] = "techage:gas",
|
|
|
|
}
|
|
|
|
|
2019-11-08 23:10:05 +03:00
|
|
|
techage.register_node({"techage:ta3_distiller1"}, {
|
2019-11-10 01:36:28 +03:00
|
|
|
on_transfer = function(pos, in_dir, topic, payload)
|
2019-11-08 23:10:05 +03:00
|
|
|
if topic == "put" then
|
2019-11-10 01:36:28 +03:00
|
|
|
local leftover = 0
|
|
|
|
local outdir = M(pos):get_int("outdir")
|
|
|
|
for _,y in ipairs({-1, 2, 4, 6, 7}) do
|
|
|
|
local pos2 = {x = pos.x, y = pos.y + y, z = pos.z}
|
|
|
|
if y == 7 then
|
|
|
|
outdir = 6
|
|
|
|
end
|
|
|
|
leftover = leftover + liquid.put(pos2, outdir, Liquids[y], 1)
|
2019-11-08 23:10:05 +03:00
|
|
|
end
|
2019-11-10 01:36:28 +03:00
|
|
|
return leftover
|
2019-11-08 23:10:05 +03:00
|
|
|
end
|
|
|
|
end,
|
|
|
|
})
|
2019-11-10 01:36:28 +03:00
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
output = 'techage:ta3_distiller2',
|
|
|
|
recipe = {
|
|
|
|
{'default:steel_ingot', 'default:tin_ingot', 'default:steel_ingot'},
|
|
|
|
{'techage:iron_ingot', 'techage:ta3_barrel_empty', 'techage:iron_ingot'},
|
|
|
|
{'default:steel_ingot', 'default:tin_ingot', 'default:steel_ingot'},
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
output = 'techage:ta3_distiller1',
|
|
|
|
recipe = {
|
|
|
|
{'', '', ''},
|
|
|
|
{'techage:ta3_pipeS', 'techage:ta3_distiller2', ''},
|
|
|
|
{'', '', ''},
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
output = 'techage:ta3_distiller3',
|
|
|
|
recipe = {
|
|
|
|
{'', '', ''},
|
|
|
|
{'', 'techage:ta3_distiller2', 'techage:ta3_pipeS'},
|
|
|
|
{'', '', ''},
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
output = 'techage:ta3_distiller4',
|
|
|
|
recipe = {
|
|
|
|
{'', 'techage:ta3_pipeS', ''},
|
|
|
|
{'', 'techage:ta3_distiller2', ''},
|
|
|
|
{'', '', ''},
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
output = 'techage:ta3_distiller_base',
|
|
|
|
recipe = {
|
|
|
|
{'basic_materials:concrete_block', 'techage:ta3_pipeS', 'basic_materials:concrete_block'},
|
|
|
|
{'', 'techage:ta3_pipeS', 'techage:ta3_pipeS'},
|
|
|
|
{'basic_materials:concrete_block', '', 'basic_materials:concrete_block'},
|
|
|
|
}
|
|
|
|
})
|