diff options
author | Erik Schilling <ablu.erikschilling@googlemail.com> | 2012-07-17 12:07:54 +0200 |
---|---|---|
committer | Erik Schilling <ablu.erikschilling@googlemail.com> | 2012-07-17 13:05:43 +0200 |
commit | 55e227f90e86a960e111a286bd70d49578eb838b (patch) | |
tree | 5c43c7f6b1a01a4982ce7ea07062ed707edf669d /src/scripting | |
parent | 66f1696f101c39f7e3f01641e562c0c5c8eac77f (diff) | |
download | manaserv-55e227f90e86a960e111a286bd70d49578eb838b.tar.gz manaserv-55e227f90e86a960e111a286bd70d49578eb838b.tar.bz2 manaserv-55e227f90e86a960e111a286bd70d49578eb838b.tar.xz manaserv-55e227f90e86a960e111a286bd70d49578eb838b.zip |
Made chr_get_level capable of retrieving skill levels
Reviewed-by: bjorn.
Diffstat (limited to 'src/scripting')
-rw-r--r-- | src/scripting/lua.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index ad4806c9..a6b26e92 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -714,13 +714,22 @@ static int chr_unequip_item(lua_State *s) } /** - * chr_get_level(Character*): int level - * Tells the character current level. + * chr_get_level(Character* [, skill]): int level + * Tells the character current level. If a skill is passed as 2nd argument it + * will return the skill level. */ static int chr_get_level(lua_State *s) { Character *ch = checkCharacter(s, 1); - lua_pushinteger(s, ch->getLevel()); + if (lua_gettop(s) > 1) + { + int skillId = checkSkill(s, 2); + lua_pushinteger(s, ch->levelForExp(ch->getExperience(skillId))); + } + else + { + lua_pushinteger(s, ch->getLevel()); + } return 1; } |