Quantcast

Fix for nil trainer and escape double-quotes in trainer names so they'll dump properly. Damn "\"Cookie\" McWeaksauce".

James D. Callahan III [03-13-11 - 22:12]
Fix for nil trainer and escape double-quotes in trainer names so they'll dump properly. Damn "\"Cookie\" McWeaksauce".
Filename
Scanner.lua
diff --git a/Scanner.lua b/Scanner.lua
index 9d0e7d6..f025f73 100644
--- a/Scanner.lua
+++ b/Scanner.lua
@@ -592,10 +592,12 @@ do
 			local trainer = private.trainer_list[identifier]
 			local trainer_name

-			if trainer.spell_id then
-				table.insert(output, ("AddTrainer(%s, %s, \"%s\", %s, %s, \"%s\")"):format(identifier, trainer.spell_id, trainer.location, trainer.coord_x, trainer.coord_y, trainer.faction))
-			else
-				table.insert(output, ("AddTrainer(%s, \"%s\", \"%s\", %s, %s, \"%s\")"):format(identifier, trainer.name, trainer.location, trainer.coord_x, trainer.coord_y, trainer.faction))
+			if trainer then
+				if trainer.spell_id then
+					table.insert(output, ("AddTrainer(%s, %s, \"%s\", %s, %s, \"%s\")"):format(identifier, trainer.spell_id, trainer.location, trainer.coord_x, trainer.coord_y, trainer.faction))
+				else
+					table.insert(output, ("AddTrainer(%s, \"%s\", \"%s\", %s, %s, \"%s\")"):format(identifier, trainer.name:gsub("\"", "\\\""), trainer.location, trainer.coord_x, trainer.coord_y, trainer.faction))
+				end
 			end
 		end
 		addon:DisplayTextDump(nil, nil, table.concat(output, "\n"))