Created
August 10, 2015 03:29
-
-
Save Tzeentchful/58c857f3eb9bee0d2012 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Push2dArrayToLUA(lua_State* _Env, int _array[9][9]) | |
{ | |
lua_createtable(_Env, 9, 0); | |
for (int t = 1; t < 10; ++t) | |
{ | |
// Puts key of the first child table on-top of Lua stack | |
lua_pushnumber(_Env, t); | |
// Creates child table | |
lua_createtable(_Env, 0, 9); | |
for (int i = 1; i < 10; ++i) | |
{ | |
// Fills the child table from the array | |
lua_pushinteger(_Env, _array[t - 1][i - 1]); | |
lua_rawseti(_Env, -2, i); | |
} | |
// Push child table into the root table with the key | |
lua_settable(_Env, -3); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment