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:14 +0200 |
commit | c943ac8eeb172f19afd602863de9a2e7d7610707 (patch) | |
tree | 197a7ed56032180321a3978d7c91f518cefe0abe /src/scripting | |
parent | 83b30bfb41aa11cbe3fc2b3dff56192c93ecf040 (diff) | |
download | manaserv-c943ac8eeb172f19afd602863de9a2e7d7610707.tar.gz manaserv-c943ac8eeb172f19afd602863de9a2e7d7610707.tar.bz2 manaserv-c943ac8eeb172f19afd602863de9a2e7d7610707.tar.xz manaserv-c943ac8eeb172f19afd602863de9a2e7d7610707.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 4c849180..9e904cc9 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; } |