diff options
author | Robin Gareus <robin@gareus.org> | 2016-05-21 15:43:19 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2016-05-21 15:55:14 +0200 |
commit | 50d6f146f4cd24b7ea4532ec70fae348056acc32 (patch) | |
tree | 4275f27401266678465b66893d85be03d279a217 /libs/lua/LuaBridge/detail/CFunctions.h | |
parent | 53c188beb3de47f903482ac3c7812d756e94508f (diff) |
allow lua to access array at an offset
Diffstat (limited to 'libs/lua/LuaBridge/detail/CFunctions.h')
-rw-r--r-- | libs/lua/LuaBridge/detail/CFunctions.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/libs/lua/LuaBridge/detail/CFunctions.h b/libs/lua/LuaBridge/detail/CFunctions.h index 6f43919216..15bc7022b3 100644 --- a/libs/lua/LuaBridge/detail/CFunctions.h +++ b/libs/lua/LuaBridge/detail/CFunctions.h @@ -969,6 +969,14 @@ struct CFunc return 0; } + // return same array at an offset + template <typename T> + static int offsetArray (lua_State* L) { + T *v = luabridge::Stack<T*>::get (L, 1); + const unsigned int i = luabridge::Stack<unsigned int>::get (L, 2); + Stack <T*>::push (L, &v[i]); + return 1; + } //-------------------------------------------------------------------------- /** |