items bauxite, gibbsite, aluminum, red mud, powders, lye added

nodes silo and furnace heater added
chemical doser/reactor activated
netID location (networks) moved to pumps
expoxy recipe changed
files/folders restructured
This commit is contained in:
Joachim Stolberg 2019-11-17 00:08:10 +01:00
parent 0ee5c82b49
commit 0a6392b2b9
71 changed files with 1305 additions and 324 deletions

View File

@ -293,5 +293,4 @@ techage.add_grinder_recipe({input="default:pine_tree", output="default:pine_need
techage.add_grinder_recipe({input="default:acacia_tree", output="default:acacia_leaves 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"}) techage.add_grinder_recipe({input="default:aspen_tree", output="default:aspen_leaves 8"})
techage.add_grinder_recipe({input="techage:bauxite_cobble", output="techage:bauxite_gravel"})

View File

@ -157,18 +157,17 @@ end
-- do the walk through the tubelib2 network -- do the walk through the tubelib2 network
-- indir is the direction which should not be covered by the walk -- indir is the direction which should not be covered by the walk
-- (coming from there or is a different network) -- (coming from there)
local function connection_walk(pos, indir, node, tlib2, lvl, clbk) -- if outdirs is given, only this dirs are used
local function connection_walk(pos, outdirs, indir, node, tlib2, clbk)
if clbk then clbk(pos, indir, node) end if clbk then clbk(pos, indir, node) end
--techage.mark_position("singleplayer", pos, "walk", "", 1) --techage.mark_position("singleplayer", pos, "walk", "", 1)
if lvl == 1 or net_def2(node.name, tlib2.tube_type).ntype == "junc" then if outdirs or net_def2(node.name, tlib2.tube_type).ntype == "junc" then
for _,outdir in pairs(get_node_connections(pos, tlib2.tube_type)) do for _,outdir in pairs(outdirs or get_node_connections(pos, tlib2.tube_type)) do
if outdir ~= Flip[indir] then local pos2, indir2 = tlib2:get_connected_node_pos(pos, outdir)
local pos2, indir2 = tlib2:get_connected_node_pos(pos, outdir) local node = techage.get_node_lvm(pos2)
local node = techage.get_node_lvm(pos2) if pos2 and not pos_already_reached(pos2) and valid_indir(indir2, node, tlib2.tube_type) then
if pos2 and not pos_already_reached(pos2) and valid_indir(indir2, node, tlib2.tube_type) then connection_walk(pos2, nil, indir2, node, tlib2, clbk)
connection_walk(pos2, indir2, node, tlib2, lvl + 1, clbk)
end
end end
end end
end end
@ -183,7 +182,7 @@ local function collect_network_nodes(pos, outdir, tlib2)
local node = techage.get_node_lvm(pos) local node = techage.get_node_lvm(pos)
local net_name = tlib2.tube_type local net_name = tlib2.tube_type
-- outdir corresponds to the indir coming from -- outdir corresponds to the indir coming from
connection_walk(pos, outdir, node, tlib2, 1, function(pos, indir, node) connection_walk(pos, outdir and {outdir}, nil, node, tlib2, function(pos, indir, node)
local ntype = net_def2(node.name, net_name).ntype local ntype = net_def2(node.name, net_name).ntype
if ntype then if ntype then
if not netw[ntype] then netw[ntype] = {} end if not netw[ntype] then netw[ntype] = {} end
@ -246,7 +245,7 @@ function techage.networks.connection_walk(pos, outdir, tlib2, clbk)
NumNodes = 0 NumNodes = 0
pos_already_reached(pos) -- don't consider the start pos pos_already_reached(pos) -- don't consider the start pos
local node = techage.get_node_lvm(pos) local node = techage.get_node_lvm(pos)
connection_walk(pos, outdir, node, tlib2, 1, clbk) connection_walk(pos, {outdir}, Flip[outdir], node, tlib2, clbk)
return NumNodes return NumNodes
end end

View File

@ -22,6 +22,18 @@ local range = techage.range
techage.recipes = {} techage.recipes = {}
local RECIPE = {
output = {name = "", num = 0},
waste = {name = "", num = 0},
input = {
{name = "", num =0},
{name = "", num =0},
{name = "", num =0},
{name = "", num =0},
},
}
-- Formspec -- Formspec
local function input_string(recipe) local function input_string(recipe)
local tbl = {} local tbl = {}
@ -88,7 +100,7 @@ function techage.recipes.formspec(x, y, rtype, mem)
local recipe_list = RecipeList[rtype] or {} local recipe_list = RecipeList[rtype] or {}
mem.recipe_idx = range(mem.recipe_idx or 1, 1, #recipe_list) mem.recipe_idx = range(mem.recipe_idx or 1, 1, #recipe_list)
local idx = mem.recipe_idx local idx = mem.recipe_idx
local recipe = recipes[recipe_list[idx]] local recipe = recipes[recipe_list[idx]] or RECIPE
local output = recipe.output.name.." "..recipe.output.num local output = recipe.output.name.." "..recipe.output.num
local waste = recipe.waste.name.." "..recipe.waste.num local waste = recipe.waste.name.." "..recipe.waste.num
return "container["..x..","..y.."]".. return "container["..x..","..y.."]"..

View File

@ -1,21 +0,0 @@
--[[
TechAge
=======
Copyright (C) 2019 Joachim Stolberg
GPL v3
See LICENSE.txt for more information
TA4 Doser
]]--
recipes.add("ta4_doser", {
output = "techage:ta4_epoxy 3",
input = {
"techage:oil_source 2",
"basic_materials:oil_extract 1",
}
})

View File

@ -12,10 +12,12 @@
]]-- ]]--
local S = techage.S local S2P = minetest.string_to_pos
local P2S = minetest.pos_to_string
local M = minetest.get_meta local M = minetest.get_meta
local N = function(pos) return minetest.get_node(pos).name end local S = techage.S
local Pipe = techage.BiogasPipe local Pipe = techage.LiquidPipe
local networks = techage.networks
local liquid = techage.liquid local liquid = techage.liquid
local recipes = techage.recipes local recipes = techage.recipes
@ -23,7 +25,27 @@ local Liquids = {} -- {hash(pos) = {name = outdir},...}
local STANDBY_TICKS = 4 local STANDBY_TICKS = 4
local COUNTDOWN_TICKS = 4 local COUNTDOWN_TICKS = 4
local CYCLE_TIME = 4 local CYCLE_TIME = 10
-- to mark the pump source and destinstion node
local DebugCache = {}
local function set_starter_name(pos, clicker)
local key = minetest.hash_node_position(pos)
DebugCache[key] = {starter = clicker:get_player_name(), count = 10}
end
local function get_starter_name(pos)
local key = minetest.hash_node_position(pos)
local def = DebugCache[key]
if def then
def.count = (def.count or 0) - 1
if def.count > 0 then
return def.starter
end
DebugCache[key] = nil
end
end
local function formspec(self, pos, mem) local function formspec(self, pos, mem)
return "size[8,7]".. return "size[8,7]"..
@ -85,6 +107,7 @@ end
local function start_node(pos, mem, state) local function start_node(pos, mem, state)
reactor_cmnd(pos, "start") reactor_cmnd(pos, "start")
del_liquids(pos)
mem.running = true mem.running = true
end end
@ -105,34 +128,44 @@ local State = techage.NodeStates:new({
stop_node = stop_node, stop_node = stop_node,
}) })
local function reset_dosing(mem)
-- alle 4 ports checken und inputs vorladen
end
local function dosing(pos, mem, elapsed) local function dosing(pos, mem, elapsed)
-- trigger reactor (power) -- trigger reactor (power)
if not reactor_cmnd(pos, "power") then if not reactor_cmnd(pos, "power") then
if not mem.techage_countdown or mem.techage_countdown < 2 then if not mem.techage_countdown or mem.techage_countdown < 3 then
reactor_cmnd(pos, "stop")
State:nopower(pos, mem, S("reactor has no power")) State:nopower(pos, mem, S("reactor has no power"))
end end
State:idle(pos, mem) State:idle(pos, mem)
return return
end end
-- check from time to time
mem.check_cnt = (mem.check_cnt or 0) + 1
if mem.check_cnt >= 4 then
mem.check_cnt = 0
local res = reactor_cmnd(pos, "check")
if not res then
State:fault(pos, mem, S("reactor defect"))
reactor_cmnd(pos, "stop")
return
end
end
-- available liquids -- available liquids
local liquids = get_liquids(pos) local liquids = get_liquids(pos)
local recipe = recipes.get(mem, "ta4_doser") local recipe = recipes.get(mem, "ta4_doser")
if not liquids or not recipe then return end if not liquids or not recipe then return end
-- inputs -- inputs
local starter = get_starter_name(pos)
for _,item in pairs(recipe.input) do for _,item in pairs(recipe.input) do
if item.name ~= "" then if item.name ~= "" then
print("dosing", item.name, dump(liquids))
local outdir = liquids[item.name] local outdir = liquids[item.name]
if not outdir then if not outdir then
State:fault(pos, mem, S("input missing")) State:standby(pos, mem)
reactor_cmnd(pos, "stop")
return return
end end
if liquid.take(pos, outdir, item.name, item.num) < item.num then if liquid.take(pos, outdir, item.name, item.num, starter) < item.num then
State:fault(pos, mem, S("input missing")) State:standby(pos, mem)
reactor_cmnd(pos, "stop")
return return
end end
end end
@ -142,16 +175,18 @@ local function dosing(pos, mem, elapsed)
leftover = reactor_cmnd(pos, "output", { leftover = reactor_cmnd(pos, "output", {
name = recipe.output.name, name = recipe.output.name,
amount = recipe.output.num}) amount = recipe.output.num})
if not leftover or leftover > 0 then if not leftover or (tonumber(leftover) or 1) > 0 then
State:fault(pos, mem, S("output blocked")) State:blocked(pos, mem)
reactor_cmnd(pos, "stop")
return return
end end
if recipe.waste.name ~= "" then if recipe.waste.name ~= "" then
leftover = reactor_cmnd(pos, "waste", { leftover = reactor_cmnd(pos, "waste", {
name = recipe.waste.name, name = recipe.waste.name,
amount = recipe.waste.num}) amount = recipe.waste.num})
if not leftover or leftover > 0 then if not leftover or (tonumber(leftover) or 1) > 0 then
State:fault(pos, mem, S("output blocked")) State:blocked(pos, mem)
reactor_cmnd(pos, "stop")
return return
end end
end end
@ -178,10 +213,18 @@ local function on_receive_fields(pos, formname, fields, player)
if not mem.running then if not mem.running then
recipes.on_receive_fields(pos, formname, fields, player) recipes.on_receive_fields(pos, formname, fields, player)
end end
set_starter_name(pos, player)
State:state_button_event(pos, mem, fields) State:state_button_event(pos, mem, fields)
M(pos):set_string("formspec", formspec(State, pos, mem)) M(pos):set_string("formspec", formspec(State, pos, mem))
end end
local nworks = {
pipe = {
sides = techage.networks.AllSides, -- Pipe connection sides
ntype = "pump",
},
}
minetest.register_node("techage:ta4_doser", { minetest.register_node("techage:ta4_doser", {
description = S("TA4 Doser"), description = S("TA4 Doser"),
@ -189,12 +232,33 @@ minetest.register_node("techage:ta4_doser", {
-- up, down, right, left, back, front -- up, down, right, left, back, front
"techage_filling_ta4.png^techage_frame_ta4_top.png^techage_appl_hole_pipe.png", "techage_filling_ta4.png^techage_frame_ta4_top.png^techage_appl_hole_pipe.png",
"techage_filling_ta4.png^techage_frame_ta4.png", "techage_filling_ta4.png^techage_frame_ta4.png",
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_pump.png^techage_appl_hole_pipe.png", "techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_pump_up.png",
}, },
after_place_node = function(pos, placer)
local meta = M(pos)
local mem = tubelib2.init_mem(pos)
local number = techage.add_node(pos, "techage:ta4_doser")
meta:set_string("node_number", number)
meta:set_string("owner", placer:get_player_name())
meta:set_string("formspec", formspec(State, pos, mem))
meta:set_string("infotext", S("TA4 Doser").." "..number)
State:node_init(pos, mem, number)
Pipe:after_place_node(pos)
end,
tubelib2_on_update2 = function(pos, dir, tlib2, node)
liquid.update_network(pos, dir)
del_liquids(pos)
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
techage.remove_node(pos)
Pipe:after_dig_node(pos)
tubelib2.del_mem(pos)
end,
on_receive_fields = on_receive_fields, on_receive_fields = on_receive_fields,
on_rightclick = on_rightclick, on_rightclick = on_rightclick,
on_timer = node_timer, on_timer = node_timer,
networks = nworks,
paramtype2 = "facedir", paramtype2 = "facedir",
on_rotate = screwdriver.disallow, on_rotate = screwdriver.disallow,
@ -210,7 +274,7 @@ minetest.register_node("techage:ta4_doser_on", {
"techage_filling_ta4.png^techage_frame_ta4_top.png^techage_appl_hole_pipe.png", "techage_filling_ta4.png^techage_frame_ta4_top.png^techage_appl_hole_pipe.png",
"techage_filling_ta4.png^techage_frame_ta4.png", "techage_filling_ta4.png^techage_frame_ta4.png",
{ {
image = "techage_filling8_ta4.png^techage_frame8_ta4.png^techage_appl_pump8.png", image = "techage_filling8_ta4.png^techage_frame8_ta4.png^techage_appl_pump_up8.png",
backface_culling = false, backface_culling = false,
animation = { animation = {
type = "vertical_frames", type = "vertical_frames",
@ -221,38 +285,40 @@ minetest.register_node("techage:ta4_doser_on", {
}, },
}, },
tubelib2_on_update2 = function(pos, dir, tlib2, node)
liquid.update_network(pos)
del_liquids(pos)
end,
on_receive_fields = on_receive_fields, on_receive_fields = on_receive_fields,
on_rightclick = on_rightclick, on_rightclick = on_rightclick,
on_timer = node_timer, on_timer = node_timer,
networks = nworks,
paramtype2 = "facedir", paramtype2 = "facedir",
on_rotate = screwdriver.disallow, on_rotate = screwdriver.disallow,
groups = {cracky=2}, diggable = false,
groups = {not_in_creative_inventory=1},
is_ground_content = false, is_ground_content = false,
sounds = default.node_sound_metal_defaults(), sounds = default.node_sound_metal_defaults(),
}) })
-- for mechanical pipe connections techage.register_node({"techage:ta4_doser", "techage:ta4_doser_on"}, {
techage.power.register_node({"techage:ta4_doser", "techage:ta4_doser_on"}, { on_recv_message = function(pos, src, topic, payload)
conn_sides = {"F", "B", "R", "L", "U"}, local resp = State:on_receive_message(pos, topic, payload)
power_network = Pipe, if resp then
after_place_node = function(pos, placer) return resp
local meta = M(pos) else
local mem = tubelib2.init_mem(pos) return "unsupported"
local number = techage.add_node(pos, "techage:ta4_doser") end
meta:set_string("node_number", number)
meta:set_string("owner", placer:get_player_name())
local node = minetest.get_node(pos)
local indir = techage.side_to_indir("R", node.param2)
meta:set_int("indir", indir) -- from liquid point of view
meta:set_string("formspec", formspec(State, pos, mem))
meta:set_string("infotext", S("TA4 Tank").." "..number)
end, end,
after_dig_node = function(pos, oldnode, oldmetadata, digger) on_node_load = function(pos)
techage.remove_node(pos) State:on_node_load(pos)
end, end,
}) })
Pipe:add_secondary_node_names({"techage:ta4_doser", "techage:ta4_doser_on"})
if minetest.global_exists("unified_inventory") then if minetest.global_exists("unified_inventory") then
unified_inventory.register_craft_type("ta4_doser", { unified_inventory.register_craft_type("ta4_doser", {
description = S("TA4 Doser"), description = S("TA4 Doser"),
@ -261,3 +327,12 @@ if minetest.global_exists("unified_inventory") then
height = 2, height = 2,
}) })
end end
minetest.register_craft({
output = "techage:ta4_doser",
recipe = {
{"", "techage:ta3_pipeS", ""},
{"techage:ta3_pipeS", "techage:t4_pump", "techage:ta3_pipeS"},
{"", "techage:ta4_wlanchip", ""},
},
})

View File

@ -133,3 +133,21 @@ minetest.register_node("techage:ta4_reactor", {
}) })
Pipe:add_secondary_node_names({"techage:ta4_reactor_fillerpipe"}) Pipe:add_secondary_node_names({"techage:ta4_reactor_fillerpipe"})
minetest.register_craft({
output = 'techage:ta4_reactor',
recipe = {
{'default:steel_ingot', 'techage:ta3_pipeS', 'default:steel_ingot'},
{'techage:iron_ingot', '', 'techage:iron_ingot'},
{'default:steel_ingot', 'techage:ta3_pipeS', 'default:steel_ingot'},
}
})
minetest.register_craft({
output = 'techage:ta4_reactor_fillerpipe',
recipe = {
{'', '', ''},
{'', 'techage:ta3_pipeS', ''},
{'default:steel_ingot', 'basic_materials:motor', 'default:steel_ingot'},
}
})

View File

@ -85,21 +85,12 @@ minetest.register_node("techage:ta4_reactor_stand", {
on_timer = function(pos, elapsed) on_timer = function(pos, elapsed)
local mem = tubelib2.get_mem(pos) local mem = tubelib2.get_mem(pos)
power.consumer_alive(pos, mem) power.consumer_alive(pos, mem)
minetest.sound_play("techage_reactor", {
pos = pos,
gain = 0.5,
max_hear_distance = 10})
return mem.running return mem.running
end, end,
on_rightclick = function(pos, node, clicker)
local mem = tubelib2.get_mem(pos)
if not mem.running and power.power_available(pos, mem, PWR_NEEDED) then
mem.running = true
power.consumer_start(pos, mem, CYCLE_TIME, PWR_NEEDED)
M(pos):set_string("infotext", "...")
else
mem.running = false
power.consumer_stop(pos, mem)
minetest.get_node_timer(pos):stop()
M(pos):set_string("infotext", S("off"))
end
end,
after_dig_node = function(pos, oldnode) after_dig_node = function(pos, oldnode)
techage.power.after_dig_node(pos, oldnode) techage.power.after_dig_node(pos, oldnode)
Pipe:after_dig_node(pos) Pipe:after_dig_node(pos)
@ -132,10 +123,11 @@ techage.power.enrich_node({"techage:ta4_reactor_stand"}, {
-- controlled by the fillerpipe -- controlled by the fillerpipe
techage.register_node({"techage:ta4_reactor_stand"}, { techage.register_node({"techage:ta4_reactor_stand"}, {
on_transfer = function(pos, in_dir, topic, payload) on_transfer = function(pos, in_dir, topic, payload)
print(topic, payload) --print(topic, dump(payload))
local mem = tubelib2.get_mem(pos) local mem = tubelib2.get_mem(pos)
if topic == "power" then if topic == "power" then
return mem.has_power --print("power", mem.has_power)
return mem.has_power or power.power_available(pos, mem, 0)
elseif topic == "output" then elseif topic == "output" then
local outdir = M(pos):get_int("outdir") local outdir = M(pos):get_int("outdir")
return liquid.put(pos, outdir, payload.name, payload.amount, payload.player_name) return liquid.put(pos, outdir, payload.name, payload.amount, payload.player_name)
@ -199,3 +191,21 @@ Pipe:add_secondary_node_names({
"techage:ta4_reactor_base", "techage:ta4_reactor_base",
"techage:ta4_reactor_stand", "techage:ta4_reactor_stand",
}) })
minetest.register_craft({
output = 'techage:ta4_reactor_stand',
recipe = {
{'', 'dye:blue', ''},
{'basic_materials:steel_bar', 'techage:ta3_pipeS', 'basic_materials:steel_bar'},
{'basic_materials:steel_bar', '', 'basic_materials:steel_bar'},
}
})
minetest.register_craft({
output = 'techage:ta4_reactor_base',
recipe = {
{'basic_materials:concrete_block', '', ''},
{'techage:ta3_pipeS', '', ''},
{'', '', ''},
}
})

View File

@ -19,8 +19,8 @@ local S = techage.S
local range = techage.range local range = techage.range
local Recipes = {} -- registered recipes local Recipes = {} -- registered recipes {output = {recipe, ...},}
local Ingredients = {} local Ingredients = {} -- {{input = output},
local KeyList = {} -- index to Recipes key translation local KeyList = {} -- index to Recipes key translation
techage.furnace = {} techage.furnace = {}
@ -72,22 +72,60 @@ function techage.furnace.get_ingredients(pos)
return tbl return tbl
end end
local function remove_item_from_list(list, item)
for _,stack in ipairs(list) do
if stack:get_name() == item then
stack:set_count(stack:get_count() - 1)
return true
end
end
return false
end
-- move recipe src items to output inventory -- move recipe src items to output inventory
local function process(inv, recipe, output) local function process(inv, recipe, output)
-- check if all ingredients are available -- check dst inv
local stack = ItemStack(output)
stack:set_count(recipe.number)
if not inv:room_for_item("dst", stack) then
return techage.BLOCKED
end
-- remove items
local list = inv:get_list("src")
for _,item in ipairs(recipe.input) do for _,item in ipairs(recipe.input) do
if not inv:contains_item("src", item) then if not remove_item_from_list(list, item) then
return techage.STANDBY
end
end
-- store changes on scr
inv:set_list("src", list)
-- add output to dst
inv:add_item("dst", stack)
return techage.RUNNING
end
function techage.furnace.check_if_worth_to_wakeup(pos, mem)
local inv = M(pos):get_inventory()
if not mem.output or not mem.num_recipe then
return false
end
local recipe = Recipes[mem.output] and Recipes[mem.output][mem.num_recipe]
if not recipe then
return false
end
-- check dst inv
local stack = ItemStack(mem.output)
stack:set_count(recipe.number)
if not inv:room_for_item("dst", stack) then
return false
end
-- check src inv
local list = inv:get_list("src")
for _,item in ipairs(recipe.input) do
if not remove_item_from_list(list, item) then
return false return false
end end
end end
-- remove items
for _,item in ipairs(recipe.input) do
inv:remove_item("src", item)
end
-- add to dst
local stack = ItemStack(output)
stack:set_count(recipe.number)
inv:add_item("dst", stack)
return true return true
end end
@ -98,23 +136,16 @@ function techage.furnace.smelting(pos, mem, elapsed)
if not mem.output or not mem.num_recipe then if not mem.output or not mem.num_recipe then
return techage.FAULT, "recipe error" return techage.FAULT, "recipe error"
end end
local recipe = Recipes[mem.output][mem.num_recipe] local recipe = Recipes[mem.output] and Recipes[mem.output][mem.num_recipe]
if not recipe then if not recipe then
return techage.FAULT, "recipe error" return techage.FAULT, "recipe error"
end end
-- check dst inv
local item = ItemStack(mem.output)
if not inv:room_for_item("dst", item) then
return techage.BLOCKED
end
elapsed = elapsed + (mem.leftover or 0) elapsed = elapsed + (mem.leftover or 0)
while elapsed >= recipe.time do while elapsed >= recipe.time do
if process(inv, recipe, mem.output) == false then state = process(inv, recipe, mem.output)
mem.leftover = 0 if state ~= techage.RUNNING then
return techage.STANDBY return state
else
state = techage.RUNNING
end end
elapsed = elapsed - recipe.time elapsed = elapsed - recipe.time
end end
@ -143,6 +174,7 @@ end
function techage.furnace.reset_cooking(mem) function techage.furnace.reset_cooking(mem)
mem.leftover = 0 mem.leftover = 0
mem.item_percent = 0
end end

View File

@ -29,14 +29,21 @@ local get_output = techage.furnace.get_output
local num_recipes = techage.furnace.get_num_recipes local num_recipes = techage.furnace.get_num_recipes
local reset_cooking = techage.furnace.reset_cooking local reset_cooking = techage.furnace.reset_cooking
local get_ingredients = techage.furnace.get_ingredients local get_ingredients = techage.furnace.get_ingredients
local check_if_worth_to_wakeup = techage.furnace.check_if_worth_to_wakeup
local range = techage.range local range = techage.range
local function formspec(self, pos, mem)
local function update_recipe_menu(pos, mem)
local ingr = get_ingredients(pos) local ingr = get_ingredients(pos)
local num = num_recipes(ingr) mem.rp_num = num_recipes(ingr)
mem.recipe_idx = range(mem.recipe_idx or 1, 0, num) mem.rp_idx = range(mem.rp_idx or 1, 0, mem.rp_num)
local idx = mem.recipe_idx mem.rp_outp = get_output(mem, ingr, mem.rp_idx)
local output = get_output(mem, ingr, idx) end
local function formspec(self, pos, mem)
local idx = mem.rp_idx or 1
local num = mem.rp_num or 1
local outp = mem.rp_outp or ""
return "size[8,7.2]".. return "size[8,7.2]"..
default.gui_bg.. default.gui_bg..
default.gui_bg_img.. default.gui_bg_img..
@ -50,7 +57,7 @@ local function formspec(self, pos, mem)
"list[context;dst;3,0;2,2;]".. "list[context;dst;3,0;2,2;]"..
"label[6,0;"..S("Outp")..": "..idx.."/"..num.."]".. "label[6,0;"..S("Outp")..": "..idx.."/"..num.."]"..
"item_image_button[6.5,0.5;1,1;"..(output or "")..";b1;]".. "item_image_button[6.5,0.5;1,1;"..outp..";b1;]"..
"button[6,1.5;1,1;priv;<<]".. "button[6,1.5;1,1;priv;<<]"..
"button[7,1.5;1,1;next;>>]".. "button[7,1.5;1,1;next;>>]"..
@ -75,23 +82,26 @@ local function firebox_cmnd(pos, cmnd)
cmnd, -- topic cmnd, -- topic
nil, -- payload nil, -- payload
nil, -- network nil, -- network
{"techage:furnace_firebox", "techage:furnace_firebox_on"}) {"techage:furnace_firebox", "techage:furnace_firebox_on",
"techage:furnace_heater", "techage:furnace_heater_on"})
end end
local function cooking(pos, crd, mem, elapsed) local function cooking(pos, crd, mem, elapsed)
if firebox_cmnd(pos, "running") then if mem.techage_state == techage.RUNNING or check_if_worth_to_wakeup(pos, mem) then
local state, err = smelting(pos, mem, elapsed) if firebox_cmnd(pos, "fuel") then
if state == techage.RUNNING then local state, err = smelting(pos, mem, elapsed)
crd.State:keep_running(pos, mem, COUNTDOWN_TICKS) if state == techage.RUNNING then
elseif state == techage.BLOCKED then crd.State:keep_running(pos, mem, COUNTDOWN_TICKS)
crd.State:blocked(pos, mem) elseif state == techage.BLOCKED then
elseif state == techage.FAULT then crd.State:blocked(pos, mem)
crd.State:fault(pos, mem, err) elseif state == techage.FAULT then
elseif state == techage.STANDBY then crd.State:fault(pos, mem, err)
elseif state == techage.STANDBY then
crd.State:idle(pos, mem)
end
else
crd.State:idle(pos, mem) crd.State:idle(pos, mem)
end end
else
crd.State:idle(pos, mem)
end end
end end
@ -100,7 +110,7 @@ local function keep_running(pos, elapsed)
local crd = CRD(pos) local crd = CRD(pos)
cooking(pos, crd, mem, elapsed) cooking(pos, crd, mem, elapsed)
mem.toggle = not mem.toggle mem.toggle = not mem.toggle
if mem.toggle then if mem.toggle then -- progress bar/arrow
M(pos):set_string("formspec", formspec(crd.State, pos, mem)) M(pos):set_string("formspec", formspec(crd.State, pos, mem))
end end
return crd.State:is_active(mem) return crd.State:is_active(mem)
@ -112,7 +122,6 @@ local function allow_metadata_inventory_put(pos, listname, index, stack, player)
end end
if listname == "src" then if listname == "src" then
local mem = tubelib2.get_mem(pos) local mem = tubelib2.get_mem(pos)
CRD(pos).State:start_if_standby(pos)
return stack:get_count() return stack:get_count()
elseif listname == "dst" then elseif listname == "dst" then
return 0 return 0
@ -144,15 +153,17 @@ local function on_receive_fields(pos, formname, fields, player)
return return
end end
local mem = tubelib2.get_mem(pos) local mem = tubelib2.get_mem(pos)
mem.recipe_idx = mem.recipe_idx or 1 mem.rp_idx = mem.rp_idx or 1
if fields.next == ">>" then if fields.next == ">>" then
local ingr = get_ingredients(pos) local ingr = get_ingredients(pos)
mem.recipe_idx = math.min(mem.recipe_idx + 1, num_recipes(ingr)) mem.rp_idx = math.min(mem.rp_idx + 1, num_recipes(ingr))
update_recipe_menu(pos, mem)
M(pos):set_string("formspec", formspec(CRD(pos).State, pos, mem)) M(pos):set_string("formspec", formspec(CRD(pos).State, pos, mem))
reset_cooking(mem) reset_cooking(mem)
elseif fields.priv == "<<" then elseif fields.priv == "<<" then
local ingr = get_ingredients(pos) local ingr = get_ingredients(pos)
mem.recipe_idx = range(mem.recipe_idx - 1, 1, num_recipes(ingr)) mem.rp_idx = range(mem.rp_idx - 1, 1, num_recipes(ingr))
update_recipe_menu(pos, mem)
M(pos):set_string("formspec", formspec(CRD(pos).State, pos, mem)) M(pos):set_string("formspec", formspec(CRD(pos).State, pos, mem))
reset_cooking(mem) reset_cooking(mem)
end end
@ -216,7 +227,6 @@ local tubing = {
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
if meta:get_int("push_dir") == in_dir or in_dir == 5 then if meta:get_int("push_dir") == in_dir or in_dir == 5 then
local inv = M(pos):get_inventory() local inv = M(pos):get_inventory()
CRD(pos).State:start_if_standby(pos)
return techage.put_items(inv, "src", stack) return techage.put_items(inv, "src", stack)
end end
end, end,

144
furnace/heater.lua Normal file
View File

@ -0,0 +1,144 @@
--[[
TechAge
=======
Copyright (C) 2019 Joachim Stolberg
GPL v3
See LICENSE.txt for more information
TA4 Industrial Furnace Heater
]]--
-- for lazy programmers
local M = minetest.get_meta
local S = techage.S
local firebox = techage.firebox
local fuel = techage.fuel
local Pipe = techage.LiquidPipe
local liquid = techage.liquid
local CYCLE_TIME = 2
local PWR_NEEDED = 8
local Power = techage.ElectricCable
local power = techage.power
local function swap_node(pos, name)
local node = techage.get_node_lvm(pos)
if node.name == name then
return
end
node.name = name
minetest.swap_node(pos, node)
end
local function on_power(pos, mem)
if mem.running then
swap_node(pos, "techage:furnace_heater_on")
minetest.get_node_timer(pos):start(CYCLE_TIME)
end
mem.has_power = true
end
local function on_nopower(pos, mem)
swap_node(pos, "techage:furnace_heater")
mem.has_power = false
end
local function node_timer(pos, elapsed)
local mem = tubelib2.get_mem(pos)
power.consumer_alive(pos, mem)
return mem.running
end
minetest.register_node("techage:furnace_heater", {
description = S("TA4 Furnace Heater"),
tiles = {
-- up, down, right, left, back, front
"techage_concrete.png^techage_appl_open.png^techage_frame_ta3.png",
"techage_concrete.png^techage_frame_ta3.png",
"techage_concrete.png^techage_frame_ta3.png",
"techage_concrete.png^techage_frame_ta3.png^techage_appl_hole_electric.png",
"techage_concrete.png^techage_frame_ta3.png",
"techage_concrete.png^techage_appl_heater.png^techage_frame_ta3.png",
},
on_timer = node_timer,
paramtype2 = "facedir",
groups = {cracky=2, crumbly=2, choppy=2},
on_rotate = screwdriver.disallow,
is_ground_content = false,
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("techage:furnace_heater_on", {
tiles = {
-- up, down, right, left, back, front
"techage_concrete.png^techage_appl_open.png^techage_frame_ta3.png",
"techage_concrete.png^techage_frame_ta3.png",
"techage_concrete.png^techage_frame_ta3.png",
"techage_concrete.png^techage_frame_ta3.png^techage_appl_hole_electric.png",
"techage_concrete.png^techage_frame_ta3.png",
"techage_concrete.png^techage_appl_heater_on.png^techage_frame_ta3.png",
},
light_source = 8,
on_timer = node_timer,
paramtype2 = "facedir",
groups = {not_in_creative_inventory = 1},
diggable = false,
on_rotate = screwdriver.disallow,
is_ground_content = false,
sounds = default.node_sound_wood_defaults(),
})
techage.power.register_node({"techage:furnace_heater", "techage:furnace_heater_on"}, {
power_network = Power,
conn_sides = {"F", "B", "U", "D", "L"},
on_power = on_power,
on_nopower = on_nopower,
after_place_node = function(pos, placer)
local mem = tubelib2.init_mem(pos)
end,
})
minetest.register_craft({
output = "techage:furnace_heater",
recipe = {
{'techage:basalt_stone', 'default:steel_ingot', 'techage:basalt_stone'},
{'default:steel_ingot', 'basic_materials:heating_element', 'default:steel_ingot'},
{'techage:basalt_stone', 'techage:basalt_stone', 'techage:basalt_stone'},
},
})
techage.register_node({"techage:furnace_heater", "techage:furnace_heater_on"}, {
-- called from furnace_top
on_transfer = function(pos, in_dir, topic, payload)
local mem = tubelib2.get_mem(pos)
if topic == "fuel" then
return mem.has_power or power.power_available(pos, mem, 0)
elseif topic == "running" then
return mem.running and (mem.has_power or power.power_available(pos, mem, 0))
elseif topic == "start" and not mem.running then
if power.power_available(pos, mem, 0) then
mem.running = true
mem.has_power = false
power.consumer_start(pos, mem, CYCLE_TIME, PWR_NEEDED)
return true
end
elseif topic == "stop" and mem.running then
mem.running = false
swap_node(pos, "techage:furnace_heater")
power.consumer_stop(pos, mem)
minetest.get_node_timer(pos):stop()
return true
end
end
})
Pipe:add_secondary_node_names({"techage:furnace_heater", "techage:furnace_heater_on"})

View File

@ -58,11 +58,6 @@ else
dofile(MP.."/doc/items.lua") dofile(MP.."/doc/items.lua")
dofile(MP.."/doc/guide.lua") -- construction guides dofile(MP.."/doc/guide.lua") -- construction guides
-- Nodes1
dofile(MP.."/nodes/baborium.lua")
dofile(MP.."/nodes/usmium.lua")
dofile(MP.."/nodes/bauxit.lua")
-- Power networks -- Power networks
dofile(MP.."/power/schedule.lua") dofile(MP.."/power/schedule.lua")
--dofile(MP.."/power/distribute.lua") --dofile(MP.."/power/distribute.lua")
@ -121,8 +116,8 @@ else
-- Liquids -- Liquids
dofile(MP.."/liquids/liquid_pipe.lua") dofile(MP.."/liquids/liquid_pipe.lua")
dofile(MP.."/liquids/liquid.lua") dofile(MP.."/liquids/liquid.lua")
dofile(MP.."/liquids/barrel.lua")
dofile(MP.."/liquids/tank.lua") dofile(MP.."/liquids/tank.lua")
dofile(MP.."/liquids/silo.lua")
dofile(MP.."/liquids/pump.lua") dofile(MP.."/liquids/pump.lua")
dofile(MP.."/liquids/fuel_lib.lua") dofile(MP.."/liquids/fuel_lib.lua")
@ -141,6 +136,7 @@ else
dofile(MP.."/furnace/cooking.lua") dofile(MP.."/furnace/cooking.lua")
dofile(MP.."/furnace/furnace_top.lua") dofile(MP.."/furnace/furnace_top.lua")
dofile(MP.."/furnace/booster.lua") dofile(MP.."/furnace/booster.lua")
dofile(MP.."/furnace/heater.lua")
dofile(MP.."/furnace/recipes.lua") dofile(MP.."/furnace/recipes.lua")
-- Tools -- Tools
@ -159,25 +155,15 @@ else
dofile(MP.."/lamps/industriallamp3.lua") dofile(MP.."/lamps/industriallamp3.lua")
-- Oil -- Oil
dofile(MP.."/oil/oil.lua")
dofile(MP.."/oil/explore.lua") dofile(MP.."/oil/explore.lua")
dofile(MP.."/oil/tower.lua") dofile(MP.."/oil/tower.lua")
dofile(MP.."/oil/drillbox.lua") dofile(MP.."/oil/drillbox.lua")
dofile(MP.."/oil/pumpjack.lua") dofile(MP.."/oil/pumpjack.lua")
dofile(MP.."/oil/generator.lua") dofile(MP.."/oil/generator.lua")
dofile(MP.."/oil/petroleum.lua")
dofile(MP.."/oil/distiller.lua") dofile(MP.."/oil/distiller.lua")
dofile(MP.."/oil/reboiler.lua") dofile(MP.."/oil/reboiler.lua")
dofile(MP.."/oil/gasflare.lua") dofile(MP.."/oil/gasflare.lua")
-- Nodes2
if techage.basalt_stone_enabled then
dofile(MP.."/nodes/basalt.lua")
end
dofile(MP.."/nodes/gateblock.lua")
dofile(MP.."/nodes/doorblock.lua")
dofile(MP.."/nodes/steelmat.lua")
-- Logic -- Logic
dofile(MP.."/logic/lib.lua") dofile(MP.."/logic/lib.lua")
dofile(MP.."/logic/terminal.lua") dofile(MP.."/logic/terminal.lua")
@ -192,6 +178,8 @@ else
dofile(MP.."/logic/node_detector.lua") dofile(MP.."/logic/node_detector.lua")
dofile(MP.."/logic/player_detector.lua") dofile(MP.."/logic/player_detector.lua")
dofile(MP.."/logic/cart_detector.lua") dofile(MP.."/logic/cart_detector.lua")
dofile(MP.."/logic/gateblock.lua")
dofile(MP.."/logic/doorblock.lua")
-- Test -- Test
dofile(MP.."/recipe_checker.lua") dofile(MP.."/recipe_checker.lua")
@ -201,14 +189,13 @@ else
--dofile(MP.."/.test/switch.lua") --dofile(MP.."/.test/switch.lua")
-- Solar -- Solar
dofile(MP.."/nodes/silicon.lua")
dofile(MP.."/solar/minicell.lua") dofile(MP.."/solar/minicell.lua")
dofile(MP.."/solar/solarcell.lua") dofile(MP.."/solar/solarcell.lua")
dofile(MP.."/solar/inverter.lua") dofile(MP.."/solar/inverter.lua")
-- Wind -- Wind
dofile(MP.."/wind_turbine/rotor.lua") dofile(MP.."/wind_turbine/rotor.lua")
dofile(MP.."/nodes/pillar.lua") dofile(MP.."/wind_turbine/pillar.lua")
dofile(MP.."/wind_turbine/signallamp.lua") dofile(MP.."/wind_turbine/signallamp.lua")
-- TA4 Energy Storage -- TA4 Energy Storage
@ -219,12 +206,30 @@ else
dofile(MP.."/energy_storage/nodes.lua") dofile(MP.."/energy_storage/nodes.lua")
-- Chemistry -- Chemistry
--dofile(MP.."/chemistry/ta4_reactor.lua") dofile(MP.."/chemistry/ta4_reactor.lua")
--dofile(MP.."/chemistry/ta4_stand.lua") dofile(MP.."/chemistry/ta4_stand.lua")
--dofile(MP.."/chemistry/ta4_doser.lua") dofile(MP.."/chemistry/ta4_doser.lua")
-- Hydrogen -- Hydrogen
dofile(MP.."/hydrogen/hydrogen.lua") dofile(MP.."/hydrogen/hydrogen.lua")
dofile(MP.."/hydrogen/electrolyzer.lua") dofile(MP.."/hydrogen/electrolyzer.lua")
dofile(MP.."/hydrogen/fuelcell.lua") dofile(MP.."/hydrogen/fuelcell.lua")
-- Items
dofile(MP.."/items/barrel.lua")
dofile(MP.."/items/baborium.lua")
dofile(MP.."/items/usmium.lua")
dofile(MP.."/items/lye.lua")
dofile(MP.."/items/oil.lua")
dofile(MP.."/items/petroleum.lua")
dofile(MP.."/items/bauxit.lua")
dofile(MP.."/items/silicon.lua")
dofile(MP.."/items/steelmat.lua")
dofile(MP.."/items/powder.lua")
dofile(MP.."/items/epoxy.lua")
dofile(MP.."/items/aluminium.lua")
if techage.basalt_stone_enabled then
dofile(MP.."/items/basalt.lua")
end
end end

62
items/aluminium.lua Normal file
View File

@ -0,0 +1,62 @@
--[[
TechAge
=======
Copyright (C) 2019 Joachim Stolberg
GPL v3
See LICENSE.txt for more information
Aluminium
]]--
local S = techage.S
minetest.register_craftitem("techage:gibbsite_powder", {
description = S("Gibbsite Powder"),
inventory_image = "techage_powder_inv.png^[colorize:#C6DCDB:120",
})
minetest.register_craftitem("techage:aluminum", {
description = S("Aluminum"),
inventory_image = "techage_aluminum_inv.png",
})
minetest.register_craftitem("techage:redmud", {
description = S("Red Mud"),
inventory_image = "techage_liquid2_inv.png^[colorize:#F80E13:120^techage_liquid1_inv.png",
})
minetest.register_craftitem("techage:barrel_redmud", {
description = S("Red Mud Barrel"),
inventory_image = "techage_barrel_inv.png^[colorize:#F80E13:120^techage_symbol_liquid.png",
stack_max = 1,
})
minetest.register_craftitem("techage:canister_redmud", {
description = S("Red Mud Canister"),
inventory_image = "techage_canister_filling.png^[colorize:#F80E13:120^techage_canister_frame.png^techage_symbol_liquid.png",
stack_max = 1,
})
techage.register_liquid("techage:barrel_redmud", "techage:ta3_barrel_empty", 10, "techage:epoxy")
techage.register_liquid("techage:canister_redmud", "techage:ta3_canister_empty", 1, "techage:epoxy")
techage.recipes.add("ta4_doser", {
output = "techage:gibbsite_powder 1",
waste = "techage:redmud 1",
input = {
"techage:bauxite_powder 1",
"techage:lye 1",
}
})
techage.furnace.register_recipe({
output = "techage:aluminum",
recipe = {"techage:gibbsite_powder", "techage:gibbsite_powder",
"techage:gibbsite_powder", "techage:gibbsite_powder"},
time = 16,
})

View File

@ -8,7 +8,7 @@
GPL v3 GPL v3
See LICENSE.txt for more information See LICENSE.txt for more information
Gravel Sieve basis functions Baborium
]]-- ]]--

84
items/barrel.lua Normal file
View File

@ -0,0 +1,84 @@
--[[
TechAge
=======
Copyright (C) 2019 Joachim Stolberg
GPL v3
See LICENSE.txt for more information
Barrel/Liquid/Canister/Water
]]--
local S = techage.S
minetest.register_craftitem("techage:water", {
description = S("Water"),
inventory_image = "techage_liquid2_inv.png^[colorize:#0b6eca:120^techage_liquid1_inv.png",
groups = {not_in_creative_inventory=1},
})
minetest.register_craftitem("techage:river_water", {
description = S("Water"),
inventory_image = "techage_liquid2_inv.png^[colorize:#189dc3:120^techage_liquid1_inv.png",
groups = {not_in_creative_inventory=1},
})
minetest.register_craftitem("techage:barrel_water", {
description = S("Water Barrel"),
inventory_image = "techage_barrel_inv.png^[colorize:#0b6eca:120^techage_symbol_liquid.png",
stack_max = 1,
})
minetest.register_craftitem("techage:barrel_river_water", {
description = S("River Water Barrel"),
inventory_image = "techage_barrel_inv.png^[colorize:#189dc3:120^techage_symbol_liquid.png",
stack_max = 1,
})
minetest.register_craftitem("techage:liquid", {
description = S("empty"),
inventory_image = "techage_liquid2_inv.png^[colorize:#BFBFBF:180^techage_liquid1_inv.png",
groups = {not_in_creative_inventory=1},
})
minetest.register_craftitem("techage:ta3_barrel_empty", {
description = S("TA Empty Barrel"),
inventory_image = "techage_barrel_inv.png^[colorize:#BFBFBF:180",
})
minetest.register_craftitem("techage:ta3_canister_empty", {
description = S("TA3 Canister"),
inventory_image = "techage_canister_filling.png^[colorize:#BFBFBF:180^techage_canister_frame.png",
})
minetest.register_craft({
output = 'techage:ta3_barrel_empty 6',
recipe = {
{'techage:iron_ingot', 'techage:iron_ingot', 'techage:iron_ingot'},
{'techage:iron_ingot', '', 'techage:iron_ingot'},
{'techage:iron_ingot', 'techage:iron_ingot', 'techage:iron_ingot'},
}
})
minetest.register_craft({
output = 'techage:ta3_canister_empty 6',
recipe = {
{'basic_materials:plastic_sheet', 'basic_materials:plastic_sheet', 'basic_materials:plastic_sheet'},
{'basic_materials:plastic_sheet', '', 'basic_materials:plastic_sheet'},
{'basic_materials:plastic_sheet', 'basic_materials:plastic_sheet', 'basic_materials:plastic_sheet'},
}
})
techage.register_liquid("bucket:bucket_water", "bucket:bucket_empty", 1, "techage:water")
techage.register_liquid("bucket:bucket_river_water", "bucket:bucket_empty", 1, "techage:river_water")
techage.register_liquid("techage:barrel_water", "techage:ta3_barrel_empty", 10, "techage:water")
techage.register_liquid("techage:barrel_river_water", "techage:ta3_barrel_empty", 10, "techage:river_water")
techage.register_liquid("bucket:bucket_lava", "bucket:bucket_empty", 1, "default:lava_source")

View File

@ -16,7 +16,7 @@ local S = techage.S
minetest.register_node("techage:bauxite_stone", { minetest.register_node("techage:bauxite_stone", {
description = S("Bauxite Stone"), description = S("Bauxite Stone"),
tiles = {"default_desert_stone.png^techage_bauxit_overlay.png^[colorize:#800000:80"}, tiles = {"default_desert_stone.png^techage_bauxit_overlay.png^[colorize:#FB2A00:120"},
groups = {cracky = 3, stone = 1}, groups = {cracky = 3, stone = 1},
drop = 'techage:bauxite_cobble', drop = 'techage:bauxite_cobble',
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
@ -24,7 +24,7 @@ minetest.register_node("techage:bauxite_stone", {
minetest.register_node("techage:bauxite_cobble", { minetest.register_node("techage:bauxite_cobble", {
description = S("Bauxite Cobblestone"), description = S("Bauxite Cobblestone"),
tiles = {"default_desert_cobble.png^[colorize:#800000:80"}, tiles = {"default_desert_cobble.png^[colorize:#FB2A00:80"},
is_ground_content = false, is_ground_content = false,
groups = {cracky = 3, stone = 2}, groups = {cracky = 3, stone = 2},
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
@ -32,12 +32,18 @@ minetest.register_node("techage:bauxite_cobble", {
minetest.register_node("techage:bauxite_gravel", { minetest.register_node("techage:bauxite_gravel", {
description = S("Bauxite Gravel"), description = S("Bauxite Gravel"),
tiles = {"default_gravel.png^[colorize:#9b1f06:180"}, tiles = {"default_gravel.png^[colorize:#FB2A00:180"},
is_ground_content = false, is_ground_content = false,
groups = {crumbly = 2, falling_node = 1}, groups = {crumbly = 2, falling_node = 1},
sounds = default.node_sound_gravel_defaults(), sounds = default.node_sound_gravel_defaults(),
}) })
minetest.register_craftitem("techage:bauxite_powder", {
description = S("Bauxite Powder"),
inventory_image = "techage_powder_inv.png^[colorize:#FB2A00:120",
})
minetest.register_ore({ minetest.register_ore({
ore_type = "blob", ore_type = "blob",
ore = "techage:bauxite_stone", ore = "techage:bauxite_stone",
@ -57,3 +63,5 @@ minetest.register_ore({
}, },
}) })
techage.add_grinder_recipe({input="techage:bauxite_cobble", output="techage:bauxite_gravel"})
techage.add_grinder_recipe({input="techage:bauxite_gravel", output="techage:bauxite_powder"})

45
items/epoxy.lua Normal file
View File

@ -0,0 +1,45 @@
--[[
TechAge
=======
Copyright (C) 2019 Joachim Stolberg
GPL v3
See LICENSE.txt for more information
Epoxy
]]--
local S = techage.S
minetest.register_craftitem("techage:epoxy", {
description = S("Epoxide Resin"),
inventory_image = "techage_liquid2_inv.png^[colorize:#ca2446:120^techage_liquid1_inv.png",
})
minetest.register_craftitem("techage:barrel_epoxy", {
description = S("Epoxide Resin Barrel"),
inventory_image = "techage_barrel_inv.png^[colorize:#ca2446:120^techage_symbol_liquid.png",
stack_max = 1,
})
minetest.register_craftitem("techage:canister_epoxy", {
description = S("Epoxide Resin Canister"),
inventory_image = "techage_canister_filling.png^[colorize:#ca2446:120^techage_canister_frame.png^techage_symbol_liquid.png",
stack_max = 1,
})
techage.recipes.add("ta4_doser", {
output = "techage:epoxy 1",
input = {
"techage:naphtha 1",
"techage:needle_powder 1",
}
})
techage.register_liquid("techage:barrel_epoxy", "techage:ta3_barrel_empty", 10, "techage:epoxy")
techage.register_liquid("techage:canister_epoxy", "techage:ta3_canister_empty", 1, "techage:epoxy")
minetest.register_alias("techage:ta4_epoxy", "techage:canister_epoxy")

43
items/lye.lua Normal file
View File

@ -0,0 +1,43 @@
--[[
TechAge
=======
Copyright (C) 2019 Joachim Stolberg
GPL v3
See LICENSE.txt for more information
Lye
]]--
local S = techage.S
minetest.register_craftitem("techage:lye", {
description = S("Lye"),
inventory_image = "techage_liquid2_inv.png^[colorize:#7fd44c:120^techage_liquid1_inv.png",
})
minetest.register_craftitem("techage:barrel_lye", {
description = S("Lye Barrel"),
inventory_image = "techage_barrel_inv.png^[colorize:#7fd44c:120^techage_symbol_liquid.png",
stack_max = 1,
})
minetest.register_craftitem("techage:canister_lye", {
description = S("Lye Canister"),
inventory_image = "techage_canister_filling.png^[colorize:#7fd44c:120^techage_canister_frame.png^techage_symbol_liquid.png",
stack_max = 1,
})
techage.recipes.add("ta4_doser", {
output = "techage:lye 1",
input = {
"techage:water 1",
"techage:usmium_powder 1",
}
})
techage.register_liquid("techage:barrel_lye", "techage:ta3_barrel_empty", 10, "techage:lye")
techage.register_liquid("techage:canister_lye", "techage:ta3_canister_empty", 1, "techage:lye")

View File

@ -22,7 +22,7 @@ minetest.register_node("techage:oil_source", {
drawtype = "liquid", drawtype = "liquid",
paramtype = "light", paramtype = "light",
inventory_image = "techage_oil_inv.png", inventory_image = "techage_liquid2_inv.png^[colorize:#000000^techage_liquid1_inv.png",
tiles = { tiles = {
{ {
name = "techage_oil_animated.png", name = "techage_oil_animated.png",
@ -119,5 +119,19 @@ bucket.register_liquid(
"techage_bucket_oil.png", "techage_bucket_oil.png",
"Oil Bucket") "Oil Bucket")
minetest.register_craftitem("techage:ta3_barrel_oil", {
description = S("TA3 Oil Barrel"),
inventory_image = "techage_barrel_inv.png^[colorize:#000000:120^techage_symbol_liquid.png",
stack_max = 1,
})
minetest.register_craftitem("techage:ta3_canister_oil", {
description = S("TA3 Oil Canister"),
inventory_image = "techage_canister_filling.png^[colorize:#000000^techage_canister_frame.png^techage_symbol_liquid.png",
stack_max = 1,
})
techage.register_liquid("techage:bucket_oil", "bucket:bucket_empty", 1, "techage:oil_source") techage.register_liquid("techage:bucket_oil", "bucket:bucket_empty", 1, "techage:oil_source")
techage.register_liquid("techage:oil_source", "", 1, "techage:oil_source") techage.register_liquid("techage:oil_source", "", 1, "techage:oil_source")
techage.register_liquid("techage:ta3_barrel_oil", "techage:ta3_barrel_empty", 10, "techage:oil_source")
techage.register_liquid("techage:ta3_canister_oil", "techage:ta3_canister_empty", 1, "techage:oil_source")

View File

@ -17,26 +17,22 @@ local S = techage.S
minetest.register_craftitem("techage:bitumen", { minetest.register_craftitem("techage:bitumen", {
description = S("TA3 Bitumen"), description = S("TA3 Bitumen"),
inventory_image = "techage_bitumen_inv.png", inventory_image = "techage_liquid2_inv.png^[colorize:#000000",
groups = {not_in_creative_inventory=1},
}) })
minetest.register_craftitem("techage:fueloil", { minetest.register_craftitem("techage:fueloil", {
description = S("TA3 Fuel Oil"), description = S("TA3 Fuel Oil"),
inventory_image = "techage_fueloil_inv.png", inventory_image = "techage_liquid2_inv.png^[colorize:#4b3f11^techage_liquid1_inv.png",
groups = {not_in_creative_inventory=1},
}) })
minetest.register_craftitem("techage:naphtha", { minetest.register_craftitem("techage:naphtha", {
description = S("TA3 Naphtha"), description = S("TA3 Naphtha"),
inventory_image = "techage_naphtha_inv.png", inventory_image = "techage_liquid2_inv.png^[colorize:#897937^techage_liquid1_inv.png",
groups = {not_in_creative_inventory=1},
}) })
minetest.register_craftitem("techage:gasoline", { minetest.register_craftitem("techage:gasoline", {
description = S("TA3 Gasoline"), description = S("TA3 Gasoline"),
inventory_image = "techage_gasoline_inv.png", inventory_image = "techage_liquid2_inv.png^[colorize:#bfaf6e^techage_liquid1_inv.png",
groups = {not_in_creative_inventory=1},
}) })
minetest.register_craftitem("techage:gas", { minetest.register_craftitem("techage:gas", {
@ -46,64 +42,52 @@ minetest.register_craftitem("techage:gas", {
}) })
minetest.register_craftitem("techage:ta3_barrel_oil", {
description = S("TA3 Oil Barrel"),
inventory_image = "techage_barrel_oil_inv.png",
stack_max = 1,
})
minetest.register_craftitem("techage:ta3_barrel_bitumen", { minetest.register_craftitem("techage:ta3_barrel_bitumen", {
description = S("TA3 Bitumen Barrel"), description = S("TA3 Bitumen Barrel"),
inventory_image = "techage_barrel_bitumen_inv.png", inventory_image = "techage_barrel_inv.png^[colorize:#000000:120",
stack_max = 1, stack_max = 1,
}) })
minetest.register_craftitem("techage:ta3_barrel_fueloil", { minetest.register_craftitem("techage:ta3_barrel_fueloil", {
description = S("TA3 Fuel Oil Barrel"), description = S("TA3 Fuel Oil Barrel"),
inventory_image = "techage_barrel_fueloil_inv.png", inventory_image = "techage_barrel_inv.png^[colorize:#4b3f11:120^techage_symbol_liquid.png",
stack_max = 1, stack_max = 1,
}) })
minetest.register_craftitem("techage:ta3_barrel_naphtha", { minetest.register_craftitem("techage:ta3_barrel_naphtha", {
description = S("TA3 Naphtha Barrel"), description = S("TA3 Naphtha Barrel"),
inventory_image = "techage_barrel_naphtha_inv.png", inventory_image = "techage_barrel_inv.png^[colorize:#897937:120^techage_symbol_liquid.png",
stack_max = 1, stack_max = 1,
}) })
minetest.register_craftitem("techage:ta3_barrel_gasoline", { minetest.register_craftitem("techage:ta3_barrel_gasoline", {
description = S("TA3 Gasoline Barrel"), description = S("TA3 Gasoline Barrel"),
inventory_image = "techage_barrel_gasoline_inv.png", inventory_image = "techage_barrel_inv.png^[colorize:#bfaf6e:120^techage_symbol_liquid.png",
stack_max = 1, stack_max = 1,
}) })
minetest.register_craftitem("techage:ta3_canister_oil", {
description = S("TA3 Oil Canister"),
inventory_image = "techage_canister_bitumen_inv.png",
stack_max = 1,
})
minetest.register_craftitem("techage:ta3_canister_bitumen", { minetest.register_craftitem("techage:ta3_canister_bitumen", {
description = S("TA3 Bitumen Canister"), description = S("TA3 Bitumen Canister"),
inventory_image = "techage_canister_bitumen_inv.png", inventory_image = "techage_canister_filling.png^[colorize:#000000^techage_canister_frame.png",
stack_max = 1, stack_max = 1,
}) })
minetest.register_craftitem("techage:ta3_canister_fueloil", { minetest.register_craftitem("techage:ta3_canister_fueloil", {
description = S("TA3 Fuel Oil Canister"), description = S("TA3 Fuel Oil Canister"),
inventory_image = "techage_canister_fueloil_inv.png", inventory_image = "techage_canister_filling.png^[colorize:#4b3f11^techage_canister_frame.png^techage_symbol_liquid.png",
stack_max = 1, stack_max = 1,
}) })
minetest.register_craftitem("techage:ta3_canister_naphtha", { minetest.register_craftitem("techage:ta3_canister_naphtha", {
description = S("TA3 Naphtha Canister"), description = S("TA3 Naphtha Canister"),
inventory_image = "techage_canister_naphtha_inv.png", inventory_image = "techage_canister_filling.png^[colorize:#897937^techage_canister_frame.png^techage_symbol_liquid.png",
stack_max = 1, stack_max = 1,
}) })
minetest.register_craftitem("techage:ta3_canister_gasoline", { minetest.register_craftitem("techage:ta3_canister_gasoline", {
description = S("TA3 Gasoline Canister"), description = S("TA3 Gasoline Canister"),
inventory_image = "techage_canister_gasoline_inv.png", inventory_image = "techage_canister_filling.png^[colorize:#bfaf6e^techage_canister_frame.png^techage_symbol_liquid.png",
stack_max = 1, stack_max = 1,
}) })

36
items/powder.lua Normal file
View File

@ -0,0 +1,36 @@
--[[
TechAge
=======
Copyright (C) 2019 Joachim Stolberg
GPL v3
See LICENSE.txt for more information
Powder
]]--
local S = techage.S
minetest.register_craftitem("techage:leave_powder", {
description = S("Leave Powder"),
inventory_image = "techage_powder_inv.png^[colorize:#71a157:120",
})
minetest.register_craftitem("techage:needle_powder", {
description = S("Needle Powder"),
inventory_image = "techage_powder_inv.png^[colorize:#1c800f:120",
})
techage.add_grinder_recipe({input="default:acacia_bush_leaves", output="techage:leave_powder"})
techage.add_grinder_recipe({input="default:acacia_leaves", output="techage:leave_powder"})
techage.add_grinder_recipe({input="default:aspen_leaves", output="techage:leave_powder"})
techage.add_grinder_recipe({input="default:blueberry_bush_leaves", output="techage:leave_powder"})
techage.add_grinder_recipe({input="default:bush_leaves", output="techage:leave_powder"})
techage.add_grinder_recipe({input="default:jungleleaves", output="techage:leave_powder"})
techage.add_grinder_recipe({input="default:leaves", output="techage:leave_powder"})
techage.add_grinder_recipe({input="default:pine_needles", output="techage:needle_powder"})

View File

@ -19,3 +19,9 @@ minetest.register_craftitem("techage:usmium_nuggets", {
inventory_image = "techage_usmium_nuggets.png", inventory_image = "techage_usmium_nuggets.png",
}) })
minetest.register_craftitem("techage:usmium_powder", {
description = S("Usmium Powder"),
inventory_image = "techage_powder_inv.png^[colorize:#46728E:120",
})
techage.add_grinder_recipe({input="techage:usmium_nuggets", output="techage:usmium_powder"})

View File

@ -1,50 +0,0 @@
--[[
TechAge
=======
Copyright (C) 2019 Joachim Stolberg
GPL v3
See LICENSE.txt for more information
Helper functions for liquid transportation (peer, put, take)
]]--
local S = techage.S
minetest.register_craftitem("techage:ta3_barrel_empty", {
description = S("TA Empty Barrel"),
inventory_image = "techage_barrel_inv.png",
})
minetest.register_craft({
output = 'techage:ta3_barrel_empty 6',
recipe = {
{'techage:iron_ingot', 'techage:iron_ingot', 'techage:iron_ingot'},
{'techage:iron_ingot', '', 'techage:iron_ingot'},
{'techage:iron_ingot', 'techage:iron_ingot', 'techage:iron_ingot'},
}
})
minetest.register_craftitem("techage:liquid", {
description = S("empty"),
inventory_image = "techage_liquid_inv.png",
groups = {not_in_creative_inventory=1},
})
minetest.register_craftitem("techage:ta3_canister_empty", {
description = S("TA3 Canister"),
inventory_image = "techage_canister_inv.png",
})
minetest.register_craft({
output = 'techage:ta3_canister_empty 6',
recipe = {
{'basic_materials:plastic_sheet', 'basic_materials:plastic_sheet', 'basic_materials:plastic_sheet'},
{'basic_materials:plastic_sheet', '', 'basic_materials:plastic_sheet'},
{'basic_materials:plastic_sheet', 'basic_materials:plastic_sheet', 'basic_materials:plastic_sheet'},
}
})

View File

@ -12,6 +12,7 @@
]]-- ]]--
local P2S = minetest.pos_to_string
local M = minetest.get_meta local M = minetest.get_meta
local N = function(pos) return minetest.get_node(pos).name end local N = function(pos) return minetest.get_node(pos).name end
local LQD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm(pos).name] or {}).liquid end local LQD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm(pos).name] or {}).liquid end
@ -30,13 +31,13 @@ local ContainerDef = {}
-- Networks -- Networks
-- --
-- determine network ID (largest hash number) -- determine network ID (largest hash number of all pumps)
local function determine_netID(pos, outdir) local function determine_netID(pos, outdir)
local netID = 0 local netID = 0
networks.connection_walk(pos, outdir, Pipe, function(pos, indir, node) networks.connection_walk(pos, outdir, Pipe, function(pos, indir, node)
local ntype = net_def(pos, "pipe").ntype local ntype = net_def(pos, "pipe").ntype
if ntype and ntype ~= "pump" then if ntype and ntype == "pump" then
local new = minetest.hash_node_position(pos) local new = minetest.hash_node_position(pos) * 8 + outdir
if netID <= new then if netID <= new then
netID = new netID = new
end end
@ -45,52 +46,59 @@ local function determine_netID(pos, outdir)
return netID return netID
end end
-- store network ID on each node -- store network ID on each pump like node
local function store_netID(pos, outdir, netID) local function store_netID(pos, outdir, netID)
networks.connection_walk(pos, outdir, Pipe, function(pos, indir, node) networks.connection_walk(pos, outdir, Pipe, function(pos, indir, node)
local ntype = net_def(pos, "pipe").ntype local ntype = net_def(pos, "pipe").ntype
if ntype and ntype ~= "pump" then if ntype and ntype == "pump" then
local mem = tubelib2.get_mem(pos) local mem = tubelib2.get_mem(pos)
local outdir = networks.Flip[indir]
mem.pipe = mem.pipe or {} mem.pipe = mem.pipe or {}
mem.pipe.netID = netID mem.pipe.netIDs = mem.pipe.netIDs or {}
mem.pipe.netIDs[outdir] = netID
end end
end) end)
end end
-- delete network and ID on each node -- delete network and ID on each pump like node
local function delete_netID(pos, outdir) local function delete_netID(pos, outdir)
local netID = 0 local netID = 0
networks.connection_walk(pos, outdir, Pipe, function(pos, indir, node) networks.connection_walk(pos, outdir, Pipe, function(pos, indir, node)
local ntype = net_def(pos, "pipe").ntype local ntype = net_def(pos, "pipe").ntype
if ntype and ntype ~= "pump" then if ntype and ntype == "pump" then
local mem = tubelib2.get_mem(pos) local mem = tubelib2.get_mem(pos)
if mem.pipe and mem.pipe.netID then local outdir = networks.Flip[indir]
netID = mem.pipe.netID if mem.pipe and mem.pipe.netIDs and mem.pipe.netIDs[outdir] then
mem.pipe.netID = nil netID = mem.pipe.netIDs[outdir]
mem.pipe.netIDs[outdir] = nil
end end
end end
end) end)
networks.delete_network(netID, Pipe) networks.delete_network(netID, Pipe)
end end
local function get_netID(pos, outdir)
local function get_network_table(pos, outdir, ntype) local mem = tubelib2.get_mem(pos)
-- jump to the next node because pumps have two network if not mem.pipe or not mem.pipe.netIDs or not mem.pipe.netIDs[outdir] then
-- interfaces and therefore can't have a netID
local pos2 = Pipe:get_connected_node_pos(pos, outdir)
local mem = tubelib2.get_mem(pos2)
if not mem.pipe or not mem.pipe.netID then
local netID = determine_netID(pos, outdir) local netID = determine_netID(pos, outdir)
store_netID(pos, outdir, netID) store_netID(pos, outdir, netID)
mem.pipe = mem.pipe or {}
mem.pipe.netID = netID
end end
local netw = networks.get_network(mem.pipe.netID, Pipe) return mem.pipe.netIDs[outdir]
if not netw then end
netw = networks.collect_network_nodes(pos, outdir, Pipe)
networks.set_network(mem.pipe.netID, Pipe, netw) local function get_network_table(pos, outdir, ntype)
local netID = get_netID(pos, outdir)
if netID then
local netw = networks.get_network(netID, Pipe)
if not netw then
netw = networks.collect_network_nodes(pos, outdir, Pipe)
networks.set_network(netID, Pipe, netw)
end
local s = minetest.pos_to_string(minetest.get_position_from_hash(netID))
--print("netw", string.format("%012X", netID), s, dump(netw))
return netw[ntype] or {}
end end
return netw[ntype] or {} return {}
end end
@ -230,44 +238,9 @@ function techage.liquid.get_full_container(empty_container, inv_item)
end end
-- To be called from each node via 'tubelib2_on_update2' -- To be called from each node via 'tubelib2_on_update2'
-- 'output' is optional and only needed for nodes with two -- 'output' is optional and only needed for nodes with dedicated
-- different networks. -- pipe sides (e.g. pumps).
function techage.liquid.update_network(pos, outdir) function techage.liquid.update_network(pos, outdir)
networks.node_connections(pos, Pipe) networks.node_connections(pos, Pipe)
delete_netID(pos, outdir) delete_netID(pos, outdir)
end end
minetest.register_craftitem("techage:water", {
description = S("Water"),
inventory_image = "techage_water_inv.png",
groups = {not_in_creative_inventory=1},
})
minetest.register_craftitem("techage:river_water", {
description = S("Water"),
inventory_image = "techage_water_inv.png",
groups = {not_in_creative_inventory=1},
})
minetest.register_craftitem("techage:barrel_water", {
description = S("Water Barrel"),
inventory_image = "techage_barrel_water_inv.png",
stack_max = 1,
})
minetest.register_craftitem("techage:barrel_river_water", {
description = S("River Water Barrel"),
inventory_image = "techage_barrel_water_inv.png",
stack_max = 1,
})
techage.register_liquid("bucket:bucket_water", "bucket:bucket_empty", 1, "techage:water")
techage.register_liquid("bucket:bucket_river_water", "bucket:bucket_empty", 1, "techage:river_water")
techage.register_liquid("techage:barrel_water", "techage:ta3_barrel_empty", 10, "techage:water")
techage.register_liquid("techage:barrel_river_water", "techage:ta3_barrel_empty", 10, "techage:river_water")
techage.register_liquid("bucket:bucket_lava", "bucket:bucket_empty", 1, "default:lava_source")

286
liquids/liquid.lua.orig Normal file
View File

@ -0,0 +1,286 @@
--[[
TechAge
=======
Copyright (C) 2019 Joachim Stolberg
GPL v3
See LICENSE.txt for more information
Liquid transportation API via Pipe(s) (peer, put, take)
]]--
local P2S = minetest.pos_to_string
local M = minetest.get_meta
local N = function(pos) return minetest.get_node(pos).name end
local LQD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm(pos).name] or {}).liquid end
local Pipe = techage.LiquidPipe
local S = techage.S
local net_def = techage.networks.net_def
local networks = techage.networks
techage.liquid = {}
local LiquidDef = {}
local ContainerDef = {}
--
-- Networks
--
-- determine network ID (largest hash number)
local function determine_netID(pos, outdir)
local netID = 0
networks.connection_walk(pos, outdir, Pipe, function(pos, indir, node)
local ntype = net_def(pos, "pipe").ntype
if ntype and ntype ~= "pump" then
local new = minetest.hash_node_position(pos)
if netID <= new then
netID = new
end
end
end)
return netID
end
-- store network ID on each node
local function store_netID(pos, outdir, netID)
networks.connection_walk(pos, outdir, Pipe, function(pos, indir, node)
local ntype = net_def(pos, "pipe").ntype
if ntype and ntype ~= "pump" then
local mem = tubelib2.get_mem(pos)
mem.pipe = mem.pipe or {}
mem.pipe.netID = netID
end
end)
end
-- delete network and ID on each node
local function delete_netID(pos, outdir)
local netID = 0
networks.connection_walk(pos, outdir, Pipe, function(pos, indir, node)
local ntype = net_def(pos, "pipe").ntype
if ntype and ntype ~= "pump" then
local mem = tubelib2.get_mem(pos)
if mem.pipe and mem.pipe.netID then
netID = mem.pipe.netID
mem.pipe.netID = nil
end
end
end)
networks.delete_network(netID, Pipe)
end
local function get_netID(pos, outdir)
-- jump to the next node because pumps have two network
-- interfaces and therefore can't have a netID
local pos2 = Pipe:get_connected_node_pos(pos, outdir)
if not vector.equals(pos2, pos) then
local mem = tubelib2.get_mem(pos2)
if not mem.pipe or not mem.pipe.netID then
-- determine the ID
local netID = determine_netID(pos2, outdir)
store_netID(pos2, outdir, netID)
mem.pipe = mem.pipe or {}
mem.pipe.netID = netID
end
return mem.pipe.netID
end
end
local function get_network_table(pos, outdir, ntype)
local netID = get_netID(pos, outdir)
if netID then
local netw = networks.get_network(netID, Pipe)
if not netw then
netw = networks.collect_network_nodes(pos, outdir, Pipe)
networks.set_network(netID, Pipe, netw)
end
local s = minetest.pos_to_string(minetest.get_position_from_hash(netID))
--print("netw", string.format("%012X", netID), s, dump(netw))
return netw[ntype] or {}
end
return {}
end
--
-- Client remote functions
--
-- Determine and return liquid 'name' from the
-- remote inventory.
function techage.liquid.peek(pos, outdir)
for _,item in ipairs(get_network_table(pos, outdir, "tank")) do
local liquid = LQD(item.pos)
if liquid and liquid.peek then
return liquid.peek(item.pos, item.indir)
end
end
end
-- Add given amount of liquid to the remote inventory.
-- return leftover amount
function techage.liquid.put(pos, outdir, name, amount, player_name)
for _,item in ipairs(get_network_table(pos, outdir, "tank")) do
local liquid = LQD(item.pos)
if liquid and liquid.put and liquid.peek then
-- wrong items?
local peek = liquid.peek(item.pos, item.indir)
if peek and peek ~= name then return amount or 0 end
if player_name then
local num = techage.get_node_number(pos) or "000"
techage.mark_position(player_name, item.pos, "("..num..") put", "", 1)
end
amount = liquid.put(item.pos, item.indir, name, amount)
if not amount or amount == 0 then break end
end
end
return amount or 0
end
-- Take given amount of liquid for the remote inventory.
-- return taken amount and item name
function techage.liquid.take(pos, outdir, name, amount, player_name)
local taken = 0
local item_name = nil
for _,item in ipairs(get_network_table(pos, outdir, "tank")) do
local liquid = LQD(item.pos)
if liquid and liquid.take then
if player_name then
local num = techage.get_node_number(pos)
techage.mark_position(player_name, item.pos, "("..num..") take", "", 1)
end
local val, name = liquid.take(item.pos, item.indir, name, amount - taken)
if val and name then
taken = taken + val
item_name = name
if amount - taken == 0 then break end
end
end
end
return taken, item_name
end
--
-- Server local functions
--
function techage.liquid.srv_peek(pos, indir)
local mem = tubelib2.get_mem(pos)
mem.liquid = mem.liquid or {}
return mem.liquid.name
end
function techage.liquid.srv_put(pos, indir, name, amount)
local mem = tubelib2.get_mem(pos)
mem.liquid = mem.liquid or {}
amount = amount or 0
if not mem.liquid.name then
mem.liquid.name = name
mem.liquid.amount = amount
return 0
elseif mem.liquid.name == name then
mem.liquid.amount = mem.liquid.amount or 0
local capa = LQD(pos).capa
if mem.liquid.amount + amount <= capa then
mem.liquid.amount = mem.liquid.amount + amount
return 0
else
local rest = mem.liquid.amount + amount - capa
mem.liquid.amount = capa
return rest
end
end
return amount
end
function techage.liquid.srv_take(pos, indir, name, amount)
local mem = tubelib2.get_mem(pos)
mem.liquid = mem.liquid or {}
amount = amount or 0
if not name or mem.liquid.name == name then
name = mem.liquid.name
mem.liquid.amount = mem.liquid.amount or 0
if mem.liquid.amount > amount then
mem.liquid.amount = mem.liquid.amount - amount
return amount, name
else
local rest = mem.liquid.amount
local name = mem.liquid.name
mem.liquid.amount = 0
mem.liquid.name = nil
return rest, name
end
end
return 0
end
--
-- Further API functions
--
-- like: register_liquid("techage:ta3_barrel_oil", "techage:ta3_barrel_empty", 10, "techage:oil")
function techage.register_liquid(full_container, empty_container, container_size, inv_item)
LiquidDef[full_container] = {container = empty_container, size = container_size, inv_item = inv_item}
ContainerDef[empty_container] = ContainerDef[empty_container] or {}
ContainerDef[empty_container][inv_item] = full_container
end
function techage.liquid.get_liquid_def(full_container)
return LiquidDef[full_container]
end
function techage.liquid.is_container_empty(container_name)
return ContainerDef[container_name]
end
function techage.liquid.get_full_container(empty_container, inv_item)
return ContainerDef[empty_container] and ContainerDef[empty_container][inv_item]
end
-- To be called from each node via 'tubelib2_on_update2'
-- 'output' is optional and only needed for nodes with dedicated
-- pipe sides (e.g. pumps).
function techage.liquid.update_network(pos, outdir)
networks.node_connections(pos, Pipe)
delete_netID(pos, outdir)
end
minetest.register_craftitem("techage:water", {
description = S("Water"),
inventory_image = "techage_water_inv.png",
groups = {not_in_creative_inventory=1},
})
minetest.register_craftitem("techage:river_water", {
description = S("Water"),
inventory_image = "techage_water_inv.png",
groups = {not_in_creative_inventory=1},
})
minetest.register_craftitem("techage:barrel_water", {
description = S("Water Barrel"),
inventory_image = "techage_barrel_water_inv.png",
stack_max = 1,
})
minetest.register_craftitem("techage:barrel_river_water", {
description = S("River Water Barrel"),
inventory_image = "techage_barrel_water_inv.png",
stack_max = 1,
})
techage.register_liquid("bucket:bucket_water", "bucket:bucket_empty", 1, "techage:water")
techage.register_liquid("bucket:bucket_river_water", "bucket:bucket_empty", 1, "techage:river_water")
techage.register_liquid("techage:barrel_water", "techage:ta3_barrel_empty", 10, "techage:water")
techage.register_liquid("techage:barrel_river_water", "techage:ta3_barrel_empty", 10, "techage:river_water")
techage.register_liquid("bucket:bucket_lava", "bucket:bucket_empty", 1, "default:lava_source")

View File

@ -128,6 +128,7 @@ end
local function after_dig_node(pos, oldnode, oldmetadata, digger) local function after_dig_node(pos, oldnode, oldmetadata, digger)
Pipe:after_dig_node(pos) Pipe:after_dig_node(pos)
tubelib2.del_mem(pos)
end end
local ta3_tiles_pas = { local ta3_tiles_pas = {

215
liquids/silo.lua Normal file
View File

@ -0,0 +1,215 @@
--[[
TechAge
=======
Copyright (C) 2019 Joachim Stolberg
GPL v3
See LICENSE.txt for more information
TA3/TA4 Powder Silo
]]--
local S2P = minetest.string_to_pos
local P2S = minetest.pos_to_string
local M = minetest.get_meta
local S = techage.S
local LQD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm(pos).name] or {}).liquid end
local Pipe = techage.LiquidPipe
local liquid = techage.liquid
local INV_SIZE = 8
local function allow_metadata_inventory_put(pos, listname, index, stack, player)
if minetest.is_protected(pos, player:get_player_name()) then
return 0
end
local mem = tubelib2.get_mem(pos)
mem.item_name = nil
local inv = minetest.get_meta(pos):get_inventory()
if inv:is_empty(listname) then
return stack:get_count()
end
if inv:contains_item(listname, ItemStack(stack:get_name())) then
return stack:get_count()
end
return 0
end
local function allow_metadata_inventory_take(pos, listname, index, stack, player)
if minetest.is_protected(pos, player:get_player_name()) then
return 0
end
local mem = tubelib2.get_mem(pos)
mem.item_name = nil
return stack:get_count()
end
local function can_dig(pos, player)
if minetest.is_protected(pos, player:get_player_name()) then
return false
end
local inv = minetest.get_meta(pos):get_inventory()
return inv:is_empty("main")
end
local function get_item_name(mem, inv)
for idx = 1, INV_SIZE do
local stack = inv:get_stack("main", idx)
if stack:get_count() > 0 then
mem.item_name = stack:get_name()
return mem.item_name
end
end
end
local function formspec()
return "size[8,6]"..
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"list[context;main;0,0;8,2;]"..
"list[current_player;main;0,2.3;8,4;]"..
"listring[context;main]"..
"listring[current_player;main]"
end
minetest.register_node("techage:ta3_silo", {
description = S("TA3 Silo"),
tiles = {
-- up, down, right, left, back, front
"techage_filling_ta3.png^techage_frame_ta3_top.png",
"techage_filling_ta3.png^techage_frame_ta3.png",
"techage_filling_ta3.png^techage_frame_ta3.png^techage_appl_silo.png",
"techage_filling_ta3.png^techage_frame_ta3.png^techage_appl_silo.png",
"techage_filling_ta3.png^techage_frame_ta3.png^techage_appl_silo.png",
"techage_filling_ta3.png^techage_frame_ta3.png^techage_appl_silo.png",
},
on_construct = function(pos)
local inv = M(pos):get_inventory()
inv:set_size('main', INV_SIZE)
end,
after_place_node = function(pos, placer)
local meta = M(pos)
local mem = tubelib2.init_mem(pos)
mem.liquid = {}
local number = techage.add_node(pos, "techage:ta3_silo")
meta:set_string("node_number", number)
meta:set_string("owner", placer:get_player_name())
meta:set_string("formspec", formspec(mem))
meta:set_string("infotext", S("TA3 Silo").." "..number)
Pipe:after_place_node(pos)
end,
tubelib2_on_update2 = function(pos, outdir, tlib2, node)
liquid.update_network(pos, outdir)
end,
on_timer = function(pos, elapsed)
local mem = tubelib2.get_mem(pos)
if mem.countdown then
mem.countdown = mem.countdown - 1
M(pos):set_string("formspec", formspec(mem))
return mem.countdown > 0
end
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
Pipe:after_dig_node(pos)
techage.remove_node(pos)
end,
liquid = {
capa = 0,
peek = function(pos, indir)
local mem = tubelib2.get_mem(pos)
local inv = M(pos):get_inventory()
if not inv:is_empty("main") then
return mem.item_name or get_item_name(mem, inv)
end
end,
put = function(pos, indir, name, amount)
local inv = M(pos):get_inventory()
local stack = ItemStack(name.." "..amount)
if inv:room_for_item("main", stack) then
inv:add_item("main", stack)
return 0
end
return amount
end,
take = function(pos, indir, name, amount)
local inv = M(pos):get_inventory()
local stack = ItemStack(name.." "..amount)
if inv:contains_item("main", stack) then
inv:room_for_item("main", stack)
return amount, name
end
return 0
end,
},
networks = {
pipe = {
sides = techage.networks.AllSides, -- Pipe connection sides
ntype = "tank",
},
},
can_dig = can_dig,
allow_metadata_inventory_put = allow_metadata_inventory_put,
allow_metadata_inventory_take = allow_metadata_inventory_take,
paramtype2 = "facedir",
on_rotate = screwdriver.disallow,
groups = {cracky=2},
is_ground_content = false,
sounds = default.node_sound_metal_defaults(),
})
techage.register_node({"techage:ta3_silo", "techage:ta4_silo"}, {
on_pull_item = function(pos, in_dir, num)
local inv = M(pos):get_inventory()
if not inv:is_empty("main") then
return techage.get_items(inv, "main", num)
end
end,
on_push_item = function(pos, in_dir, stack)
local inv = M(pos):get_inventory()
if inv:room_for_item("main", stack) then
inv:add_item("main", stack)
return true
end
return false
end,
on_unpull_item = function(pos, in_dir, stack)
local meta = M(pos)
local inv = meta:get_inventory()
return techage.put_items(inv, "main", stack)
end,
on_recv_message = function(pos, src, topic, payload)
if topic == "state" then
local meta = M(pos)
local inv = meta:get_inventory()
return techage.get_inv_state(inv, "main")
else
return "unsupported"
end
end,
})
Pipe:add_secondary_node_names({"techage:ta3_silo", "techage:ta4_silo"})
minetest.register_craft({
output = "techage:ta3_silo",
recipe = {
{"", "", ""},
{"techage:tubeS", "techage:chest_ta3", "techage:ta3_pipeS"},
{"", "", ""},
},
})
minetest.register_craft({
output = "techage:ta4_silo",
recipe = {
{"default:tin_ingot", "dye:blue", "default:steel_ingot"},
{"", "techage:ta3_silo", ""},
{"", "", ""},
},
})

View File

@ -180,8 +180,8 @@ minetest.register_node("techage:ta3_tank", {
meta:set_string("infotext", S("TA3 Tank").." "..number) meta:set_string("infotext", S("TA3 Tank").." "..number)
Pipe:after_place_node(pos) Pipe:after_place_node(pos)
end, end,
tubelib2_on_update2 = function(pos, dir, tlib2, node) tubelib2_on_update2 = function(pos, outdir, tlib2, node)
liquid.update_network(pos) liquid.update_network(pos, outdir)
end, end,
on_timer = function(pos, elapsed) on_timer = function(pos, elapsed)
local mem = tubelib2.get_mem(pos) local mem = tubelib2.get_mem(pos)
@ -267,8 +267,8 @@ minetest.register_node("techage:oiltank", {
meta:set_string("infotext", S("Oil Tank").." "..number) meta:set_string("infotext", S("Oil Tank").." "..number)
Pipe:after_place_node(pos) Pipe:after_place_node(pos)
end, end,
tubelib2_on_update2 = function(pos, dir, tlib2, node) tubelib2_on_update2 = function(pos, outdir, tlib2, node)
liquid.update_network(pos) liquid.update_network(pos, outdir)
end, end,
on_timer = function(pos, elapsed) on_timer = function(pos, elapsed)
local mem = tubelib2.get_mem(pos) local mem = tubelib2.get_mem(pos)
@ -344,8 +344,8 @@ minetest.register_node("techage:ta4_tank", {
meta:set_string("infotext", S("TA4 Tank").." "..number) meta:set_string("infotext", S("TA4 Tank").." "..number)
Pipe:after_place_node(pos) Pipe:after_place_node(pos)
end, end,
tubelib2_on_update2 = function(pos, dir, tlib2, node) tubelib2_on_update2 = function(pos, outdir, tlib2, node)
liquid.update_network(pos) liquid.update_network(pos, outdir)
end, end,
on_timer = function(pos, elapsed) on_timer = function(pos, elapsed)
local mem = tubelib2.get_mem(pos) local mem = tubelib2.get_mem(pos)

View File

@ -56,7 +56,7 @@ Meridium Axe=Meridium Axt
Meridium Pickaxe=Meridium Pickel Meridium Pickaxe=Meridium Pickel
Meridium Shovel=Meridium Schaufel Meridium Shovel=Meridium Schaufel
Meridium Sword=Meridium Schwert Meridium Sword=Meridium Schwert
More water expected (2 m deep)!= More water expected (2 m deep)!=Mehr Wasser erwartet (2 m tief)
Network Data=Netzwerkdaten Network Data=Netzwerkdaten
No plan available=Kein Plan verfügar No plan available=Kein Plan verfügar
No wind at this altitude!=Kein Wind auf dieser Höhe No wind at this altitude!=Kein Wind auf dieser Höhe
@ -207,14 +207,14 @@ TA4 Heat Exchanger 1=TA4 Wärmetauscher 1
TA4 Heat Exchanger 2=TA4 Wärmetauscher 2 TA4 Heat Exchanger 2=TA4 Wärmetauscher 2
TA4 Heat Exchanger 3=TA4 Wärmetauscher 3 TA4 Heat Exchanger 3=TA4 Wärmetauscher 3
TA4 Hydrogen=TA4 Wasserstoff TA4 Hydrogen=TA4 Wasserstoff
TA4 Low Power Box==TA4 Niederspannungsverteilerbox TA4 Low Power Box=TA4 Niederspannungsverteilerbox
TA4 Low Power Cable=TA4 Niederspannungskabel TA4 Low Power Cable=TA4 Niederspannungskabel
TA4 Pillar=TA4 Säule TA4 Pillar=TA4 Säule
TA4 Pipe Inlet=TA4 Rohrzulauf TA4 Pipe Inlet=TA4 Rohrzulauf
TA4 Protected Chest=TA4 Gesicherte Kiste TA4 Protected Chest=TA4 Gesicherte Kiste
TA4 Pump=TA4 Pumpe TA4 Pump=TA4 Pumpe
TA4 Reactor=Reaktor TA4 Reactor=Reaktor
TA4 Reactor Base= TA4 Reactor Base=TA4 Reaktor Basis
TA4 Reactor Filler Pipe=TA4 Reaktor Einfüllstutzen TA4 Reactor Filler Pipe=TA4 Reaktor Einfüllstutzen
TA4 Rotor Blade=TA4 Rotorblatt TA4 Rotor Blade=TA4 Rotorblatt
TA4 Silicon Wafer=TA4 Silizium-Wafer TA4 Silicon Wafer=TA4 Silizium-Wafer

View File

@ -92,7 +92,7 @@ local function node_timer(pos, elapsed)
if mem.liquid.amount >= 5 and mem.liquid.name == "techage:oil_source" then if mem.liquid.amount >= 5 and mem.liquid.name == "techage:oil_source" then
mem.liquid.amount = mem.liquid.amount - 5 mem.liquid.amount = mem.liquid.amount - 5
local leftover = pump_cmnd(pos, "put") local leftover = pump_cmnd(pos, "put")
if leftover > 0 then if (tonumber(leftover) or 1) > 0 then
swap_node(pos, false) swap_node(pos, false)
return false return false
end end

BIN
sounds/techage_reactor.ogg Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 343 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 385 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 386 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 386 B

After

Width:  |  Height:  |  Size: 343 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 385 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 385 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 419 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 656 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 406 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 281 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 414 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 285 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 285 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 412 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 300 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 308 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 310 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 379 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 298 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 351 B

View File

@ -265,11 +265,6 @@ techage.register_node({"techage:ta4_wind_turbine"}, {
end, end,
}) })
minetest.register_craftitem("techage:ta4_epoxy", {
description = S("TA4 Epoxide Resin"),
inventory_image = "techage_epoxy.png",
})
minetest.register_craftitem("techage:ta4_carbon_fiber", { minetest.register_craftitem("techage:ta4_carbon_fiber", {
description = S("TA4 Carbon Fiber"), description = S("TA4 Carbon Fiber"),
inventory_image = "techage_carbon_fiber.png", inventory_image = "techage_carbon_fiber.png",
@ -303,9 +298,13 @@ minetest.register_craft({
output = "techage:ta4_rotor_blade", output = "techage:ta4_rotor_blade",
recipe = { recipe = {
{"techage:ta4_carbon_fiber", "dye:white", "techage:ta4_carbon_fiber"}, {"techage:ta4_carbon_fiber", "dye:white", "techage:ta4_carbon_fiber"},
{"techage:ta4_epoxy", "techage:ta4_carbon_fiber", "techage:ta4_epoxy"}, {"techage:canister_epoxy", "techage:ta4_carbon_fiber", "techage:canister_epoxy"},
{"techage:ta4_carbon_fiber", "dye:red", "techage:ta4_carbon_fiber"}, {"techage:ta4_carbon_fiber", "dye:red", "techage:ta4_carbon_fiber"},
}, },
replacements = {
{"techage:canister_epoxy", "techage:ta3_canister_empty"},
{"techage:canister_epoxy", "techage:ta3_canister_empty"},
},
}) })
techage.furnace.register_recipe({ techage.furnace.register_recipe({
@ -314,11 +313,3 @@ techage.furnace.register_recipe({
heat = 4, heat = 4,
time = 3, time = 3,
}) })
techage.furnace.register_recipe({
output = "techage:ta4_epoxy",
recipe = {"basic_materials:oil_extract", "techage:oil_source",
"basic_materials:oil_extract", "techage:oil_source"},
heat = 4,
time = 3,
})