summaryrefslogtreecommitdiff
path: root/src/scripting
diff options
context:
space:
mode:
authorPhilipp Sehmisch <mana@crushnet.org>2011-02-08 18:15:08 +0100
committerPhilipp Sehmisch <mana@crushnet.org>2011-02-08 18:15:08 +0100
commita36fd4479a22281ea6e9d03e434d5dc6768f6c5a (patch)
treecd0a0d19703f155f372283e11bd99366097aacd0 /src/scripting
parent19d140fb6989ada459b0a71ec3bf5647ff93bec2 (diff)
downloadmanaserv-a36fd4479a22281ea6e9d03e434d5dc6768f6c5a.tar.gz
manaserv-a36fd4479a22281ea6e9d03e434d5dc6768f6c5a.tar.bz2
manaserv-a36fd4479a22281ea6e9d03e434d5dc6768f6c5a.tar.xz
manaserv-a36fd4479a22281ea6e9d03e434d5dc6768f6c5a.zip
Implemented LUA binding to get the gender of a character
The function is named mana.chr_get_gender. It returns 0 for male and 1 for female. libmana-constants.lua defines the variables GENDER_MALE and GENDER_FEMALE with these values. Also made the banker NPC refer to the gender of the player character. Reviewed-by: Jaxad0127
Diffstat (limited to 'src/scripting')
-rw-r--r--src/scripting/lua.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp
index 3a615412..92835048 100644
--- a/src/scripting/lua.cpp
+++ b/src/scripting/lua.cpp
@@ -1367,6 +1367,22 @@ static int chr_get_kill_count(lua_State *s)
return 1;
}
+/**
+ * Get the gender of the character
+ * mana.chr_get_gender (character)
+ */
+static int chr_get_gender(lua_State *s)
+{
+ Character *c = getCharacter(s, 1);
+ if (!c)
+ {
+ raiseScriptError(s, "chr_get_gender called for nonexistent character.");
+ return 0;
+ }
+
+ lua_pushinteger(s, c->getGender());
+ return 1;
+}
/**
* Enables a special for a character
@@ -1608,6 +1624,7 @@ LuaScript::LuaScript():
{ "chr_set_hair_color", &chr_set_hair_color },
{ "chr_get_hair_color", &chr_get_hair_color },
{ "chr_get_kill_count", &chr_get_kill_count },
+ { "chr_get_gender", &chr_get_gender },
{ "chr_give_special", &chr_give_special },
{ "chr_has_special", &chr_has_special },
{ "chr_take_special", &chr_take_special },