summaryrefslogtreecommitdiff
path: root/src/scripting/lua.cpp
diff options
context:
space:
mode:
authorErik Schilling <ablu.erikschilling@googlemail.com>2012-03-17 20:20:10 +0100
committerErik Schilling <ablu.erikschilling@googlemail.com>2012-03-17 23:40:30 +0100
commit61ac3cbf1e507f103e5fc240958971f512cd8c73 (patch)
tree28fc78e2047a91f9b6131d2f3e62d83c4db23711 /src/scripting/lua.cpp
parenta6c3eed2b9a91e9768ec6ce137879cac13703dea (diff)
downloadmanaserv-61ac3cbf1e507f103e5fc240958971f512cd8c73.tar.gz
manaserv-61ac3cbf1e507f103e5fc240958971f512cd8c73.tar.bz2
manaserv-61ac3cbf1e507f103e5fc240958971f512cd8c73.tar.xz
manaserv-61ac3cbf1e507f103e5fc240958971f512cd8c73.zip
Made skill related function capable of taking the skill name as parameter
Reviewed-by: bjorn.
Diffstat (limited to 'src/scripting/lua.cpp')
-rw-r--r--src/scripting/lua.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp
index 136350da..2d98c713 100644
--- a/src/scripting/lua.cpp
+++ b/src/scripting/lua.cpp
@@ -1019,7 +1019,10 @@ static int being_damage(lua_State *s)
return 0;
}
}
- dmg.skill = luaL_optint(s, 8, 0);
+ if (lua_gettop(s) >= 8)
+ {
+ dmg.skill = checkSkill(s, 8);
+ }
being->damage(source, dmg);
return 0;
@@ -1682,12 +1685,15 @@ static int chr_shake_screen(lua_State *s)
/**
* chr_get_exp(Character*, int skill): int
- * Gets the exp total in a skill of a specific character
+ * chr_get_exp(Character*, string skillname): int
+ * Gets the exp total in a skill of a specific character.
+ * If called with skillname this name has to be in this format:
+ * "<setname>_<skillname>"
*/
static int chr_get_exp(lua_State *s)
{
Character *c = checkCharacter(s, 1);
- const int skill = luaL_checkint(s, 2);
+ int skill = checkSkill(s, 2);
const int exp = c->getExperience(skill);
lua_pushinteger(s, exp);
@@ -1696,14 +1702,17 @@ static int chr_get_exp(lua_State *s)
/**
* chr_give_exp(Character*, int skill, int amount[, int optimal_level]): void
+ * chr_give_exp(Character*, string skillname, int amount
+ * [, int optimal_level]): void
* Gives the character a certain amount of experience points
* in a skill. Can also be used to reduce the exp amount when
- * desired.
+ * desired. If called with skillname this name has to be in this format:
+ * "<setname>_<skillname>"
*/
static int chr_give_exp(lua_State *s)
{
Character *c = checkCharacter(s, 1);
- const int skill = luaL_checkint(s, 2);
+ int skill = checkSkill(s, 2);
const int exp = luaL_checkint(s, 3);
const int optimalLevel = luaL_optint(s, 4, 0);