diff options
| author | Philipp Sehmisch <tmw@crushnet.org> | 2008-03-15 02:39:52 +0000 |
|---|---|---|
| committer | Philipp Sehmisch <tmw@crushnet.org> | 2008-03-15 02:39:52 +0000 |
| commit | 20cc45b27ecb5264b1e71e99e233b8e4b4aaea50 (patch) | |
| tree | 37a13fdeac32b60bcccea8362ddf26ca53c2428e /src/scripting | |
| parent | 68c0625ee9a3a01090f0bc93612bf84dd71eaa67 (diff) | |
Added pathblocking rules to NPCs, added script bindings to query being positions and created script infrastructure for regularily called script functions. This allows NPCs which wander around automatically.
Diffstat (limited to 'src/scripting')
| -rw-r--r-- | src/scripting/lua.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index 7437af8..3d70661 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -400,6 +400,34 @@ static int LuaBeing_Walk(lua_State *s) } /** + * Function for getting the x-coordinate of the position of a being + */ +static int LuaPosX(lua_State *s) +{ + lua_pushlightuserdata(s, (void *)®istryKey); + lua_gettable(s, LUA_REGISTRYINDEX); + + int x = getBeing(s, 1)->getPosition().x; + lua_pushinteger(s, x); + + return 1; +} + +/** + * Function for getting the y-coordinate of the position of a being + */ +static int LuaPosY(lua_State *s) +{ + lua_pushlightuserdata(s, (void *)®istryKey); + lua_gettable(s, LUA_REGISTRYINDEX); + + int y = getBeing(s, 1)->getPosition().y; + lua_pushinteger(s, y); + + return 1; +} + +/** * Callback for creating a monster on the current map. * tmw.monster_create(int type, int x, int y) */ @@ -524,6 +552,8 @@ LuaScript::LuaScript(): { "chr_set_quest", &LuaChr_SetQuest }, { "monster_create", &LuaMonster_Create }, { "being_walk", &LuaBeing_Walk }, + { "posX", &LuaPosX }, + { "posY", &LuaPosY }, { NULL, NULL } }; luaL_register(mState, "tmw", callbacks); |
