static public void StartInitFlow() { BubConsole.CSay("Looking for Init script!"); var mainfile = ""; foreach (string e in SBubble.ResFiles) { var ce = e.ToUpper(); if (ce == "INIT.LUA" || qstr.Suffixed(ce, "/INIT.LUA") || ce == "INIT.NIL" || qstr.Suffixed(ce, "/INIT.NIL")) { mainfile = e; } } if (mainfile == "") { Error.GoError("Startup error", "INIT.LUA or INIT.NIL required somewhere in any folder.", "None have been found"); } else { //mainfile = "Script/Viezelul.lua"; GoHardFlow(BubConsole.Flow); try { BubConsole.WriteLine($"Loading Init Script: {mainfile}"); SBubble.NewState("$INIT", mainfile); //SBubble.State("$INIT").state.DoString("local fc = ''\nfor k,v in pairs(_G) do\n fc=fc .. type(v) .. ' ' ..k..'\\n'\n end\n error(fc)"); // debug line SBubble.State("$INIT").state.DoString("assert(type(Bubble_Init)=='function','Function expected for Bubble_Init, got '..type(Bubble_Init))\nBubble_Init()"); } catch (Exception e) { Error.GoError("Init Error", e.Message, ""); } } }
public void LoadFlow(string flow, string file) { flow = flow.ToUpper(); if (!qstr.Prefixed(flow, "FLOW_")) { flow = $"FLOW_{flow}"; } SBubble.NewState(flow, file); BubConsole.WriteLine($"Created new flow: {flow}"); SBubble.State(flow).state.DoString("if BUB_Load then BUB_Load() end"); }
static void InitSwap() { if (SwapMap == null) { if (SwapFolderSet == "") { SwapFolderSet = "Swap"; } var ADir = $"{Bubble_Save.SWorkDir}/{SwapFolderSet}"; BubConsole.WriteLine($"Swap system initialized to folder: {ADir}"); SwapMap = new Swap(ADir); } }
public void GoToFlow(string flow) { flow = flow.ToUpper(); if (!qstr.Prefixed(flow, "FLOW_")) { flow = $"FLOW_{flow}"; } if (!SBubble.HaveState(flow)) { SBubble.MyError("Flow Management Error", $"GoToFlow: Flow {flow} doesn't exist!", SBubble.TraceLua(State)); } else { FlowManager.CurrentFlow = flow; BubConsole.WriteLine($"Flow set to: {flow}"); SBubble.State(flow).DoString("if BUB_Arrive then assert(type(BUB_Arrive)=='function','BUB_Arrive must be a function but it is a '..type(BUB_Arrive)) BUB_Arrive() end"); } }
static public void GoError(string ct, string message, string trace) { blocked = true; BubConsole.WriteLine($"ERROR>{message}", 255, 0, 0); Debug.WriteLine($"{ct}: {message}\nTraceback:\n{trace}\n\n"); if (crashed) { return; } crashed = true; var s = QuickStream.OpenEmbedded("Death.png"); if (s == null) { Debug.WriteLine("ERROR! Trying to read Death resulted into null!"); } s.Position = 0; Death = TQMG.GetImage(s); sct = ct; smsg = message; strace = trace; FlowManager.GoHardFlow(new Error(), true); }