summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-10-13 18:29:15 -0600
committerJared Adams <jaxad0127@gmail.com>2009-10-13 18:29:15 -0600
commit257b9e19f26ecd29cd86177dd70765517bbc9863 (patch)
tree54e0210230c84fbc63632c58f298843ff84e6403
parent8993816ef862c7a74bcc411d33ac03fc8ae47b05 (diff)
downloadmanaserv-257b9e19f26ecd29cd86177dd70765517bbc9863.tar.gz
manaserv-257b9e19f26ecd29cd86177dd70765517bbc9863.tar.bz2
manaserv-257b9e19f26ecd29cd86177dd70765517bbc9863.tar.xz
manaserv-257b9e19f26ecd29cd86177dd70765517bbc9863.zip
Add script bindings for being directions
-rw-r--r--src/scripting/lua.cpp46
1 files changed, 44 insertions, 2 deletions
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp
index b3f9ce38..62bf3729 100644
--- a/src/scripting/lua.cpp
+++ b/src/scripting/lua.cpp
@@ -705,7 +705,7 @@ static int being_get_name(lua_State *s)
}
/**
- * Gets the being's name
+ * Gets the being's current action
* tmw.being_get_action(being)
*/
static int being_get_action(lua_State *s)
@@ -724,7 +724,7 @@ static int being_get_action(lua_State *s)
}
/**
- * Gets the being's name
+ * Sets the being's current action
* tmw.being_set_action(being, action)
*/
static int being_set_action(lua_State *s)
@@ -745,6 +745,46 @@ static int being_set_action(lua_State *s)
}
/**
+ * Gets the being's current direction
+ * tmw.being_get_direction(being)
+ */
+static int being_get_direction(lua_State *s)
+{
+ lua_pushlightuserdata(s, (void *)&registryKey);
+ lua_gettable(s, LUA_REGISTRYINDEX);
+
+ Being *being = getBeing(s, 1);
+
+ if (being)
+ {
+ lua_pushinteger(s, being->getDirection());
+ }
+
+ return 1;
+}
+
+/**
+ * Sets the being's current direction
+ * tmw.being_set_direction(being, direction)
+ */
+static int being_set_direction(lua_State *s)
+{
+ lua_pushlightuserdata(s, (void *)&registryKey);
+ lua_gettable(s, LUA_REGISTRYINDEX);
+
+ Being *being = getBeing(s, 1);
+
+ int dir = lua_tointeger(s, 2);
+
+ if (being)
+ {
+ being->setDirection(dir);
+ }
+
+ return 1;
+}
+
+/**
* Function for getting the x-coordinate of the position of a being
*/
static int posX(lua_State *s)
@@ -1433,6 +1473,8 @@ LuaScript::LuaScript():
{ "being_get_name", &being_get_name },
{ "being_get_action", &being_get_action },
{ "being_set_action", &being_set_action },
+ { "being_get_direction", &being_get_direction },
+ { "being_set_direction", &being_set_direction },
{ "posX", &posX },
{ "posY", &posY },
{ "trigger_create", &trigger_create },