Ejemplo n.º 1
0
 public API(Lua State, string Script)
 {
     this.State  = State;
     this.Script = Script;
     this.State["LuaQuickNeil"] = this;
     this.State.DoString($"Neil.Load([[{QuickStream.StringFromEmbed("QuickNeil.Neil")}]],\"QuickNeil API Linkup\")()", "QuickNeil API Linkup from C#");
 }
Ejemplo n.º 2
0
        private Bubble_Input(string state)
        {
            var script = QuickStream.StringFromEmbed("Input.lua");

            SBubble.State(state).state["Bubble_Input"] = this;
            SBubble.DoNIL(state, "#macro MouseLeft 1\n#macro MouseRight 2\n#macro MouseCenter 3", "Mouse Button macros");
            SBubble.State(state).DoString(script, "Input API header");
        }
Ejemplo n.º 3
0
        public Bubble_Audio(string s)
        {
            var state  = SBubble.State(s).state;
            var script = QuickStream.StringFromEmbed("Audio.nil");

            state["Bubble_Audio"] = this;
            SBubble.DoNIL(s, script, "Audio init script");
        }
Ejemplo n.º 4
0
        private APIFlow(string state)
        {
            State = state;
            var s = SBubble.State(state).state;

            s["Bubble_Flow"] = this;
            SBubble.State(state).DoString(QuickStream.StringFromEmbed("Flow.lua"), "Flow Management");
        }
Ejemplo n.º 5
0
        static public void Init(string state)
        {
            me = new RPG_API();
            var script = QuickStream.StringFromEmbed("RPG_API.nil");

            SBubble.State(state).state["NALA_RPG"] = me;
            SBubble.DoNIL(state, script, "Link code RPG API");
            me.statename = state;
        }
Ejemplo n.º 6
0
        static public void API_Init(string namestate)
        {
            var ret    = new MapScriptAPI();
            var state  = SBubble.State(namestate).state;
            var script = QuickStream.StringFromEmbed("MapScriptAPI.nil");

            state["NALAMSAPI"] = ret;
            SBubble.DoNIL(namestate, script, "MapScript init script");
        }
Ejemplo n.º 7
0
        public static void Init(string s)
        {
            var state  = SBubble.State(s).state;
            var script = QuickStream.StringFromEmbed("Bubble_Conf.nil");

            state["Bubble_Conf"] = new Bubble_Conf();
            Debug.WriteLine($"Initiating state: {s}");
            BubConsole.CSay($"State \"{s}\" being prepared for Bubble_Conf");
            SBubble.DoNIL(s, script, "Message box init script");
        }
Ejemplo n.º 8
0
        static void RunScript(string[] args)
        {
            var API       = new NIL_API();
            var argscript = new StringBuilder("AppArgs={}\n");

            API.NILScript = QuickStream.StringFromEmbed("NIL.lua");
            for (int i = 0; i < args.Length; i++)
            {
                if (i == 0)
                {
                    argscript.Append("AppArgs.Application =");
                }
                else
                {
                    argscript.Append($"AppArgs[{i}] = ");
                }
                argscript.Append($"\"{qstr.SafeString(args[i].Replace("\\","/"))}\"\n");
            }
            var state = new Lua();

            try {
                state["QNIL"] = API;
                var initNIL = "NIL = assert((loadstring or load)(QNIL.NILScript,\"NIL\")())"; //$"NIL = (loadstring or load)(\n\"{qstr.SafeString(nilscript)}\"\n,'NIL')\n()";
                Debug.WriteLine($"initNIL: {initNIL}");
                state.DoString(initNIL, "Internal: NIL");
                state.DoString("NIL.SayFuncs[#NIL.SayFuncs+1]=function(sayit) print(\"#say \"..tostring(sayit)) end", "NIL.Say Init");
                //var initARGS = $"local act = assert(NIL.Load(\"{qstr.SafeString(argscript.ToString())}\"))\nact()";
                //Debug.WriteLine($"--- ARGUMENTS ---\n{initARGS}\n--- END ARGUMENTS ---");
                Debug.WriteLine($"--- ARGUMENTS ---\n{argscript.ToString()}\n--- END ARGUMENTS ---");
                state.DoString(argscript.ToString(), "Interal: CLI Arguments");
                var script = QuickStream.LoadString(args[0]);
                switch (qstr.ExtractExt(args[0]).ToLower())
                {
                case "lua":
                    state.DoString(script, $"Lua:{args[0]}");
                    break;

                case "nil":
                    state.DoString($"local run = assert(NIL.Load(\"{qstr.SafeString(script)}\"))\nrun()", $"NIL:{args[0]}");
                    break;

                default:
                    throw new Exception("Unknown file extension!");
                }
            } catch (Exception Fout) {
                Debug.WriteLine($"ERROR: {Fout.Message}");
                Console.ForegroundColor = ConsoleColor.Red;
                Console.Write("ERROR! ");
                Console.Beep();
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine(Fout.Message);
                Console.ResetColor();
            }
        }
Ejemplo n.º 9
0
        static public void Init(string statename)
        {
            var me = new Bubble_Swap();

            try {
                var script = QuickStream.StringFromEmbed("Bubble_Swap.nil");
                me.statename = statename;
                me.State     = SBubble.State(statename);
                me.LuaState  = me.State.state;
                me.LuaState["Bubble_Swap"] = me;
                SBubble.DoNIL(statename, script, "BUBBLE_Swap Init");
            } catch (Exception DoffeEllende) {
                SBubble.MyError("Init BUBBLE_Swap Error", DoffeEllende.Message, $"{SBubble.TraceLua(statename)}\n\n{DoffeEllende.StackTrace}");
            }
        }