Quantcast

Fix generate.lua to work after WoWAPI module changes.

Johnny C. Lam [07-13-14 - 11:30]
Fix generate.lua to work after WoWAPI module changes.

git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1534 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
generate.lua
diff --git a/generate.lua b/generate.lua
index 16122cc..1531fd4 100644
--- a/generate.lua
+++ b/generate.lua
@@ -1,38 +1,53 @@
+--[[------------------------------
+	Load fake WoW environment.
+--]]------------------------------
+local root = "../"
 do
+	local state = {
+		class = "DRUID",
+	}
 	dofile("WoWAPI.lua")
+	WoWAPI:Initialize("Ovale", state)
+	WoWAPI:ExportSymbols()
+end

-	Ovale = {}
-	LoadAddonFile("OvaleLexer.lua")
-	LoadAddonFile("OvaleSimulationCraft.lua")
-	local OvaleSimulationCraft = Ovale.OvaleSimulationCraft
-
-	local profilesDirectory = "..\\SimulationCraft\\profiles\\Tier16H"
-	local outputDirectory = "scripts"
-
-	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 = "simulationcraft_" .. string.lower(string.gsub(filename, ".simc", ".lua"))
-				outputFileName = string.gsub(outputFileName, "death_knight", "deathknight")
-				print("Generating " .. outputFileName)
-				local outputName = outputDirectory .. "/" .. outputFileName
-				io.output(outputName)
-				io.write(table.concat(simc:GenerateScript(), "\n"))
-			end
+do
+	-- Load all of the addon files.
+	WoWAPI:LoadAddonFile("Ovale.toc")
+
+	-- Pretend to fire ADDON_LOADED event.
+	local AceAddon = LibStub("AceAddon-3.0")
+	AceAddon:ADDON_LOADED()
+end
+
+local OvaleSimulationCraft = Ovale.OvaleSimulationCraft
+
+local profilesDirectory = "..\\SimulationCraft\\profiles\\Tier16H"
+local outputDirectory = "scripts"
+
+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 = "simulationcraft_" .. string.lower(string.gsub(filename, ".simc", ".lua"))
+			outputFileName = string.gsub(outputFileName, "death_knight", "deathknight")
+			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
+io.input(saveInput)
+io.output(saveOutput)