From 443c635c00c948444c7726e599dde3b64e7bec12 Mon Sep 17 00:00:00 2001 From: FaceDeer Date: Sat, 17 Sep 2022 18:17:08 -0600 Subject: [PATCH] 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