diff --git a/basic_machines/grinder.lua b/basic_machines/grinder.lua index 4e8461b..8e68021 100644 --- a/basic_machines/grinder.lua +++ b/basic_machines/grinder.lua @@ -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:aspen_tree", output="default:aspen_leaves 8"}) -techage.add_grinder_recipe({input="techage:bauxite_cobble", output="techage:bauxite_gravel"}) diff --git a/basis/networks.lua b/basis/networks.lua index 711cf29..6080997 100644 --- a/basis/networks.lua +++ b/basis/networks.lua @@ -157,18 +157,17 @@ end -- do the walk through the tubelib2 network -- indir is the direction which should not be covered by the walk --- (coming from there or is a different network) -local function connection_walk(pos, indir, node, tlib2, lvl, clbk) +-- (coming from there) +-- 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 --techage.mark_position("singleplayer", pos, "walk", "", 1) - if lvl == 1 or net_def2(node.name, tlib2.tube_type).ntype == "junc" then - for _,outdir in pairs(get_node_connections(pos, tlib2.tube_type)) do - if outdir ~= Flip[indir] then - local pos2, indir2 = tlib2:get_connected_node_pos(pos, outdir) - local node = techage.get_node_lvm(pos2) - if pos2 and not pos_already_reached(pos2) and valid_indir(indir2, node, tlib2.tube_type) then - connection_walk(pos2, indir2, node, tlib2, lvl + 1, clbk) - end + if outdirs or net_def2(node.name, tlib2.tube_type).ntype == "junc" then + for _,outdir in pairs(outdirs or get_node_connections(pos, tlib2.tube_type)) do + local pos2, indir2 = tlib2:get_connected_node_pos(pos, outdir) + local node = techage.get_node_lvm(pos2) + 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) end end end @@ -183,7 +182,7 @@ local function collect_network_nodes(pos, outdir, tlib2) local node = techage.get_node_lvm(pos) local net_name = tlib2.tube_type -- 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 if ntype then if not netw[ntype] then netw[ntype] = {} end @@ -246,7 +245,7 @@ function techage.networks.connection_walk(pos, outdir, tlib2, clbk) NumNodes = 0 pos_already_reached(pos) -- don't consider the start 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 end diff --git a/basis/recipe_lib.lua b/basis/recipe_lib.lua index 7435dad..85af1b9 100644 --- a/basis/recipe_lib.lua +++ b/basis/recipe_lib.lua @@ -22,6 +22,18 @@ local range = techage.range 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 local function input_string(recipe) local tbl = {} @@ -88,7 +100,7 @@ function techage.recipes.formspec(x, y, rtype, mem) local recipe_list = RecipeList[rtype] or {} mem.recipe_idx = range(mem.recipe_idx or 1, 1, #recipe_list) 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 waste = recipe.waste.name.." "..recipe.waste.num return "container["..x..","..y.."]".. diff --git a/chemistry/recipes.lua b/chemistry/recipes.lua deleted file mode 100644 index f5ca85c..0000000 --- a/chemistry/recipes.lua +++ /dev/null @@ -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", - } -}) \ No newline at end of file diff --git a/chemistry/ta4_doser.lua b/chemistry/ta4_doser.lua index 5bacd8f..b9e219b 100644 --- a/chemistry/ta4_doser.lua +++ b/chemistry/ta4_doser.lua @@ -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 N = function(pos) return minetest.get_node(pos).name end -local Pipe = techage.BiogasPipe +local S = techage.S +local Pipe = techage.LiquidPipe +local networks = techage.networks local liquid = techage.liquid local recipes = techage.recipes @@ -23,7 +25,27 @@ local Liquids = {} -- {hash(pos) = {name = outdir},...} local STANDBY_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) return "size[8,7]".. @@ -85,6 +107,7 @@ end local function start_node(pos, mem, state) reactor_cmnd(pos, "start") + del_liquids(pos) mem.running = true end @@ -105,34 +128,44 @@ local State = techage.NodeStates:new({ stop_node = stop_node, }) -local function reset_dosing(mem) - -- alle 4 ports checken und inputs vorladen -end - local function dosing(pos, mem, elapsed) -- trigger reactor (power) 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")) end State:idle(pos, mem) return 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 local liquids = get_liquids(pos) local recipe = recipes.get(mem, "ta4_doser") if not liquids or not recipe then return end -- inputs + local starter = get_starter_name(pos) for _,item in pairs(recipe.input) do if item.name ~= "" then - print("dosing", item.name, dump(liquids)) local outdir = liquids[item.name] if not outdir then - State:fault(pos, mem, S("input missing")) + State:standby(pos, mem) + reactor_cmnd(pos, "stop") return end - if liquid.take(pos, outdir, item.name, item.num) < item.num then - State:fault(pos, mem, S("input missing")) + if liquid.take(pos, outdir, item.name, item.num, starter) < item.num then + State:standby(pos, mem) + reactor_cmnd(pos, "stop") return end end @@ -142,16 +175,18 @@ local function dosing(pos, mem, elapsed) leftover = reactor_cmnd(pos, "output", { name = recipe.output.name, amount = recipe.output.num}) - if not leftover or leftover > 0 then - State:fault(pos, mem, S("output blocked")) + if not leftover or (tonumber(leftover) or 1) > 0 then + State:blocked(pos, mem) + reactor_cmnd(pos, "stop") return end if recipe.waste.name ~= "" then leftover = reactor_cmnd(pos, "waste", { name = recipe.waste.name, amount = recipe.waste.num}) - if not leftover or leftover > 0 then - State:fault(pos, mem, S("output blocked")) + if not leftover or (tonumber(leftover) or 1) > 0 then + State:blocked(pos, mem) + reactor_cmnd(pos, "stop") return end end @@ -178,10 +213,18 @@ local function on_receive_fields(pos, formname, fields, player) if not mem.running then recipes.on_receive_fields(pos, formname, fields, player) end + set_starter_name(pos, player) State:state_button_event(pos, mem, fields) M(pos):set_string("formspec", formspec(State, pos, mem)) end +local nworks = { + pipe = { + sides = techage.networks.AllSides, -- Pipe connection sides + ntype = "pump", + }, +} + minetest.register_node("techage:ta4_doser", { description = S("TA4 Doser"), @@ -189,12 +232,33 @@ minetest.register_node("techage:ta4_doser", { -- 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.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_rightclick = on_rightclick, on_timer = node_timer, + networks = nworks, paramtype2 = "facedir", 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.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, animation = { 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_rightclick = on_rightclick, on_timer = node_timer, + networks = nworks, paramtype2 = "facedir", on_rotate = screwdriver.disallow, - groups = {cracky=2}, + diggable = false, + groups = {not_in_creative_inventory=1}, is_ground_content = false, sounds = default.node_sound_metal_defaults(), }) --- for mechanical pipe connections -techage.power.register_node({"techage:ta4_doser", "techage:ta4_doser_on"}, { - conn_sides = {"F", "B", "R", "L", "U"}, - power_network = Pipe, - 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()) - 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) +techage.register_node({"techage:ta4_doser", "techage:ta4_doser_on"}, { + on_recv_message = function(pos, src, topic, payload) + local resp = State:on_receive_message(pos, topic, payload) + if resp then + return resp + else + return "unsupported" + end end, - after_dig_node = function(pos, oldnode, oldmetadata, digger) - techage.remove_node(pos) + on_node_load = function(pos) + State:on_node_load(pos) end, }) +Pipe:add_secondary_node_names({"techage:ta4_doser", "techage:ta4_doser_on"}) + + if minetest.global_exists("unified_inventory") then unified_inventory.register_craft_type("ta4_doser", { description = S("TA4 Doser"), @@ -261,3 +327,12 @@ if minetest.global_exists("unified_inventory") then height = 2, }) end + +minetest.register_craft({ + output = "techage:ta4_doser", + recipe = { + {"", "techage:ta3_pipeS", ""}, + {"techage:ta3_pipeS", "techage:t4_pump", "techage:ta3_pipeS"}, + {"", "techage:ta4_wlanchip", ""}, + }, +}) diff --git a/chemistry/ta4_reactor.lua b/chemistry/ta4_reactor.lua index 6a12927..7902836 100644 --- a/chemistry/ta4_reactor.lua +++ b/chemistry/ta4_reactor.lua @@ -133,3 +133,21 @@ minetest.register_node("techage:ta4_reactor", { }) 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'}, + } +}) diff --git a/chemistry/ta4_stand.lua b/chemistry/ta4_stand.lua index 740ad04..4de8b9b 100644 --- a/chemistry/ta4_stand.lua +++ b/chemistry/ta4_stand.lua @@ -85,21 +85,12 @@ minetest.register_node("techage:ta4_reactor_stand", { on_timer = function(pos, elapsed) local mem = tubelib2.get_mem(pos) power.consumer_alive(pos, mem) + minetest.sound_play("techage_reactor", { + pos = pos, + gain = 0.5, + max_hear_distance = 10}) return mem.running 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) techage.power.after_dig_node(pos, oldnode) Pipe:after_dig_node(pos) @@ -132,10 +123,11 @@ techage.power.enrich_node({"techage:ta4_reactor_stand"}, { -- controlled by the fillerpipe techage.register_node({"techage:ta4_reactor_stand"}, { on_transfer = function(pos, in_dir, topic, payload) - print(topic, payload) + --print(topic, dump(payload)) local mem = tubelib2.get_mem(pos) 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 local outdir = M(pos):get_int("outdir") 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_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', '', ''}, + {'', '', ''}, + } +}) diff --git a/furnace/cooking.lua b/furnace/cooking.lua index be2838f..1235e29 100644 --- a/furnace/cooking.lua +++ b/furnace/cooking.lua @@ -19,8 +19,8 @@ local S = techage.S local range = techage.range -local Recipes = {} -- registered recipes -local Ingredients = {} +local Recipes = {} -- registered recipes {output = {recipe, ...},} +local Ingredients = {} -- {{input = output}, local KeyList = {} -- index to Recipes key translation techage.furnace = {} @@ -72,22 +72,60 @@ function techage.furnace.get_ingredients(pos) return tbl 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 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 - 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 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 end @@ -98,23 +136,16 @@ function techage.furnace.smelting(pos, mem, elapsed) if not mem.output or not mem.num_recipe then return techage.FAULT, "recipe error" 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 return techage.FAULT, "recipe error" 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) while elapsed >= recipe.time do - if process(inv, recipe, mem.output) == false then - mem.leftover = 0 - return techage.STANDBY - else - state = techage.RUNNING + state = process(inv, recipe, mem.output) + if state ~= techage.RUNNING then + return state end elapsed = elapsed - recipe.time end @@ -143,6 +174,7 @@ end function techage.furnace.reset_cooking(mem) mem.leftover = 0 + mem.item_percent = 0 end diff --git a/furnace/furnace_top.lua b/furnace/furnace_top.lua index 856e18e..b7be461 100644 --- a/furnace/furnace_top.lua +++ b/furnace/furnace_top.lua @@ -29,14 +29,21 @@ local get_output = techage.furnace.get_output local num_recipes = techage.furnace.get_num_recipes local reset_cooking = techage.furnace.reset_cooking 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 function formspec(self, pos, mem) + +local function update_recipe_menu(pos, mem) local ingr = get_ingredients(pos) - local num = num_recipes(ingr) - mem.recipe_idx = range(mem.recipe_idx or 1, 0, num) - local idx = mem.recipe_idx - local output = get_output(mem, ingr, idx) + mem.rp_num = num_recipes(ingr) + mem.rp_idx = range(mem.rp_idx or 1, 0, mem.rp_num) + mem.rp_outp = get_output(mem, ingr, mem.rp_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]".. default.gui_bg.. default.gui_bg_img.. @@ -50,7 +57,7 @@ local function formspec(self, pos, mem) "list[context;dst;3,0;2,2;]".. "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[7,1.5;1,1;next;>>]".. @@ -75,23 +82,26 @@ local function firebox_cmnd(pos, cmnd) cmnd, -- topic nil, -- payload nil, -- network - {"techage:furnace_firebox", "techage:furnace_firebox_on"}) + {"techage:furnace_firebox", "techage:furnace_firebox_on", + "techage:furnace_heater", "techage:furnace_heater_on"}) end local function cooking(pos, crd, mem, elapsed) - if firebox_cmnd(pos, "running") then - local state, err = smelting(pos, mem, elapsed) - if state == techage.RUNNING then - crd.State:keep_running(pos, mem, COUNTDOWN_TICKS) - elseif state == techage.BLOCKED then - crd.State:blocked(pos, mem) - elseif state == techage.FAULT then - crd.State:fault(pos, mem, err) - elseif state == techage.STANDBY then + if mem.techage_state == techage.RUNNING or check_if_worth_to_wakeup(pos, mem) then + if firebox_cmnd(pos, "fuel") then + local state, err = smelting(pos, mem, elapsed) + if state == techage.RUNNING then + crd.State:keep_running(pos, mem, COUNTDOWN_TICKS) + elseif state == techage.BLOCKED then + crd.State:blocked(pos, mem) + elseif state == techage.FAULT then + crd.State:fault(pos, mem, err) + elseif state == techage.STANDBY then + crd.State:idle(pos, mem) + end + else crd.State:idle(pos, mem) end - else - crd.State:idle(pos, mem) end end @@ -100,7 +110,7 @@ local function keep_running(pos, elapsed) local crd = CRD(pos) cooking(pos, crd, mem, elapsed) 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)) end return crd.State:is_active(mem) @@ -112,7 +122,6 @@ local function allow_metadata_inventory_put(pos, listname, index, stack, player) end if listname == "src" then local mem = tubelib2.get_mem(pos) - CRD(pos).State:start_if_standby(pos) return stack:get_count() elseif listname == "dst" then return 0 @@ -144,15 +153,17 @@ local function on_receive_fields(pos, formname, fields, player) return end 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 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)) reset_cooking(mem) elseif fields.priv == "<<" then 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)) reset_cooking(mem) end @@ -216,7 +227,6 @@ local tubing = { local meta = minetest.get_meta(pos) if meta:get_int("push_dir") == in_dir or in_dir == 5 then local inv = M(pos):get_inventory() - CRD(pos).State:start_if_standby(pos) return techage.put_items(inv, "src", stack) end end, diff --git a/furnace/heater.lua b/furnace/heater.lua new file mode 100644 index 0000000..61534fd --- /dev/null +++ b/furnace/heater.lua @@ -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"}) + diff --git a/init.lua b/init.lua index 7eba324..6e34ff2 100644 --- a/init.lua +++ b/init.lua @@ -58,11 +58,6 @@ else dofile(MP.."/doc/items.lua") 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 dofile(MP.."/power/schedule.lua") --dofile(MP.."/power/distribute.lua") @@ -121,8 +116,8 @@ else -- Liquids dofile(MP.."/liquids/liquid_pipe.lua") dofile(MP.."/liquids/liquid.lua") - dofile(MP.."/liquids/barrel.lua") dofile(MP.."/liquids/tank.lua") + dofile(MP.."/liquids/silo.lua") dofile(MP.."/liquids/pump.lua") dofile(MP.."/liquids/fuel_lib.lua") @@ -141,6 +136,7 @@ else dofile(MP.."/furnace/cooking.lua") dofile(MP.."/furnace/furnace_top.lua") dofile(MP.."/furnace/booster.lua") + dofile(MP.."/furnace/heater.lua") dofile(MP.."/furnace/recipes.lua") -- Tools @@ -159,25 +155,15 @@ else dofile(MP.."/lamps/industriallamp3.lua") -- Oil - dofile(MP.."/oil/oil.lua") dofile(MP.."/oil/explore.lua") dofile(MP.."/oil/tower.lua") dofile(MP.."/oil/drillbox.lua") dofile(MP.."/oil/pumpjack.lua") dofile(MP.."/oil/generator.lua") - dofile(MP.."/oil/petroleum.lua") dofile(MP.."/oil/distiller.lua") dofile(MP.."/oil/reboiler.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 dofile(MP.."/logic/lib.lua") dofile(MP.."/logic/terminal.lua") @@ -192,6 +178,8 @@ else dofile(MP.."/logic/node_detector.lua") dofile(MP.."/logic/player_detector.lua") dofile(MP.."/logic/cart_detector.lua") + dofile(MP.."/logic/gateblock.lua") + dofile(MP.."/logic/doorblock.lua") -- Test dofile(MP.."/recipe_checker.lua") @@ -201,14 +189,13 @@ else --dofile(MP.."/.test/switch.lua") -- Solar - dofile(MP.."/nodes/silicon.lua") dofile(MP.."/solar/minicell.lua") dofile(MP.."/solar/solarcell.lua") dofile(MP.."/solar/inverter.lua") -- Wind dofile(MP.."/wind_turbine/rotor.lua") - dofile(MP.."/nodes/pillar.lua") + dofile(MP.."/wind_turbine/pillar.lua") dofile(MP.."/wind_turbine/signallamp.lua") -- TA4 Energy Storage @@ -219,12 +206,30 @@ else dofile(MP.."/energy_storage/nodes.lua") -- Chemistry - --dofile(MP.."/chemistry/ta4_reactor.lua") - --dofile(MP.."/chemistry/ta4_stand.lua") - --dofile(MP.."/chemistry/ta4_doser.lua") + dofile(MP.."/chemistry/ta4_reactor.lua") + dofile(MP.."/chemistry/ta4_stand.lua") + dofile(MP.."/chemistry/ta4_doser.lua") -- Hydrogen dofile(MP.."/hydrogen/hydrogen.lua") dofile(MP.."/hydrogen/electrolyzer.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 \ No newline at end of file diff --git a/items/aluminium.lua b/items/aluminium.lua new file mode 100644 index 0000000..fb049ce --- /dev/null +++ b/items/aluminium.lua @@ -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, + +}) diff --git a/nodes/baborium.lua b/items/baborium.lua similarity index 97% rename from nodes/baborium.lua rename to items/baborium.lua index f23b799..a541052 100644 --- a/nodes/baborium.lua +++ b/items/baborium.lua @@ -8,7 +8,7 @@ GPL v3 See LICENSE.txt for more information - Gravel Sieve basis functions + Baborium ]]-- diff --git a/items/barrel.lua b/items/barrel.lua new file mode 100644 index 0000000..053dd7b --- /dev/null +++ b/items/barrel.lua @@ -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") diff --git a/nodes/basalt.lua b/items/basalt.lua similarity index 100% rename from nodes/basalt.lua rename to items/basalt.lua diff --git a/nodes/bauxit.lua b/items/bauxit.lua similarity index 71% rename from nodes/bauxit.lua rename to items/bauxit.lua index a06feb6..bd25a93 100644 --- a/nodes/bauxit.lua +++ b/items/bauxit.lua @@ -16,7 +16,7 @@ local S = techage.S minetest.register_node("techage: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}, drop = 'techage:bauxite_cobble', sounds = default.node_sound_stone_defaults(), @@ -24,7 +24,7 @@ minetest.register_node("techage:bauxite_stone", { minetest.register_node("techage:bauxite_cobble", { description = S("Bauxite Cobblestone"), - tiles = {"default_desert_cobble.png^[colorize:#800000:80"}, + tiles = {"default_desert_cobble.png^[colorize:#FB2A00:80"}, is_ground_content = false, groups = {cracky = 3, stone = 2}, sounds = default.node_sound_stone_defaults(), @@ -32,12 +32,18 @@ minetest.register_node("techage:bauxite_cobble", { minetest.register_node("techage:bauxite_gravel", { description = S("Bauxite Gravel"), - tiles = {"default_gravel.png^[colorize:#9b1f06:180"}, + tiles = {"default_gravel.png^[colorize:#FB2A00:180"}, is_ground_content = false, groups = {crumbly = 2, falling_node = 1}, 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({ ore_type = "blob", 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"}) diff --git a/items/epoxy.lua b/items/epoxy.lua new file mode 100644 index 0000000..dda8c44 --- /dev/null +++ b/items/epoxy.lua @@ -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") \ No newline at end of file diff --git a/items/lye.lua b/items/lye.lua new file mode 100644 index 0000000..1047e34 --- /dev/null +++ b/items/lye.lua @@ -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") diff --git a/oil/oil.lua b/items/oil.lua similarity index 78% rename from oil/oil.lua rename to items/oil.lua index e4b9b24..61828d8 100644 --- a/oil/oil.lua +++ b/items/oil.lua @@ -22,7 +22,7 @@ minetest.register_node("techage:oil_source", { drawtype = "liquid", paramtype = "light", - inventory_image = "techage_oil_inv.png", + inventory_image = "techage_liquid2_inv.png^[colorize:#000000^techage_liquid1_inv.png", tiles = { { name = "techage_oil_animated.png", @@ -119,5 +119,19 @@ bucket.register_liquid( "techage_bucket_oil.png", "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: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") diff --git a/oil/petroleum.lua b/items/petroleum.lua similarity index 73% rename from oil/petroleum.lua rename to items/petroleum.lua index 6e8acca..5c532c9 100644 --- a/oil/petroleum.lua +++ b/items/petroleum.lua @@ -17,26 +17,22 @@ local S = techage.S minetest.register_craftitem("techage:bitumen", { description = S("TA3 Bitumen"), - inventory_image = "techage_bitumen_inv.png", - groups = {not_in_creative_inventory=1}, + inventory_image = "techage_liquid2_inv.png^[colorize:#000000", }) minetest.register_craftitem("techage:fueloil", { description = S("TA3 Fuel Oil"), - inventory_image = "techage_fueloil_inv.png", - groups = {not_in_creative_inventory=1}, + inventory_image = "techage_liquid2_inv.png^[colorize:#4b3f11^techage_liquid1_inv.png", }) minetest.register_craftitem("techage:naphtha", { description = S("TA3 Naphtha"), - inventory_image = "techage_naphtha_inv.png", - groups = {not_in_creative_inventory=1}, + inventory_image = "techage_liquid2_inv.png^[colorize:#897937^techage_liquid1_inv.png", }) minetest.register_craftitem("techage:gasoline", { description = S("TA3 Gasoline"), - inventory_image = "techage_gasoline_inv.png", - groups = {not_in_creative_inventory=1}, + inventory_image = "techage_liquid2_inv.png^[colorize:#bfaf6e^techage_liquid1_inv.png", }) 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", { description = S("TA3 Bitumen Barrel"), - inventory_image = "techage_barrel_bitumen_inv.png", + inventory_image = "techage_barrel_inv.png^[colorize:#000000:120", stack_max = 1, }) minetest.register_craftitem("techage:ta3_barrel_fueloil", { 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, }) minetest.register_craftitem("techage:ta3_barrel_naphtha", { 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, }) minetest.register_craftitem("techage:ta3_barrel_gasoline", { 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, }) -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", { 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, }) minetest.register_craftitem("techage:ta3_canister_fueloil", { 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, }) minetest.register_craftitem("techage:ta3_canister_naphtha", { 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, }) minetest.register_craftitem("techage:ta3_canister_gasoline", { 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, }) diff --git a/items/powder.lua b/items/powder.lua new file mode 100644 index 0000000..2e81c9f --- /dev/null +++ b/items/powder.lua @@ -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"}) + diff --git a/nodes/silicon.lua b/items/silicon.lua similarity index 100% rename from nodes/silicon.lua rename to items/silicon.lua diff --git a/nodes/steelmat.lua b/items/steelmat.lua similarity index 100% rename from nodes/steelmat.lua rename to items/steelmat.lua diff --git a/nodes/usmium.lua b/items/usmium.lua similarity index 53% rename from nodes/usmium.lua rename to items/usmium.lua index 505cda7..888c4df 100644 --- a/nodes/usmium.lua +++ b/items/usmium.lua @@ -19,3 +19,9 @@ minetest.register_craftitem("techage:usmium_nuggets", { 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"}) diff --git a/liquids/barrel.lua b/liquids/barrel.lua deleted file mode 100644 index e431137..0000000 --- a/liquids/barrel.lua +++ /dev/null @@ -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'}, - } -}) diff --git a/liquids/liquid.lua b/liquids/liquid.lua index 429b169..fac6e0f 100644 --- a/liquids/liquid.lua +++ b/liquids/liquid.lua @@ -12,6 +12,7 @@ ]]-- +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 @@ -30,13 +31,13 @@ local ContainerDef = {} -- Networks -- --- determine network ID (largest hash number) +-- determine network ID (largest hash number of all pumps) 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 ntype and ntype == "pump" then + local new = minetest.hash_node_position(pos) * 8 + outdir if netID <= new then netID = new end @@ -45,52 +46,59 @@ local function determine_netID(pos, outdir) return netID end --- store network ID on each node +-- store network ID on each pump like 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 + if ntype and ntype == "pump" then local mem = tubelib2.get_mem(pos) + local outdir = networks.Flip[indir] mem.pipe = mem.pipe or {} - mem.pipe.netID = netID + mem.pipe.netIDs = mem.pipe.netIDs or {} + mem.pipe.netIDs[outdir] = netID 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 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 + 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 + local outdir = networks.Flip[indir] + if mem.pipe and mem.pipe.netIDs and mem.pipe.netIDs[outdir] then + netID = mem.pipe.netIDs[outdir] + mem.pipe.netIDs[outdir] = nil end end end) networks.delete_network(netID, Pipe) end - -local function get_network_table(pos, outdir, ntype) - -- 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) - local mem = tubelib2.get_mem(pos2) - if not mem.pipe or not mem.pipe.netID then +local function get_netID(pos, outdir) + local mem = tubelib2.get_mem(pos) + if not mem.pipe or not mem.pipe.netIDs or not mem.pipe.netIDs[outdir] then local netID = determine_netID(pos, outdir) store_netID(pos, outdir, netID) - mem.pipe = mem.pipe or {} - mem.pipe.netID = netID end - local netw = networks.get_network(mem.pipe.netID, Pipe) - if not netw then - netw = networks.collect_network_nodes(pos, outdir, Pipe) - networks.set_network(mem.pipe.netID, Pipe, netw) + return mem.pipe.netIDs[outdir] +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 netw[ntype] or {} + return {} end @@ -230,44 +238,9 @@ function techage.liquid.get_full_container(empty_container, inv_item) end -- To be called from each node via 'tubelib2_on_update2' --- 'output' is optional and only needed for nodes with two --- different networks. +-- '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") - diff --git a/liquids/liquid.lua.orig b/liquids/liquid.lua.orig new file mode 100644 index 0000000..d337e6d --- /dev/null +++ b/liquids/liquid.lua.orig @@ -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") + diff --git a/liquids/pump.lua b/liquids/pump.lua index 911048a..7fb4337 100644 --- a/liquids/pump.lua +++ b/liquids/pump.lua @@ -128,6 +128,7 @@ end local function after_dig_node(pos, oldnode, oldmetadata, digger) Pipe:after_dig_node(pos) + tubelib2.del_mem(pos) end local ta3_tiles_pas = { diff --git a/liquids/silo.lua b/liquids/silo.lua new file mode 100644 index 0000000..f4e9c10 --- /dev/null +++ b/liquids/silo.lua @@ -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", ""}, + {"", "", ""}, + }, +}) diff --git a/liquids/tank.lua b/liquids/tank.lua index 5188f33..b079cd0 100644 --- a/liquids/tank.lua +++ b/liquids/tank.lua @@ -180,8 +180,8 @@ minetest.register_node("techage:ta3_tank", { meta:set_string("infotext", S("TA3 Tank").." "..number) Pipe:after_place_node(pos) end, - tubelib2_on_update2 = function(pos, dir, tlib2, node) - liquid.update_network(pos) + 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) @@ -267,8 +267,8 @@ minetest.register_node("techage:oiltank", { meta:set_string("infotext", S("Oil Tank").." "..number) Pipe:after_place_node(pos) end, - tubelib2_on_update2 = function(pos, dir, tlib2, node) - liquid.update_network(pos) + 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) @@ -344,8 +344,8 @@ minetest.register_node("techage:ta4_tank", { meta:set_string("infotext", S("TA4 Tank").." "..number) Pipe:after_place_node(pos) end, - tubelib2_on_update2 = function(pos, dir, tlib2, node) - liquid.update_network(pos) + 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) diff --git a/locale/techage.de.tr b/locale/techage.de.tr index b379c64..539b646 100644 --- a/locale/techage.de.tr +++ b/locale/techage.de.tr @@ -56,7 +56,7 @@ Meridium Axe=Meridium Axt Meridium Pickaxe=Meridium Pickel Meridium Shovel=Meridium Schaufel 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 No plan available=Kein Plan verfügar 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 3=TA4 Wärmetauscher 3 TA4 Hydrogen=TA4 Wasserstoff -TA4 Low Power Box==TA4 Niederspannungsverteilerbox +TA4 Low Power Box=TA4 Niederspannungsverteilerbox TA4 Low Power Cable=TA4 Niederspannungskabel TA4 Pillar=TA4 Säule TA4 Pipe Inlet=TA4 Rohrzulauf TA4 Protected Chest=TA4 Gesicherte Kiste TA4 Pump=TA4 Pumpe TA4 Reactor=Reaktor -TA4 Reactor Base= +TA4 Reactor Base=TA4 Reaktor Basis TA4 Reactor Filler Pipe=TA4 Reaktor Einfüllstutzen TA4 Rotor Blade=TA4 Rotorblatt TA4 Silicon Wafer=TA4 Silizium-Wafer diff --git a/nodes/doorblock.lua b/logic/doorblock.lua similarity index 100% rename from nodes/doorblock.lua rename to logic/doorblock.lua diff --git a/nodes/gateblock.lua b/logic/gateblock.lua similarity index 100% rename from nodes/gateblock.lua rename to logic/gateblock.lua diff --git a/oil/reboiler.lua b/oil/reboiler.lua index c7e74b7..2bdadc0 100644 --- a/oil/reboiler.lua +++ b/oil/reboiler.lua @@ -92,7 +92,7 @@ local function node_timer(pos, elapsed) if mem.liquid.amount >= 5 and mem.liquid.name == "techage:oil_source" then mem.liquid.amount = mem.liquid.amount - 5 local leftover = pump_cmnd(pos, "put") - if leftover > 0 then + if (tonumber(leftover) or 1) > 0 then swap_node(pos, false) return false end diff --git a/sounds/techage_reactor.ogg b/sounds/techage_reactor.ogg new file mode 100644 index 0000000..38d5538 Binary files /dev/null and b/sounds/techage_reactor.ogg differ diff --git a/textures/techage_aluminum_inv.png b/textures/techage_aluminum_inv.png new file mode 100644 index 0000000..7dc3a7b Binary files /dev/null and b/textures/techage_aluminum_inv.png differ diff --git a/textures/techage_appl_heater.png b/textures/techage_appl_heater.png new file mode 100644 index 0000000..c806490 Binary files /dev/null and b/textures/techage_appl_heater.png differ diff --git a/textures/techage_appl_heater_on.png b/textures/techage_appl_heater_on.png new file mode 100644 index 0000000..6549d4c Binary files /dev/null and b/textures/techage_appl_heater_on.png differ diff --git a/textures/techage_appl_silo.png b/textures/techage_appl_silo.png new file mode 100644 index 0000000..deae740 Binary files /dev/null and b/textures/techage_appl_silo.png differ diff --git a/textures/techage_barrel_bitumen_inv.png b/textures/techage_barrel_bitumen_inv.png deleted file mode 100644 index 8301496..0000000 Binary files a/textures/techage_barrel_bitumen_inv.png and /dev/null differ diff --git a/textures/techage_barrel_fueloil_inv.png b/textures/techage_barrel_fueloil_inv.png deleted file mode 100644 index ca1fcda..0000000 Binary files a/textures/techage_barrel_fueloil_inv.png and /dev/null differ diff --git a/textures/techage_barrel_gasoline_inv.png b/textures/techage_barrel_gasoline_inv.png deleted file mode 100644 index 38d43a8..0000000 Binary files a/textures/techage_barrel_gasoline_inv.png and /dev/null differ diff --git a/textures/techage_barrel_inv.png b/textures/techage_barrel_inv.png index cf2a4ab..46b492f 100644 Binary files a/textures/techage_barrel_inv.png and b/textures/techage_barrel_inv.png differ diff --git a/textures/techage_barrel_naphtha_inv.png b/textures/techage_barrel_naphtha_inv.png deleted file mode 100644 index 68f7add..0000000 Binary files a/textures/techage_barrel_naphtha_inv.png and /dev/null differ diff --git a/textures/techage_barrel_oil_inv.png b/textures/techage_barrel_oil_inv.png deleted file mode 100644 index 985ae05..0000000 Binary files a/textures/techage_barrel_oil_inv.png and /dev/null differ diff --git a/textures/techage_barrel_water_inv.png b/textures/techage_barrel_water_inv.png deleted file mode 100644 index 28992f6..0000000 Binary files a/textures/techage_barrel_water_inv.png and /dev/null differ diff --git a/textures/techage_biomass.png b/textures/techage_biomass.png deleted file mode 100644 index 61e493f..0000000 Binary files a/textures/techage_biomass.png and /dev/null differ diff --git a/textures/techage_canister_bitumen_inv.png b/textures/techage_canister_bitumen_inv.png deleted file mode 100644 index 5b24a8d..0000000 Binary files a/textures/techage_canister_bitumen_inv.png and /dev/null differ diff --git a/textures/techage_canister_filling.png b/textures/techage_canister_filling.png new file mode 100644 index 0000000..f464575 Binary files /dev/null and b/textures/techage_canister_filling.png differ diff --git a/textures/techage_canister_frame.png b/textures/techage_canister_frame.png new file mode 100644 index 0000000..e18e204 Binary files /dev/null and b/textures/techage_canister_frame.png differ diff --git a/textures/techage_canister_fueloil_inv.png b/textures/techage_canister_fueloil_inv.png deleted file mode 100644 index 0b1c611..0000000 Binary files a/textures/techage_canister_fueloil_inv.png and /dev/null differ diff --git a/textures/techage_canister_gasoline_inv.png b/textures/techage_canister_gasoline_inv.png deleted file mode 100644 index 5cef9c5..0000000 Binary files a/textures/techage_canister_gasoline_inv.png and /dev/null differ diff --git a/textures/techage_canister_inv.png b/textures/techage_canister_inv.png deleted file mode 100644 index 585e1d5..0000000 Binary files a/textures/techage_canister_inv.png and /dev/null differ diff --git a/textures/techage_canister_naphtha_inv.png b/textures/techage_canister_naphtha_inv.png deleted file mode 100644 index eaab1f1..0000000 Binary files a/textures/techage_canister_naphtha_inv.png and /dev/null differ diff --git a/textures/techage_canister_water_inv.png b/textures/techage_canister_water_inv.png deleted file mode 100644 index 2c03e0c..0000000 Binary files a/textures/techage_canister_water_inv.png and /dev/null differ diff --git a/textures/techage_epoxy.png b/textures/techage_epoxy.png deleted file mode 100644 index d4db6e8..0000000 Binary files a/textures/techage_epoxy.png and /dev/null differ diff --git a/textures/techage_fueloil_inv.png b/textures/techage_fueloil_inv.png deleted file mode 100644 index 06e7ebd..0000000 Binary files a/textures/techage_fueloil_inv.png and /dev/null differ diff --git a/textures/techage_gasoline_inv.png b/textures/techage_gasoline_inv.png deleted file mode 100644 index 478ef20..0000000 Binary files a/textures/techage_gasoline_inv.png and /dev/null differ diff --git a/textures/techage_liquid1_inv.png b/textures/techage_liquid1_inv.png new file mode 100644 index 0000000..26c4aea Binary files /dev/null and b/textures/techage_liquid1_inv.png differ diff --git a/textures/techage_liquid2_inv.png b/textures/techage_liquid2_inv.png new file mode 100644 index 0000000..374f0b2 Binary files /dev/null and b/textures/techage_liquid2_inv.png differ diff --git a/textures/techage_liquid_inv.png b/textures/techage_liquid_inv.png deleted file mode 100644 index e733458..0000000 Binary files a/textures/techage_liquid_inv.png and /dev/null differ diff --git a/textures/techage_naphtha_inv.png b/textures/techage_naphtha_inv.png deleted file mode 100644 index e2e6f2d..0000000 Binary files a/textures/techage_naphtha_inv.png and /dev/null differ diff --git a/textures/techage_oil_inv.png b/textures/techage_oil_inv.png deleted file mode 100644 index e00c3b4..0000000 Binary files a/textures/techage_oil_inv.png and /dev/null differ diff --git a/textures/techage_powder_inv.png b/textures/techage_powder_inv.png new file mode 100644 index 0000000..35a8570 Binary files /dev/null and b/textures/techage_powder_inv.png differ diff --git a/textures/techage_symbol_liquid.png b/textures/techage_symbol_liquid.png new file mode 100644 index 0000000..aecb97e Binary files /dev/null and b/textures/techage_symbol_liquid.png differ diff --git a/textures/techage_symbol_powder.png b/textures/techage_symbol_powder.png new file mode 100644 index 0000000..63d94f8 Binary files /dev/null and b/textures/techage_symbol_powder.png differ diff --git a/textures/techage_tes_core_elem.png b/textures/techage_tes_core_elem.png deleted file mode 100644 index b92a25a..0000000 Binary files a/textures/techage_tes_core_elem.png and /dev/null differ diff --git a/textures/techage_tes_core_elem_top.png b/textures/techage_tes_core_elem_top.png deleted file mode 100644 index 5bfefd4..0000000 Binary files a/textures/techage_tes_core_elem_top.png and /dev/null differ diff --git a/textures/techage_water_inv.png b/textures/techage_water_inv.png deleted file mode 100644 index 0946393..0000000 Binary files a/textures/techage_water_inv.png and /dev/null differ diff --git a/nodes/pillar.lua b/wind_turbine/pillar.lua similarity index 100% rename from nodes/pillar.lua rename to wind_turbine/pillar.lua diff --git a/wind_turbine/rotor.lua b/wind_turbine/rotor.lua index 4bceb34..179ce52 100644 --- a/wind_turbine/rotor.lua +++ b/wind_turbine/rotor.lua @@ -265,11 +265,6 @@ techage.register_node({"techage:ta4_wind_turbine"}, { end, }) -minetest.register_craftitem("techage:ta4_epoxy", { - description = S("TA4 Epoxide Resin"), - inventory_image = "techage_epoxy.png", -}) - minetest.register_craftitem("techage:ta4_carbon_fiber", { description = S("TA4 Carbon Fiber"), inventory_image = "techage_carbon_fiber.png", @@ -303,9 +298,13 @@ minetest.register_craft({ output = "techage:ta4_rotor_blade", recipe = { {"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"}, }, + replacements = { + {"techage:canister_epoxy", "techage:ta3_canister_empty"}, + {"techage:canister_epoxy", "techage:ta3_canister_empty"}, + }, }) techage.furnace.register_recipe({ @@ -314,11 +313,3 @@ techage.furnace.register_recipe({ heat = 4, 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, -})