diff options
author | Bardur Arantsson <bardur@scientician.net> | 2012-06-11 20:43:12 +0200 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2012-06-19 18:36:20 +0200 |
commit | f71485a5448f1e978101f9033f34875a96c88880 (patch) | |
tree | a8907bb003d49659b1dbbe53c981a2aa93366552 | |
parent | b9894d348db43cacb2807c325fb48d8d46e84985 (diff) |
Lua: Move increase_mana() to C
-rw-r--r-- | lib/core/player.lua | 15 | ||||
-rw-r--r-- | lib/mods/theme/core/player.lua | 15 | ||||
-rw-r--r-- | src/lua_bind.c | 14 |
3 files changed, 11 insertions, 33 deletions
diff --git a/lib/core/player.lua b/lib/core/player.lua index f5c7c13b..65406de2 100644 --- a/lib/core/player.lua +++ b/lib/core/player.lua @@ -30,21 +30,6 @@ function player.inventory(i) return player.inventory_real[i + 1] end --- modify mana --- returns TRUE if there is a pb -function increase_mana(amt) - player.csp = player.csp + amt - player.redraw = bor(player.redraw, PR_MANA) - if (player.csp < 0) then - player.csp = 0 - return TRUE - end - if (player.csp > player.msp) then - player.csp = player.msp - end - return FALSE -end - -- Return the coordinates of the player whether in wild or not function player.get_wild_coord() diff --git a/lib/mods/theme/core/player.lua b/lib/mods/theme/core/player.lua index f5c7c13b..65406de2 100644 --- a/lib/mods/theme/core/player.lua +++ b/lib/mods/theme/core/player.lua @@ -30,21 +30,6 @@ function player.inventory(i) return player.inventory_real[i + 1] end --- modify mana --- returns TRUE if there is a pb -function increase_mana(amt) - player.csp = player.csp + amt - player.redraw = bor(player.redraw, PR_MANA) - if (player.csp < 0) then - player.csp = 0 - return TRUE - end - if (player.csp > player.msp) then - player.csp = player.msp - end - return FALSE -end - -- Return the coordinates of the player whether in wild or not function player.get_wild_coord() diff --git a/src/lua_bind.c b/src/lua_bind.c index 4ae8ed80..0f41f9dc 100644 --- a/src/lua_bind.c +++ b/src/lua_bind.c @@ -483,9 +483,17 @@ int get_lua_list_size(cptr list_var) void increase_mana(int delta) { - char buf[256]; - sprintf(buf, "increase_mana(%d)", delta); - exec_lua(buf); + p_ptr->csp += delta; + p_ptr->redraw |= PR_MANA; + + if (p_ptr->csp < 0) + { + p_ptr->csp = 0; + } + if (p_ptr->csp > p_ptr->msp) + { + p_ptr->csp = p_ptr->msp; + } } timer_type *TIMER_AGGRAVATE_EVIL = 0; |