Add 'airtanks' mod
parent
464156cc07
commit
322de32889
|
@ -68,6 +68,8 @@ The game includes the mods from the default [minetest_game](https://github.com/m
|
|||
* [painting][] (???)
|
||||
* [pipeworks][] ([WTFPL](mods/pipeworks/LICENSE))
|
||||
* plantlife/
|
||||
* player/
|
||||
* [airtanks][] ([MIT][lic.airtanks]) -- version: [fc01ffb Git][ver.airtanks] *2017-04-01*
|
||||
* player_action/
|
||||
* [throwing][] ([WTFPL][lic.throwing]) -- version: [0.14-79ad788 Git][ver.throwing] *2012-02-10*
|
||||
* player_visuals/
|
||||
|
@ -197,6 +199,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
|
|||
|
||||
|
||||
[3d_armor]: https://forum.minetest.net/viewtopic.php?t=4654
|
||||
[airtanks]: https://forum.minetest.net/viewtopic.php?t=17102
|
||||
[ambience_ultralite]: https://forum.minetest.net/viewtopic.php?p=151166#p151166
|
||||
[animals_modpack]: https://forum.minetest.net/viewtopic.php?t=629
|
||||
[antum]: https://github.com/AntumDeluge/mtmp-antum
|
||||
|
@ -291,6 +294,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
|
|||
[worldedge]: https://forum.minetest.net/viewtopic.php?t=10753
|
||||
|
||||
[lic.3d_armor]: mods/mp_3d_armor/LICENSE.md
|
||||
[lic.airtanks]: mods/player/airtanks/LICENSE.txt
|
||||
[lic.ambience_ultralite.1]: https://forum.minetest.net/viewtopic.php?t=2807
|
||||
[lic.ambience_ultralite.2]: mods/sound/ambience/sounds/SoundLicenses.txt
|
||||
[lic.amp_adv_spawning]: mods/spawning/adv_spawning/README.txt
|
||||
|
@ -358,6 +362,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
|
|||
|
||||
[ver.3d_armor]: https://github.com/stujones11/minetest-3d_armor/tree/793c748
|
||||
[ver.adv_spawning]: https://github.com/sapier/adv_spawning/tree/ec41aa9
|
||||
[ver.airtanks]: https://github.com/minetest-mods/airtanks/tree/fc01ffb
|
||||
[ver.antum]: https://github.com/AntumDeluge/mtmp-antum/tree/4477d40
|
||||
[ver.areas]: https://github.com/ShadowNinja/areas/tree/6080ff0
|
||||
[ver.awards]: https://github.com/minetest-mods/awards/tree/096fe16
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
Sounds are under various licenses, see the license.txt file in the /sounds directory for details.
|
||||
|
||||
License for Code and Textures
|
||||
-----------------------------
|
||||
|
||||
Copyright 2017 by FaceDeer
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
|
@ -0,0 +1,3 @@
|
|||
default
|
||||
doc?
|
||||
intllib?
|
|
@ -0,0 +1,257 @@
|
|||
-- internationalization boilerplate
|
||||
local MP = minetest.get_modpath(minetest.get_current_modname())
|
||||
local S, NS = dofile(MP.."/intllib.lua")
|
||||
|
||||
local print_settingtypes = false
|
||||
local CONFIG_FILE_PREFIX = "airtanks_"
|
||||
local config = {}
|
||||
|
||||
local function setting(stype, name, default, description)
|
||||
local value
|
||||
if stype == "bool" then
|
||||
value = minetest.setting_getbool(CONFIG_FILE_PREFIX..name)
|
||||
elseif stype == "string" then
|
||||
value = minetest.setting_get(CONFIG_FILE_PREFIX..name)
|
||||
elseif stype == "int" or stype == "float" then
|
||||
value = tonumber(minetest.setting_get(CONFIG_FILE_PREFIX..name))
|
||||
end
|
||||
if value == nil then
|
||||
value = default
|
||||
end
|
||||
config[name] = value
|
||||
|
||||
if print_settingtypes then
|
||||
minetest.debug(CONFIG_FILE_PREFIX..name.." ("..description..") "..stype.." "..tostring(default))
|
||||
end
|
||||
end
|
||||
|
||||
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")
|
||||
setting("bool", "wear_in_creative", true, "Air tanks wear out in creative mode")
|
||||
|
||||
local full_tank_desc = S("A tank containing compressed air.")
|
||||
local full_tank_help = 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 %i uses before it becomes empty.")
|
||||
|
||||
local empty_tank_desc = S("A compressed air tank, currently empty.")
|
||||
local empty_tank_help = S("This tank can be recharged with compressed air by using it on a compressor block. When fully charged this tank has %i uses before it becomes empty.")
|
||||
|
||||
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 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()
|
||||
local leftover = inv:add_item("main", full_item)
|
||||
if leftover:get_count() == 0 then
|
||||
itemstack:set_count(itemstack:get_count()-1)
|
||||
end
|
||||
end
|
||||
minetest.sound_play("airtanks_compressor", {pos = pointed_thing.under, gain = 0.5})
|
||||
end
|
||||
return itemstack
|
||||
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 breath = user:get_breath()
|
||||
if breath > 9 then return itemstack end
|
||||
breath = math.min(10, breath+5)
|
||||
user:set_breath(breath)
|
||||
minetest.sound_play("airtanks_hiss", {pos = user:getpos(), gain = 0.5})
|
||||
|
||||
if (not minetest.setting_getbool("creative_mode")) or config.wear_in_creative then
|
||||
local wdef = itemstack:get_definition()
|
||||
itemstack:add_wear(65535/(wdef._airtank_uses-1))
|
||||
if itemstack:get_count() == 0 then
|
||||
if wdef.sound and wdef.sound.breaks then
|
||||
minetest.sound_play(wdef.sound.breaks,
|
||||
{pos = user:getpos(), gain = 0.5})
|
||||
end
|
||||
local inv = user:get_inventory()
|
||||
itemstack = inv:add_item("main", wdef._airtank_empty)
|
||||
end
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
|
||||
local function register_air_tank(name, desc, color, uses, material)
|
||||
minetest.register_craftitem("airtanks:empty_"..name.."_tank", {
|
||||
description = S("Empty @1", desc),
|
||||
_doc_items_longdesc = empty_tank_desc,
|
||||
_doc_items_usagehelp = string.format(empty_tank_help, uses),
|
||||
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 = full_tank_desc,
|
||||
_doc_items_usagehelp = string.format(full_tank_help, uses),
|
||||
_airtank_uses = uses,
|
||||
_airtank_empty = "airtanks:empty_"..name.."_tank",
|
||||
groups = {not_repaired_by_anvil = 1, airtank = 1},
|
||||
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")
|
||||
end,
|
||||
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
return use_airtank(itemstack, user, pointed_thing, "airtanks:"..name.."_tank", "airtanks:empty_"..name.."_tank")
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
recipe = {
|
||||
{"", material, ""},
|
||||
{material, "", material},
|
||||
{"", material, ""},
|
||||
},
|
||||
output = "airtanks:empty_"..name.."_tank"
|
||||
})
|
||||
|
||||
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")
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- Compressor
|
||||
|
||||
local sounds
|
||||
if default.node_sound_metal_defaults then -- 0.4.14 doesn't have metal sounds
|
||||
sounds = default.node_sound_metal_defaults()
|
||||
else
|
||||
sounds = default.node_sound_stone_defaults()
|
||||
end
|
||||
|
||||
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},
|
||||
sounds = sounds,
|
||||
tiles = {
|
||||
"airtanks_compressor_bottom.png^[transformR90",
|
||||
"airtanks_compressor_bottom.png^[transformR90",
|
||||
"airtanks_compressor.png"
|
||||
},
|
||||
drawtype = "nodebox",
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.25, -0.4375, -0.5, 0.25, 0.0625, 0.5},
|
||||
{-0.3125, -0.5, -0.375, 0.3125, 0.125, 0.375},
|
||||
{-0.125, 0.125, -0.25, 0.125, 0.4375, 0.25},
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
recipe = {
|
||||
{"", "default:steel_ingot", ""},
|
||||
{"default:steel_ingot", "default:mese_crystal_fragment", "default:steel_ingot"},
|
||||
{"group:wood", "default:steel_ingot", "group:wood"},
|
||||
},
|
||||
output = "airtanks:compressor"
|
||||
})
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- breathing tube
|
||||
|
||||
minetest.register_craftitem("airtanks:breathing_tube", {
|
||||
description = S("Breathing Tube"),
|
||||
_doc_items_longdesc = tube_desc,
|
||||
_doc_items_usagehelp = tube_help,
|
||||
inventory_image = "airtanks_breathing_tube.png",
|
||||
wield_image = "airtanks_breathing_tube.png",
|
||||
stack_max = 99,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
recipe = {
|
||||
{"", "group:stick", ""},
|
||||
{"", "group:stick", ""},
|
||||
{"group:wood", "group:stick", ""},
|
||||
},
|
||||
output = "airtanks:breathing_tube"
|
||||
})
|
||||
|
||||
local function tool_active(player, item)
|
||||
local inv = player:get_inventory()
|
||||
local hotbar = player:hud_get_hotbar_itemcount()
|
||||
for i=1, hotbar do
|
||||
if inv:get_stack("main", i):get_name() == item then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function use_any_airtank(player)
|
||||
local inv = player:get_inventory()
|
||||
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
|
||||
itemstack = use_airtank(itemstack, player)
|
||||
inv:set_stack("main", i, itemstack)
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
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 not use_any_airtank(player) then
|
||||
minetest.sound_play("airtanks_gasp", {pos = player:getpos(), gain = 0.5})
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
minetest.register_playerevent(player_event_handler)
|
|
@ -0,0 +1,45 @@
|
|||
|
||||
-- Fallback functions for when `intllib` is not installed.
|
||||
-- Code released under Unlicense <http://unlicense.org>.
|
||||
|
||||
-- Get the latest version of this file at:
|
||||
-- https://raw.githubusercontent.com/minetest-mods/intllib/master/lib/intllib.lua
|
||||
|
||||
local function format(str, ...)
|
||||
local args = { ... }
|
||||
local function repl(escape, open, num, close)
|
||||
if escape == "" then
|
||||
local replacement = tostring(args[tonumber(num)])
|
||||
if open == "" then
|
||||
replacement = replacement..close
|
||||
end
|
||||
return replacement
|
||||
else
|
||||
return "@"..open..num..close
|
||||
end
|
||||
end
|
||||
return (str:gsub("(@?)@(%(?)(%d+)(%)?)", repl))
|
||||
end
|
||||
|
||||
local gettext, ngettext
|
||||
if minetest.get_modpath("intllib") then
|
||||
if intllib.make_gettext_pair then
|
||||
-- New method using gettext.
|
||||
gettext, ngettext = intllib.make_gettext_pair()
|
||||
else
|
||||
-- Old method using text files.
|
||||
gettext = intllib.Getter()
|
||||
end
|
||||
end
|
||||
|
||||
-- Fill in missing functions.
|
||||
|
||||
gettext = gettext or function(msgid, ...)
|
||||
return format(msgid, ...)
|
||||
end
|
||||
|
||||
ngettext = ngettext or function(msgid, msgid_plural, n, ...)
|
||||
return format(n==1 and msgid or msgid_plural, ...)
|
||||
end
|
||||
|
||||
return gettext, ngettext
|
|
@ -0,0 +1 @@
|
|||
name = airtanks
|
|
@ -0,0 +1,9 @@
|
|||
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.
|
||||
|
||||
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.
|
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
|
@ -0,0 +1,4 @@
|
|||
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
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,3 @@
|
|||
airtanks_hiss - from https://www.freesound.org/people/josepharaoh99/sounds/367125/ by josepharaoh99 under the public domain via CC 0
|
||||
airtanks_comressor - from https://www.freesound.org/people/Cell31_Sound_Productions/sounds/376927/ by Cell31_Sound_Productions under CC BY 3.0
|
||||
airtanks_compressor_fail - from https://www.freesound.org/people/Cell31_Sound_Productions/sounds/383020/ by Cell31_Sound_Productions under CC BY 3.0
|
Binary file not shown.
After Width: | Height: | Size: 372 B |
Binary file not shown.
After Width: | Height: | Size: 496 B |
Binary file not shown.
After Width: | Height: | Size: 850 B |
Binary file not shown.
After Width: | Height: | Size: 629 B |
Binary file not shown.
After Width: | Height: | Size: 222 B |
Loading…
Reference in New Issue