Jump to content

C# Lua to Multiple Variables


Brian
 Share

Recommended Posts

So, I know you can do this

string name = Lua.LuaDoString<string>("name = UnitAura('player', 'BUFF_NAME'); return name; ");
string rank = Lua.LuaDoString<string>("name,rank = UnitAura('player', 'BUFF_NAME'); return rank; ");
string icon = Lua.LuaDoString<string>("name,rank,icon = UnitAura('player', 'BUFF_NAME'); return icon; ");
  //etc.. for all

Is there a better way to return all the different properties of UnitAura into c# variables?

Link to comment
Share on other sites

If i see this example from Droidz (http://wrobot.eu/forums/topic/2493-luascript-in-is-complete-condition/), it's not possible

        int shipmentCapacity = wManager.Wow.Helpers.Lua.LuaDoString<int>("local name, texture, shipmentCapacity, shipmentsTotal, creationTime, duration, timeLeftString, itemName, itemIcon, itemQuality, itemID = C_Garrison.GetLandingPageShipmentInfo(); return shipmentCapacity;");
        int shipmentsTotal = wManager.Wow.Helpers.Lua.LuaDoString<int>("local name, texture, shipmentCapacity, shipmentsTotal, creationTime, duration, timeLeftString, itemName, itemIcon, itemQuality, itemID = C_Garrison.GetLandingPageShipmentInfo(); return shipmentsTotal;");
        return shipmentsTotal >= shipmentCapacity;

I tried to return in a structure or in a Tuple, but that is not possible too

Link to comment
Share on other sites

Hello, like this:

        var r = Lua.LuaDoString<List<string>>(
            string.Format(@"local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, canStealOrPurge, shouldConsolidate, spellId, canApplyAura, isBossDebuff, isCastByPlayer = UnitAura('player', 'BUFF_NAME');
                            return name .. '{0}' .. rank .. '{0}' .. icon;", Lua.ListSeparator));

        if (r != null && r.Count == 3)
        {
            var name = r[0];
            var rank = r[1];
            var icon = r[2];
        }

 

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
 Share

×
×
  • Create New...