summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoderic Morris <roderic@ccs.neu.edu>2008-12-31 17:02:24 -0500
committerRoderic Morris <roderic@ccs.neu.edu>2009-02-15 23:24:08 -0500
commit12fa1a338f6360607d3d472de0b0ad97a5ffbcf9 (patch)
treefd0a5fd37547f8b537f9e7b775e58212d53a1453 /src
parentfcdb57d7a41f053b1cad6d154ff42cfcf5915111 (diff)
downloadmanaserv-12fa1a338f6360607d3d472de0b0ad97a5ffbcf9.tar.gz
manaserv-12fa1a338f6360607d3d472de0b0ad97a5ffbcf9.tar.bz2
manaserv-12fa1a338f6360607d3d472de0b0ad97a5ffbcf9.tar.xz
manaserv-12fa1a338f6360607d3d472de0b0ad97a5ffbcf9.zip
add hair style and color getting and setting to lua scripts
Diffstat (limited to 'src')
-rw-r--r--src/scripting/lua.cpp91
1 files changed, 91 insertions, 0 deletions
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp
index 1cfb8766..8dcf69b7 100644
--- a/src/scripting/lua.cpp
+++ b/src/scripting/lua.cpp
@@ -884,6 +884,93 @@ static int chr_give_exp(lua_State *s)
return 0;
}
+/**
+ * Sets the given character's hair style to the given style id
+ * tmw.chr_set_hair_style (character, styleid)
+ */
+static int chr_set_hair_style(lua_State *s)
+{
+ Character *c = getCharacter(s, 1);
+ if (!c)
+ {
+ raiseScriptError(s, "chr_set_hair_style called for nonexistent character.");
+ return 0;
+ }
+
+ int style = lua_tointeger(s, 2);
+ if (style < 0)
+ {
+ raiseScriptError(s, "chr_set_hair_style called for nonexistent style id %d.", style);
+ return 0;
+ }
+
+ c->setHairStyle(style);
+
+ return 0;
+}
+
+/**
+ * Gets the hair style of the given character
+ * tmw.chr_get_hair_style (character)
+ */
+static int chr_get_hair_style(lua_State *s)
+{
+ Character *c = getCharacter(s, 1);
+ if (!c)
+ {
+ raiseScriptError(s, "chr_get_hair_style called for nonexistent character.");
+ return 0;
+ }
+
+ int style = c->getHairStyle();
+
+ lua_pushinteger(s, style);
+ return 1;
+}
+
+/**
+ * Set the hair color of the given character to the given color id
+ * tmw.chr_set_hair_color (character, colorid)
+ */
+static int chr_set_hair_color(lua_State *s)
+{
+ Character *c = getCharacter(s, 1);
+ if (!c)
+ {
+ raiseScriptError(s, "chr_set_hair_color called for nonexistent character.");
+ return 0;
+ }
+
+ int color = lua_tointeger(s, 2);
+ if (color < 0)
+ {
+ raiseScriptError(s, "chr_set_hair_color called for nonexistent style id %d.", color);
+ return 0;
+ }
+
+ c->setHairColor(color);
+
+ return 0;
+}
+
+/**
+ * Get the hair color of the given character
+ * tmw.chr_get_hair_color (character)
+ */
+static int chr_get_hair_color(lua_State *s)
+{
+ Character *c = getCharacter(s, 1);
+ if (!c)
+ {
+ raiseScriptError(s, "chr_get_hair_color called for nonexistent character.");
+ return 0;
+ }
+
+ int color = c->getHairColor();
+
+ lua_pushinteger(s, color);
+ return 1;
+}
/**
* Returns the rights level of a character.
@@ -1044,6 +1131,10 @@ LuaScript::LuaScript():
{ "chr_get_exp", &chr_get_exp },
{ "chr_give_exp", &chr_give_exp },
{ "chr_get_rights", &chr_get_rights },
+ { "chr_set_hair_style", &chr_set_hair_style },
+ { "chr_get_hair_style", &chr_get_hair_style },
+ { "chr_set_hair_color", &chr_set_hair_color },
+ { "chr_get_hair_color", &chr_get_hair_color },
{ "exp_for_level", &exp_for_level },
{ "monster_create", &monster_create },
{ "being_type", &being_type },