i think it requires minetest 0.4.7 to work (or some version with player:breath exposed)
make a folder in mods called scuba
make a empty init.lua file and put the code in it
create a folder inside the scuba folder called textures
download and put this image in it:
name the image psi.png
enable the new 'scuba' mod
go diving! - tank recharge is approx 5 minutes - wish it were as simple irl lol
todo: add a fill station, crafting tanks, dive skin, etc
enjoy
DEVELOPERS: yeah, I know the hud stuff isn't finished yet but wow, nice job on the hud y'all - much love to all who are working on it <3 <3 - you have great ideas plizadam! - and the hud_remove(hud_id) works wonderfully!
the code for init.lua:
--scuba v0.0.0 ( requires a minetest version of 4.7 or some version with player:breath exposed )
local a = 100
local t = 0
local zid = -1
local c = "psi.png"
local timer = 0
local function scuba()
local players = minetest.get_connected_players()
if #players == 0 then return end
for i,player in ipairs(players) do
local b = player:get_breath()
if b < 10 then
if zid == -1 then
zid = player:hud_add( {
hud_elem_type = "statbar",
position = {x=0.52,y=0.88},
offset = {x=0, y=0},
name = "scuba air gauge",
text = c,
number = a,
alignment = {x=-1,y=-1},
scale = {x=1, y=1},
} )
else
player:hud_change(zid, "number", a)
end --if
a=a-1
if a > 0 then player:set_breath(9) end
else
if zid ~= -1 then
player:hud_remove(zid)
zid = -1
end --if
t=t+1
if t > 300 then --5 minute recharge
t=0
a=100
--print ("tank recharged")
end --if
end --if
end --for
--print (zid,t)
end --function
minetest.after(3, function()
minetest.register_globalstep(function(dtime)
timer = timer + dtime
if timer < 1 then return end
timer = 0
scuba()
end) --function
end) --function