public static bool GenerateLUAFile(bool reloadUI = true) { try { if (!Directory.Exists(AddonPath)) { Directory.CreateDirectory(AddonPath); } if (!Directory.Exists(LibBossPath)) { Directory.CreateDirectory(LibBossPath); } if (!Directory.Exists(LibStubPath)) { Directory.CreateDirectory(LibStubPath); } if (!Directory.Exists(LibRangePath)) { Directory.CreateDirectory(LibRangePath); } if (!Directory.Exists(LibRangeStubPath)) { Directory.CreateDirectory(LibRangeStubPath); } Log.Write($"Creating Addon from SpellBook, AddonName will be [{AddonName}]..."); Log.Write($"Creating file: [{AddonName}.toc]", Color.Gray); using (var sr = new StreamWriter($"{AddonPath}\\{AddonName}.toc")) { // ## Author: WiNiFiX // ## Interface: 60200 // ## Title: DoIt // ## Version: 1.0.0 // ## SavedVariablesPerCharacter: DoItOptions // DoItBase.lua sr.WriteLine($"## Author: {AddonAuthor.Replace("\r", "").Replace("\n", "")}"); sr.WriteLine($"## Interface: {NumericInterfaceVersion}"); sr.WriteLine($"## Title: {AddonName.Replace("\r", "").Replace("\n", "")}"); sr.WriteLine($"## Version: {Application.ProductVersion}"); sr.WriteLine($"## SavedVariablesPerCharacter: {AddonName.Replace("\r", "").Replace("\n", "")}_settings"); sr.WriteLine($"{AddonName.Replace("\r", "").Replace("\n", "")}.lua"); sr.WriteLine(@"#@no-lib-strip@"); sr.WriteLine("BossLib.xml"); sr.WriteLine("RangeLib.xml"); sr.WriteLine(@"#@end-no-lib-strip@"); sr.Close(); } ///////////////////////////////////////////////////////////////////////////////////////////////// BOSS LIB ///////////////////////////////////////// Log.Write("Creating file: [BossLib.xml]", Color.Gray); using (var sr = new StreamWriter($"{AddonPath}\\BossLib.xml")) { sr.WriteLine(@"<Ui xmlns=""http://www.blizzard.com/wow/ui/"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xsi:schemaLocation=""http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd"">"); sr.WriteLine(@"<Script file=""Boss\LibStub\LibStub.lua""/>"); sr.WriteLine(@"<Include file=""Boss\lib.xml""/>"); sr.WriteLine(@"</Ui>"); sr.Close(); } Log.Write("Creating file: [Boss\\LibBossIDs-1.0.toc]", Color.Gray); using (var sr = new StreamWriter($"{LibBossPath}\\LibBossIDs-1.0.toc")) { sr.WriteLine(InterfaceVersion.Contains("-")? $"## Interface: {InterfaceVersion.Split('-')[1].Trim()}" : $"## Interface: {InterfaceVersion}"); sr.WriteLine("## LoadOnDemand: 1"); sr.WriteLine("## Title: Lib: BossIDs-1.0"); sr.WriteLine("## A library to provide mobIDs for bosses."); sr.WriteLine("## Author: Elsia"); sr.WriteLine("## X-Category: Library"); sr.WriteLine("## X-License: Public Domain"); sr.WriteLine("## X-Curse-Packaged-Version: r97-release"); sr.WriteLine("## X-Curse-Project-Name: LibBossIDs-1.0"); sr.WriteLine("## X-Curse-Project-ID: libbossids-1-0"); sr.WriteLine("## X-Curse-Repository-ID: wow/libbossids-1-0/mainline"); sr.WriteLine("LibStub\\LibStub.lua"); sr.WriteLine("lib.xml"); sr.Close(); } Log.Write("Creating file: [Boss\\lib.xml]", Color.Gray); using (var sr = new StreamWriter($"{AddonPath}\\Boss\\lib.xml")) { sr.WriteLine(@"<Ui xmlns=""http://www.blizzard.com/wow/ui/"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xsi:schemaLocation=""http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd"">"); sr.WriteLine(@"<Script file=""LibBossIDs-1.0.lua"" />"); sr.WriteLine("</Ui>"); sr.Close(); } Log.Write("Creating file: [Boss\\LibBossIDs-1.0.lua]", Color.Gray); using (var sr = new StreamWriter($"{AddonPath}\\Boss\\LibBossIDs-1.0.lua")) { var luaContents1 = AddonLibBoss.LuaContents; sr.WriteLine(luaContents1); sr.Close(); } Log.Write("Creating file: [Boss\\LibStub\\LibStub.lua]", Color.Gray); using (var sr = new StreamWriter($"{AddonPath}\\Boss\\LibStub\\LibStub.lua")) { var luaContents2 = AddonLibStub.LuaContents; sr.WriteLine(luaContents2); sr.Close(); } ///////////////////////////////////////////////////////////////////////////////////////////////// RANGE LIB ///////////////////////////////////////// Log.Write("Creating file: [RangeLib.xml]", Color.Gray); using (var sr = new StreamWriter($"{AddonPath}\\RangeLib.xml")) { sr.WriteLine(@"<Ui xmlns=""http://www.blizzard.com/wow/ui/"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xsi:schemaLocation=""http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd"">"); sr.WriteLine(@"<Script file=""Range\LibStub\LibStub.lua""/>"); sr.WriteLine(@"<Include file=""Range\lib.xml""/>"); sr.WriteLine(@"</Ui>"); sr.Close(); } Log.Write("Creating file: [Range\\LibSpellRange - 1.0.toc]", Color.Gray); using (var sr = new StreamWriter($"{LibRangePath}\\LibSpellRange-1.0.toc")) { sr.WriteLine(InterfaceVersion.Contains("-") ? $"## Interface: {InterfaceVersion.Split('-')[1].Trim()}" : $"## Interface: {InterfaceVersion}"); sr.WriteLine("## LoadOnDemand: 1"); sr.WriteLine("## Title: Lib: SpellRange-1.0"); sr.WriteLine("## Notes: Provides enhanced spell range checking functionality"); sr.WriteLine("## Author: Cybeloras of Aerie Peak"); sr.WriteLine("## X-Category: Library"); sr.WriteLine("## X-License: Public Domain"); sr.WriteLine("## X-Curse-Packaged-Version: 1.0.011"); sr.WriteLine("## X-Curse-Project-Name: LibSpellRange-1.0"); sr.WriteLine("## X-Curse-Project-ID: libspellrange-1-0"); sr.WriteLine("## X-Curse-Repository-ID: wow/libspellrange-1-0/mainline"); sr.WriteLine("LibStub\\LibStub.lua"); sr.WriteLine("lib.xml"); sr.Close(); } Log.Write("Creating file: [Range\\lib.xml]", Color.Gray); using (var sr = new StreamWriter($"{AddonPath}\\Range\\lib.xml")) { sr.WriteLine(@"<Ui xmlns=""http://www.blizzard.com/wow/ui/"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xsi:schemaLocation=""http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd"">"); sr.WriteLine(@"<Script file=""LibSpellRange-1.0.lua"" />"); sr.WriteLine("</Ui>"); sr.Close(); } Log.Write("Creating file: [Range\\LibSpellRange-1.0.lua]", Color.Gray); using (var sr = new StreamWriter($"{AddonPath}\\Range\\LibSpellRange-1.0.lua")) { var luaContents = AddonLibRange.LuaContents; sr.WriteLine(luaContents); sr.Close(); } Log.Write("Creating file: [Range\\LibStub\\LibStub.lua]", Color.Gray); using (var sr = new StreamWriter($"{AddonPath}\\Range\\LibStub\\LibStub.lua")) { var luaContents = AddonLibStubRange.LuaContents; sr.WriteLine(luaContents); sr.Close(); } Log.Write($"Creating file: [{AddonName}.lua]", Color.Gray); using (var sr = new StreamWriter($"{AddonPath}\\{AddonName}.lua")) { //local cooldowns = { --These should be spellIDs for the spell you want to track for cooldowns // 56641, -- Steadyshot // 3044, -- Arcane Shot // 34026 -- Kill Command //} var cooldowns = "local cooldowns = { --These should be spellIDs for the spell you want to track for cooldowns" + Environment.NewLine; foreach (var spell in Spells) { if (spell.InternalSpellNo == Spells.Count) // We are adding the last spell, dont include the comma { cooldowns += $" {spell.SpellId} \t -- {spell.SpellName}" + Environment.NewLine; } else { cooldowns += $" {spell.SpellId},\t -- {spell.SpellName}" + Environment.NewLine; } } cooldowns += "}" + Environment.NewLine; sr.Write(cooldowns); var auras = "local buffs = { --These should be auraIDs for the spell you want to track " + Environment.NewLine; foreach (var aura in Auras) { if (aura.InternalAuraNo == Auras.Count) // We are adding the last aura, dont include the comma { auras += $" {aura.AuraId} \t -- {aura.AuraName}" + Environment.NewLine; } else { auras += $" {aura.AuraId},\t -- {aura.AuraName}" + Environment.NewLine; } } auras += "}" + Environment.NewLine; sr.Write(auras); var debuffs = "local debuffs = { --These should be auraIDs for the spell you want to track " + Environment.NewLine; foreach (var aura in Auras) { if (aura.InternalAuraNo == Auras.Count) // We are adding the last aura, dont include the comma { debuffs += $" {aura.AuraId} \t -- {aura.AuraName}" + Environment.NewLine; } else { debuffs += $" {aura.AuraId},\t -- {aura.AuraName}" + Environment.NewLine; } } debuffs += "}" + Environment.NewLine; sr.Write(debuffs); var items = "local items = { --These should be itemIDs for the items you want to track " + Environment.NewLine; foreach (var item in Items) { if (item.ItemId == Items.Count) // We are adding the last item, dont include the comma { items += $" {item.ItemId} \t -- {item.ItemName}" + Environment.NewLine; } else { items += $" {item.ItemId},\t -- {item.ItemName}" + Environment.NewLine; } } items += "}" + Environment.NewLine; sr.Write(items); var luaContents = Addon.LuaContents; luaContents = luaContents.Replace("[PixelMagic]", AddonName); sr.WriteLine(luaContents); sr.Close(); } Log.Write("Addon file generated.", Color.Green); CustomLua(); Log.Write($"Make sure that the addon: [{AddonName}] is enabled in your list of WoW Addons or the rotation bot will fail to work", Color.Black); if (reloadUI) { WoW.SendMacro("/reload"); } return(true); } catch (Exception ex) { Log.Write("Failed to generate addon file:", Color.Red); Log.Write(ex.Message, Color.Red); return(false); } }
public static bool GenerateLUAFile(bool reloadUI = true) { try { if (!Directory.Exists(AddonPath)) { Directory.CreateDirectory(AddonPath); } Log.Write($"Creating Addon from SpellBook, AddonName will be [{AddonName}]..."); Log.Write($"Creating file: [{AddonName}.toc]", Color.Gray); using (var sr = new StreamWriter($"{AddonPath}\\{AddonName}.toc")) { // ## Author: WiNiFiX // ## Interface: 60200 // ## Title: DoIt // ## Version: 1.0.0 // ## SavedVariablesPerCharacter: DoItOptions // DoItBase.lua sr.WriteLine($"## Author: {AddonAuthor.Replace("\r", "").Replace("\n", "")}"); if (InterfaceVersion.Contains("-")) { sr.WriteLine($"## Interface: {InterfaceVersion.Split('-')[1].Trim()}"); } else { sr.WriteLine($"## Interface: {InterfaceVersion}"); } sr.WriteLine($"## Title: {AddonName.Replace("\r", "").Replace("\n", "")}"); sr.WriteLine($"## Version: {Application.ProductVersion}"); sr.WriteLine($"## SavedVariablesPerCharacter: {AddonName.Replace("\r", "").Replace("\n", "")}_settings"); sr.WriteLine($"{AddonName.Replace("\r", "").Replace("\n", "")}.lua"); sr.Close(); } Log.Write($"Creating file: [{AddonName}.lua]", Color.Gray); using (var sr = new StreamWriter($"{AddonPath}\\{AddonName}.lua")) { //local cooldowns = { --These should be spellIDs for the spell you want to track for cooldowns // 56641, -- Steadyshot // 3044, -- Arcane Shot // 34026 -- Kill Command //} var cooldowns = "local cooldowns = { --These should be spellIDs for the spell you want to track for cooldowns" + Environment.NewLine; foreach (var spell in Spells) { if (spell.InternalSpellNo == Spells.Count) // We are adding the last spell, dont include the comma { cooldowns += $" {spell.SpellId} \t -- {spell.SpellName}" + Environment.NewLine; } else { cooldowns += $" {spell.SpellId},\t -- {spell.SpellName}" + Environment.NewLine; } } cooldowns += "}" + Environment.NewLine; sr.Write(cooldowns); var auras = "local buffs = { --These should be auraIDs for the spell you want to track " + Environment.NewLine; foreach (var aura in Auras) { if (aura.InternalAuraNo == Auras.Count) // We are adding the last aura, dont include the comma { auras += $" {aura.AuraId} \t -- {aura.AuraName}" + Environment.NewLine; } else { auras += $" {aura.AuraId},\t -- {aura.AuraName}" + Environment.NewLine; } } auras += "}" + Environment.NewLine; sr.Write(auras); var debuffs = "local debuffs = { --These should be auraIDs for the spell you want to track " + Environment.NewLine; foreach (var aura in Auras) { if (aura.InternalAuraNo == Auras.Count) // We are adding the last aura, dont include the comma { debuffs += $" {aura.AuraId} \t -- {aura.AuraName}" + Environment.NewLine; } else { debuffs += $" {aura.AuraId},\t -- {aura.AuraName}" + Environment.NewLine; } } debuffs += "}" + Environment.NewLine; sr.Write(debuffs); var luaContents = Addon.LuaContents; luaContents = luaContents.Replace("DoIt", AddonName); string AddonInterfaceVersion = InterfaceVersion; if (InterfaceVersion.Contains("-")) { AddonInterfaceVersion = InterfaceVersion.Split('-')[1].Trim(); } if (AddonInterfaceVersion == "70000") // Legion changes as per http://www.wowinterface.com/forums/showthread.php?t=53248 { luaContents = luaContents.Replace("SetTexture", "SetColorTexture"); // For now the below are disabled till further testing is done // luaContents = luaContents.Replace(@"UnitPower(""player"");", @"UnitPower(""player"", UnitPowerType(""player""))"); // luaContents = luaContents.Replace(@"UnitPowerMax(""player"");", @"UnitPowerMax(""player"", UnitPowerType(""player""))"); } sr.WriteLine(luaContents); sr.Close(); } Log.Write("Addon file generated.", Color.Green); Log.Write($"Make sure that the addon: [{AddonName}] is enabled in your list of WoW Addons or the rotation bot will fail to work", Color.Black); if (reloadUI) { WoW.SendMacro("/console scriptErrors 1"); // Show wow Lua errors WoW.SendMacro("/reload"); } return(true); } catch (Exception ex) { Log.Write("Failed to generate addon file:", Color.Red); Log.Write(ex.Message, Color.Red); return(false); } }