-
-
Save Salada/7c82fab23cf4d6e8cbf1 to your computer and use it in GitHub Desktop.
workaround example
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
// checkType https://github.com/pangweiwei/slua/blob/master/Assets/Slua/Script/LuaObject_overload.cs#L56-L68 | |
static public bool checkType(IntPtr l, int p, out Vector3[] t) | |
{ | |
if(LuaDLL.luaL_checktype(l, p, LuaTypes.LUA_TTABLE, true) { | |
int n = LuaDLL.lua_rawlen(l, p); | |
t = new Vector3[n]; | |
for (int k = 0; k < n; k++) | |
{ | |
LuaDLL.lua_rawgeti(l, p, k + 1); | |
checkType(l, -1, out t[k]); | |
LuaDLL.lua_pop(l, 1); | |
} | |
} else { | |
return checkType<Vector3[]>(l, p, out t); | |
} | |
} | |
// luaL_checktype https://github.com/pangweiwei/slua/blob/master/Assets/Slua/Script/LuaDLL.cs#L484-L491 | |
public static bool luaL_checktype(IntPtr luaState, int p, LuaTypes t, bool ignoreError=false) { | |
LuaTypes ct = LuaDLL.lua_type(luaState, p); | |
if (ct != t) { | |
if (!ignoreError) throw new Exception(string.Format("arg {0} expect {1}, got {2}", p, lua_typenamestr(luaState, t), lua_typenamestr(luaState, ct))); | |
else return false; | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment