public static void SetEnvironment(LuaFuncRef Func, LuaReference Env) { Func.GetRef(); Env.GetRef(); LL.lua_setfenv(L, -2); LL.lua_pop(L, 1); }
public static void SetTable <T>(LuaReference Table, string Name, T Obj) where T : struct { Table.GetRef(); using (LuaReference Tbl = ConvertToTable(Obj)) { Tbl.GetRef(); LL.lua_setfield(L, -2, Name); } }
public static T Get <T>(LuaReference Table, string Name) { int Top = GetTop(); Table.GetRef(); LL.lua_getfield(L, -1, Name); T Val = (T)Advanced.Get(L, 1, typeof(T)); SetTop(Top); return(Val); }
public static void Copy(LuaReference TableFrom, LuaReference TableTo, string FromName, string ToName = null) { if (ToName == null) { ToName = FromName; } TableTo.GetRef(); TableFrom.GetRef(); LL.lua_getfield(L, -1, FromName); LL.lua_setfield(L, -3, ToName); LL.lua_pop(L, 2); }
public static void Set(LuaReference Table, string Name, object Obj) { Table.GetRef(); if (Obj is LuaReference Ref) { Ref.GetRef(); } else { Advanced.Push(L, Obj); } LL.lua_setfield(L, -2, Name); LL.lua_pop(L, 1); }
public static LuaReference CreateNewEnvironment(LuaReference OldEnvironment = null) { if (OldEnvironment != null) { OldEnvironment.GetRef(); CopyTable(); } else { LL.lua_newtable(L); } LuaReference Ref = new LuaReference(L); if (OldEnvironment != null) { LL.lua_pop(L, 1); } return(Ref); }