diff --git a/API.md b/API.md index e015471..8ca2357 100644 --- a/API.md +++ b/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 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)` 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. +### `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)` Adds the specified non-negative amount of mana to the player, but only if the sum would not be greater than the maximum, diff --git a/init.lua b/init.lua index a7e3d83..268b665 100644 --- a/init.lua +++ b/init.lua @@ -67,6 +67,14 @@ function mana.setmax(playername, value) 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) return mana.playerlist[playername].mana end @@ -75,6 +83,10 @@ function mana.getmax(playername) return mana.playerlist[playername].maxmana end +function mana.getregen(playername) + return mana.playerlist[playername].regen +end + function mana.add_up_to(playername, value) local t = mana.playerlist[playername] if(t ~= nil and value >= 0) then