shithub: pokecrystal

Download patch

ref: cb5eae3e9de8c1a79ce6b69a70fb4a5dd0b73d9b
parent: c16d796c27ad011f409f2110cf3e50b94198812a
author: Bryan Bishop <[email protected]>
date: Tue May 22 07:44:42 EDT 2012

check if trainer_names has been set yet before using that key

--- a/extras/crystal.py
+++ b/extras/crystal.py
@@ -1719,7 +1719,8 @@
         trainer_group_id = self.parent.params[foundit].byte
 
         # check the rule to see whether to use an id or not
-        if "uses_numeric_trainer_ids" in trainer_group_names[trainer_group_id].keys():
+        if ("uses_numeric_trainer_ids" in trainer_group_names[trainer_group_id].keys()) or \
+           (not "trainer_names" in trainer_group_names[trainer_group_id].keys()):
             return str(self.byte)
         else:
             return trainer_group_names[trainer_group_id]["trainer_names"][self.byte-1]
@@ -1743,6 +1744,7 @@
     pass
 
 
+string_to_text_texts = []
 class RawTextPointerLabelParam(PointerLabelParam):
     #not sure if these are always to a text script or raw text?
     def parse(self):
@@ -1754,6 +1756,8 @@
         #self.text = TextScript(address, map_group=self.map_group, map_id=self.map_id, debug=self.debug)
         self.text = parse_text_engine_script_at(address, map_group=self.map_group, map_id=self.map_id, debug=self.debug)
 
+        string_to_text_texts.append(self.text)
+
     def get_dependencies(self, recompute=False, global_dependencies=set()):
         global_dependencies.add(self.text)
         return [self.text]
@@ -3439,9 +3443,11 @@
 
         # give this object a possibly better label
         label = "Trainer"
-        if "uses_numeric_trainer_ids" in trainer_group_names[trainer_group].keys():
+        if ("uses_numeric_trainer_ids" in trainer_group_names[trainer_group].keys()) \
+           or ("trainer_names" not in trainer_group_names[trainer_group].keys()):
             label += string.capwords(trainer_group_names[trainer_group]["constant"])
-            if len(trainer_group_names[trainer_group]["trainer_names"]) > 1:
+            if "trainer_names" in trainer_group_names[trainer_group].keys() \
+               and len(trainer_group_names[trainer_group]["trainer_names"]) > 1:
                 label += str(trainer_id)
         else:
             label += string.capwords(trainer_group_names[trainer_group]["constant"]) + \