forked from mtcontrib/minetest_mana
Add API for Mana regneration
This commit is contained in:
parent
97f1079852
commit
47c4d35baa
13
API.md
13
API.md
@ -43,6 +43,12 @@ If the new maximum would become smaller than the current value,
|
|||||||
the current value will automatically be set to
|
the current value will automatically be set to
|
||||||
the new maximum.
|
the new maximum.
|
||||||
|
|
||||||
|
### `mana.setregen(playername, value)`
|
||||||
|
Sets the mana regeneration per mana tick of the player to `value`.
|
||||||
|
Negative values are not permitted.
|
||||||
|
The length of one “mana tick” is specified as the server-wide setting
|
||||||
|
`mana_default_regen` in seconds.
|
||||||
|
|
||||||
|
|
||||||
### `mana.get(playername)`
|
### `mana.get(playername)`
|
||||||
Returns the current mana of the specified player as number.
|
Returns the current mana of the specified player as number.
|
||||||
@ -52,6 +58,13 @@ Returns the current mana of the specified player as number.
|
|||||||
Returns the current maximum mana of the specified player as number.
|
Returns the current maximum mana of the specified player as number.
|
||||||
|
|
||||||
|
|
||||||
|
### `mana.getregen(playername)`
|
||||||
|
Returns the current mana regneration per mana tick of the specified
|
||||||
|
player as number.
|
||||||
|
The length of one “mana tick” is specified as the server-wide setting
|
||||||
|
`mana_default_regen` in seconds.
|
||||||
|
|
||||||
|
|
||||||
### `mana.add(playername, value)`
|
### `mana.add(playername, value)`
|
||||||
Adds the specified non-negative amount of mana to the player, but only
|
Adds the specified non-negative amount of mana to the player, but only
|
||||||
if the sum would not be greater than the maximum,
|
if the sum would not be greater than the maximum,
|
||||||
|
12
init.lua
12
init.lua
@ -67,6 +67,14 @@ function mana.setmax(playername, value)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function mana.setregen(playername, value)
|
||||||
|
if value < 0 then
|
||||||
|
value = 0
|
||||||
|
minetest.log("info", "[mana] Warning: mana.setregen was called with negative value!")
|
||||||
|
end
|
||||||
|
mana.playerlist[playername].regen = value
|
||||||
|
end
|
||||||
|
|
||||||
function mana.get(playername)
|
function mana.get(playername)
|
||||||
return mana.playerlist[playername].mana
|
return mana.playerlist[playername].mana
|
||||||
end
|
end
|
||||||
@ -75,6 +83,10 @@ function mana.getmax(playername)
|
|||||||
return mana.playerlist[playername].maxmana
|
return mana.playerlist[playername].maxmana
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function mana.getregen(playername)
|
||||||
|
return mana.playerlist[playername].regen
|
||||||
|
end
|
||||||
|
|
||||||
function mana.add_up_to(playername, value)
|
function mana.add_up_to(playername, value)
|
||||||
local t = mana.playerlist[playername]
|
local t = mana.playerlist[playername]
|
||||||
if(t ~= nil and value >= 0) then
|
if(t ~= nil and value >= 0) then
|
||||||
|
Loading…
Reference in New Issue
Block a user