check if trainer_names has been set yet before using that key

This commit is contained in:
Bryan Bishop 2012-05-22 11:44:42 -05:00
parent c16d796c27
commit cb5eae3e9d
1 changed files with 9 additions and 3 deletions

View File

@ -1719,7 +1719,8 @@ class TrainerIdParam(SingleByteParam):
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 @@ class MenuDataPointerParam(PointerLabelParam):
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 @@ class RawTextPointerLabelParam(PointerLabelParam):
#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 @@ class TrainerFragment(Command):
# 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"]) + \