Modders Resource. Does nothing on its own.
For one of my own mods I wanted to utitilise the stamina bar.
Problem being that unlike hitpoints or breath (which are set by the engine) or mana (which tends to always use the mod under the same name) - the stamina bar tends to re-implemented every time by sprint mods.
Making compatibility patches for each one proves to be a nightmare.
Unified Stamina API acts as an abstracion layer between your mod and whatever sprint mod might be installed.
It provides you with just a single API rather than having to figure out compatibility patches for each one individually.
Just use this as a dependency instead of the sprint mods.
Compatibility Mods like Stamina or Stamina (Fork) don't actually provide a stamina bar (despite the name) but only a hunger bar instead. Thus, they aren't included. If no compatible mod is installed then the API will still work but always return a full stamina bar.
How to use
Code: Select all
-- true if a compatible sprint mod has been found
local is_active = unified_stamina.active
-- get current stamina value of a given player
-- return float between 0 and 1
-- always return 1 if no mod with a stamina bar is present
local stamina_value = unified_stamina.get(player_name)
-- sets the current stamina value of a given player
-- expects normalized value between 0 and 1 (here: 0.4 = 40% of the bar)
local new_value = 0.4
unified_stamina.set(player_name, new_value)
-- changes the current stamina value of a given player by the specified amount
-- expects normalized value between 0 and 1
-- positive values will increase stamina, negative values will decrease it (here: decrease by 20%)
local change = -0.2
unified_stamina.add(player_name, change)
-- returns the scale of the stamina bar for display purposes
-- a return value of e.g. 20 means that a player has a total value of 20 points at 100%
local display_scale = unified_stamina.get_scale()
License: MIT
Links
Download on ContentDB - Source Code on Github