use staminoid if available

This commit is contained in:
flux 2023-04-08 15:19:43 -07:00
parent cb9a744a1b
commit 5443195296
No known key found for this signature in database
GPG Key ID: 9333B27816848A15
8 changed files with 27 additions and 26 deletions

View File

@ -669,6 +669,7 @@ stds.cottages = {
"player_monoids",
"stairs",
"stamina",
"staminoid",
"unified_inventory",
},
}

View File

@ -21,6 +21,7 @@ player_monoids,
stairs,
stairsplus,
stamina,
staminoid,
technic,
unified_inventory,
wool,

View File

@ -17,9 +17,9 @@ local v_sub = vector.subtract
local get_safe_short_description = cottages.util.get_safe_short_description
local resolve_item = cottages.util.resolve_item
local exhaust_player = cottages.util.exhaust_player
local has_broken_tools = cottages.has.broken_tools
local has_stamina = cottages.has.stamina
local repair_amount = cottages.settings.anvil.repair_amount
local hammer_wear = cottages.settings.anvil.hammer_wear
@ -199,9 +199,7 @@ function anvil.use_anvil(pos, puncher)
update_hud(puncher, tool)
if has_stamina then
stamina.exhaust_player(puncher, stamina_use, "cottages:anvil")
end
exhaust_player(puncher, stamina_use, "cottages:anvil")
else
-- tell the player when the job is done, but only once
if meta:get_int("informed") > 0 then

View File

@ -1,8 +1,10 @@
local S = cottages.S
local exhaust_player = cottages.util.exhaust_player
local api = cottages.doorlike
local stamina_use = cottages.settings.doorlike.stamina
local has_stamina = cottages.has.stamina
-- propagate shutting/closing of window shutters to window shutters below/above this one
local offsets = {
@ -43,16 +45,12 @@ end
function api.shutter_open(pos, puncher)
api.shutter_operate(pos, "cottages:window_shutter_closed", "cottages:window_shutter_open")
if has_stamina then
stamina.exhaust_player(puncher, stamina_use, "cottages:shutter")
end
exhaust_player(puncher, stamina_use, "cottages:shutter")
end
function api.shutter_close(pos, puncher)
api.shutter_operate(pos, "cottages:window_shutter_open", "cottages:window_shutter_closed")
if has_stamina then
stamina.exhaust_player(puncher, stamina_use, "cottages:shutter")
end
exhaust_player(puncher, stamina_use, "cottages:shutter")
end
function api.is_night()
@ -141,9 +139,7 @@ function api.register_hatch(nodename, description, texture, receipe_item, def)
fixed = { -0.5, -0.55, -0.5, 0.5, -0.45, 0.5 },
},
on_rightclick = function(pos, node, puncher)
if has_stamina then
stamina.exhaust_player(puncher, stamina_use, nodename)
end
exhaust_player(puncher, stamina_use, nodename)
minetest.swap_node(pos, { name = node.name, param2 = new_facedirs[node.param2 + 1] })
end,

View File

@ -1,6 +1,6 @@
local S = cottages.S
local has_stamina = cottages.has.stamina
local exhaust_player = cottages.util.exhaust_player
local stamina_use = cottages.settings.pitchfork.stamina
minetest.register_node("cottages:pitchfork", {
@ -91,9 +91,7 @@ local function override_on_dig(node_name, replacement)
minetest.swap_node(pos, { name = replacement })
minetest.swap_node(pos_above, { name = "cottages:hay_mat", param2 = math.random(2, 25) })
if has_stamina then
stamina.exhaust_player(digger, stamina_use, "cottages:pitchfork")
end
exhaust_player(digger, stamina_use, "cottages:pitchfork")
return true
end,

View File

@ -7,8 +7,8 @@ local FS = function(...)
end
local get_safe_short_description = cottages.util.get_safe_short_description
local exhaust_player = cottages.util.exhaust_player
local has_stamina = cottages.has.stamina
local stamina_use = cottages.settings.straw.quern_stamina
local quern_min_per_turn = cottages.settings.straw.quern_min_per_turn
local quern_max_per_turn = cottages.settings.straw.quern_max_per_turn
@ -125,9 +125,7 @@ function straw.use_quern(pos, player)
minetest.sound_play({ name = cottages.sounds.use_quern }, { pos = pos, gain = 1, pitch = 0.25 }, true)
if has_stamina then
stamina.exhaust_player(player, stamina_use, "cottages:quern")
end
exhaust_player(player, stamina_use, "cottages:quern")
return true
end

View File

@ -7,8 +7,8 @@ local FS = function(...)
end
local get_safe_short_description = cottages.util.get_safe_short_description
local exhaust_player = cottages.util.exhaust_player
local has_stamina = cottages.has.stamina
local stamina_use = cottages.settings.straw.threshing_stamina
local threshing_min_per_punch = cottages.settings.straw.threshing_min_per_punch
local threshing_max_per_punch = cottages.settings.straw.threshing_max_per_punch
@ -166,9 +166,7 @@ function straw.use_threshing(pos, player)
minetest.sound_play({ name = cottages.sounds.use_thresher }, { pos = particle_pos, gain = 1, pitch = 0.5 }, true)
if has_stamina then
stamina.exhaust_player(player, stamina_use, "cottages:quern")
end
exhaust_player(player, stamina_use, "cottages:threshing")
return true
end

View File

@ -314,4 +314,15 @@ else
end
end
local has_stamina = cottages.has.stamina
local has_staminoid = cottages.has.staminoid
function util.exhaust_player(player, amount, reason)
if has_stamina then
stamina.exhaust_player(player, amount, reason)
elseif has_staminoid then
staminoid.exhaust(player, 1, reason)
end
end
cottages.util = util