From 1e85d0c309d2cc8e92db98d23339da0d90b5de18 Mon Sep 17 00:00:00 2001 From: FaceDeer Date: Thu, 11 Mar 2021 22:46:11 -0700 Subject: [PATCH 01/10] bugfix - double and triple tanks were returning empty singles when used up --- init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 0b17241..aaa4012 100644 --- a/init.lua +++ b/init.lua @@ -186,7 +186,7 @@ local function register_air_tank_2(name, desc, color, uses) _doc_items_longdesc = S("A pair of tanks containing compressed air."), _doc_items_usagehelp = S("If you're underwater and you're running out of breath, wield this item and use it to replenish 5 bubbles on your breath bar. When fully charged these tanks have @1 uses before it becomes empty.", uses), _airtank_uses = uses, - _airtank_empty = "airtanks:empty_"..name.."_tank", + _airtank_empty = "airtanks:empty_"..name.."_tank_2", groups = {not_repaired_by_anvil = 1, airtank = 1}, inventory_image = "airtanks_airtank_two.png^[colorize:"..color.."^[mask:airtanks_airtank_two.png", wield_image = "airtanks_airtank_two.png^[colorize:"..color.."^[mask:airtanks_airtank_two.png", @@ -243,7 +243,7 @@ local function register_air_tank_3(name, desc, color, uses) _doc_items_longdesc = S("A set of three tanks containing compressed air."), _doc_items_usagehelp = S("If you're underwater and you're running out of breath, wield this item and use it to replenish 5 bubbles on your breath bar. When fully charged these tanks have @1 uses before it becomes empty.", uses), _airtank_uses = uses, - _airtank_empty = "airtanks:empty_"..name.."_tank", + _airtank_empty = "airtanks:empty_"..name.."_tank_3", groups = {not_repaired_by_anvil = 1, airtank = 1}, inventory_image = "airtanks_airtank_three.png^[colorize:"..color.."^[mask:airtanks_airtank_three.png", wield_image = "airtanks_airtank_three.png^[colorize:"..color.."^[mask:airtanks_airtank_three.png", From 2bf396e5bf19d506cf11bce68c87abfecc87571b Mon Sep 17 00:00:00 2001 From: FaceDeer Date: Sat, 13 Mar 2021 02:19:11 -0700 Subject: [PATCH 02/10] fancy compressor with formspec and fuel requirement (optional) --- init.lua | 380 ++++++++++++++++++++++++++++++++++---------- locale/template.txt | 8 +- settingtypes.txt | 3 +- 3 files changed, 301 insertions(+), 90 deletions(-) diff --git a/init.lua b/init.lua index aaa4012..39cd40a 100644 --- a/init.lua +++ b/init.lua @@ -42,55 +42,30 @@ setting("int", "bronze_3_uses", config.bronze_uses * 3, "Number of uses for thre setting("bool", "wear_in_creative", true, "Air tanks wear out in creative mode") +setting("bool", "compressor_needs_fuel", true, "Compressor needs fuel") + local compressor_desc = S("A machine for filling air tanks with compressed air.") -local compressor_help = S("Place this machine somewhere that it has access to air (one of its adjacent nodes needs to have air in it). When you click on it with an empty or partly-empty compressed air tank the tank will be refilled.") +local compressor_help +if config.compressor_needs_fuel then + compressor_help = S("This machine requires fuel to operate. Place something that can burn in the fuel slot, and then place empty tanks in the inventory to the right. The compressor will start filling the largest capacity tanks first.") +else + compressor_help = S("Place place empty tanks in the inventory to the right. The compressor will start filling the largest capacity tanks first.") +end local tube_desc = S("A breathing tube to allow automatic hands-free use of air tanks.") local tube_help = S("If this item is present in your quick-use inventory then whenever your breath bar goes below 5 it will automatically make use of any air tanks that are present in your quick-use inventory to replenish your breath supply. Note that it will not use air tanks that are present elsewhere in your inventory, only ones in your quick-use bar.") local cardinal_dirs = {{x=1,y=0,z=0},{x=-1,y=0,z=0},{x=0,y=1,z=0},{x=0,y=-1,z=0},{x=0,y=0,z=1},{x=0,y=0,z=-1},} -local function recharge_airtank(itemstack, user, pointed_thing, full_item) - if pointed_thing.type ~= "node" then return itemstack end - local node = minetest.get_node(pointed_thing.under) - if minetest.get_item_group(node.name, "airtanks_compressor") > 0 then - - local has_air = false - for _, dir in pairs(cardinal_dirs) do - if minetest.get_node(vector.add(pointed_thing.under, dir)).name == "air" then - has_air = true - break - end - end - if not has_air then - minetest.sound_play("airtanks_compressor_fail", {pos = pointed_thing.under, gain = 0.5}) - return itemstack - end - - if itemstack:get_name() == full_item then - itemstack:set_wear(0) - else - local inv = user:get_inventory() - - if itemstack:get_count() == 1 then - itemstack = ItemStack(full_item) -- replace with new stack containing one full tank - else - local leftover = inv:add_item("main", full_item) - if leftover:get_count() == 0 then - itemstack:take_item(1) - end - end - end - minetest.sound_play("airtanks_compressor", {pos = pointed_thing.under, gain = 0.5}) - end - return itemstack +-- For compressor code use later on +local max_uses = math.max(config.steel_uses, config.copper_uses, config.bronze_uses) +if config.enable_triple then + max_uses = max_uses * 3 +elseif config.enable_double then + max_uses = max_uses * 2 end -local function use_airtank(itemstack, user, pointed_thing, full_item) - if pointed_thing then - itemstack = recharge_airtank(itemstack, user, pointed_thing, full_item) -- first check if we're clicking on a compressor - end - +local function use_airtank(itemstack, user) local breath = user:get_breath() if breath > 9 then return itemstack end breath = math.min(10, breath+5) @@ -99,14 +74,14 @@ local function use_airtank(itemstack, user, pointed_thing, full_item) if (not minetest.settings:get_bool("creative_mode")) or config.wear_in_creative then local wdef = itemstack:get_definition() - itemstack:add_wear(65535/(wdef._airtank_uses-1)) + itemstack:add_wear(65535/(wdef._airtanks_uses-1)) if itemstack:get_count() == 0 then if wdef.sound and wdef.sound.breaks then minetest.sound_play(wdef.sound.breaks, {pos = user:get_pos(), gain = 0.5}) end local inv = user:get_inventory() - itemstack = inv:add_item("main", wdef._airtank_empty) + itemstack = inv:add_item("main", wdef._airtanks_empty) end end return itemstack @@ -116,38 +91,33 @@ end local function register_air_tank(name, desc, color, uses, material) minetest.register_craftitem("airtanks:empty_"..name.."_tank", { description = S("Empty @1", desc), + groups = {airtank = 1}, _doc_items_longdesc = S("A compressed air tank, currently empty."), _doc_items_usagehelp = S("This tank can be recharged with compressed air by using it on a compressor block. When fully charged this tank has @1 uses before it becomes empty.", uses), + _airtanks_uses = uses, + _airtanks_full = "airtanks:"..name.."_tank", inventory_image = "airtanks_airtank.png^[colorize:"..color.."^[mask:airtanks_airtank.png^airtanks_empty.png", wield_image = "airtanks_airtank.png^[colorize:"..color.."^[mask:airtanks_airtank.png^airtanks_empty.png", stack_max = 99, - - on_place = function(itemstack, user, pointed_thing) - return recharge_airtank(itemstack, user, pointed_thing, "airtanks:"..name.."_tank") - end, - - on_use = function(itemstack, user, pointed_thing) - return recharge_airtank(itemstack, user, pointed_thing, "airtanks:"..name.."_tank") - end, }) minetest.register_tool("airtanks:"..name.."_tank", { description = desc, _doc_items_longdesc = S("A tank containing compressed air."), _doc_items_usagehelp = S("If you're underwater and you're running out of breath, wield this item and use it to replenish 5 bubbles on your breath bar. When fully charged this tank has @1 uses before it becomes empty.", uses), - _airtank_uses = uses, - _airtank_empty = "airtanks:empty_"..name.."_tank", - groups = {not_repaired_by_anvil = 1, airtank = 1}, + _airtanks_uses = uses, + _airtanks_empty = "airtanks:empty_"..name.."_tank", + groups = {not_repaired_by_anvil = 1, airtank = 2}, inventory_image = "airtanks_airtank.png^[colorize:"..color.."^[mask:airtanks_airtank.png", wield_image = "airtanks_airtank.png^[colorize:"..color.."^[mask:airtanks_airtank.png", stack_max = 1, on_place = function(itemstack, user, pointed_thing) - return use_airtank(itemstack, user, pointed_thing, "airtanks:"..name.."_tank", "airtanks:empty_"..name.."_tank") + return use_airtank(itemstack, user) end, on_use = function(itemstack, user, pointed_thing) - return use_airtank(itemstack, user, pointed_thing, "airtanks:"..name.."_tank", "airtanks:empty_"..name.."_tank") + return use_airtank(itemstack, user) end, }) @@ -166,38 +136,33 @@ end local function register_air_tank_2(name, desc, color, uses) minetest.register_craftitem("airtanks:empty_"..name.."_tank_2", { description = S("Empty @1", desc), + groups = {airtank = 1}, _doc_items_longdesc = S("A pair of compressed air tanks, currently empty."), _doc_items_usagehelp = S("This tank can be recharged with compressed air by using it on a compressor block. When fully charged these tanks have @1 uses before it becomes empty.", uses), + _airtanks_uses = uses, + _airtanks_full = "airtanks:"..name.."_tank_2", inventory_image = "airtanks_airtank_two.png^[colorize:"..color.."^[mask:airtanks_airtank_two.png^airtanks_empty.png", wield_image = "airtanks_airtank_two.png^[colorize:"..color.."^[mask:airtanks_airtank_two.png^airtanks_empty.png", stack_max = 99, - - on_place = function(itemstack, user, pointed_thing) - return recharge_airtank(itemstack, user, pointed_thing, "airtanks:"..name.."_tank_2") - end, - - on_use = function(itemstack, user, pointed_thing) - return recharge_airtank(itemstack, user, pointed_thing, "airtanks:"..name.."_tank_2") - end, }) minetest.register_tool("airtanks:"..name.."_tank_2", { description = desc, _doc_items_longdesc = S("A pair of tanks containing compressed air."), _doc_items_usagehelp = S("If you're underwater and you're running out of breath, wield this item and use it to replenish 5 bubbles on your breath bar. When fully charged these tanks have @1 uses before it becomes empty.", uses), - _airtank_uses = uses, - _airtank_empty = "airtanks:empty_"..name.."_tank_2", - groups = {not_repaired_by_anvil = 1, airtank = 1}, + _airtanks_uses = uses, + _airtanks_empty = "airtanks:empty_"..name.."_tank_2", + groups = {not_repaired_by_anvil = 1, airtank = 2}, inventory_image = "airtanks_airtank_two.png^[colorize:"..color.."^[mask:airtanks_airtank_two.png", wield_image = "airtanks_airtank_two.png^[colorize:"..color.."^[mask:airtanks_airtank_two.png", stack_max = 1, on_place = function(itemstack, user, pointed_thing) - return use_airtank(itemstack, user, pointed_thing, "airtanks:"..name.."_tank_2", "airtanks:empty_"..name.."_tank_2") + return use_airtank(itemstack, user) end, on_use = function(itemstack, user, pointed_thing) - return use_airtank(itemstack, user, pointed_thing, "airtanks:"..name.."_tank_2", "airtanks:empty_"..name.."_tank_2") + return use_airtank(itemstack, user) end, }) @@ -223,41 +188,36 @@ end local function register_air_tank_3(name, desc, color, uses) minetest.register_craftitem("airtanks:empty_"..name.."_tank_3", { description = S("Empty @1", desc), + groups = {airtank = 1}, _doc_items_longdesc = S("A set of three compressed air tanks, currently empty."), _doc_items_usagehelp = S("These tanks can be recharged with compressed air by using it on a compressor block. When fully charged these tanks have @1 uses before it becomes empty.", uses), + _airtanks_uses = uses, + _airtanks_full = "airtanks:"..name.."_tank_3", inventory_image = "airtanks_airtank_three.png^[colorize:"..color.."^[mask:airtanks_airtank_three.png^airtanks_empty.png", wield_image = "airtanks_airtank_three.png^[colorize:"..color.."^[mask:airtanks_airtank_three.png^airtanks_empty.png", stack_max = 99, - - on_place = function(itemstack, user, pointed_thing) - return recharge_airtank(itemstack, user, pointed_thing, "airtanks:"..name.."_tank_3") - end, - - on_use = function(itemstack, user, pointed_thing) - return recharge_airtank(itemstack, user, pointed_thing, "airtanks:"..name.."_tank_3") - end, }) minetest.register_tool("airtanks:"..name.."_tank_3", { description = desc, _doc_items_longdesc = S("A set of three tanks containing compressed air."), _doc_items_usagehelp = S("If you're underwater and you're running out of breath, wield this item and use it to replenish 5 bubbles on your breath bar. When fully charged these tanks have @1 uses before it becomes empty.", uses), - _airtank_uses = uses, - _airtank_empty = "airtanks:empty_"..name.."_tank_3", - groups = {not_repaired_by_anvil = 1, airtank = 1}, + _airtanks_uses = uses, + _airtanks_empty = "airtanks:empty_"..name.."_tank_3", + groups = {not_repaired_by_anvil = 1, airtank = 2}, inventory_image = "airtanks_airtank_three.png^[colorize:"..color.."^[mask:airtanks_airtank_three.png", wield_image = "airtanks_airtank_three.png^[colorize:"..color.."^[mask:airtanks_airtank_three.png", stack_max = 1, on_place = function(itemstack, user, pointed_thing) - return use_airtank(itemstack, user, pointed_thing, "airtanks:"..name.."_tank_3", "airtanks:empty_"..name.."_tank_3") + return use_airtank(itemstack, user) end, on_use = function(itemstack, user, pointed_thing) - return use_airtank(itemstack, user, pointed_thing, "airtanks:"..name.."_tank_3", "airtanks:empty_"..name.."_tank_3") + return use_airtank(itemstack, user) end, }) - + -- Allow empty tanks minetest.register_craft({ recipe = { @@ -310,11 +270,204 @@ end --------------------------------------------------------------------------------------------------------- -- Compressor -local sounds -if default.node_sound_metal_defaults then -- 0.4.14 doesn't have metal sounds - sounds = default.node_sound_metal_defaults() +local sounds = default.node_sound_metal_defaults() + +local tank_inv_size = 4*4 + +local get_compressor_formspec +if config.compressor_needs_fuel then + get_compressor_formspec = function(remaining_time) + local formspec = + "size[8,9]" .. + "label[1,1.5;" .. S("Fuel") .. "]" .. + "list[context;fuel;1,2;1,1;]" .. + "label[4.5,0;" .. S("Tanks") .. "]" .. + "label[2,2;" .. S("Pressure:\n@1", remaining_time) .. "]" .. + "list[context;tanks;3,0.5;4,4;]" .. + "list[current_player;main;0,4.85;8,1;]" .. + "list[current_player;main;0,6.08;8,3;8]" .. + "listring[context;tanks]" .. + "listring[current_player;main]" .. + default.get_hotbar_bg(0,4.85) + return formspec + end else - sounds = default.node_sound_stone_defaults() + get_compressor_formspec = function() + local formspec = + "size[8,9]" .. + "label[3.5,0;" .. S("Tanks") .. "]" .. + "list[context;tanks;2,0.5;4,4;]" .. + "list[current_player;main;0,4.85;8,1;]" .. + "list[current_player;main;0,6.08;8,3;8]" .. + "listring[context;tanks]" .. + "listring[current_player;main]" .. + default.get_hotbar_bg(0,4.85) + return formspec + end +end + +-- ensures only valid items can be placed into compressor inventories +local test_can_put = function(pos, listname, index, itemstack) + if listname == "tanks" then + if minetest.get_item_group(itemstack:get_name(), "airtank") > 0 then + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + if inv:get_stack(listname, index):get_count() == 0 then + return 1 + end + end + return 0 + end + if listname == "fuel" then + local fuel, afterfuel = minetest.get_craft_result({method="fuel",width=1,items={itemstack:get_name()}}) + if fuel.time ~= 0 then + return itemstack:get_count() + end + return 0 + end + return itemstack:get_count() +end + +-- whenever an inventory action is performed, makes sure there's a timer running +local ensure_timer = function(pos) + local timer = minetest.get_node_timer(pos) + if not timer:is_started() then + timer:start(1) + end +end + +-- Locates the target tank to fill +local find_most_fillable = function(inv) + local most_fillable_index = 0 + local most_fillable_capacity = 0 + local most_fillable_needs = max_uses + 1 + local most_fillable_stack + local most_fillable_def + for i = 1, tank_inv_size do + local tank = inv:get_stack("tanks", i) + local count = tank:get_count() -- for sanity-checking purposes + if count > 1 then + minetest.log("error", "[airtanks] Compressor at " .. minetest.pos_to_string(pos) + .. " had a tank stack with more than one tank in it. Currently not something that's" + .. " handled gracefully.") + return false + elseif count == 1 then + local tank_def = tank:get_definition() + local tank_capacity = tank_def._airtanks_uses + local tank_needs + if tank_def._airtanks_full then + tank_needs = tank_capacity -- this is an empty tank + else + tank_needs = tank_capacity * (tank:get_wear() / 65535) + end + if tank_needs > 0 then -- ignore tanks that are already full + if tank_capacity > most_fillable_capacity then -- fill biggest tanks first + most_fillable_needs = max_uses + 1 + most_fillable_capacity = tank_capacity + end + if tank_needs < most_fillable_needs then-- fill tanks closest to being full first + most_fillable_needs = tank_needs + end + if most_fillable_capacity == tank_capacity and most_fillable_needs == tank_needs then + most_fillable_index = i + most_fillable_stack = tank + most_fillable_def = tank_def + end + end + end + end + + return most_fillable_index, most_fillable_stack, most_fillable_def +end + +local compressor_timestep_with_fuel = function(pos) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + local fuel_time = meta:get_float("fuel_time") + + if (fuel_time < 1 and inv:is_empty("fuel")) or inv:is_empty("tanks") then + return false + end + + local most_fillable_index, most_fillable_stack, most_fillable_def = find_most_fillable(inv) + + if most_fillable_index == 0 then + return false + end + + -- we now have a tank to fill. Do we have enough fuel? + if fuel_time < 1 then + local fuel_item = inv:get_stack("fuel", 1) -- there should be something here or we would have exited early above + fuel_item:set_count(1) + local fuel_item = inv:remove_item("fuel", fuel_item) + local burn = minetest.get_craft_result({method="fuel",width=1,items={fuel_item:get_name()}}) + fuel_time = fuel_time + burn.time + end + + if fuel_time < 1 then + -- this fuel source is producing less than 1 second of burn time. Weird, but maybe so. + -- don't refill yet, just update the fuel burned and try again. + -- this is an edge case so I'm not too worried about efficiency here + meta:set_float("fuel_time", fuel_time) + return true + end + + fuel_time = fuel_time - 1 + local wear_per_use = 65535/most_fillable_def._airtanks_uses + if most_fillable_def._airtanks_full then + -- we're starting with a completely empty tank, turn it into a full tank and add wear. + most_fillable_stack = ItemStack(most_fillable_def._airtanks_full) + most_fillable_stack:set_wear(65535 - wear_per_use) + else + most_fillable_stack:set_wear(math.max(most_fillable_stack:get_wear() - wear_per_use, 0)) + end + + inv:set_stack("tanks", most_fillable_index, most_fillable_stack) + meta:set_float("fuel_time", fuel_time) + return true +end + +local compressor_timestep_without_fuel = function(pos) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + + if inv:is_empty("tanks") then + return false + end + + local most_fillable_index, most_fillable_stack, most_fillable_def = find_most_fillable(inv) + + if most_fillable_index == 0 then + return false + end + + local wear_per_use = 65535/most_fillable_def._airtanks_uses + if most_fillable_def._airtanks_full then + -- we're starting with a completely empty tank, turn it into a full tank and add wear. + most_fillable_stack = ItemStack(most_fillable_def._airtanks_full) + most_fillable_stack:set_wear(65535 - wear_per_use) + else + most_fillable_stack:set_wear(math.max(most_fillable_stack:get_wear() - wear_per_use, 0)) + end + + inv:set_stack("tanks", most_fillable_index, most_fillable_stack) + return true +end + +local compressor_timestep +if config.compressor_needs_fuel then + compressor_timestep = compressor_timestep_with_fuel +else + compressor_timestep = compressor_timestep_without_fuel +end + +local compressor_construct = function(pos) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + inv:set_size("fuel", 1) + inv:set_size("tanks", tank_inv_size) + meta:set_float("fuel_time", 0) + meta:set_string("formspec", get_compressor_formspec(0)) end minetest.register_node("airtanks:compressor", { @@ -328,6 +481,7 @@ minetest.register_node("airtanks:compressor", { "airtanks_compressor_bottom.png^[transformR90", "airtanks_compressor.png" }, + use_texture_alpha = "clip", drawtype = "nodebox", paramtype = "light", paramtype2 = "facedir", @@ -338,9 +492,49 @@ minetest.register_node("airtanks:compressor", { {-0.3125, -0.5, -0.375, 0.3125, 0.125, 0.375}, {-0.125, 0.125, -0.25, 0.125, 0.4375, 0.25}, } - } + }, + + on_construct = compressor_construct, + + can_dig = function(pos,player) + local meta = minetest.get_meta(pos); + local inv = meta:get_inventory() + return inv:is_empty("fuel") and inv:is_empty("tanks") + end, + + allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + local stack = inv:get_stack(from_list, from_index) + return test_can_put(pos, to_list, to_index, stack) + end, + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + return test_can_put(pos, listname, index, stack) + end, + on_metadata_inventory_move = ensure_timer, + on_metadata_inventory_put = ensure_timer, + on_metadata_inventory_take = ensure_timer, + + on_timer = function(pos, elapsed) + local meta = minetest.get_meta(pos) + local last_return = true + while elapsed > 0 and last_return == true do + last_return = compressor_timestep(pos) + elapsed = elapsed - 1 + end + if last_return == true then + minetest.sound_play("airtanks_compressor", {pos = pos, gain = 0.5}) + minetest.get_node_timer(pos):start(1) + meta:set_string("last_state", "success") + elseif meta:get("last_state") == "success" then + minetest.sound_play("airtanks_compressor_fail", {pos = pos, gain = 0.5}) + meta:set_string("last_state", "fail") + end + meta:set_string("formspec", get_compressor_formspec(math.floor(meta:get_float("fuel_time")))) + end }) + minetest.register_craft({ recipe = { {"", "default:steel_ingot", ""}, @@ -409,3 +603,15 @@ end minetest.register_playerevent(player_event_handler) +----------------------------------------------------------------------------------------- +-- Update old compressors + +minetest.register_lbm({ + label = "Upgrade airtanks compressors", + name = "airtanks:upgrade_compressors", + nodenames = {"airtanks:compressor"}, + run_at_every_load = false, + action = function(pos, node) + compressor_construct(pos) + end, +}) diff --git a/locale/template.txt b/locale/template.txt index 4d12226..47ce280 100644 --- a/locale/template.txt +++ b/locale/template.txt @@ -29,6 +29,7 @@ Double Copper Air Tanks= Double Steel Air Tanks= #for indicating that a particular type of air tank is empty Empty @1= +Fuel= #documentation text If this item is present in your quick-use inventory then whenever your breath bar goes below 5 it will automatically make use of any air tanks that are present in your quick-use inventory to replenish your breath supply. Note that it will not use air tanks that are present elsewhere in your inventory, only ones in your quick-use bar.= @@ -38,14 +39,17 @@ If you're underwater and you're running out of breath, wield this item and use i #documentation text If you're underwater and you're running out of breath, wield this item and use it to replenish 5 bubbles on your breath bar. When fully charged this tank has @1 uses before it becomes empty.= -#documentation text -Place this machine somewhere that it has access to air (one of its adjacent nodes needs to have air in it). When you click on it with an empty or partly-empty compressed air tank the tank will be refilled.= +Place place empty tanks in the inventory to the right. The compressor will start filling the largest capacity tanks first.= +Pressure:@n@1= #compressed air tank made of steel Steel Air Tank= +Tanks= These tanks can be recharged with compressed air by using it on a compressor block. When fully charged these tanks have @1 uses before it becomes empty.= +This machine requires fuel to operate. Place something that can burn in the fuel slot, and then place empty tanks in the inventory to the right. The compressor will start filling the largest capacity tanks first.= + This tank can be recharged with compressed air by using it on a compressor block. When fully charged these tanks have @1 uses before it becomes empty.= #documentation text diff --git a/settingtypes.txt b/settingtypes.txt index d7190af..d973ad4 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -3,4 +3,5 @@ airtanks_copper_uses (Number of uses for a copper air tank) int 10 2 1000 airtanks_bronze_uses (Number of uses for a bronze air tank) int 20 2 1000 airtanks_wear_in_creative (Air tanks wear out in creative mode) bool true airtanks_enable_double (Enable double tanks) bool true -airtanks_enable_triple (Enable triple tanks) bool true \ No newline at end of file +airtanks_enable_triple (Enable triple tanks) bool true +airtanks_compressor_needs_fuel (Compressor requires fuel) bool true \ No newline at end of file From b686694979f0dc007f22038a24a1fc416ec39b9b Mon Sep 17 00:00:00 2001 From: FaceDeer Date: Sat, 13 Mar 2021 17:17:24 -0700 Subject: [PATCH 03/10] pack the two and three tank art together more --- textures/airtanks_airtank.png | Bin 372 -> 333 bytes textures/airtanks_airtank_three.png | Bin 385 -> 669 bytes textures/airtanks_airtank_two.png | Bin 379 -> 424 bytes textures/airtanks_breathing_tube.png | Bin 496 -> 398 bytes textures/airtanks_compressor.png | Bin 850 -> 843 bytes textures/airtanks_compressor_bottom.png | Bin 629 -> 627 bytes textures/airtanks_empty.png | Bin 222 -> 137 bytes 7 files changed, 0 insertions(+), 0 deletions(-) diff --git a/textures/airtanks_airtank.png b/textures/airtanks_airtank.png index 2a0a9de4a40ea684fbf8acb81d1d67e76ffe5aab..f9a15a4920b7a809da88fc6f24c14c303bcf8d35 100644 GIT binary patch delta 317 zcmV-D0mA+b8jyt&ED$h^I{xVf?V{QStv$Gp9_xx2HuyST;2!@0Y(yS=%=!@#$= zv9-6Zw70adv#hbSs<*kfx4E^gu%@i8q_efItgfc1tf9NTxPPv(tf;A?sH~yAz`Uxh zsiml)rKzC1y}YQZsiLK%o}r!a^6WG%o<_wjTiJb-xJo{qf-sHERW$MSc=) P00000NkvXXu0mjfv?H&D delta 356 zcmX@h^o41HWIY=L1B3kM|A|0~Ey>&6h2cL4F4((#GEjuGz$3Dlfq`2Xgc%uT&5-~K zvX^-Jy0SlHmSWYj@L{|26(}T|84^+AoS&PUnpXnkGB7w7r6!i7rYMwWmSiZnd-?{X z=%um)#cz1JIEGl9o;%4m>#zfl+x%noH>cfM`O=c>t?h1&mP;~=Kkf?1IX-ja*UPQf zg(bMRO!{)+yQh%gl}B-2I^NHIluU^_zc5T-B11$-rO3*#4vv|{Y4euXHoQL_e&^Z5 zeeZwT)VpkMNtD_VS1<9e?&QyV`y7=PuA0HBbct_6!8UHzNkP^Q0zRU}htHOIcr?8- zd-E{XWOl?fQU2v?w3VzGVqX;$pAkD$+s@7z!u>E|-{EFG&ec}Cv_3u%UM&<4Ai>mXjLA61N8`R+dFYjHM-v6&TV^XX(oQ zK+DZGHr>W~?r?f{+#S0y#5rxvNkt8P*bl}+q-@C0K8yZ=4(^VF?|nb7_t)5@JYOs< z6$%7`V#Nh{GrW=fePACvt0ae10zrYQ>5{q;KCPppc88N@$?a@*b8D03NSc{tIcjMo zN--o!1sINXIPFBxPts(N4Du27ZDM6QFiA5MMHA^C>A)-&U0x(9VvfWy+`W^_&CcNq zi;>0X0>jc6KDqXOjo~Pqz`Q<}7ju&IoY(IQ@wCh1rkNna(cuX1!}11@fCrX=1lGe` zlVu2&fph4E!D1T*&%m=@7y(+?1cX-G(1_It0FaNnUV#me|NJyDV(B;Ah6kP-4CrH+ z3lc!0gL)VWNWi~#jzJ*so(}542AO};f)EP{5DOJ>AbB1`K@P{W{%N1b>-6~EKmxQw zAow94+RYZzdi#VJxYZAvm2k}eb$z+EHU>Y$6mpqbcU808X)2N-=&EDvUgzDihW6Av zF~2MQow+I9h<|r)xd)LOr=zD1o5LN)e`;RdsX#pCqSgSxbbr+FlB2qky7Gxf{WasM zl5H&XDWM{oVra~Et1#78XtOCl?~(BQbdksy|JqQK{2Y?i)t6Q^d)mrQCckA1!(AUt>37vL+O8|y{Ul%8 kH!vxzTuz*A+24xnO-aQXXvYw5BfkFQB|3o0gmgMd3!tfsi7wla=87RV8;1OBOz`!jG!i)^F=12eq z*-JcqUD=;9vxulkbTZvN0ThzW42dXl&d<$F%_{+N85o?4QWHy3QxwWGOEMJPJ$(aG z^itV@;!izY978NlPrY>4>xh9s+r#quOZR40$u`|v#@=+IN;t;C zbP%erlbE4caBWs`&t-`_p=%jg1a@a_iL#21EKZA^{(D*IGzPu+`GwKxZHW*5KGuy| z!#-nL=j*StGyf<)kB`!ss=aX43|1wl*^FX-E)0!JHcgB2W@t)SHA6bjt$V8Aqymx5mE$h>;7@X!B? zQLh<;t}o7tV2S9=TFYLbeSD2`>Efe82QD98d}rDj8~r^t`@OpVGA11C7N|VE^)o0e NJYD@<);T3K0RUd?maYH* diff --git a/textures/airtanks_airtank_two.png b/textures/airtanks_airtank_two.png index f221b6c8a5b5d5fe3294d8d685a054c166afebbf..738d39a2bc3375f5441b372fdeac9f3f2cd56bc5 100644 GIT binary patch delta 409 zcmey(w1RnpWIZzj1A~Sxe=v|b8Q>G*3Z%dN`0?S>hwVEyOr0@fwf+DvtrG{ox3;BTR3;+nuP}r?^(KX0Z`e_J==lmfx3VS&R#gPYVFGHJGY-WeSF96 z?LgBePVSq%VCK=|hj;GYvU~5&gNF}n-?0&BT1#v7mhD^WH*8)5v;%0|(iIE0@7%g} z!!n>{&7GBtmM&SdZrSd=d*;qtIB{xkdv^=avb_iP0Nr%_#8IFN_UzpbbjpfVD|hbR z@%r8C%U3T09khAty2(>}Cr)nLe_&_j@2S;5`vppZ{6M}#0dku5w}Aq6p7kz{Ar*0{ zr;qX-HV|}*dFNyaTP557tul^N6F0v- uyYR?{@?+L3jMuE|77k(AZkNK)FHt&6Nbt1(^Ute5j`MW&b6Mw<&;$TtA=}je delta 363 zcmZ3%{F`ZlWIY=L1B3kM|A|0~Ey>&6h2cL4F4((#GEjuGz$3Dlfq`2Xgc%uT&5-~K zvX^-Jy0SlIW)V^4*gs=lK2S(DGbEzKIX^cyHLnE7WngeFN=+Fe6GjlakJE{xyq9Vzn%UlQPZf~7l#-Bf>{aJ_zrV>vt!6m| z{EN62Ejj6M?57LQ4*g3{xcJMzm(8(iKYZl!8j)E5 diff --git a/textures/airtanks_breathing_tube.png b/textures/airtanks_breathing_tube.png index 83ff5728b15ddd6b415a0107cb1285bac94e48a1..2af21279cbcb692fb51e2d7ccc72070ee8241eec 100644 GIT binary patch delta 382 zcmeys+{ZjYvYwfNfk8u;KNv{u4e$wZ1=9cj|Nrsz`+-9TqvPX3Bf_idYi%7J)V0*T z!o#_ExJ}HBt?g{DUcc_??G+Rl*gkbiLqkn`e0+IJi@KUh-?Yh%{ZnL=6vL8}^i0iy zV&ip8OnYX}v2n0ZDk@di(e(@oQ`a|8)YJ%wi}#6$s?RAcSJ%@ENlcbgQSph6jfhV& zwYAaI)svN%GqSPui;Y#))lJCFRnkyn70+z#>5G!R`cla!zoX!|aAyBozK8ekbu0*)%D31}_+r-aAHx1$ z*v%#_@t8dG+@=Wb%_ghAsLAy6y85}S Ib4q9e0DA(3LI3~& delta 481 zcmV<70UrL21MmZo8Gi-<001BJ|6u?C00v@9M??Vs0RI60puMM)00009a7bBm000XU z000XU0RWnu7ytkO2XskIMF-&n8x$ls6S10I0000TX;fHrLvL+uWo~o;00000Lvm$d zbY)~9cWHEJAV*0}P-HG;2LJ#8R7pfZR5;6>(mO9haTv$(?|*Tc^y0Yo9BGJ4qIw|= zk|MNKLtPV_kVu`xY!!>4ufQU)BL>7`FsPus2Js3EiovBh)r7|;BrZLD#wYoG{?GH| z4<%M1Z!u>s%F^}+l^GdGJMs1<5?D|7?{6!LkVU!Lp( zv5^D^`+L;Z>+}r_+6OMr&M_K%(icx~dXiCWeI$=oNoQAxo7-FT`y5BRyFX7b6psOL zb$t!M#MC4J7>~B3eRoYm4+oV=|peNjkmyW9D-L z(=>Uw%i+|jr1@M?n8|myzRv5(@cq$ba@90`a`)GrL6)U&uB@$0^6nzjX@47|bM}*uKl1-FdR7or z^6u?l?tJ#+&pRAG{)_F)TfDgW{DIVI9E~SpGO|r@?KR-r{}r4)zp}h~ah)q<9PAzN z(yOmCSEhx`3hw^!J^S|`6}{g4!YuP2LG<2ly}ZfxmDd>bhdew!0Xt?sQ}mx4GB`P8 zt|OkAW#nub9Dg6VGi4X8B5A5vT`Wn%h(a_x*ndcjk!fA8&oTnwo3FlHGuB_NjlX7$ zU8%-XvLqwPbE;~B5Q^Z2BsxJ#*D#q&*XyQPZH&VON#2=5 zD?yrQ0wATr7=y7b-c*!DN>LQ!Jnwv{t&2AomzF!#pnp%A)O6?1QItJEf)I>H1B8$i z-4eWGTtx&>l)ci_qZ@j8b-nY#<}2*o`-x%ynCG@Gvvgq%q#}fXbA}|**ruhaD|UBo z)0!z;+i&pOy*ub`(jx5%A{ule5fc7B+QZrwmE@dRSi*Z44<3`GnxdOCbt80`u+Y`$ zY4wD9pns`G6{ay%M|3PsV8*g9b}>|>3k?(bqICx{Q;dnZaINVA+M z0CGY*A;w6I5D`Em(F&mwgp!EhXpI3tx2>hnIn!xF+j{a2WC{Whi2y*vJ4bYZ#ySL^ zR0~1~XzKzr7TbEf4@i{|RKx{Oj1dqJBUzddiE>zLAbOO_s2hu3S$!((|M^G`2SY;e zq~n&_n$zJBV?>-btu=~(4~{I)xwP>#`uv6Ex6Ynh`XZppKkn}mBV1g6mNWAuA;i-U r1ktw~JUC!nov^WS39S`Hs;>V7ZM1T$>8@E}00000NkvXXu0mjf*Qj$| delta 768 zcmV+b1ONQX2GRzQUVq<7L_t(I%Waa+Yg|kWO-ZPUu_!1}gCL~= zaphlO5ph*STnVl!QUrHyTHLr2T~z!Z#6?BjlvJt^YLePYlZH4mZ|2Q=_rCkXMN$~S z@9r!zk~uh98cq>WXe$b@#XJL7FCSFRw0FS$}td$)pXzTJz~A*W6P^ zO&fR_zkmDJJD>mb%Qgp(|7PpbCNFQixF4w`jK-CyMyBz$y$XEyzXoT{EibKHSmQD& z`@8$R^7@<16iFVXId^~jfxY{W@?LLtewz7@L2%A(zPiEI=14$xTStv;Sh+H&0*n3C_fk|DjO)~=E+poV`)y7?^ zwY#ddSuV#D(l{l~GRm?-2#L2tViglbQGaovcPsCtH`==Yhq(F0XYbb9Uay;GrO_7a zBeKp6N(z!#;ejZUXsywv#p#kFPssCpoMoMlm9gRG!hhmYryTT2;+pR4S@NQH(oP7* zqX9xhI-K)FGRDh*^^Oq2$$3;lAWdQd0b?`-hm;D36v~sKYdWVDn0000XN#y7gaTUZGDu3>*I}KJAa)}79FFNb?Rmn(4Z8H z`4puz^{9aqS+s%z>SncZ-Ta;1*xDXGc=(9p!;j1+f4RT+nDOQv(1x5dF*=IE;`>0~ zwH$r^KyXX;o;>Bt;V0~<2xxzX5{E4`O2fa?W4sTTqT=e>n3P~K{Y_C?>QTiq&awHN zwUNax+dp(uOMg3WalNBGJ!ZAZ5F-6N(@zXq8S0_NcLnp=1n)fEMdwy9;p;5!A)9)?&z{92ry1~rDDg;)d|!QR^t zv9=WKgSCypD-!I)A{Ieo6hWfI-JRX+%=i0RxHpm0o$fs6aNyEQ9lm+}tab6A?YiyG zMPk-e{VQ0bC<{vlv^F^Ba6XV+!>}%?>v~>Q{a4mUIlMO7?0+|tF=f#*SlOT+t^pd9 zVm_Ool%^gGAw}kmpn!U~HgxUmt=-(->ED0wkdvbiOvit?xBrOI)@{&+oHH>xio)W% zK-V@Le|k@F3-%vB;q%c)?4Sr}e~uD|Ei_8Q-?J0E51682b$vuiFrWOQC@uA%Vi9N9 ze8Kv_Vi(PC+JA|qnKii1(VU&IHp~zr-7M3M4O$uMzQ(r&v*{S`Jni@xcX5t-`Qo`~ zqbPe7q5vv#xIjb@f&aupVGYU@D5Ft15}X6ThTy4f#bVJBLZa$J&p-wQS&k*77?GIi zd_<8bts>`)^)W-|@gb2?Mw^0cgqRZ|0w@rnR~86@_i+v+VN8#<^Vl2PxAM0iKlOAn zCFevr547GbgM)~mmd;v>A(L{XS5@ro-oakq+I)I-WArX#hF`xNBLX*f?y|ZvBxhN6 uppXmj!Q delta 206 zcmeBVyvH~}qMn0|fq_B(^Z!I3#g^pl?!xdN1Q+aGJ{c&&S>O>_%)r1c48n{Iv*t(u z1=&kHeO=ifGE1?ssm~KV_!%f9n;8;O;+&tGo0?Yw Date: Tue, 6 Sep 2022 23:54:18 -0600 Subject: [PATCH 04/10] empty airtanks were working with the breathing tube --- init.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index 39cd40a..e5c4dc9 100644 --- a/init.lua +++ b/init.lua @@ -581,7 +581,7 @@ local function use_any_airtank(player) local hotbar = player:hud_get_hotbar_itemcount() for i=1, hotbar do local itemstack = inv:get_stack("main", i) - if minetest.get_item_group(itemstack:get_name(), "airtank") > 0 then + if minetest.get_item_group(itemstack:get_name(), "airtank") > 1 then itemstack = use_airtank(itemstack, player) inv:set_stack("main", i, itemstack) return true @@ -591,8 +591,7 @@ local function use_any_airtank(player) end local function player_event_handler(player, eventname) - assert(player:is_player()) - if eventname == "breath_changed" and player:get_breath() < 5 and tool_active(player, "airtanks:breathing_tube") then + if player:is_player() and eventname == "breath_changed" and player:get_breath() < 5 and tool_active(player, "airtanks:breathing_tube") then if not use_any_airtank(player) then minetest.sound_play("airtanks_gasp", {pos = player:get_pos(), gain = 0.5}) end From 443c635c00c948444c7726e599dde3b64e7bec12 Mon Sep 17 00:00:00 2001 From: FaceDeer Date: Sat, 17 Sep 2022 18:17:08 -0600 Subject: [PATCH 05/10] initial compatibility work (#7) --- README.md | 10 ++++-- depends.txt | 2 -- description.txt | 1 - init.lua | 85 ++++++++++++++++++++++++++++++++++++------------- mod.conf | 4 +-- 5 files changed, 72 insertions(+), 30 deletions(-) delete mode 100644 depends.txt delete mode 100644 description.txt diff --git a/README.md b/README.md index 69ca416..5152f8c 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,14 @@ A simple mod for extending one's underwater excursion time. Air tanks are crafted from copper, steel, or bronze ingots and are wielded like tools. A compressor is crafted from steel, mese shard, and wood. -Place a compressor in world and click on it with an empty air tank to fill it. Compressors can also recharge partly-used tanks. +Place a compressor in world and click on it with an empty air tank to fill it. Compressors can also recharge partly-used tanks. Compressors require fuel, unless that configuration option has been disabled. When running low on breath use a filled air tank to recharge your breath bar. One use will replenish 5 steps of breath (out of 10). By default a steel air tank will hold 30 uses, a bronze one holds 20, and a copper one holds 10 - these settings can be changed in the mod's section under Advanced Settings. Once a tank runs out of uses it turns into an empty tank, which can be recharged again with a compressor. -To automatically draw air from air tanks, craft a breathing tube and put it in your quick-use inventory row. When your breath bar drops below 5 steps it will automatically attempt to use an air tank from your quick-use inventory row to replenish it. \ No newline at end of file +To automatically draw air from air tanks, craft a breathing tube and put it in your quick-use inventory row. When your breath bar drops below 5 steps it will automatically attempt to use an air tank from your quick-use inventory row to replenish it. + +## Dependencies + +This mod will work with either the default minetest_game (and most other games derived from it), or it will work with MineClone2 or MineClone5. Bronze ingots aren't available in Mineclone and so bronze tanks are not an option when running in that environment. + +Although these games are listed as optional dependencies this mod will throw an assert if one of the two are not installed. \ No newline at end of file diff --git a/depends.txt b/depends.txt deleted file mode 100644 index 92dd391..0000000 --- a/depends.txt +++ /dev/null @@ -1,2 +0,0 @@ -default -doc? \ No newline at end of file diff --git a/description.txt b/description.txt deleted file mode 100644 index ae12865..0000000 --- a/description.txt +++ /dev/null @@ -1 +0,0 @@ -Provides pressurized air tanks for extended underwater excursions \ No newline at end of file diff --git a/init.lua b/init.lua index e5c4dc9..bbfe36a 100644 --- a/init.lua +++ b/init.lua @@ -44,6 +44,39 @@ setting("bool", "wear_in_creative", true, "Air tanks wear out in creative mode") setting("bool", "compressor_needs_fuel", true, "Compressor needs fuel") +-- these may come from default or from mineclone mods +local steel_ingot +local copper_ingot +local bronze_ingot +local mese_crystal_fragment +local get_itemslot_bg = function(x, y, w, h) return "" end +local get_hotbar_bg = function(x, y) return "" end +local sounds + +if minetest.get_modpath("default") then + steel_ingot = "default:steel_ingot" + copper_ingot = "default:copper_ingot" + bronze_ingot = "default:bronze_ingot" + mese_crystal_fragment = "default:mese_crystal_fragment" + get_hotbar_bg = default.get_hotbar_bg + sounds = default.node_sound_metal_defaults() +elseif minetest.get_modpath("mcl_core") then + steel_ingot = "mcl_core:iron_ingot" + mese_crystal_fragment = "mesecons:wire_00000000_off" +else + assert(false, "This mod requires either Mineclone or the default Minetest Game to be installed.") +end + +if minetest.get_modpath("mcl_formspec") then + get_itemslot_bg = mcl_formspec.get_itemslot_bg +end +if minetest.get_modpath("mcl_sounds") then + sounds = mcl_sounds.node_sound_metal_defaults() +end +if minetest.get_modpath("mcl_copper") then + copper_ingot = "mcl_copper:copper_ingot" +end + local compressor_desc = S("A machine for filling air tanks with compressed air.") local compressor_help if config.compressor_needs_fuel then @@ -89,6 +122,7 @@ end -- This will only work for single use tanks... we need to add separate functions for the others local function register_air_tank(name, desc, color, uses, material) + if not material then return end minetest.register_craftitem("airtanks:empty_"..name.."_tank", { description = S("Empty @1", desc), groups = {airtank = 1}, @@ -98,7 +132,6 @@ local function register_air_tank(name, desc, color, uses, material) _airtanks_full = "airtanks:"..name.."_tank", inventory_image = "airtanks_airtank.png^[colorize:"..color.."^[mask:airtanks_airtank.png^airtanks_empty.png", wield_image = "airtanks_airtank.png^[colorize:"..color.."^[mask:airtanks_airtank.png^airtanks_empty.png", - stack_max = 99, }) minetest.register_tool("airtanks:"..name.."_tank", { @@ -133,7 +166,9 @@ local function register_air_tank(name, desc, color, uses, material) end -local function register_air_tank_2(name, desc, color, uses) +local function register_air_tank_2(name, desc, color, uses, material) + if not material then return end + minetest.register_craftitem("airtanks:empty_"..name.."_tank_2", { description = S("Empty @1", desc), groups = {airtank = 1}, @@ -143,7 +178,6 @@ local function register_air_tank_2(name, desc, color, uses) _airtanks_full = "airtanks:"..name.."_tank_2", inventory_image = "airtanks_airtank_two.png^[colorize:"..color.."^[mask:airtanks_airtank_two.png^airtanks_empty.png", wield_image = "airtanks_airtank_two.png^[colorize:"..color.."^[mask:airtanks_airtank_two.png^airtanks_empty.png", - stack_max = 99, }) minetest.register_tool("airtanks:"..name.."_tank_2", { @@ -185,7 +219,9 @@ local function register_air_tank_2(name, desc, color, uses) end -local function register_air_tank_3(name, desc, color, uses) +local function register_air_tank_3(name, desc, color, uses, material) + if not material then return end + minetest.register_craftitem("airtanks:empty_"..name.."_tank_3", { description = S("Empty @1", desc), groups = {airtank = 1}, @@ -195,7 +231,6 @@ local function register_air_tank_3(name, desc, color, uses) _airtanks_full = "airtanks:"..name.."_tank_3", inventory_image = "airtanks_airtank_three.png^[colorize:"..color.."^[mask:airtanks_airtank_three.png^airtanks_empty.png", wield_image = "airtanks_airtank_three.png^[colorize:"..color.."^[mask:airtanks_airtank_three.png^airtanks_empty.png", - stack_max = 99, }) minetest.register_tool("airtanks:"..name.."_tank_3", { @@ -251,27 +286,25 @@ local function register_air_tank_3(name, desc, color, uses) end -register_air_tank("steel", S("Steel Air Tank"), "#d6d6d6", config.steel_uses, "default:steel_ingot") -register_air_tank("copper", S("Copper Air Tank"), "#cd8e54", config.copper_uses, "default:copper_ingot") -register_air_tank("bronze", S("Bronze Air Tank"), "#c87010", config.bronze_uses, "default:bronze_ingot") +register_air_tank("steel", S("Steel Air Tank"), "#d6d6d6", config.steel_uses, steel_ingot) +register_air_tank("copper", S("Copper Air Tank"), "#cd8e54", config.copper_uses, copper_ingot) +register_air_tank("bronze", S("Bronze Air Tank"), "#c87010", config.bronze_uses, bronze_ingot) if config.enable_double then - register_air_tank_2("steel", S("Double Steel Air Tanks"), "#d6d6d6", config.steel_2_uses) - register_air_tank_2("copper", S("Double Copper Air Tanks"), "#cd8e54", config.copper_2_uses) - register_air_tank_2("bronze", S("Double Bronze Air Tanks"), "#c87010", config.bronze_2_uses) + register_air_tank_2("steel", S("Double Steel Air Tanks"), "#d6d6d6", config.steel_2_uses, steel_ingot) + register_air_tank_2("copper", S("Double Copper Air Tanks"), "#cd8e54", config.copper_2_uses, copper_ingot) + register_air_tank_2("bronze", S("Double Bronze Air Tanks"), "#c87010", config.bronze_2_uses, bronze_ingot) end if config.enable_triple then - register_air_tank_3("steel", S("Triple Steel Air Tanks"), "#d6d6d6", config.steel_3_uses) - register_air_tank_3("copper", S("Triple Copper Air Tanks"), "#cd8e54", config.copper_3_uses) - register_air_tank_3("bronze", S("Triple Bronze Air Tanks"), "#c87010", config.bronze_3_uses) + register_air_tank_3("steel", S("Triple Steel Air Tanks"), "#d6d6d6", config.steel_3_uses, steel_ingot) + register_air_tank_3("copper", S("Triple Copper Air Tanks"), "#cd8e54", config.copper_3_uses, copper_ingot) + register_air_tank_3("bronze", S("Triple Bronze Air Tanks"), "#c87010", config.bronze_3_uses, bronze_ingot) end --------------------------------------------------------------------------------------------------------- -- Compressor -local sounds = default.node_sound_metal_defaults() - local tank_inv_size = 4*4 local get_compressor_formspec @@ -280,15 +313,19 @@ if config.compressor_needs_fuel then local formspec = "size[8,9]" .. "label[1,1.5;" .. S("Fuel") .. "]" .. + get_itemslot_bg(1,2,1,1) .. "list[context;fuel;1,2;1,1;]" .. "label[4.5,0;" .. S("Tanks") .. "]" .. "label[2,2;" .. S("Pressure:\n@1", remaining_time) .. "]" .. + get_itemslot_bg(3,0.5,4,4) .. "list[context;tanks;3,0.5;4,4;]" .. + get_itemslot_bg(0,4.85,8,1) .. "list[current_player;main;0,4.85;8,1;]" .. + get_itemslot_bg(0,6.08,8,3) .. "list[current_player;main;0,6.08;8,3;8]" .. "listring[context;tanks]" .. "listring[current_player;main]" .. - default.get_hotbar_bg(0,4.85) + get_hotbar_bg(0,4.85) return formspec end else @@ -296,12 +333,15 @@ else local formspec = "size[8,9]" .. "label[3.5,0;" .. S("Tanks") .. "]" .. + get_itemslot_bg(2,0.5,4,4) .. "list[context;tanks;2,0.5;4,4;]" .. + get_itemslot_bg(0,4.85,8,1) .. "list[current_player;main;0,4.85;8,1;]" .. + get_itemslot_bg(0,6.08,8,3) .. "list[current_player;main;0,6.08;8,3;8]" .. "listring[context;tanks]" .. "listring[current_player;main]" .. - default.get_hotbar_bg(0,4.85) + get_hotbar_bg(0,4.85) return formspec end end @@ -474,7 +514,7 @@ minetest.register_node("airtanks:compressor", { description = S("Air Compressor"), _doc_items_longdesc = compressor_desc, _doc_items_usagehelp = compressor_help, - groups = {oddly_breakable_by_hand = 1, airtanks_compressor = 1}, + groups = {oddly_breakable_by_hand = 1, airtanks_compressor = 1, handy = 1}, sounds = sounds, tiles = { "airtanks_compressor_bottom.png^[transformR90", @@ -537,9 +577,9 @@ minetest.register_node("airtanks:compressor", { minetest.register_craft({ recipe = { - {"", "default:steel_ingot", ""}, - {"default:steel_ingot", "default:mese_crystal_fragment", "default:steel_ingot"}, - {"group:wood", "default:steel_ingot", "group:wood"}, + {"", steel_ingot, ""}, + {steel_ingot, mese_crystal_fragment, steel_ingot}, + {"group:wood", steel_ingot, "group:wood"}, }, output = "airtanks:compressor" }) @@ -553,7 +593,6 @@ minetest.register_craftitem("airtanks:breathing_tube", { _doc_items_usagehelp = tube_help, inventory_image = "airtanks_breathing_tube.png", wield_image = "airtanks_breathing_tube.png", - stack_max = 99, }) minetest.register_craft({ diff --git a/mod.conf b/mod.conf index 762f446..e13b27e 100644 --- a/mod.conf +++ b/mod.conf @@ -1,4 +1,4 @@ name = airtanks description = Provides pressurized air tanks for extended underwater excursions -depends = default -optional_depends = doc \ No newline at end of file +depends = +optional_depends = doc, default, mcl_formspec, mcl_sounds, mcl_core, mcl_copper \ No newline at end of file From 70d9f58f6b9e82deeba9aa4e3f0ad1505bf562da Mon Sep 17 00:00:00 2001 From: "Github is a non-free platform owned by Microsoft. Reasonable alternatives exist, such as Gitea, Sourcehut. We need a federated, mastodon-like forge based on ForgeFed. See: https://forgefed.org" Date: Wed, 11 Oct 2023 20:04:20 +0200 Subject: [PATCH 06/10] Airtanks and breathing tube in armor slots (#8) Integrates MineClone/MineClonia so that those items can be used in the armor slot. --- init.lua | 58 +++++++++++++++++--- mod.conf | 2 +- textures/airtanks_chestplate_tank.png | Bin 0 -> 413 bytes textures/airtanks_chestplate_tank_three.png | Bin 0 -> 463 bytes textures/airtanks_chestplate_tank_two.png | Bin 0 -> 433 bytes textures/airtanks_helmet_tube.png | Bin 0 -> 201 bytes textures/airtanks_helmet_tube_preview.png | Bin 0 -> 206 bytes 7 files changed, 52 insertions(+), 8 deletions(-) create mode 100644 textures/airtanks_chestplate_tank.png create mode 100644 textures/airtanks_chestplate_tank_three.png create mode 100644 textures/airtanks_chestplate_tank_two.png create mode 100644 textures/airtanks_helmet_tube.png create mode 100644 textures/airtanks_helmet_tube_preview.png diff --git a/init.lua b/init.lua index bbfe36a..775dcd7 100644 --- a/init.lua +++ b/init.lua @@ -4,6 +4,8 @@ local print_settingtypes = false local CONFIG_FILE_PREFIX = "airtanks_" local config = {} +local has_mcl_armor = minetest.get_modpath("mcl_armor") + local function setting(stype, name, default, description) local value if stype == "bool" then @@ -87,6 +89,9 @@ end local tube_desc = S("A breathing tube to allow automatic hands-free use of air tanks.") local tube_help = S("If this item is present in your quick-use inventory then whenever your breath bar goes below 5 it will automatically make use of any air tanks that are present in your quick-use inventory to replenish your breath supply. Note that it will not use air tanks that are present elsewhere in your inventory, only ones in your quick-use bar.") +if has_mcl_armor then + tube_help = S("If this item is present in your head armor slot then whenever your breath bar goes below 5 it will automatically make use of any air tanks that are present in your chestplate armor slot to replenish your breath supply. Note that it will not use air tanks that are present elsewhere in your inventory, only ones in your chestplate armor slot.") +end local cardinal_dirs = {{x=1,y=0,z=0},{x=-1,y=0,z=0},{x=0,y=1,z=0},{x=0,y=-1,z=0},{x=0,y=0,z=1},{x=0,y=0,z=-1},} @@ -144,11 +149,19 @@ local function register_air_tank(name, desc, color, uses, material) inventory_image = "airtanks_airtank.png^[colorize:"..color.."^[mask:airtanks_airtank.png", wield_image = "airtanks_airtank.png^[colorize:"..color.."^[mask:airtanks_airtank.png", stack_max = 1, + _mcl_armor_element = "torso", + _mcl_armor_texture = "airtanks_chestplate_tank.png", on_place = function(itemstack, user, pointed_thing) - return use_airtank(itemstack, user) + if has_mcl_armor then + return mcl_armor.equip_on_use(itemstack, user, pointed_thing) + else + return use_airtank(itemstack, user) + end end, + on_secondary_use = has_mcl_armor and mcl_armor.equip_on_use, + on_use = function(itemstack, user, pointed_thing) return use_airtank(itemstack, user) end, @@ -190,11 +203,19 @@ local function register_air_tank_2(name, desc, color, uses, material) inventory_image = "airtanks_airtank_two.png^[colorize:"..color.."^[mask:airtanks_airtank_two.png", wield_image = "airtanks_airtank_two.png^[colorize:"..color.."^[mask:airtanks_airtank_two.png", stack_max = 1, + _mcl_armor_element = "torso", + _mcl_armor_texture = "airtanks_chestplate_tank_two.png", on_place = function(itemstack, user, pointed_thing) - return use_airtank(itemstack, user) + if has_mcl_armor then + return mcl_armor.equip_on_use(itemstack, user, pointed_thing) + else + return use_airtank(itemstack, user) + end end, + on_secondary_use = has_mcl_armor and mcl_armor.equip_on_use, + on_use = function(itemstack, user, pointed_thing) return use_airtank(itemstack, user) end, @@ -243,11 +264,19 @@ local function register_air_tank_3(name, desc, color, uses, material) inventory_image = "airtanks_airtank_three.png^[colorize:"..color.."^[mask:airtanks_airtank_three.png", wield_image = "airtanks_airtank_three.png^[colorize:"..color.."^[mask:airtanks_airtank_three.png", stack_max = 1, + _mcl_armor_element = "torso", + _mcl_armor_texture = "airtanks_chestplate_tank_three.png", on_place = function(itemstack, user, pointed_thing) - return use_airtank(itemstack, user) + if has_mcl_armor then + mcl_armor.equip_on_use(itemstack, user, pointed_thing) + else + return use_airtank(itemstack, user) + end end, + on_secondary_use = has_mcl_armor and mcl_armor.equip_on_use, + on_use = function(itemstack, user, pointed_thing) return use_airtank(itemstack, user) end, @@ -356,7 +385,7 @@ local test_can_put = function(pos, listname, index, itemstack) return 1 end end - return 0 + return 0 end if listname == "fuel" then local fuel, afterfuel = minetest.get_craft_result({method="fuel",width=1,items={itemstack:get_name()}}) @@ -593,6 +622,13 @@ minetest.register_craftitem("airtanks:breathing_tube", { _doc_items_usagehelp = tube_help, inventory_image = "airtanks_breathing_tube.png", wield_image = "airtanks_breathing_tube.png", + + _mcl_armor_element = "head", + _mcl_armor_texture = "airtanks_helmet_tube.png", + _mcl_armor_preview = "airtanks_helmet_tube_preview.png", + + on_place = has_mcl_armor and mcl_armor.equip_on_use, + on_secondary_use = has_mcl_armor and mcl_armor.equip_on_use, }) minetest.register_craft({ @@ -606,9 +642,13 @@ minetest.register_craft({ local function tool_active(player, item) local inv = player:get_inventory() + local inv_list = "main" local hotbar = player:hud_get_hotbar_itemcount() + if has_mcl_armor then + inv_list = "armor" + end for i=1, hotbar do - if inv:get_stack("main", i):get_name() == item then + if inv:get_stack(inv_list, i):get_name() == item then return true end end @@ -617,12 +657,16 @@ end local function use_any_airtank(player) local inv = player:get_inventory() + local inv_list = "main" local hotbar = player:hud_get_hotbar_itemcount() + if has_mcl_armor then + inv_list = "armor" + end for i=1, hotbar do - local itemstack = inv:get_stack("main", i) + local itemstack = inv:get_stack(inv_list, i) if minetest.get_item_group(itemstack:get_name(), "airtank") > 1 then itemstack = use_airtank(itemstack, player) - inv:set_stack("main", i, itemstack) + inv:set_stack(inv_list, i, itemstack) return true end end diff --git a/mod.conf b/mod.conf index e13b27e..7dfb028 100644 --- a/mod.conf +++ b/mod.conf @@ -1,4 +1,4 @@ name = airtanks description = Provides pressurized air tanks for extended underwater excursions depends = -optional_depends = doc, default, mcl_formspec, mcl_sounds, mcl_core, mcl_copper \ No newline at end of file +optional_depends = doc, default, mcl_formspec, mcl_sounds, mcl_core, mcl_copper, mcl_armor \ No newline at end of file diff --git a/textures/airtanks_chestplate_tank.png b/textures/airtanks_chestplate_tank.png new file mode 100644 index 0000000000000000000000000000000000000000..081ceb90b955bc30f1d43b94dbc1ec7a54dc351e GIT binary patch literal 413 zcmV;O0b>4%P)Aw7k8z$;`;Oxv`Rzhm)3$h>V4WhJ3fVwbRwpwYRQ@ih8@fxwEyd z>+b8Dp_#kAyt}=)go=8otf8^As;#i5xx2Ktxwpl~!@$G5$H>LGyR)gRp}D)byS%x* zz`Uxhsiml)rKzC5z`3xqtgNo4!Nb6}xUsCRq?447ggNZg00001bW%=J06^y0W&i*H z0b)x>L;#2d9Y_EG010qNS#tmY3ljhU3ljkVnw%H_000McNliruA&U;ANsrKRY|m0K33IMP8pG0~kduxhOKgL_%DWA_Mq^ zgbgV&z*tX*GA}6E*eXzDfEc5d7DWc=%4yqC7KqB$M!01G;?D&&FJB&&00000NkvXX Hu0mjf1>C`; literal 0 HcmV?d00001 diff --git a/textures/airtanks_chestplate_tank_three.png b/textures/airtanks_chestplate_tank_three.png new file mode 100644 index 0000000000000000000000000000000000000000..7f961d9039669b9c4085cbc6723a94db953211e5 GIT binary patch literal 463 zcmV;=0WkiFP)k5h>L&v{QUO#_^7I>xVyKKm5Ip9 z$Gp9_oT8e|(9E>Aw7k8z$;`;Oxv`Rzhm)3$h>V4WhJ3fVwbRwpwYRQ@ih8@fxwEyd z>+b8Dp_#kAyt}=)go=8otf8^As;#i5xx2Ktxwpl~!@$G5$H>LGyR)gRp}D)byS%x* zz`Uxhsiml)rKzC5z`3xqtgNo4!Nb6}xUsCRq?447w3hhy00001bW%=J06^y0W&i*H z0b)x>L;#2d9Y_EG010qNS#tmY3ljhU3ljkVnw%H_000McNliruA&`VCG|B;A5u10A3DeJ`P@rT)@jgi3<#b2_l$TmP%PFvSbPTP)b z1K2ou1dKR&6v;L~orOtSgM~?xYy;Hz*-b6@*;#SP0{{|*2n7i{v7-P0002ovPDHLk FV1h$p+}r>F literal 0 HcmV?d00001 diff --git a/textures/airtanks_chestplate_tank_two.png b/textures/airtanks_chestplate_tank_two.png new file mode 100644 index 0000000000000000000000000000000000000000..ea7598ffb9594cfb70525bf2b43ce3840fc91376 GIT binary patch literal 433 zcmeAS@N?(olHy`uVBq!ia0vp^4nVBH!3-p)I`?e@QU?NjLR?p@T(on~_79&vtlPL| z-om;4Q+gLIT>_NsozOaETHp2^8#=n{fBpIM?Z=N5t5)vVy?yGm-bqtCPn_9W7l|E7mOBxMkJa4a;`!-m-n?_M^uSA2__{_=%%CcW+*~X5r4= zJ9h8cx%a@HRclu+U9oWK$_4um?A)+<&6;(~4jw+ReaFT%>y}KO(%)kF<_gfcj3q&S z!3+-1Zlr-YN#5=*3>~bp9zYIffk$L90|U1(2s1Lwnj--eWH0gbb!C6b#VaBpH#7AJ zP@W;n)5S5w<9Kp{1nc4ik)EbN2b+XPsR<8K7ad@bD^qwN=^!q#;>7D_gPUvyT~S4i zKzhR}FK-b2ftyph2}n!4epvwGYuvn{)c~YB45KnZ{1>M(Z#NqJY+R9(%W`PP6UI1x WF8w*hOEZABGI+ZBxvXHYaZfQi=gSA+E~G%94_jD<1vV(a|wA zHTCrLw6(Q;`~83Ux!v zL>4nJa0`PlBg3pY5H=O_NQFDLZW literal 0 HcmV?d00001 diff --git a/textures/airtanks_helmet_tube_preview.png b/textures/airtanks_helmet_tube_preview.png new file mode 100644 index 0000000000000000000000000000000000000000..829d644c30d1b17c07b720c783a1f35380c1363a GIT binary patch literal 206 zcmeAS@N?(olHy`uVBq!ia0vp^0zj<5!VDx|E`RzTNNEN5gt#gzD@#gBnwpx%ue+h6 zqvPr6`S$z&6_5VA*3RR}W8kY};3;4To_>%gmtkYCt^!aOV@Z%-FoVOh8)+a;lDE4H zLkFv@2av;A;1OBOz`!jG!i)^F=12eq*-JcqUD=;<@d}9=dixdL1q#V}x;TbNTux44 tU<_l^P-qimSs2nHqQG;Eq3t0z!_P!UVeu`yRst0=c)I$ztaD0e0szCVG|vD4 literal 0 HcmV?d00001 From 2825e97bfd2fd2aaf1056fff3e557622e52a5411 Mon Sep 17 00:00:00 2001 From: Cpyte-Engine-Developer <132003677+Cpyte-Engine-Developer@users.noreply.github.com> Date: Sun, 3 Mar 2024 11:39:13 +0300 Subject: [PATCH 07/10] Add Russian translation (#9) --- locale/template.txt | 2 +- locale/translate.ru.tr | 60 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 locale/translate.ru.tr diff --git a/locale/template.txt b/locale/template.txt index 47ce280..8795c13 100644 --- a/locale/template.txt +++ b/locale/template.txt @@ -39,7 +39,7 @@ If you're underwater and you're running out of breath, wield this item and use i #documentation text If you're underwater and you're running out of breath, wield this item and use it to replenish 5 bubbles on your breath bar. When fully charged this tank has @1 uses before it becomes empty.= -Place place empty tanks in the inventory to the right. The compressor will start filling the largest capacity tanks first.= +Place empty tanks in the inventory to the right. The compressor will start filling the largest capacity tanks first.= Pressure:@n@1= #compressed air tank made of steel diff --git a/locale/translate.ru.tr b/locale/translate.ru.tr new file mode 100644 index 0000000..1a45e9f --- /dev/null +++ b/locale/translate.ru.tr @@ -0,0 +1,60 @@ +# textdomain: airtanks + + +### init.lua ### + +#documentation text +A breathing tube to allow automatic hands-free use of air tanks.=Дыхательная трубка позволяет автоматически использовать воздушный баллон без рук. + +#documentation text +A compressed air tank, currently empty.=Пустой баллон сжатого воздуха. +#documentation text +A machine for filling air tanks with compressed air.=Устройство для заполнения баллонов сжатым воздухом. +A pair of compressed air tanks, currently empty.=Пара пустых баллонов сжатого воздуха. +A pair of tanks containing compressed air.=Пара заполненных баллонов сжатого воздуха. +A set of three compressed air tanks, currently empty.=Набор из 3-ех пустых баллонов сжатого воздуха. +A set of three tanks containing compressed air.=Набор из 3-ех заполненных баллонов сжатого воздуха +#documentation text +A tank containing compressed air.=Баллон содержащий сжатый воздух. +#node name, compresses air to fill pressurized gas tanks +Air Compressor=Воздушный компрессор +#item name, a snorkel mouthpiece for breathing underwater +Breathing Tube=Дыхательная трубка +#compressed air tank made of bronze +Bronze Air Tank=Бронзовый воздушный баллон +#compressed air tank made of copper +Copper Air Tank=Медный воздушный баллон +Double Bronze Air Tanks=Двойной бронзовый воздушный баллон +Double Copper Air Tanks=Двойной медный воздушный баллон +Double Steel Air Tanks=Двойной стальной воздушный баллон +#for indicating that a particular type of air tank is empty +Empty @1=Пустой @1 +Fuel=Топливо + +#documentation text +If this item is present in your quick-use inventory then whenever your breath bar goes below 5 it will automatically make use of any air tanks that are present in your quick-use inventory to replenish your breath supply. Note that it will not use air tanks that are present elsewhere in your inventory, only ones in your quick-use bar.=Если этот предмет находится в ячейке быстрого доступа, то когда останется меньше 5 пузырьков воздуха игрок автоматически испоьзует воздушный баллон находящийся в слоте быстрого доступа который заполнит запасы воздуха. Запомните, что автоматически будут использоваться только баллоны находящиеся в слотах быстрого доступа. + +If you're underwater and you're running out of breath, wield this item and use it to replenish 5 bubbles on your breath bar. When fully charged these tanks have @1 uses before it becomes empty.=Если вы находитесь под водой и вы задыхаетесь, наденьте этот предмет и используйте его для восстановления 5 пузырьков. Полностью заполненные баллоны могут быть использованы @1 раз. + +#documentation text +If you're underwater and you're running out of breath, wield this item and use it to replenish 5 bubbles on your breath bar. When fully charged this tank has @1 uses before it becomes empty.=Если вы находитесь под водой и вы задыхаетесь, наденьте этот предмет и используйте его для восстановления 5 пузырьков. Полностью заполненные баллон может быть использован @1 раз. + +Place empty tanks in the inventory to the right. The compressor will start filling the largest capacity tanks first.=Разместите пустые баллоны в инвентаре справа. Компресор автоматически заполнит их воздухом. + +Pressure:@n@1=Давление:@n@1 +#compressed air tank made of steel +Steel Air Tank=Стальной воздушный баллон +Tanks=Баллоны + +These tanks can be recharged with compressed air by using it on a compressor block. When fully charged these tanks have @1 uses before it becomes empty.=Эти баллоны могут быть заполнены сжатым воздухом с помощью компрессора. Полностью запоненные баллоны могут быть использованы @1 раз. + +This machine requires fuel to operate. Place something that can burn in the fuel slot, and then place empty tanks in the inventory to the right. The compressor will start filling the largest capacity tanks first.=Это устройство требует топливо дл работы. Поместите что-то в слот с топливом, а потом положите пустые баллоны в инвентарь справа. Компрессор заполнит сперва баллоны с самм большим объемом. + +This tank can be recharged with compressed air by using it on a compressor block. When fully charged these tanks have @1 uses before it becomes empty.=Этот баллон может быть заполнен сжатым воздухом с помощью компрессора. Полностью заполненный баллон может быть использован @1 раз. + +#documentation text +This tank can be recharged with compressed air by using it on a compressor block. When fully charged this tank has @1 uses before it becomes empty.=Этот баллон может быть заполнен с помощью компрессора. Полностью заполненный баллон может быть использован @1 раз. + +Triple Bronze Air Tanks=Тройной бронзовый баллон +Triple Copper Air Tanks=Тройной медный баллон +Triple Steel Air Tanks=Тройной стальной баллон From f88520a24d09b16372eb4fde1e24126bb06726ad Mon Sep 17 00:00:00 2001 From: "Github is a non-free platform owned by Microsoft. Reasonable alternatives exist, such as Gitea, Sourcehut. We need a federated, mastodon-like forge based on ForgeFed. See: https://forgefed.org" Date: Tue, 25 Mar 2025 21:58:33 +0100 Subject: [PATCH 08/10] Fix duplicate in Mineclonia on_place (#11) An itemstack must be returned to not duplicate the item. --- init.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/init.lua b/init.lua index 775dcd7..17d16c6 100644 --- a/init.lua +++ b/init.lua @@ -268,11 +268,11 @@ local function register_air_tank_3(name, desc, color, uses, material) _mcl_armor_texture = "airtanks_chestplate_tank_three.png", on_place = function(itemstack, user, pointed_thing) - if has_mcl_armor then - mcl_armor.equip_on_use(itemstack, user, pointed_thing) - else - return use_airtank(itemstack, user) - end + if has_mcl_armor then + return mcl_armor.equip_on_use(itemstack, user, pointed_thing) + else + return use_airtank(itemstack, user) + end end, on_secondary_use = has_mcl_armor and mcl_armor.equip_on_use, From 15f64201b6ab2c362937341dcd9fd26ca6c66f23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20Eng=C3=A9libert?= Date: Sun, 15 Jun 2025 18:16:20 +0200 Subject: [PATCH 09/10] Keep only steel tanks --- init.lua | 21 +-------------------- locale/template.txt | 8 -------- locale/translate.ru.tr | 7 ------- settingtypes.txt | 4 +--- 4 files changed, 2 insertions(+), 38 deletions(-) diff --git a/init.lua b/init.lua index 17d16c6..dafddcf 100644 --- a/init.lua +++ b/init.lua @@ -27,20 +27,14 @@ end -- Single tanks setting("int", "steel_uses", 20, "Number of uses for a steel air tank") -setting("int", "copper_uses", 10, "Number of uses for a copper air tank") -setting("int", "bronze_uses", config.steel_uses + config.copper_uses, "Number of uses for a bronze air tank") -- Double tanks setting("bool", "enable_double", true, "Enable double tanks") setting("int", "steel_2_uses", config.steel_uses * 2, "Number of uses for a pair of steel air tanks") -setting("int", "copper_2_uses", config.copper_uses * 2, "Number of uses for a pair of copper air tanks") -setting("int", "bronze_2_uses", config.bronze_uses * 2, "Number of uses for a pair of bronze air tanks") -- Triple tanks setting("bool", "enable_triple", true, "Enable triple tanks") setting("int", "steel_3_uses", config.steel_uses * 3, "Number of uses for three steel air tanks") -setting("int", "copper_3_uses", config.copper_uses * 3, "Number of uses for threee copper air tanks") -setting("int", "bronze_3_uses", config.bronze_uses * 3, "Number of uses for three bronze air tanks") setting("bool", "wear_in_creative", true, "Air tanks wear out in creative mode") @@ -48,8 +42,6 @@ setting("bool", "compressor_needs_fuel", true, "Compressor needs fuel") -- these may come from default or from mineclone mods local steel_ingot -local copper_ingot -local bronze_ingot local mese_crystal_fragment local get_itemslot_bg = function(x, y, w, h) return "" end local get_hotbar_bg = function(x, y) return "" end @@ -57,8 +49,6 @@ local sounds if minetest.get_modpath("default") then steel_ingot = "default:steel_ingot" - copper_ingot = "default:copper_ingot" - bronze_ingot = "default:bronze_ingot" mese_crystal_fragment = "default:mese_crystal_fragment" get_hotbar_bg = default.get_hotbar_bg sounds = default.node_sound_metal_defaults() @@ -75,9 +65,6 @@ end if minetest.get_modpath("mcl_sounds") then sounds = mcl_sounds.node_sound_metal_defaults() end -if minetest.get_modpath("mcl_copper") then - copper_ingot = "mcl_copper:copper_ingot" -end local compressor_desc = S("A machine for filling air tanks with compressed air.") local compressor_help @@ -96,7 +83,7 @@ end local cardinal_dirs = {{x=1,y=0,z=0},{x=-1,y=0,z=0},{x=0,y=1,z=0},{x=0,y=-1,z=0},{x=0,y=0,z=1},{x=0,y=0,z=-1},} -- For compressor code use later on -local max_uses = math.max(config.steel_uses, config.copper_uses, config.bronze_uses) +local max_uses = math.max(config.steel_uses) if config.enable_triple then max_uses = max_uses * 3 elseif config.enable_double then @@ -316,19 +303,13 @@ local function register_air_tank_3(name, desc, color, uses, material) end register_air_tank("steel", S("Steel Air Tank"), "#d6d6d6", config.steel_uses, steel_ingot) -register_air_tank("copper", S("Copper Air Tank"), "#cd8e54", config.copper_uses, copper_ingot) -register_air_tank("bronze", S("Bronze Air Tank"), "#c87010", config.bronze_uses, bronze_ingot) if config.enable_double then register_air_tank_2("steel", S("Double Steel Air Tanks"), "#d6d6d6", config.steel_2_uses, steel_ingot) - register_air_tank_2("copper", S("Double Copper Air Tanks"), "#cd8e54", config.copper_2_uses, copper_ingot) - register_air_tank_2("bronze", S("Double Bronze Air Tanks"), "#c87010", config.bronze_2_uses, bronze_ingot) end if config.enable_triple then register_air_tank_3("steel", S("Triple Steel Air Tanks"), "#d6d6d6", config.steel_3_uses, steel_ingot) - register_air_tank_3("copper", S("Triple Copper Air Tanks"), "#cd8e54", config.copper_3_uses, copper_ingot) - register_air_tank_3("bronze", S("Triple Bronze Air Tanks"), "#c87010", config.bronze_3_uses, bronze_ingot) end --------------------------------------------------------------------------------------------------------- diff --git a/locale/template.txt b/locale/template.txt index 8795c13..e176567 100644 --- a/locale/template.txt +++ b/locale/template.txt @@ -20,12 +20,6 @@ A tank containing compressed air.= Air Compressor= #item name, a snorkel mouthpiece for breathing underwater Breathing Tube= -#compressed air tank made of bronze -Bronze Air Tank= -#compressed air tank made of copper -Copper Air Tank= -Double Bronze Air Tanks= -Double Copper Air Tanks= Double Steel Air Tanks= #for indicating that a particular type of air tank is empty Empty @1= @@ -55,6 +49,4 @@ This tank can be recharged with compressed air by using it on a compressor block #documentation text This tank can be recharged with compressed air by using it on a compressor block. When fully charged this tank has @1 uses before it becomes empty.= -Triple Bronze Air Tanks= -Triple Copper Air Tanks= Triple Steel Air Tanks= diff --git a/locale/translate.ru.tr b/locale/translate.ru.tr index 1a45e9f..a92742c 100644 --- a/locale/translate.ru.tr +++ b/locale/translate.ru.tr @@ -21,11 +21,6 @@ Air Compressor=Воздушный компрессор #item name, a snorkel mouthpiece for breathing underwater Breathing Tube=Дыхательная трубка #compressed air tank made of bronze -Bronze Air Tank=Бронзовый воздушный баллон -#compressed air tank made of copper -Copper Air Tank=Медный воздушный баллон -Double Bronze Air Tanks=Двойной бронзовый воздушный баллон -Double Copper Air Tanks=Двойной медный воздушный баллон Double Steel Air Tanks=Двойной стальной воздушный баллон #for indicating that a particular type of air tank is empty Empty @1=Пустой @1 @@ -55,6 +50,4 @@ This tank can be recharged with compressed air by using it on a compressor block #documentation text This tank can be recharged with compressed air by using it on a compressor block. When fully charged this tank has @1 uses before it becomes empty.=Этот баллон может быть заполнен с помощью компрессора. Полностью заполненный баллон может быть использован @1 раз. -Triple Bronze Air Tanks=Тройной бронзовый баллон -Triple Copper Air Tanks=Тройной медный баллон Triple Steel Air Tanks=Тройной стальной баллон diff --git a/settingtypes.txt b/settingtypes.txt index d973ad4..4163d5c 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -1,7 +1,5 @@ airtanks_steel_uses (Number of uses for a steel air tank) int 30 2 1000 -airtanks_copper_uses (Number of uses for a copper air tank) int 10 2 1000 -airtanks_bronze_uses (Number of uses for a bronze air tank) int 20 2 1000 airtanks_wear_in_creative (Air tanks wear out in creative mode) bool true airtanks_enable_double (Enable double tanks) bool true airtanks_enable_triple (Enable triple tanks) bool true -airtanks_compressor_needs_fuel (Compressor requires fuel) bool true \ No newline at end of file +airtanks_compressor_needs_fuel (Compressor requires fuel) bool true From a47d4c9040add7e059b8bd0607b6e74afb0f10e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20Eng=C3=A9libert?= Date: Sun, 15 Jun 2025 18:49:49 +0200 Subject: [PATCH 10/10] Change recipes --- init.lua | 31 +++++++++++++++++++------------ mod.conf | 4 ++-- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/init.lua b/init.lua index dafddcf..4fdcce6 100644 --- a/init.lua +++ b/init.lua @@ -48,7 +48,7 @@ local get_hotbar_bg = function(x, y) return "" end local sounds if minetest.get_modpath("default") then - steel_ingot = "default:steel_ingot" + steel_ingot = "technic:stainless_steel_ingot" mese_crystal_fragment = "default:mese_crystal_fragment" get_hotbar_bg = default.get_hotbar_bg sounds = default.node_sound_metal_defaults() @@ -156,12 +156,11 @@ local function register_air_tank(name, desc, color, uses, material) minetest.register_craft({ recipe = { - {"", material, ""}, - {material, "airtanks:compressor", material}, + {material, "technic:rubber", material}, + {material, "default:mese_crystal_fragment", material}, {"", material, ""}, }, output = "airtanks:empty_"..name.."_tank", - replacements = {{"airtanks:compressor", "airtanks:compressor"}}, }) end @@ -212,6 +211,7 @@ local function register_air_tank_2(name, desc, color, uses, material) minetest.register_craft({ recipe = { -- Use 2 singles to make a double + {"technic:rubber", "pipeworks:pipe_1_empty"}, {"airtanks:empty_"..name.."_tank", "airtanks:empty_"..name.."_tank"}, }, output = "airtanks:empty_"..name.."_tank_2", @@ -220,6 +220,7 @@ local function register_air_tank_2(name, desc, color, uses, material) minetest.register_craft({ recipe = { -- Use 2 singles to make a double + {"technic:rubber", "pipeworks:pipe_1_empty"}, {"airtanks:"..name.."_tank", "airtanks:"..name.."_tank"}, }, output = "airtanks:"..name.."_tank_2", @@ -273,6 +274,8 @@ local function register_air_tank_3(name, desc, color, uses, material) minetest.register_craft({ recipe = { -- Use 3 singles to make a triple + {"", "pipeworks:pipe_1_empty", ""}, + {"technic:rubber", "pipeworks:pipe_1_empty", "technic:rubber"}, {"airtanks:empty_"..name.."_tank", "airtanks:empty_"..name.."_tank", "airtanks:empty_"..name.."_tank"}, }, output = "airtanks:empty_"..name.."_tank_3", @@ -280,7 +283,8 @@ local function register_air_tank_3(name, desc, color, uses, material) minetest.register_craft({ recipe = { -- Use 1 single and 1 double to make a triple - {"airtanks:empty_"..name.."_tank", "airtanks:empty_"..name.."_tank_2", ""}, + {"technic:rubber", "pipeworks:pipe_1_empty"}, + {"airtanks:empty_"..name.."_tank", "airtanks:empty_"..name.."_tank_2"}, }, output = "airtanks:empty_"..name.."_tank_3", }) @@ -288,6 +292,8 @@ local function register_air_tank_3(name, desc, color, uses, material) minetest.register_craft({ recipe = { -- Use 3 singles to make a triple + {"", "pipeworks:pipe_1_empty", ""}, + {"technic:rubber", "pipeworks:pipe_1_empty", "technic:rubber"}, {"airtanks:"..name.."_tank", "airtanks:"..name.."_tank", "airtanks:"..name.."_tank"}, }, output = "airtanks:"..name.."_tank_3", @@ -295,7 +301,8 @@ local function register_air_tank_3(name, desc, color, uses, material) minetest.register_craft({ recipe = { -- Use 1 single and 1 double to make a triple - {"airtanks:"..name.."_tank", "airtanks:"..name.."_tank_2", ""}, + {"technic:rubber", "pipeworks:pipe_1_empty"}, + {"airtanks:"..name.."_tank", "airtanks:"..name.."_tank_2"}, }, output = "airtanks:"..name.."_tank_3", }) @@ -587,9 +594,9 @@ minetest.register_node("airtanks:compressor", { minetest.register_craft({ recipe = { - {"", steel_ingot, ""}, - {steel_ingot, mese_crystal_fragment, steel_ingot}, - {"group:wood", steel_ingot, "group:wood"}, + {"technic:rubber", mese_crystal_fragment, "technic:rubber"}, + {steel_ingot, "technic:machine_casing", steel_ingot}, + {"basic_materials:gear_steel", steel_ingot, "mesecons_pistons:piston_normal_off"}, }, output = "airtanks:compressor" }) @@ -614,9 +621,9 @@ minetest.register_craftitem("airtanks:breathing_tube", { minetest.register_craft({ recipe = { - {"", "group:stick", ""}, - {"", "group:stick", ""}, - {"group:wood", "group:stick", ""}, + {"", "pipeworks:pipe_1_empty", ""}, + {"", "pipeworks:pipe_1_empty", ""}, + {"technic:rubber", "", ""}, }, output = "airtanks:breathing_tube" }) diff --git a/mod.conf b/mod.conf index 7dfb028..afad9c1 100644 --- a/mod.conf +++ b/mod.conf @@ -1,4 +1,4 @@ name = airtanks description = Provides pressurized air tanks for extended underwater excursions -depends = -optional_depends = doc, default, mcl_formspec, mcl_sounds, mcl_core, mcl_copper, mcl_armor \ No newline at end of file +depends = technic, basic_materials, mesecons_pistons, pipeworks +optional_depends = doc, default, mcl_formspec, mcl_sounds, mcl_core, mcl_copper, mcl_armor