Quantcast

Add Lua program to generate Ovale scripts from SimC profiles.

Johnny C. Lam [04-21-14 - 05:03]
Add Lua program to generate Ovale scripts from SimC profiles.

This program reads the hard-coded directory containing SimC profiles and
outputs the scripts to a "profiles" subdirectory in the current directory.

git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1314 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
OvaleSimulationCraft.lua
generate.lua
diff --git a/OvaleSimulationCraft.lua b/OvaleSimulationCraft.lua
index f8dba14..1542a8c 100644
--- a/OvaleSimulationCraft.lua
+++ b/OvaleSimulationCraft.lua
@@ -481,7 +481,7 @@ do
 					if needAnd then
 						tinsert(scriptLine, "and")
 					end
-					tinsert(scriptLine, "BuffStacks(pet_frenzy any=1) == 5")
+					tinsert(scriptLine, "pet.BuffStacks(pet_frenzy_buff any=1) == 5")
 					needAnd = true
 				end
 				if action == "stance" and scriptLine.choose then
@@ -632,6 +632,10 @@ do
 		["^buff%.wild_mushroom%.stack$"] = "WildMushroomCount()",
 		-- Hunter
 		["^debuff%.ranged_vulnerability%.up$"] = "target.DebuffPresent(ranged_vulnerability any=1)",
+		["^buff%.beast_cleave$.down$"] = function(simc, action)
+				tinsert(simc.symbols, "pet_beast_cleave_buff")
+				return "pet.BuffExpires(pet_beast_cleave_buff any=1)"
+			end,
 		-- Mage
 		["^buff%.arcane_charge%.stack$"] = function(simc, action)
 				tinsert(simc.symbols, "arcane_charge_debuff")
diff --git a/generate.lua b/generate.lua
new file mode 100644
index 0000000..c3dafdc
--- /dev/null
+++ b/generate.lua
@@ -0,0 +1,37 @@
+do
+	dofile("WoWAPI.lua")
+
+	Ovale = {}
+	LoadAddonFile("OvaleLexer.lua")
+	LoadAddonFile("OvaleSimulationCraft.lua")
+	local OvaleSimulationCraft = Ovale.OvaleSimulationCraft
+
+	local profilesDirectory = "..\\SimulationCraft\\profiles\\Tier16H"
+	local outputDirectory = "profiles"
+
+	local saveInput = io.input()
+	local saveOutput = io.output()
+
+	local dir = io.popen("dir /b " .. profilesDirectory)
+	os.execute("mkdir " .. outputDirectory)
+	for filename in dir:lines() do
+		if string.match(filename, "^[A-Z]") then
+			local inputName = string.gsub(profilesDirectory, "\\", "/") .. "/" .. filename
+			io.input(inputName)
+			local simcStr = io.read("*all")
+			if not string.find(simcStr, "optimal_raid=") then
+				local simc = OvaleSimulationCraft(simcStr)
+				simc.simcComments = true
+
+				local outputFileName = string.gsub(filename, ".simc", ".txt")
+				print("Generating " .. outputFileName)
+				local outputName = outputDirectory .. "/" .. outputFileName
+				io.output(outputName)
+				io.write(table.concat(simc:GenerateScript(), "\n"))
+			end
+		end
+	end
+
+	io.input(saveInput)
+	io.output(saveOutput)
+end
\ No newline at end of file