Example #1
0
            private Lua CreateLuaVM()
            {
                Lua l = new Lua();
                Type t = GetType();
                MethodInfo m = t.GetMethod("WriteLog");
                l.RegisterFunction("Bot_PrintLog", this, m);

                m = t.GetMethod("Connect");
                l.RegisterFunction("Bot_Connect", this, m);

                m = t.GetMethod("Disconnect");
                l.RegisterFunction("Bot_Disconnect", this, m);

                m = t.GetMethod("SendPacket");
                l.RegisterFunction("Bot_SendPacket", this, m);

                m = t.GetMethod("StartTimer");
                l.RegisterFunction("Bot_StartTimer", this, m);

                m = t.GetMethod("ResetTimer");
                l.RegisterFunction("Bot_ResetTimer", this, m);

                m = t.GetMethod("StopTimer");
                l.RegisterFunction("Bot_StopTimer", this, m);

                m = t.GetMethod("GetTick");
                l.RegisterFunction("Bot_GetTick", this, m);

                return l;
            }
Example #2
0
        public void Write(Lua.Function function, int indentLevel = 0)
        {
            // top level function
            if(function.lineNumber == 0 && function.lastLineNumber == 0)
            {
            //				WriteConstants(function);

                WriteChildFunctions(function);

                WriteInstructions(function);
            }
            else
            {
                string indents = new string('\t', indentLevel);

                string functionHeader = indents + "function func" + functionCount + "(";

                for(int i = 0; i < function.numParameters; ++i)
                {
                    functionHeader += "arg" + i + (i + 1 != function.numParameters ? ", " : ")");
                }

                writer.Write(functionHeader);
                ++functionCount;

            //				WriteConstants(function, indentLevel + 1);

                WriteChildFunctions(function, indentLevel + 1);

                WriteInstructions(function, indentLevel + 1);
            }
        }
Example #3
0
    void Start()
    {
        Debug.Log("== 测试 ==   C#获取Lua Float");
        Lua lua = new Lua();
        lua.DoString("num1 = -0.9999999");
        Debug.Log(lua["num1"]);
	}
    public void Start()
    {
        //Init LuaBinding class that demonstrates communication
        LuaBinding binding = new LuaBinding();

        //Init instance of Lua virtual machine (Note: Can only init ONCE)
        luaVirtualMachine = new Lua();
        //Tell Lua about the LuaBinding object to allow Lua to call C# functions
        luaVirtualMachine["luabinding"] = binding;

        //test luabinding test
        LuaBindingTest bindingTest = LuaBindingTest.SharedInstance();
        bindingTest.name = "name1";
        luaVirtualMachine["LuaBindingTest"] = bindingTest;
        //luaVirtualMachine[""] = ;

        //Debug.LogError("LuaManager: " + Application.persistentDataPath);

        //Run the code contained within the file
        #if UNITY_ANDROID
        luaVirtualMachine.DoFile("/sdcard/Download/"+LuaFileToLoad);
        #else
        luaVirtualMachine.DoFile(Application.streamingAssetsPath+"/"+LuaFileToLoad);
        #endif
        //Trigger binding in c# to call the bound Lua function

        binding.MessageToLua();
        TestStaticFunction();
    }
Example #5
0
    public static int attachMovie(Lua.lua_State L)
    {
        LWF.Movie a;
        int args = Lua.lua_gettop(L);
        if (args < 3 || args > 6)
            goto error;
        if (Luna.get_uniqueid(L, 1) != LunaTraits_LWF_Movie.uniqueID)
            goto error;
        if (Lua.lua_isstring(L, 2)==0 || Lua.lua_isstring(L, 3)==0)
            goto error;
        if (args >= 4 && !Lua.lua_istable(L, 4))
            goto error;
        if (args >= 5 && Lua.lua_isnumber(L, 5)==0)
            goto error;
        if (args >= 6 && !Lua.lua_isboolean(L, 6))
            goto error;

        a = Luna_LWF_Movie.check(L, 1);
        return a.lwf.AttachMovieLua(a);

        error:
        Luna.printStack(L);
        Lua.luaL_error(L, "luna typecheck failed: LWF.Movie.attachMovie");
        return 1;
    }
Example #6
0
 private void WriteChildFunctions(Lua.Function function, int indentLevel = 0)
 {
     foreach(var f in function.functions)
     {
         Write(f, indentLevel + 1);
     }
 }
Example #7
0
            //Filename of the Lua file to load
            public static void Init()
            {
                if (_lua != null)
                {
                    return;
                }
                //Init instance of Lua virtual machine (Note: Can only init ONCE)
                _lua = new LuaInterface.Lua ();

                System.Type t = typeof(LuaManager);
                lua.RegisterFunction ("print", null, t.GetMethod ("LuaPrint"));
                lua.RegisterFunction ("error", null, t.GetMethod ("LuaError"));
                lua.RegisterFunction ("assert", null, t.GetMethod ("LuaAssert",
                                                                BindingFlags.Static | BindingFlags.Public,
                                                                System.Type.DefaultBinder,
                                                                new[] {
                    typeof(bool),
                    typeof(string)
                },
                                                                null)
                );
                lua.RegisterFunction ("require", null, t.GetMethod ("AddFilePath"));

                //Init LuaBinding class that demonstrates communication
                //Also tell Lua about the LuaBinding object to allow Lua to call C# functions
                mainBinding = new MainBinding ();
            }
Example #8
0
 public static void open(Lua.lua_State L)
 {
     Luna.dostring(L,"if __luna==nil then __luna={} end");
     Luna.dostring(L,"    if __luna.copyMethodsFrom==nil then\n        function __luna.copyMethodsFrom(methodsChild, methodsParent)\n            for k,v in pairs(methodsParent) do\n                if k~='__index' and k~='__newindex' and methodsChild[k]==nil then\n                    methodsChild[k]=v\n                end\n            end\n        end\n        function __luna.overwriteMethodsFrom(methodsChild, methodsParent)\n            for k,v in pairs(methodsParent) do\n                if k~='__index' and k~='__newindex' then\n                    if verbose then print('registering', k, methodsChild[k]) end\n                    methodsChild[k]=v\n                end\n            end\n        end\n    end\n    ");
     impl_LunaTraits_LWF_LWF.luna_init_hashmap();
     impl_LunaTraits_LWF_LWF.luna_init_write_hashmap();
     Luna_LWF_LWF.Register(L);
     Luna.dostring(L, "if not LWF then LWF={} end LWF.LWF=__luna.LWF_LWF");
     Luna.dostring(L,"                __luna.LWF_LWF.luna_class='.LWF'");
     impl_LunaTraits_LWF_Button.luna_init_hashmap();
     impl_LunaTraits_LWF_Button.luna_init_write_hashmap();
     Luna_LWF_Button.Register(L);
     Luna.dostring(L, "if not LWF then LWF={} end LWF.Button=__luna.LWF_Button");
     Luna.dostring(L,"                __luna.LWF_Button.luna_class='.Button'");
     impl_LunaTraits_LWF_Movie.luna_init_hashmap();
     impl_LunaTraits_LWF_Movie.luna_init_write_hashmap();
     Luna_LWF_Movie.Register(L);
     Luna.dostring(L, "if not LWF then LWF={} end LWF.Movie=__luna.LWF_Movie");
     Luna.dostring(L,"                __luna.LWF_Movie.luna_class='.Movie'");
     impl_LunaTraits_LWF_Point.luna_init_hashmap();
     impl_LunaTraits_LWF_Point.luna_init_write_hashmap();
     Luna_LWF_Point.Register(L);
     Luna.dostring(L, "if not LWF then LWF={} end LWF.Point=__luna.LWF_Point");
     Luna.dostring(L,"                __luna.LWF_Point.luna_class='.Point'");
 }
Example #9
0
 public static void close(Lua.lua_State L)
 {
     Luna_LWF_LWF.Unregister(L);
     Luna_LWF_Button.Unregister(L);
     Luna_LWF_Movie.Unregister(L);
     Luna_LWF_Point.Unregister(L);
 }
Example #10
0
		/// <summary>Create a new environment for the lua script manager/compiler.</summary>
		/// <param name="lua">The lua script compiler.</param>
		public LuaGlobalPortable(Lua lua)
		{
			if (lua == null)
				throw new ArgumentNullException("lua");

			this.lua = lua;
		} // ctor
Example #11
0
	void Start () {
        Debug.Log("== 测试 ==   C#获取Lua对象引用");
        Lua lua = new Lua();
        lua["gameObject"] = gameObject;
        GameObject backRef = (GameObject)lua["gameObject"];
        Debug.Log(backRef.name);
	}
Example #12
0
 public IrcScriptEngine()
 {
     Engine = new Lua (
         integerType: LuaIntegerType.Int32,
         floatType: LuaFloatType.Float
     );
     LuaEnvironment = Engine.CreateEnvironment<LuaGlobal> ();
 }
Example #13
0
 public void TestGlobalMember01()
 {
     using (Lua l = new Lua())
       {
     dynamic g = new LuaGlobalNew(l);
     TestResult(g.dochunk("return LogInfo('Hello');"), 3);
       }
 }
Example #14
0
 public static void dostring(Lua.lua_State L, Lua.CharPtr luacode)
 {
     // Lua.luaL_dostring followed by pcall error checking
     if (Lua.luaL_dostring(L, luacode)==1)
     {
         print("Lua error: stack :");
         printStack(L,false);
     }
 }
Example #15
0
		private static void TestDynamic()
		{
			var lua = new Lua();
			var global = new LuaGlobalPortable(lua) { ["workspace"] = new DynData() };

			var r = global.DoChunk("return workspace.Part", "Test.lua");

			Console.WriteLine(r.ToString());
		}
Example #16
0
 public static void dostring(Lua.lua_State L, Lua.CharPtr luacode)
 {
     // Lua.luaL_dostring followed by pcall error checking
     if (Lua.luaL_loadstring(L, luacode) != 0 || Lua.lua_pcall(L, 0, Lua.LUA_MULTRET, 0) != 0)
     {
         print("Lua error: stack :");
         printStack(L,false);
     }
 }
    public static LWF.Point _bind_ctor(Lua.lua_State L)
    {
        if (Lua.lua_gettop(L)!= 0) return _bind_ctor_overload_1(L);
        if (Lua.lua_gettop(L)!= 2
            || Lua.lua_isnumber(L, 1)==0
            || Lua.lua_isnumber(L, 2)==0) return _bind_ctor_overload_2(L);
        Lua.luaL_error(L, "ctor ( cannot find overloads:)");

        return null;
    }
 protected LibraryTestBase()
 {
     Lua = new Lua();
     Lua.Register((Action<object, object, string>)Assert.AreEqual, "assertEquals");
     Lua.Register((Action<bool, string>)Assert.IsTrue, "assertTrue");
     Lua.Register((Action<bool, string>)Assert.IsFalse, "assertFalse");
     Lua.Register((Action<double, double, string>)assertEqualsDelta);
     Lua.Register((Action<string>)Assert.Fail, "fail");
     Lua.Register(typeof(UserData));
 }
Example #19
0
        public void TestGlobalProperty01()
        {
            using (Lua l = new Lua())
            {
                var g = l.CreateEnvironment<LuaGlobalNew>();

                g.DoChunk("BoolProperty = true", "test1.lua");
                TestResult(g.DoChunk("return BoolProperty", "test2.lua"), true);
            }
        }
Example #20
0
    public static void RegisterNLuaDelegate(Lua context)
    {
        //Only For IOS 
        context.RegisterLuaDelegateType(typeof(EventTriggerListener.VoidDelegate), typeof(CallbackLuaFunction<GameObject>));

        context.RegisterLuaDelegateType(typeof(Action<object>), typeof(CallbackLuaFunction<object>));
        context.RegisterLuaDelegateType(typeof(Action), typeof(CallbackLuaFunction));
        context.RegisterLuaDelegateType(typeof(Callback), typeof(CallbackLuaFunction));
        context.RegisterLuaDelegateType(typeof(Callback<object>), typeof(CallbackLuaFunction<object>));
        context.RegisterLuaDelegateType(typeof(Callback<string, AssetBundle>), typeof(CallbackLuaFunction<string, AssetBundle>));
    }
 public static int _bind_getHeight(Lua.lua_State L)
 {
     if (Lua.lua_gettop(L)!=1
         || Luna.get_uniqueid(L,1)!=7105034 ) { Luna.printStack(L); Lua.luaL_error(L, "luna typecheck failed:getHeight(LWF.LWF self ...)"); }
     LWF.LWF o=Luna_LWF_LWF.check(L,1);
     try {
     float ret=getHeight(o);
     Lua.lua_pushnumber(L, ret);
     } catch(Exception e) { Lua.luaL_error( L,new Lua.CharPtr(e.ToString())); }
     return 1;
 }
Example #22
0
 public void CallGlobalFunctionOneArg()
 {
     using (Lua lua = new Lua())
     {
         lua.DoString("a=2\nfunction f(x)\na=a+x\nend");
         lua.GetFunction("f").Call(1);
         double num = lua.GetNumber("a");
         //Console.WriteLine("a="+num);
         Assert.Equal(num, 3d);
     }
 }
Example #23
0
	void Start()
	{
		_lua = new Lua();
		_lua.DoString("UnityEngine = luanet.UnityEngine");
		_lua.DoString("System = luanet.System");
		_lua["gameObject"] = this;
		
		Code = "function update(dt)\n\nend\n";
		
		DoCode(Code);
	}
Example #24
0
    public static int _bind_detachFromParent(Lua.lua_State L)
    {
        if (Lua.lua_gettop(L)!=1
            || Luna.get_uniqueid(L,1)!=29625181 ) { Luna.printStack(L); Lua.luaL_error(L, "luna typecheck failed:detachFromParent(LWF.Movie self)"); }

        LWF.Movie self=Luna_LWF_Movie.check(L,1);
        try {
        self.DetachFromParent();
        } catch(Exception e) { Lua.luaL_error( L,new Lua.CharPtr(e.ToString())); }
        return 0;
    }
Example #25
0
 public void CodePlexExample0()
 {
   using (Lua l = new Lua()) // create the lua script engine
   {
     dynamic g = l.CreateEnvironment(); // create a environment
     g.dochunk("a = 'Hallo World!';", "test.lua"); // create a variable in lua
     Console.WriteLine(g.a); // access a variable in c#
     g.dochunk("function add(b) return b + 3; end;", "test.lua"); // create a function in lua
     Console.WriteLine("Add(3) = {0}", g.add(3)); // call the function in c#
   }
 }
	public static int _bind_getLWF(Lua.lua_State L)
	{
		if (Lua.lua_gettop(L) != 1 || Luna.get_uniqueid(L, 1) !=
						LunaTraits_LWF_Button.uniqueID) {
				Luna.printStack(L);
				Lua.luaL_error(L, "luna typecheck failed: LWF.Button.lwf");
		}
		LWF.Button a = Luna_LWF_Button.check(L, 1);
		Luna_LWF_LWF.push(L, a.lwf, false);
		return 1;
	}
 public static int _bind_getName(Lua.lua_State L)
 {
     if (Lua.lua_gettop(L)!=1
         || Luna.get_uniqueid(L,1)!=55459900 ) { Luna.printStack(L); Lua.luaL_error(L, "luna typecheck failed:getName(LWF.BitmapClip self ...)"); }
     LWF.BitmapClip o=Luna_LWF_BitmapClip.check(L,1);
     try {
     string ret=getName(o);
     Lua.lua_pushstring(L, ret);
     } catch(Exception e) { Lua.luaL_error( L,new Lua.CharPtr(e.ToString())); }
     return 1;
 }
    public static int _bind_getFullName(Lua.lua_State L)
    {
        if (Lua.lua_gettop(L)!=1
            || Luna.get_uniqueid(L,1)!=8952431 ) { Luna.printStack(L); Lua.luaL_error(L, "luna typecheck failed:getFullName(LWF.Button self)"); }

        LWF.Button self=Luna_LWF_Button.check(L,1);
        try {
        string ret=self.GetFullName();
        Lua.lua_pushstring(L, ret);
        } catch(Exception e) { Lua.luaL_error( L,new Lua.CharPtr(e.ToString())); }
        return 1;
    }
    public static int addButtonEventListener(Lua.lua_State L)
    {
        if (Lua.lua_gettop(L) != 3 ||
                Luna.get_uniqueid(L, 1) != LunaTraits_LWF_LWF.uniqueID ||
                Lua.lua_isstring(L, 2)==0 || !Lua.lua_istable(L, 3)) {
            Luna.printStack(L);
            Lua.luaL_error(L, "luna typecheck failed: LWF.addButtonEventListener");
        }

        LWF.LWF a = Luna_LWF_LWF.check(L, 1);
        return a.AddEventHandlerLua();
    }
Example #30
0
    public void Load(Lua lua)
    {
        if(lua == null)
        {
            return;
        }

        foreach(TextAsset code in Scripts)
        {
            lua.DoString(code.text);
        }
    }
Example #31
0
 // Deletes items passed as string
 public static void LuaDeleteOneItem(string item)
 {
     Lua.LuaDoString("for bag = 0, 4, 1 do for slot = 1, 32, 1 do local name = GetContainerItemLink(bag, slot); " +
                     "if name and string.find(name, \"" + item + "\") then PickupContainerItem(bag, slot); " +
                     "DeleteCursorItem(); return; end; end; end", false);
 }
Example #32
0
 public ScriptableSink(Lua vm)
 {
     LuaVm = vm;
     LuaHelpers.RegisterLuaFunctions(LuaVm, this);
 }
Example #33
0
 public ConsoleLuaLibrary(Lua lua)
     : base(lua)
 {
 }
Example #34
0
        [TestMethod] public void CFunctions()
        {
            const uint iterations = 2048 * 2048;

            using (var li = new Lua())
            {
                var L = luanet.getstate(li);
                Trace.WriteLine(iterations.ToString("N0") + " iterations");
                Noop(L);                 // jit


                var timer = Stopwatch.StartNew();
                for (uint i = 0; i < iterations; ++i)
                {
                    Noop(L);
                }
                timer.Stop();
                Display(timer, "CLR -> CLR");


                luaL.loadstring(L, @"
					local Noop = Noop
					for i=1,"                     + iterations + @" do
						Noop()
					end
				"                );

                                #if false
                                #pragma warning disable 618
                luanet.CSFunction cs_function = Noop;
                luanet.pushstdcallcfunction(L, cs_function);
                lua.setglobal(L, "Noop");

                lua.pushvalue(L, -1);
                timer.Reset(); timer.Start();
                lua.call(L, 0, 0);
                timer.Stop();
                Display(timer, "Lua -> stdcall -> CLR");

                GC.KeepAlive(cs_function);
                                #pragma warning restore 618
                                #endif


                lua.CFunction c_function = Noop;
                lua.pushcfunction(L, c_function);
                lua.setglobal(L, "Noop");

                lua.pushvalue(L, -1);
                timer.Reset(); timer.Start();
                lua.call(L, 0, 0);
                timer.Stop();
                Display(timer, "Lua -> cdecl -> CLR");

                GC.KeepAlive(c_function);


                luaL.dostring(L, "function Noop() end");

                lua.pushvalue(L, -1);
                timer.Reset(); timer.Start();
                lua.call(L, 0, 0);
                timer.Stop();
                Display(timer, "Lua -> Lua");

                /*
                 *      4,194,304 iterations
                 *      CLR -> CLR: 12ms
                 *      Lua -> stdcall -> CLR: 731ms
                 *      Lua -> cdecl -> CLR: 420ms
                 *      Lua -> Lua: 468ms
                 */
            }
        }
Example #35
0
        [TestMethod] public void Indexer()
        {
            const uint iterations = 128 * 1024;

            using (var li = new Lua())
            {
                var L = luanet.getstate(li);
                Trace.WriteLine(iterations.ToString("N0") + " iterations");

                const int pool_size = 100;

                lua.createtable(L, pool_size, 0);
                lua.createtable(L, 0, pool_size);
                lua.createtable(L, 0, pool_size);
                var i_int = new int[pool_size];
                var i_str = new string[pool_size];
                var i_lud = new IntPtr[pool_size];
                for (int i = 0; i < pool_size; ++i)
                {
                    lua.pushboolean(L, true);
                    lua.rawseti(L, 1, i_int[i] = i);

                    lua.pushboolean(L, true);
                    lua.setfield(L, 2, i_str[i] = i.ToString());

                    lua.pushboolean(L, true);
                    lua.pushlightuserdata(L, i_lud[i] = new IntPtr(i));
                    lua.settable(L, 3);
                }


                var timer = Stopwatch.StartNew();
                for (uint n = 0; n < iterations; ++n)
                {
                    for (int i = 0; i < i_int.Length; ++i)
                    {
                        lua.rawgeti(L, 1, i_int[i]);
                        lua.pop(L, 1);
                    }
                }
                timer.Stop();
                Display(timer, "int");


                timer.Reset(); timer.Start();
                for (uint n = 0; n < iterations; ++n)
                {
                    for (int i = 0; i < i_str.Length; ++i)
                    {
                        lua.getfield(L, 2, i_str[i]);
                        lua.pop(L, 1);
                    }
                }
                timer.Stop();
                Display(timer, "string");


                timer.Reset(); timer.Start();
                for (uint n = 0; n < iterations; ++n)
                {
                    for (int i = 0; i < i_lud.Length; ++i)
                    {
                        lua.pushlightuserdata(L, i_lud[i]);
                        lua.rawget(L, 3);
                        lua.pop(L, 1);
                    }
                }
                timer.Stop();
                Display(timer, "lightuserdata");

                /*
                 *      131,072 iterations
                 *      int: 1824ms
                 *      string: 4082ms
                 *      lightuserdata: 3005ms
                 *
                 *      release mode:
                 *      131,072 iterations
                 *      int: 471ms
                 *      string: 1316ms
                 *      lightuserdata: 729ms
                 */
            }
        }
Example #36
0
 public static bool itemIsUsable(string itemName)
 {
     return(Lua.LuaDoString <bool>("local cooldown = GetItemCooldown(" + ItemsManager.GetIdByName(itemName) + ") if (cooldown == 0 ) then     return true; else     return false; end "));
 }
Example #37
0
 // Returns the cooldown of the spell passed as argument
 public static float GetSpellCooldown(string spellName)
 {
     return(Lua.LuaDoString <float>("local startTime, duration, enable = GetSpellCooldown('" + spellName + "'); return duration - (GetTime() - startTime)"));
 }
Example #38
0
    /// <summary>
    /// Registers all custom Lua functions.
    /// Call in OnEnable().
    /// </summary>
    private void RegisterLuaFunctions()
    {
        // ===CONDITION FUNCTIONS===

        // general:
        Lua.RegisterFunction("HaveFlag", this, SymbolExtensions.GetMethodInfo(() => HaveFlag(string.Empty)));

        Lua.RegisterFunction("CanStartShooterStateMode", this, SymbolExtensions.GetMethodInfo(() => CanStartShooterStateMode()));

        // HContent:
        Lua.RegisterFunction("CanShowHcontent", this, SymbolExtensions.GetMethodInfo(() => CanShowHcontent()));

        // activity partner:
        Lua.RegisterFunction("CanActivityPartnerWaifu1", this, SymbolExtensions.GetMethodInfo(() => CanActivityPartnerWaifu1()));
        Lua.RegisterFunction("CanActivityPartnerWaifu2", this, SymbolExtensions.GetMethodInfo(() => CanActivityPartnerWaifu2()));
        Lua.RegisterFunction("CanActivityPartnerWaifu3", this, SymbolExtensions.GetMethodInfo(() => CanActivityPartnerWaifu3()));

        Lua.RegisterFunction("IsActivityPartnerWaifu1", this, SymbolExtensions.GetMethodInfo(() => IsActivityPartnerWaifu1()));
        Lua.RegisterFunction("IsActivityPartnerWaifu2", this, SymbolExtensions.GetMethodInfo(() => IsActivityPartnerWaifu2()));
        Lua.RegisterFunction("IsActivityPartnerWaifu3", this, SymbolExtensions.GetMethodInfo(() => IsActivityPartnerWaifu3()));

        // activity:
        Lua.RegisterFunction("CanDoActivity", this, SymbolExtensions.GetMethodInfo(() => CanDoActivity(string.Empty)));

        // sexual:
        Lua.RegisterFunction("IsRomancedWaifu1", this, SymbolExtensions.GetMethodInfo(() => IsRomancedWaifu1()));
        Lua.RegisterFunction("IsRomancedWaifu2", this, SymbolExtensions.GetMethodInfo(() => IsRomancedWaifu2()));
        Lua.RegisterFunction("IsRomancedWaifu3", this, SymbolExtensions.GetMethodInfo(() => IsRomancedWaifu3()));

        Lua.RegisterFunction("IsSexuallyComfortableWaifu1", this, SymbolExtensions.GetMethodInfo(() => IsSexuallyComfortableWaifu1()));
        Lua.RegisterFunction("IsSexuallyComfortableWaifu2", this, SymbolExtensions.GetMethodInfo(() => IsSexuallyComfortableWaifu2()));
        Lua.RegisterFunction("IsSexuallyComfortableWaifu3", this, SymbolExtensions.GetMethodInfo(() => IsSexuallyComfortableWaifu3()));



        // ===SCRIPT FUNCTIONS===

        // general:
        Lua.RegisterFunction("SetFlag", this, SymbolExtensions.GetMethodInfo(() => SetFlag(string.Empty)));
        Lua.RegisterFunction("AddExp", this, SymbolExtensions.GetMethodInfo(() => AddExp((double)0)));

        Lua.RegisterFunction("StartShooterStateMode", this, SymbolExtensions.GetMethodInfo(() => StartShooterStateMode()));
        Lua.RegisterFunction("StartVisualNovelStateMode", this, SymbolExtensions.GetMethodInfo(() => StartVisualNovelStateMode()));

        Lua.RegisterFunction("TutorialDone", this, SymbolExtensions.GetMethodInfo(() => TutorialDone()));

        // HContent:
        Lua.RegisterFunction("DialogueUIChangeHBackgroundL1", this, SymbolExtensions.GetMethodInfo(() => DialogueUIChangeHBackgroundL1(string.Empty)));
        Lua.RegisterFunction("DialogueUIChangeHBackgroundL2", this, SymbolExtensions.GetMethodInfo(() => DialogueUIChangeHBackgroundL2(string.Empty)));

        Lua.RegisterFunction("DialogueUIStartHcontentActivityBackground", this, SymbolExtensions.GetMethodInfo(() => DialogueUIStartHcontentActivityBackground()));
        Lua.RegisterFunction("DialogueUINextHcontentActivityBackground", this, SymbolExtensions.GetMethodInfo(() => DialogueUINextHcontentActivityBackground()));

        // activity partner:
        Lua.RegisterFunction("SetActivityPartnerWaifu1", this, SymbolExtensions.GetMethodInfo(() => SetActivityPartnerWaifu1()));
        Lua.RegisterFunction("SetActivityPartnerWaifu2", this, SymbolExtensions.GetMethodInfo(() => SetActivityPartnerWaifu2()));
        Lua.RegisterFunction("SetActivityPartnerWaifu3", this, SymbolExtensions.GetMethodInfo(() => SetActivityPartnerWaifu3()));

        // activity:
        Lua.RegisterFunction("SetActivity", this, SymbolExtensions.GetMethodInfo(() => SetActivity(string.Empty)));
        Lua.RegisterFunction("SetActivityStart", this, SymbolExtensions.GetMethodInfo(() => SetActivityStart()));

        // character:
        Lua.RegisterFunction("PartyAddWaifu1", this, SymbolExtensions.GetMethodInfo(() => AddCharacterToPartyWaifu1()));
        Lua.RegisterFunction("PartyAddWaifu2", this, SymbolExtensions.GetMethodInfo(() => AddCharacterToPartyWaifu2()));
        Lua.RegisterFunction("PartyAddWaifu3", this, SymbolExtensions.GetMethodInfo(() => AddCharacterToPartyWaifu3()));

        Lua.RegisterFunction("AddLeechShotAbilityMC", this, SymbolExtensions.GetMethodInfo(() => AddLeechShotAbilityToCharacterMC()));
        Lua.RegisterFunction("AddShieldAbilityWaifu1", this, SymbolExtensions.GetMethodInfo(() => AddShieldAbilityToCharacterWaifu1()));
        Lua.RegisterFunction("AddTrapAbilityWaifu2", this, SymbolExtensions.GetMethodInfo(() => AddTrapAbilityToCharacterWaifu2()));
        Lua.RegisterFunction("AddWeakenAbilityWaifu3", this, SymbolExtensions.GetMethodInfo(() => AddWeakenAbilityToCharacterWaifu3()));

        // dialogue UI:
        Lua.RegisterFunction("DialogueUIChangeBackgroundL1", this, SymbolExtensions.GetMethodInfo(() => DialogueUIChangeBackgroundL1(string.Empty)));
        Lua.RegisterFunction("DialogueUIChangeBackgroundL2", this, SymbolExtensions.GetMethodInfo(() => DialogueUIChangeBackgroundL2(string.Empty)));
        Lua.RegisterFunction("DialogueUIChangeBackgroundL1FromHavenActivity", this, SymbolExtensions.GetMethodInfo(() => DialogueUIChangeBackgroundL1FromHavenActivity()));
        Lua.RegisterFunction("DialogueUIChangeBackgroundL1FromHavenLocationActivityHub", this, SymbolExtensions.GetMethodInfo(() => DialogueUIChangeBackgroundL1FromHavenLocationActivityHub(string.Empty)));
        Lua.RegisterFunction("DialogueUIChangeBackgroundL1FromHavenLocationEvent", this, SymbolExtensions.GetMethodInfo(() => DialogueUIChangeBackgroundL1FromHavenLocationEvent(string.Empty)));

        Lua.RegisterFunction("DialogueUIPortraitEnterWaifu1", this, SymbolExtensions.GetMethodInfo(() => DialogueUIPortraitEnterWaifu1(string.Empty)));
        Lua.RegisterFunction("DialogueUIPortraitEnterWaifu2", this, SymbolExtensions.GetMethodInfo(() => DialogueUIPortraitEnterWaifu2(string.Empty)));
        Lua.RegisterFunction("DialogueUIPortraitEnterWaifu3", this, SymbolExtensions.GetMethodInfo(() => DialogueUIPortraitEnterWaifu3(string.Empty)));

        Lua.RegisterFunction("DialogueUIPortraitExitWaifu1", this, SymbolExtensions.GetMethodInfo(() => DialogueUIPortraitExitWaifu1()));
        Lua.RegisterFunction("DialogueUIPortraitExitWaifu2", this, SymbolExtensions.GetMethodInfo(() => DialogueUIPortraitExitWaifu2()));
        Lua.RegisterFunction("DialogueUIPortraitExitWaifu3", this, SymbolExtensions.GetMethodInfo(() => DialogueUIPortraitExitWaifu3()));

        Lua.RegisterFunction("DialogueUIChangeExpressionWaifu1", this, SymbolExtensions.GetMethodInfo(() => DialogueUIChangeExpressionWaifu1(string.Empty)));
        Lua.RegisterFunction("DialogueUIChangeExpressionWaifu2", this, SymbolExtensions.GetMethodInfo(() => DialogueUIChangeExpressionWaifu2(string.Empty)));
        Lua.RegisterFunction("DialogueUIChangeExpressionWaifu3", this, SymbolExtensions.GetMethodInfo(() => DialogueUIChangeExpressionWaifu3(string.Empty)));

        Lua.RegisterFunction("DialogueUIAssignSpeakerMC", this, SymbolExtensions.GetMethodInfo(() => DialogueUIAssignSpeakerMC()));
        Lua.RegisterFunction("DialogueUIAssignSpeakerWaifu1", this, SymbolExtensions.GetMethodInfo(() => DialogueUIAssignSpeakerWaifu1()));
        Lua.RegisterFunction("DialogueUIAssignSpeakerWaifu2", this, SymbolExtensions.GetMethodInfo(() => DialogueUIAssignSpeakerWaifu2()));
        Lua.RegisterFunction("DialogueUIAssignSpeakerWaifu3", this, SymbolExtensions.GetMethodInfo(() => DialogueUIAssignSpeakerWaifu3()));

        Lua.RegisterFunction("DialogueUISetOverrideSpeakerName", this, SymbolExtensions.GetMethodInfo(() => DialogueUISetOverrideSpeakerName(string.Empty)));
        Lua.RegisterFunction("DialogueUIRemoveSpeaker", this, SymbolExtensions.GetMethodInfo(() => DialogueUIRemoveSpeaker()));



        // ===DIALOGUE TAG FUNCTIONS===

        Lua.RegisterFunction("LevelingInfo", this, SymbolExtensions.GetMethodInfo(() => LevelingInfo()));

        Lua.RegisterFunction("CharNameActPartner", this, SymbolExtensions.GetMethodInfo(() => CharNameActPartner()));
        Lua.RegisterFunction("CharNameWaifu1", this, SymbolExtensions.GetMethodInfo(() => CharNameWaifu1()));
        Lua.RegisterFunction("CharNameWaifu2", this, SymbolExtensions.GetMethodInfo(() => CharNameWaifu2()));
        Lua.RegisterFunction("CharNameWaifu3", this, SymbolExtensions.GetMethodInfo(() => CharNameWaifu3()));
    }
Example #39
0
 protected LuaLibraryBase(Lua lua)
 {
     Lua = lua;
 }
Example #40
0
    /// <summary>
    /// Un-registers all custom Lua functions.
    /// Call in OnDisable().
    /// </summary>
    private void UnregisterLuaFunctions()
    {
        // ===CONDITION FUNCTIONS===

        // general:
        Lua.UnregisterFunction("HaveFlag");

        Lua.UnregisterFunction("CanStartShooterStateMode");

        // HContent:
        Lua.UnregisterFunction("CanShowHcontent");

        // activity partner:
        Lua.UnregisterFunction("CanActivityPartnerWaifu1");
        Lua.UnregisterFunction("CanActivityPartnerWaifu2");
        Lua.UnregisterFunction("CanActivityPartnerWaifu3");

        Lua.UnregisterFunction("IsActivityPartnerWaifu1");
        Lua.UnregisterFunction("IsActivityPartnerWaifu2");
        Lua.UnregisterFunction("IsActivityPartnerWaifu3");

        // activity:
        Lua.UnregisterFunction("CanDoActivity");

        // sexual:
        Lua.UnregisterFunction("CanShowHcontent");

        Lua.UnregisterFunction("IsRomancedWaifu1");
        Lua.UnregisterFunction("IsRomancedWaifu2");
        Lua.UnregisterFunction("IsRomancedWaifu3");

        Lua.UnregisterFunction("IsSexuallyComfortableWaifu1");
        Lua.UnregisterFunction("IsSexuallyComfortableWaifu2");
        Lua.UnregisterFunction("IsSexuallyComfortableWaifu3");



        // ===SCRIPT FUNCTIONS===

        // general:
        Lua.UnregisterFunction("SetFlag");
        Lua.UnregisterFunction("AddExp");

        Lua.UnregisterFunction("StartShooterStateMode");
        Lua.UnregisterFunction("StartVisualNovelStateMode");

        Lua.UnregisterFunction("TutorialDone");

        // HContent:
        Lua.UnregisterFunction("DialogueUIChangeHBackgroundL1");
        Lua.UnregisterFunction("DialogueUIChangeHBackgroundL2");

        Lua.UnregisterFunction("DialogueUIStartHcontentActivityBackground");
        Lua.UnregisterFunction("DialogueUINextHcontentActivityBackground");

        // activity partner:
        Lua.UnregisterFunction("SetActivityPartnerWaifu1");
        Lua.UnregisterFunction("SetActivityPartnerWaifu2");
        Lua.UnregisterFunction("SetActivityPartnerWaifu3");

        // activity:
        Lua.UnregisterFunction("SetActivity");
        Lua.UnregisterFunction("StartActivity");

        // character:
        Lua.UnregisterFunction("PartyAddWaifu1");
        Lua.UnregisterFunction("PartyAddWaifu2");
        Lua.UnregisterFunction("PartyAddWaifu3");

        Lua.UnregisterFunction("AddLeechShotAbilityMC");
        Lua.UnregisterFunction("AddShieldAbilityWaifu1");
        Lua.UnregisterFunction("AddTrapAbilityWaifu2");
        Lua.UnregisterFunction("AddWeakenAbilityWaifu3");

        // dialogue UI:
        Lua.UnregisterFunction("DialogueUIChangeBackgroundL1");
        Lua.UnregisterFunction("DialogueUIChangeBackgroundL2");
        Lua.UnregisterFunction("DialogueUIChangeBackgroundL1FromHavenActivity");
        Lua.UnregisterFunction("DialogueUIChangeBackgroundL1FromHavenLocationActivityHub");
        Lua.UnregisterFunction("DialogueUIChangeBackgroundL1FromHavenLocationEvent");

        Lua.UnregisterFunction("DialogueUIPortraitEnterWaifu1");
        Lua.UnregisterFunction("DialogueUIPortraitEnterWaifu2");
        Lua.UnregisterFunction("DialogueUIPortraitEnterWaifu3");

        Lua.UnregisterFunction("DialogueUIPortraitExitWaifu1");
        Lua.UnregisterFunction("DialogueUIPortraitExitWaifu2");
        Lua.UnregisterFunction("DialogueUIPortraitExitWaifu3");

        Lua.UnregisterFunction("DialogueUIChangeExpressionWaifu1");
        Lua.UnregisterFunction("DialogueUIChangeExpressionWaifu2");
        Lua.UnregisterFunction("DialogueUIChangeExpressionWaifu3");

        Lua.UnregisterFunction("DialogueUIAssignSpeakerMC");
        Lua.UnregisterFunction("DialogueUIAssignSpeakerWaifu1");
        Lua.UnregisterFunction("DialogueUIAssignSpeakerWaifu2");
        Lua.UnregisterFunction("DialogueUIAssignSpeakerWaifu3");

        Lua.UnregisterFunction("DialogueUISetOverrideSpeakerName");
        Lua.UnregisterFunction("DialogueUIRemoveSpeaker");



        // ===DIALOGUE TAG FUNCTIONS===

        Lua.UnregisterFunction("LevelingInfo");

        Lua.UnregisterFunction("CharNameActPartner");
        Lua.UnregisterFunction("CharNameWaifu1");
        Lua.UnregisterFunction("CharNameWaifu2");
        Lua.UnregisterFunction("CharNameWaifu3");
    }
Example #41
0
 /// <summary>
 /// Creates a new instance of <c>LuaFunctions</c>
 /// </summary>
 /// <param name="vm">Lua VM</param>
 /// <param name="conn">IRC connection</param>
 public LuaFunctions(ref Lua vm) : base(string.Empty)
 {
     _lua = vm;
 }
Example #42
0
 public static bool inCombat()
 {
     return(Lua.LuaDoString <bool>("local inCombat = UnitAffectingCombat('player'); return inCombat;"));
 }
Example #43
0
 // Return Main hand weapon type as a string
 public static string GetMHWeaponType()
 {
     return(Lua.LuaDoString <string>(@"local _, _, _, _, _, _, weapontype = 
                                         GetItemInfo(GetInventoryItemLink('player', 16)); return weapontype;"));
 }
Example #44
0
 public MemorySavestateEmuLuaLibrary(Lua lua)
     : base(lua)
 {
 }
Example #45
0
 public static int castTime(string spellname)
 {
     return(Lua.LuaDoString <int>("local name,_,time = GetSpellInfo(" + spellname + "); return time;"));
 }
Example #46
0
 public MemorySavestateEmuLuaLibrary(Lua lua, Action <string> logOutputCallback)
     : base(lua, logOutputCallback)
 {
 }
Example #47
0
        public static void RunQuest(object RunQuestOb)
        {
            Lua        lua       = new Lua();
            QFunctions functions = new QFunctions();

            //Updated In 1.1
            lua.RegisterFunction("AtXY", functions, functions.GetType().GetMethod("AtXY"));                                       //int x, int y, QPlayer Player
            lua.RegisterFunction("TileEdit", functions, functions.GetType().GetMethod("TileEdit"));                               //int x, int y, string tile
            lua.RegisterFunction("WallEdit", functions, functions.GetType().GetMethod("WallEdit"));                               //int x, int y, string wall
            lua.RegisterFunction("DeleteBoth", functions, functions.GetType().GetMethod("DeleteBoth"));                           //int x, int y
            lua.RegisterFunction("DeleteWall", functions, functions.GetType().GetMethod("DeleteWall"));                           //int x, int y
            lua.RegisterFunction("DeleteTile", functions, functions.GetType().GetMethod("DeleteTile"));                           //int x, int y
            lua.RegisterFunction("Sleep", functions, functions.GetType().GetMethod("Sleep"));                                     //int time
            lua.RegisterFunction("Teleport", functions, functions.GetType().GetMethod("Teleport"));                               //int x, int y, QPlayer Player
            lua.RegisterFunction("ClearKillList", functions, functions.GetType().GetMethod("ClearKillList"));                     //QPlayer Player
            lua.RegisterFunction("GoCollectItem", functions, functions.GetType().GetMethod("GoCollectItem"));                     //string itemname, int amount, QPlayer Player
            lua.RegisterFunction("TakeItem", functions, functions.GetType().GetMethod("TakeItem"));                               //string qname, string iname, int amt, QPlayer Player
            lua.RegisterFunction("GetRegionTilePercentage", functions, functions.GetType().GetMethod("GetRegionTilePercentage")); //string tiletype, string regionname
            lua.RegisterFunction("GetXYTilePercentage", functions, functions.GetType().GetMethod("GetXYTilePercentage"));         //string tiletype, int X, int Y, int Width, int Height
            lua.RegisterFunction("GetRegionWallPercentage", functions, functions.GetType().GetMethod("GetRegionWallPercentage")); //string walltype, string regionname
            lua.RegisterFunction("GetXYWallPercentage", functions, functions.GetType().GetMethod("GetXYWallPercentage"));         //string walltype, int X, int Y, int Width, int Height
            //Updated In 1.2
            lua.RegisterFunction("Give", functions, functions.GetType().GetMethod("Give"));                                       //string name, QPlayer Player
            lua.RegisterFunction("Kill", functions, functions.GetType().GetMethod("Kill"));                                       //string name, QPlayer Player, int amount = 1
            lua.RegisterFunction("KillNpc", functions, functions.GetType().GetMethod("KillNpc"));                                 //int id
            lua.RegisterFunction("StartQuest", functions, functions.GetType().GetMethod("StartQuest"));                           //string qname, QPlayer Player
            lua.RegisterFunction("ReadNextChatLine", functions, functions.GetType().GetMethod("ReadNextChatLine"));               //QPlayer Player, bool hide = false
            lua.RegisterFunction("SetNPCHealth", functions, functions.GetType().GetMethod("SetNPCHealth"));                       //int id, int health
            lua.RegisterFunction("Private", functions, functions.GetType().GetMethod("Private"));                                 //string message, QPlayer Player, Color color
            lua.RegisterFunction("Broadcast", functions, functions.GetType().GetMethod("Broadcast"));                             //string message, Color color
            lua.RegisterFunction("SpawnMob", functions, functions.GetType().GetMethod("SpawnMob"));                               //string name, int x, int y, int amount = 1

            var             parameters = (RunQuestParameters)RunQuestOb;
            QuestPlayerData qdata      = null;

            if ((qdata = GetPlayerQuestData(parameters.Quest.Name, parameters.Player)) != null)
            {
                qdata.Attempts++;
            }
            else
            {
                qdata = new QuestPlayerData(parameters.Quest.Name, false, 0);
                parameters.Player.MyDBPlayer.QuestPlayerData.Add(qdata);
                qdata.Attempts++;
            }
            parameters.Player.RunningQuests.Add(parameters.Quest.Name);
            object[] returnvalues = new object[1];
            try
            {
                lua["Player"] = parameters.Player;
                lua["Name"]   = parameters.Player.TSPlayer.Name;
                lua["QName"]  = parameters.Quest.Name;
                lua["Color"]  = new Color();
                returnvalues  = lua.DoFile(parameters.Quest.FilePath);

                if (returnvalues == null || returnvalues[0] == null || (bool)returnvalues[0])
                {
                    qdata.Complete = true;
                }
                UpdateStoredPlayersInDB();
                parameters.Player.RunningQuests.Remove(parameters.Quest.Name);
                parameters.Player.RunningQuestThreads.Remove(parameters);
            }
            catch (LuaException e)
            {
                Log.Error(e.Message);
                parameters.Player.RunningQuests.Remove(parameters.Quest.Name);
                parameters.Player.RunningQuestThreads.Remove(parameters);
                UpdateStoredPlayersInDB();
            }
            catch
            {
                parameters.Player.RunningQuests.Remove(parameters.Quest.Name);
                parameters.Player.RunningQuestThreads.Remove(parameters);
                UpdateStoredPlayersInDB();
            }
        }
Example #48
0
 string GetBindLocation()
 {
     return(Lua.GetReturnVal <string>("return GetBindLocation();", 0));
 }
Example #49
0
 public GuiLuaLibrary(Lua lua)
     : base(lua)
 {
 }
Example #50
0
 // Count the amount of the specified item stacks in your bags
 public static int CountItemStacks(string itemArg)
 {
     return(Lua.LuaDoString <int>("local count = GetItemCount('" + itemArg + "'); return count"));
 }
Example #51
0
 // Returns the cast time in milliseconds of the spell passed as argument
 public static float GetSpellCastTime(string spellName)
 {
     return(Lua.LuaDoString <float>("local name, rank, icon, cost, isFunnel, powerType, castTime, minRange, maxRange = GetSpellInfo('" + spellName + "'); return castTime"));
 }
Example #52
0
 public void CallExitEvent(Lua thread)
 {
     EventsLibrary.CallExitEvent(thread);
 }
 public SnesLuaLibrary(Lua lua)
     : base(lua)
 {
 }
Example #54
0
 protected LuaLibraryBase(Lua lua, Action <string> logOutputCallback)
     : this(lua)
 {
     LogOutputCallback = logOutputCallback;
 }
Example #55
0
        public bool Load(string FolderName, string ScenarioFileName, string FolderParentPath)
        {
            System.Text.Encoding encodeType = System.Text.Encoding.ASCII;

            //string MapPath = EnvPaths.GetMapsPath();

            string loadedFile = "";

            Debug.Log("Load file: " + FolderParentPath + FolderName + "/" + ScenarioFileName + ".lua");
            string loc = FolderParentPath + FolderName + "/" + ScenarioFileName + ".lua";

            loadedFile = System.IO.File.ReadAllText(loc, encodeType);

            LuaFile = new Lua();
            LuaFile.LoadCLRPackage();
            try
            {
                LuaFile.DoString(MapLuaParser.Current.SaveLuaHeader.text + loadedFile);
            }
            catch (NLua.Exceptions.LuaException e)
            {
                Debug.LogError(LuaParser.Read.FormatException(e), MapLuaParser.Current.gameObject);
                //HelperGui.MapLoaded = false;
                return(false);
            }

            // Load Map Prop
            LuaTable ScenarioInfoTab = LuaFile.GetTable(TABLE_SCENARIOINFO);

            Data.name        = LuaParser.Read.StringFromTable(ScenarioInfoTab, ScenarioInfo.KEY_NAME);
            Data.description = LuaParser.Read.StringFromTable(ScenarioInfoTab, ScenarioInfo.KEY_DESCRIPTION);
            Data.type        = LuaParser.Read.StringFromTable(ScenarioInfoTab, ScenarioInfo.KEY_TYPE);
            Data.starts      = LuaParser.Read.BoolFromTable(ScenarioInfoTab, ScenarioInfo.KEY_STARTS, true);

            Data.map_version = LuaParser.Read.FloatFromTable(ScenarioInfoTab, ScenarioInfo.KEY_MAPVERSION, 1);

            Data.AdaptiveMap = LuaParser.Read.BoolFromTable(ScenarioInfoTab, ScenarioInfo.KEY_ADAPTIVEMAP, false);

            Data.preview = LuaParser.Read.StringFromTable(ScenarioInfoTab, ScenarioInfo.KEY_PREVIEW, "");
            Data.save    = LuaParser.Read.StringFromTable(ScenarioInfoTab, ScenarioInfo.KEY_SAVE, "");
            Data.map     = LuaParser.Read.StringFromTable(ScenarioInfoTab, ScenarioInfo.KEY_MAP, "");
            Data.script  = LuaParser.Read.StringFromTable(ScenarioInfoTab, ScenarioInfo.KEY_SCRIPT, "");
            Data.Size    = LuaParser.Read.IntArrayFromTable((LuaTable)ScenarioInfoTab.RawGet(ScenarioInfo.KEY_SIZE), 512);

            object ReclaimTable = ScenarioInfoTab.RawGet(ScenarioInfo.KEY_RECLAIM);

            if (ReclaimTable != null)
            {
                Data.Reclaim = LuaParser.Read.FloatArrayFromTable((LuaTable)ReclaimTable, 0);
            }
            else
            {
                Data.Reclaim = new float[2];
            }

            Data.MaxHeight = 128;
            //CamControll.MapSize = Mathf.Max(ScenarioData.Size.x, ScenarioData.Size.y);
            //CamControll.RestartCam();

            List <string> AllArmys = new List <string>();

            LuaTable ConfigurationsTable = LuaFile.GetTable(TABLE_SCENARIOINFO + "." + ScenarioInfo.KEY_CONFIGURATIONS);


            string[] ConfKeys = LuaParser.Read.GetTableKeys(ConfigurationsTable);
            Data.Configurations = new Configuration[ConfKeys.Length];
            for (int Ct = 0; Ct < Data.Configurations.Length; Ct++)
            {
                Data.Configurations[Ct]      = new Configuration();
                Data.Configurations[Ct].name = ConfKeys[Ct];

                // Teams
                LuaTable[] TeamsTables = LuaParser.Read.TableArrayFromTable(
                    LuaFile.GetTable(TABLE_SCENARIOINFO + "." + ScenarioInfo.KEY_CONFIGURATIONS + "." + ConfKeys[Ct] + "." + Configuration.KEY_TEAMS)
                    );

                Data.Configurations[Ct].Teams = new Team[TeamsTables.Length];
                for (int T = 0; T < Data.Configurations[Ct].Teams.Length; T++)
                {
                    Data.Configurations[Ct].Teams[T]      = new Team();
                    Data.Configurations[Ct].Teams[T].name = LuaParser.Read.StringFromTable(TeamsTables[T], Team.KEY_NAME, "FFA");
                    //Data.Configurations[Ct].Teams[T].Armys = LuaParser.Read.StringArrayFromTable(TeamsTables[T], Team.KEY_ARMIES);
                    string[] ArmyArray = LuaParser.Read.StringArrayFromTable(TeamsTables[T], Team.KEY_ARMIES);
                    Data.Configurations[Ct].Teams[T].ArmysFromStringArray(ArmyArray, ScenarioInfoTab);
                    AllArmys.AddRange(ArmyArray);
                }

                // Custom Props
                LuaTable CustomPropsTable = LuaFile.GetTable(TABLE_SCENARIOINFO + "." + ScenarioInfo.KEY_CONFIGURATIONS + "." + ConfKeys[Ct] + "." + Configuration.KEY_CUSTOMPROPS);

                string[] CustomPropsKeys   = LuaParser.Read.GetTableKeys(CustomPropsTable);
                string[] CustomPropsValues = LuaParser.Read.GetTableValues(CustomPropsTable);
                Data.Configurations[Ct].customprops = new CustomProps[CustomPropsKeys.Length];
                for (int cp = 0; cp < CustomPropsKeys.Length; cp++)
                {
                    Data.Configurations[Ct].customprops[cp]       = new CustomProps();
                    Data.Configurations[Ct].customprops[cp].key   = CustomPropsKeys[cp];
                    Data.Configurations[Ct].customprops[cp].value = CustomPropsValues[cp];
                }

                Data.Configurations[Ct].ArmysFromCustomProps(ScenarioInfoTab);

                // Factions
                LuaTable[] FactionsTables = LuaParser.Read.TableArrayFromTable(
                    LuaFile.GetTable(TABLE_SCENARIOINFO + "." + ScenarioInfo.KEY_CONFIGURATIONS + "." + ConfKeys[Ct] + "." + Configuration.KEY_FACTIONS)
                    );
                Data.Configurations[Ct].factions = new Factions[FactionsTables.Length];

                for (int i = 0; i < Data.Configurations[Ct].factions.Length; i++)
                {
                    Data.Configurations[Ct].factions[i]        = new Factions();
                    Data.Configurations[Ct].factions[i].Values = LuaParser.Read.StringArrayFromTable(FactionsTables[i]);
                }
            }

            if (Data.Configurations == null || Data.Configurations.Length == 0)
            {
                Data.Configurations                   = new Configuration[1];
                Data.Configurations[0]                = new Configuration();
                Data.Configurations[0].name           = "standard";
                Data.Configurations[0].Teams          = new Team[1];
                Data.Configurations[0].Teams[0]       = new Team();
                Data.Configurations[0].Teams[0].name  = "FFA";
                Data.Configurations[0].Teams[0].Armys = new List <Army>();
                Data.Configurations[0].ExtraArmys     = new List <Army>();
                Data.Configurations[0].customprops    = new CustomProps[0];
            }


            //All NoRushOffsets
            Data.norushradius = LuaParser.Read.FloatFromTable(ScenarioInfoTab, NoRusnOffset.VALUE_RADIUS, NoRusnOffset.DefaultRadius);

            /*
             * Data.NoRushOffsets = new NoRusnOffset[AllArmys.Count];
             * for(int i = 0; i < AllArmys.Count; i++)
             * {
             *      Data.NoRushOffsets[i] = new NoRusnOffset();
             *      Data.NoRushOffsets[i].ARMY = AllArmys[i];
             *
             *      Data.NoRushOffsets[i].X = LuaParser.Read.FloatFromTable(ScenarioInfoTab, NoRusnOffset.VALUE_X + AllArmys[i], 0);
             *      Data.NoRushOffsets[i].Y = LuaParser.Read.FloatFromTable(ScenarioInfoTab, NoRusnOffset.VALUE_Y + AllArmys[i], 0);
             * }
             */

            return(true);
        }
Example #56
0
 /*
  * Dispose()
  * When product stopped
  */
 public void Dispose()
 {
     _isRunning = false;
     Logging.Write(name + " Stop in progress.");
     Lua.LuaDoString(@"dRotationFrame.text:SetText(""Stopped!"")");
 }
Example #57
0
 public static float GetSpellCooldownCharges(string spellName)
 {
     return(Lua.LuaDoString <float>("local _, _, startTime, duration = GetSpellCharges('" + spellName + "'); return duration - (GetTime() - startTime)"));
 }
Example #58
0
    // Returns the cooldown of the pet spell passed as argument
    public static int GetPetSpellCooldown(string spellName)
    {
        int _spellIndex = GetPetSpellIndex(spellName);

        return(Lua.LuaDoString <int>("local startTime, duration, enable = GetPetActionCooldown(" + _spellIndex + "); return duration - (GetTime() - startTime)"));
    }
Example #59
0
 public ConsoleLuaLibrary(Lua lua, Action <string> logOutputCallback)
     : base(lua, logOutputCallback)
 {
 }
Example #60
0
 public Game_Screen(World _world, GameCamera _camera, PenumbraComponent _lighting, Particle_World _particle_world, Physics_Engine _physics_engine, Lua _lua, GraphicsDevice _device, string _id) : base(_id)
 {
     world          = _world;
     camera         = _camera;
     lighting       = _lighting;
     particle_world = _particle_world;
     physics_engine = _physics_engine;
     lua            = _lua;
     device         = _device;
 }