Add a use for dry sponges
Dry sponges act as air tanks while diving, but the effect is limited by their tendency to soak up water from the environment.
This commit is contained in:
parent
f4cdda972c
commit
9995d9bfc8
@ -17,6 +17,7 @@ local breath_mask = "^[mask:nc_player_hud_breath_mask.png\\^[resize\\:" .. w ..
|
||||
|
||||
nodecore.register_playerstep({
|
||||
label = "breath hud",
|
||||
priority = -1000,
|
||||
action = function(player)
|
||||
local br = player:get_breath()
|
||||
nodecore.player_discover(player, "breath_" .. br)
|
||||
|
31
mods/nc_sponge/diving.lua
Normal file
31
mods/nc_sponge/diving.lua
Normal file
@ -0,0 +1,31 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local minetest, nodecore
|
||||
= minetest, nodecore
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
|
||||
nodecore.register_playerstep({
|
||||
label = "sponge diving breath",
|
||||
action = function(player, data)
|
||||
local breath = player:get_breath()
|
||||
|
||||
if breath > 0 then
|
||||
local old = data.spongebreath or data.properties.breath_max
|
||||
data.spongebreath = breath
|
||||
if breath >= old then return end
|
||||
end
|
||||
|
||||
local inv = player:get_inventory()
|
||||
for i = 1, inv:get_size("main") do
|
||||
if inv:get_stack("main", i):get_name() == modname .. ":sponge" then
|
||||
local nb = breath + 2
|
||||
if nb > data.properties.breath_max then
|
||||
nb = data.properties.breath_max
|
||||
end
|
||||
data.spongebreath = nb
|
||||
return player:set_breath(nb)
|
||||
end
|
||||
end
|
||||
end
|
||||
})
|
@ -10,4 +10,5 @@ include("abm")
|
||||
include("gen")
|
||||
include("cultivate")
|
||||
include("squeeze")
|
||||
include("diving")
|
||||
include("hints")
|
||||
|
Loading…
x
Reference in New Issue
Block a user