Jump to content

How can I run Lua.LuaString a set amount of times?


Zan

Recommended Posts

18 minutes ago, Zan said:

How can i run Lua.LuaDoString 5 times rather than have 5 lines in my code?

i'm not sure and did not test it but try

Lua.LuaDoString(new List<string>() { "FirstCommand", "Second command", "ThirdCommand" });

 

Link to comment
Share on other sites

Hello, iMod method is good, but you can also use @ http://net-informations.com/q/faq/multilines.html (method 1) like:

  int numberPetAlive = Lua.LuaDoString<int>(@"  local aliveCount = 0;
                                                for p=1, 3 do
	                                                local petID, ability1ID, ability2ID, ability3ID, locked = C_PetJournal.GetPetLoadOutInfo(p);
	                                                if petID then
		                                                local health, maxHealth, _ = C_PetJournal.GetPetStats(petID);
		                                                if health > 0 then
			                                                aliveCount = aliveCount + 1;
		                                                end
	                                                end
                                                end
                                                return aliveCount;");

 

Link to comment
Share on other sites

  • 2 months later...

I found an easy way that could be used universally with c#:

private static void RepeatAction(int repeatCount, Action action)
        {
            for (int i = 0; i < repeatCount; i++)
                action();
        }

Then in the profile:

RepeatAction(5, () => 
{                          
	// Action to repeat 5 times.
});

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...