diff --git a/basic_machines/consumer.lua b/basic_machines/consumer.lua index eee6225..13b92ed 100644 --- a/basic_machines/consumer.lua +++ b/basic_machines/consumer.lua @@ -122,6 +122,7 @@ function techage.register_consumer(base_name, inv_name, tiles, tNode, validState nominal = tNode.power_consumption[stage], on_power = on_power, on_nopower = on_nopower, + is_running = function(pos, nvm) return techage.is_running(nvm) end, }, } if tNode.networks and tNode.networks.pipe2 then diff --git a/basic_machines/quarry.lua b/basic_machines/quarry.lua index 8ee6893..66b1927 100644 --- a/basic_machines/quarry.lua +++ b/basic_machines/quarry.lua @@ -354,6 +354,8 @@ local tubing = { local nvm = techage.get_nvm(pos) if nvm.techage_state == techage.RUNNING then play_sound(pos) + else + stop_sound(pos) end end, } diff --git a/basis/gravel_lib.lua b/basis/gravel_lib.lua index 844f714..2cd64b7 100644 --- a/basis/gravel_lib.lua +++ b/basis/gravel_lib.lua @@ -20,8 +20,9 @@ local ore_probability = { } local ProbabilityCorrections = { + ["default:tin_lump"] = 0.5, -- extensively used ["default:coal_lump"] = 0.3, -- extensively used - ["default:iron_lump"] = 0.4, -- extensively used + ["default:iron_lump"] = 0.5, -- extensively used ["techage:baborium_lump"] = 99999, -- mining required } diff --git a/basis/node_states.lua b/basis/node_states.lua index 8230866..ddb38ec 100644 --- a/basis/node_states.lua +++ b/basis/node_states.lua @@ -148,6 +148,10 @@ function techage.is_operational(nvm) return state < NOPOWER end +function techage.is_running(nvm) + return (nvm.techage_state or STOPPED) == RUNNING +end + -- consumes power function techage.needs_power(nvm) local state = nvm.techage_state or STOPPED diff --git a/chemistry/ta4_stand.lua b/chemistry/ta4_stand.lua index a5c445d..c28ca55 100644 --- a/chemistry/ta4_stand.lua +++ b/chemistry/ta4_stand.lua @@ -59,6 +59,10 @@ local function on_nopower(pos) nvm.has_power = false end +local function is_running(pos, nvm) + return nvm.has_power +end + minetest.register_node("techage:ta4_reactor_stand", { description = S("TA4 Reactor Stand"), tiles = { @@ -134,6 +138,7 @@ minetest.register_node("techage:ta4_reactor_stand", { on_power = on_power, on_nopower = on_nopower, nominal = PWR_NEEDED, + is_running = is_running, }, }, }) diff --git a/energy_storage/heatexchanger1.lua b/energy_storage/heatexchanger1.lua index b68339a..da123eb 100644 --- a/energy_storage/heatexchanger1.lua +++ b/energy_storage/heatexchanger1.lua @@ -93,6 +93,10 @@ end local function on_nopower(pos) end +local function is_running(pos, nvm) + return nvm.charging +end + local function start_node(pos, nvm) nvm.running = true nvm.needed = 0 @@ -196,6 +200,7 @@ local net_def = { nominal = PWR_PERF, on_power = on_power, on_nopower = on_nopower, + is_running = is_running, }, pipe2 = { sides = {L = 1, R = 1}, @@ -279,6 +284,8 @@ techage.register_node({"techage:heatexchanger1"}, { local nvm = techage.get_nvm(pos) if nvm.running and nvm.charging then play_sound(pos) + else + stop_sound(pos) end local mem = tubelib2.get_mem(pos) nvm.capa = (nvm.capa or 0) + (mem.capa or 0) diff --git a/furnace/booster.lua b/furnace/booster.lua index 75edf9b..5f283ac 100644 --- a/furnace/booster.lua +++ b/furnace/booster.lua @@ -93,16 +93,6 @@ local function tubelib2_on_update2(pos, outdir, tlib2, node) power.update_network(pos, outdir, tlib2) end -local net_def = { - ele1 = { - sides = {B = true, F = true, L = true, D = true, U = true}, - ntype = "con1", - on_power = on_power, - on_nopower = on_nopower, - nominal = PWR_NEEDED, - }, -} - minetest.register_node("techage:ta3_booster", { description = S("TA3 Booster"), tiles = { @@ -119,7 +109,15 @@ minetest.register_node("techage:ta3_booster", { after_place_node = after_place_node, after_dig_node = after_dig_node, tubelib2_on_update2 = tubelib2_on_update2, - networks = net_def, + networks = { + ele1 = { + sides = {B = true, F = true, L = true, D = true, U = true}, + ntype = "con1", + on_power = on_power, + on_nopower = on_nopower, + nominal = PWR_NEEDED, + }, + }, paramtype2 = "facedir", groups = {cracky=2, crumbly=2, choppy=2}, @@ -162,7 +160,16 @@ minetest.register_node("techage:ta3_booster_on", { after_place_node = after_place_node, after_dig_node = after_dig_node, tubelib2_on_update2 = tubelib2_on_update2, - networks = net_def, + networks = { + ele1 = { + sides = {B = true, F = true, L = true, D = true, U = true}, + ntype = "con1", + on_power = on_power, + on_nopower = on_nopower, + nominal = PWR_NEEDED, + is_running = function() return true end, + }, + }, paramtype2 = "facedir", groups = {not_in_creative_inventory = 1}, diff --git a/furnace/cooking.lua b/furnace/cooking.lua index e2fd653..c0cb96e 100644 --- a/furnace/cooking.lua +++ b/furnace/cooking.lua @@ -90,6 +90,12 @@ local function process(inv, recipe, output) if not inv:room_for_item("dst", stack) then return techage.BLOCKED end + -- handle waste + if recipe.waste then + if not inv:room_for_item("dst", ItemStack(recipe.waste)) then + return techage.BLOCKED + end + end -- remove items local list = inv:get_list("src") for _,item in ipairs(recipe.input) do @@ -101,6 +107,14 @@ local function process(inv, recipe, output) inv:set_list("src", list) -- add output to dst inv:add_item("dst", stack) + -- add waste to dst + if recipe.waste then + local leftover = inv:add_item("dst", ItemStack(recipe.waste)) + if leftover:get_count() > 0 then + inv:set_list("src", leftover) + return techage.BLOCKED + end + end return techage.RUNNING end @@ -198,6 +212,7 @@ function techage.furnace.register_recipe(recipe) end table.insert(Recipes[output], { input = recipe.recipe, + waste = recipe.waste, number = number, time = math.max((recipe.time or 3) * number, 2), }) diff --git a/furnace/heater.lua b/furnace/heater.lua index 3b88b0b..3909772 100644 --- a/furnace/heater.lua +++ b/furnace/heater.lua @@ -62,16 +62,6 @@ local function tubelib2_on_update2(pos, outdir, tlib2, node) power.update_network(pos, outdir, tlib2) end -local net_def = { - ele1 = { - sides = {B = true, F = true, L = true, D = true, U = true}, - ntype = "con1", - on_power = on_power, - on_nopower = on_nopower, - nominal = PWR_NEEDED, - }, -} - minetest.register_node("techage:furnace_heater", { description = S("TA4 Furnace Heater"), tiles = { @@ -88,7 +78,15 @@ minetest.register_node("techage:furnace_heater", { after_place_node = after_place_node, after_dig_node = after_dig_node, tubelib2_on_update2 = tubelib2_on_update2, - networks = net_def, + networks = { + ele1 = { + sides = {B = true, F = true, L = true, D = true, U = true}, + ntype = "con1", + on_power = on_power, + on_nopower = on_nopower, + nominal = PWR_NEEDED, + }, + }, paramtype2 = "facedir", groups = {cracky=2, crumbly=2, choppy=2}, @@ -113,7 +111,16 @@ minetest.register_node("techage:furnace_heater_on", { after_place_node = after_place_node, after_dig_node = after_dig_node, tubelib2_on_update2 = tubelib2_on_update2, - networks = net_def, + networks = { + ele1 = { + sides = {B = true, F = true, L = true, D = true, U = true}, + ntype = "con1", + on_power = on_power, + on_nopower = on_nopower, + nominal = PWR_NEEDED, + is_running = function() return true end, + }, + }, light_source = 8, paramtype2 = "facedir", diff --git a/hydrogen/electrolyzer.lua b/hydrogen/electrolyzer.lua index dd5956e..f469f37 100644 --- a/hydrogen/electrolyzer.lua +++ b/hydrogen/electrolyzer.lua @@ -86,6 +86,9 @@ local function on_nopower(pos) nvm.running = false end +local function is_running(pos, nvm) + return nvm.running +end local function generating(pos, nvm) nvm.num_pwr_units = nvm.num_pwr_units or 0 @@ -172,6 +175,7 @@ local netw_def = { on_power = on_power, on_nopower = on_nopower, nominal = PWR_NEEDED, + is_running = is_running, }, } diff --git a/icta_controller/display.lua b/icta_controller/display.lua index 5bf4018..0c37533 100644 --- a/icta_controller/display.lua +++ b/icta_controller/display.lua @@ -12,6 +12,8 @@ ]]-- +local S = techage.S + local NUM_ROWS = 5 local RADIUS = 6 local Param2ToFacedir = {[0] = 0, 0, 3, 1, 2, 0} @@ -81,7 +83,7 @@ local lcd_box = { } minetest.register_node("techage:ta4_display", { - description = "TA4 Display", + description = S("TA4 Display"), inventory_image = 'techage_display_inventory.png', tiles = {"techage_display.png"}, drawtype = "nodebox", @@ -101,6 +103,7 @@ minetest.register_node("techage:ta4_display", { local number = techage.add_node(pos, "techage:ta4_display") local meta = minetest.get_meta(pos) meta:set_string("number", number) + meta:set_string("infotext", S("Display no: ")..number) local nvm = techage.get_nvm(pos) nvm.text = {"My", "Techage","TA4", "Display", "No: "..number} lcdlib.update_entities(pos) @@ -127,7 +130,7 @@ local lcd_boxXL = { } minetest.register_node("techage:ta4_displayXL", { - description = "TA4 Display XL", + description = S("TA4 Display XL"), inventory_image = 'techage_display_inventoryXL.png', tiles = {"techage_displayXL.png"}, drawtype = "nodebox", @@ -147,6 +150,7 @@ minetest.register_node("techage:ta4_displayXL", { local number = techage.add_node(pos, "techage:ta4_displayXL") local meta = minetest.get_meta(pos) meta:set_string("number", number) + meta:set_string("infotext", S("Display no: ")..number) local nvm = techage.get_nvm(pos) nvm.text = {"My", "Techage","TA4", "Display", "No: "..number} lcdlib.update_entities(pos) @@ -214,14 +218,9 @@ local function write_row(pos, payload, cycle_time) mem.ticks = cycle_time end - if row < 0 then row = 1 end + if row < 1 then row = 1 end if row > NUM_ROWS then row = NUM_ROWS end - if row == 0 then - meta:set_string("infotext", str) - return - end - while #nvm.text < row do table.insert(nvm.text, "") end diff --git a/items/aluminium.lua b/items/aluminium.lua index fdbae75..60a6613 100644 --- a/items/aluminium.lua +++ b/items/aluminium.lua @@ -17,6 +17,7 @@ local S = techage.S minetest.register_craftitem("techage:gibbsite_powder", { description = S("Gibbsite Powder"), inventory_image = "techage_powder_inv.png^[colorize:#C6DCDB:120", + groups = {powder = 1}, }) minetest.register_craftitem("techage:aluminum", { diff --git a/items/bauxit.lua b/items/bauxit.lua index 3cfb2dc..7252343 100644 --- a/items/bauxit.lua +++ b/items/bauxit.lua @@ -41,6 +41,7 @@ minetest.register_node("techage:bauxite_gravel", { minetest.register_craftitem("techage:bauxite_powder", { description = S("Bauxite Powder"), inventory_image = "techage_powder_inv.png^[colorize:#FB2A00:120", + groups = {powder = 1}, }) diff --git a/items/powder.lua b/items/powder.lua index 2e81c9f..872ea31 100644 --- a/items/powder.lua +++ b/items/powder.lua @@ -17,11 +17,13 @@ local S = techage.S minetest.register_craftitem("techage:leave_powder", { description = S("Leave Powder"), inventory_image = "techage_powder_inv.png^[colorize:#71a157:120", + groups = {powder = 1}, }) minetest.register_craftitem("techage:needle_powder", { description = S("Needle Powder"), inventory_image = "techage_powder_inv.png^[colorize:#1c800f:120", + groups = {powder = 1}, }) techage.add_grinder_recipe({input="default:acacia_bush_leaves", output="techage:leave_powder"}) diff --git a/items/redstone.lua b/items/redstone.lua index 259d355..733fdd1 100644 --- a/items/redstone.lua +++ b/items/redstone.lua @@ -95,9 +95,10 @@ minetest.register_craft({ techage.furnace.register_recipe({ output = "techage:red_stone", recipe = { - "techage:redmud", + "techage:canister_redmud", "default:sand", }, + waste = "techage:ta3_canister_empty", time = 4, }) diff --git a/items/usmium.lua b/items/usmium.lua index 888c4df..e90b908 100644 --- a/items/usmium.lua +++ b/items/usmium.lua @@ -22,6 +22,7 @@ minetest.register_craftitem("techage:usmium_nuggets", { minetest.register_craftitem("techage:usmium_powder", { description = S("Usmium Powder"), inventory_image = "techage_powder_inv.png^[colorize:#46728E:120", + groups = {powder = 1}, }) techage.add_grinder_recipe({input="techage:usmium_nuggets", output="techage:usmium_powder"}) diff --git a/lamps/lib.lua b/lamps/lib.lua index da19e1b..c1c41a1 100644 --- a/lamps/lib.lua +++ b/lamps/lib.lua @@ -39,10 +39,18 @@ end local function on_power(pos) swap_node(pos, "on") + local nvm = techage.get_nvm(pos) + nvm.turned_on = true end local function on_nopower(pos) swap_node(pos, "off") + local nvm = techage.get_nvm(pos) + nvm.turned_on = false +end + +local function is_running(pos, nvm) + return nvm.turned_on end local function node_timer(pos, elapsed) @@ -106,6 +114,7 @@ local net_def = { on_power = on_power, on_nopower = on_nopower, nominal = PWR_NEEDED, + is_running = is_running, }, } @@ -116,6 +125,7 @@ local net_def2 = { on_power = on_power, on_nopower = on_nopower, nominal = PWR_NEEDED * 2, + is_running = is_running, }, } diff --git a/liquids/node_api.lua b/liquids/node_api.lua index 550297b..e897391 100644 --- a/liquids/node_api.lua +++ b/liquids/node_api.lua @@ -83,6 +83,7 @@ local function get_netID(pos, outdir) return nvm.pipe2 and nvm.pipe2.netIDs and nvm.pipe2.netIDs[outdir] end +-- return list of nodes {pos = ..., indir = ...} of given type local function get_network_table(pos, outdir, ntype) local netID = get_netID(pos, outdir) if netID then @@ -133,7 +134,7 @@ function liquid.put(pos, outdir, name, amount, player_name) return amount or 0 end --- Take given amount of liquid for the remote inventory. +-- Take given amount of liquid from the remote inventory. -- return taken amount and item name function liquid.take(pos, outdir, name, amount, player_name) local taken = 0 diff --git a/liquids/silo.lua b/liquids/silo.lua index a097fb8..1114565 100644 --- a/liquids/silo.lua +++ b/liquids/silo.lua @@ -97,11 +97,15 @@ local tLiquid = { 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 + -- check if it is powder + local ndef = minetest.registered_craftitems[name] or {} + if ndef.groups and ndef.groups.powder == 1 then + 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 end return amount end, diff --git a/liquids/tank.lua b/liquids/tank.lua index 5763e01..d5dace8 100644 --- a/liquids/tank.lua +++ b/liquids/tank.lua @@ -54,12 +54,17 @@ local function take_liquid(pos, indir, name, amount) end local function put_liquid(pos, indir, name, amount) - local leftover = liquid.srv_put(pos, indir, name, amount) - if techage.is_activeformspec(pos) then - local nvm = techage.get_nvm(pos) - M(pos):set_string("formspec", liquid.formspec(pos, nvm)) + -- check if it is not powder + local ndef = minetest.registered_craftitems[name] or {} + if not ndef.groups or ndef.groups.powder ~= 1 then + local leftover = liquid.srv_put(pos, indir, name, amount) + if techage.is_activeformspec(pos) then + local nvm = techage.get_nvm(pos) + M(pos):set_string("formspec", liquid.formspec(pos, nvm)) + end + return leftover end - return leftover + return amount end local networks_def = { diff --git a/oil/reboiler.lua b/oil/reboiler.lua index a5c5ebf..5eabcd5 100644 --- a/oil/reboiler.lua +++ b/oil/reboiler.lua @@ -76,6 +76,10 @@ local function on_nopower(pos) swap_node(pos, false) end +local function is_running(pos, nvm) + return nvm.running +end + local function pump_cmnd(pos, cmnd, payload) return techage.transfer( pos, @@ -178,6 +182,7 @@ local net_def = { on_power = on_power, on_nopower = on_nopower, nominal = PWR_NEEDED, + is_running = is_running, }, } diff --git a/power/distribution.lua b/power/distribution.lua index fc67921..0c624a5 100644 --- a/power/distribution.lua +++ b/power/distribution.lua @@ -39,8 +39,8 @@ local function stop_consumer(tbl, tlib_type) for _,v in pairs(tbl or {}) do local nvm = techage.get_nvm(v.pos) local def = nvm[tlib_type] -- power related network data - if def and def["cstate"] == RUNNING then - local ndef = net_def(v.pos, tlib_type) + local ndef = net_def(v.pos, tlib_type) + if (def and def["cstate"] == RUNNING) or (ndef.is_running and ndef.is_running(v.pos, nvm)) then def["cstate"] = NOPOWER def["taken"] = 0 if ndef.on_nopower then diff --git a/screenshot.png b/screenshot.png index 91fd153..d3aa7b6 100644 Binary files a/screenshot.png and b/screenshot.png differ diff --git a/solar/solarcell.lua b/solar/solarcell.lua index 7d50f8a..a22cf13 100644 --- a/solar/solarcell.lua +++ b/solar/solarcell.lua @@ -137,6 +137,7 @@ minetest.register_node("techage:ta4_solar_module", { on_rotate = screwdriver.disallow, groups = {cracky=2, crumbly=2, choppy=2}, is_ground_content = false, + sounds = default.node_sound_glass_defaults(), }) minetest.register_node("techage:ta4_solar_carrier", { @@ -175,6 +176,7 @@ minetest.register_node("techage:ta4_solar_carrier", { on_rotate = screwdriver.disallow, groups = {cracky=2, crumbly=2, choppy=2}, is_ground_content = false, + sounds = default.node_sound_stone_defaults(), }) minetest.register_node("techage:ta4_solar_carrierB", { @@ -213,6 +215,7 @@ minetest.register_node("techage:ta4_solar_carrierB", { on_rotate = screwdriver.disallow, groups = {cracky=2, crumbly=2, choppy=2}, is_ground_content = false, + sounds = default.node_sound_stone_defaults(), }) minetest.register_node("techage:ta4_solar_carrierT", { @@ -239,6 +242,7 @@ minetest.register_node("techage:ta4_solar_carrierT", { paramtype2 = "facedir", groups = {cracky=2, crumbly=2, choppy=2}, is_ground_content = false, + sounds = default.node_sound_stone_defaults(), }) Cable:add_secondary_node_names({"techage:ta4_solar_carrier", "techage:ta4_solar_carrierB"})