public LuaContext(UiContext context) { uiContext = context; script = new Script(CoreModules.Preset_HardSandbox | CoreModules.Metatables); script.Options.DebugPrint = s => FLLog.Info("Lua", s); script.Globals["HorizontalAlignment"] = UserData.CreateStatic <HorizontalAlignment>(); script.Globals["VerticalAlignment"] = UserData.CreateStatic <VerticalAlignment>(); script.Globals["AnchorKind"] = UserData.CreateStatic <AnchorKind>(); script.Options.ScriptLoader = new UiScriptLoader(context); var globalTable = script.Globals; foreach (var g in script.Globals.Keys) { globalTable[g] = script.Globals[g]; } var typeTable = new Table(script); globalTable["ClrTypes"] = typeTable; typeTable["System_Collections_Generic_List___LibreLancer_Interface_XmlStyle___"] = typeof(List <XmlStyle>); typeTable["System_Collections_Generic_List___LibreLancer_Interface_DisplayElement___"] = typeof(List <DisplayElement>); typeTable["System_Collections_Generic_List___LibreLancer_Interface_UiWidget___"] = typeof(List <UiWidget>); typeTable["System_Collections_Generic_List___LibreLancer_Interface_ListItem___"] = typeof(List <ListItem>); typeTable["System_Collections_Generic_List___LibreLancer_Interface_TableColumn___"] = typeof(List <TableColumn>); foreach (var type in typeof(LuaContext).Assembly.GetTypes()) { if (type.GetCustomAttributes(false).OfType <MoonSharpUserDataAttribute>().Any()) { typeTable[type.FullName.Replace(".", "_")] = type; } } globalTable["Game"] = context.GameApi; //Functions globalTable["Funcs"] = new ContextFunctions(this); script.DoString(DEFAULT_LUA, null, "LuaContext.LuaCode"); }
public LuaContext(UiContext context, Scene scene) { uiContext = context; script.Options.ScriptLoader = new UiScriptLoader(context); globalTable = new Table(script); foreach (var g in script.Globals.Keys) { globalTable[g] = script.Globals[g]; } globalTable["Game"] = context.GameApi; //Functions globalTable["Funcs"] = new ContextFunctions(this); if (Debugger.IsAttached) { script.DoString(DEFAULT_LUA, globalTable, "LuaContext.LuaCode"); } else { RunBytes(script, globalTable, baseCode); } _serialize = globalTable["Serialize"]; _callevent = globalTable["CallEvent"]; }
internal static extern IntPtr Dtls_Create(ContextFunctions contextFunctions);