Fixed instant crash in last commit by adding valid testdata.yml, and fixed testdata.yml parsing.
This commit is contained in:
parent
9cda61a895
commit
aba0014e27
4 changed files with 39 additions and 14 deletions
17
gamebase.py
17
gamebase.py
|
@ -555,23 +555,28 @@ Object can be the name of the object, or its coordinates."""
|
|||
data = None
|
||||
with open(dataFile, 'r') as f:
|
||||
data = yaml.load(f)
|
||||
# In this context, 'singleton' means a 'thing' that can be accessed by
|
||||
# any map. This is useful for when you have major characters who will
|
||||
# show up in many scenes, and their inventory must stay the same, for
|
||||
# example.
|
||||
if 'singletons' in data:
|
||||
for datum in data['singletons']:
|
||||
thing = data['singletons'][datum]
|
||||
for thing in data['singletons']:
|
||||
#thing = data['singletons'][datum]
|
||||
if not isinstance(thing, _gt.Thing):
|
||||
print("Non-thing in singletons, ignoring.\n", _sys.stderr)
|
||||
continue
|
||||
thing.thingID = self.nextThing
|
||||
self.nextThing += 1
|
||||
if thing.thingType in 'iun':
|
||||
nextThing = self.addThingRecursive(thing.customValues, nextThing)
|
||||
self.nextThing = _gm.GameMap.addThingRecursive(thing.customValues, self.nextThing)
|
||||
if thing.thingType == 'n':
|
||||
for i in thing.tempInventory:
|
||||
if i.thingID == -1:
|
||||
i.thingID = nextThing
|
||||
nextThing = self.addThingRecursive(i.customValues, nextThing + 1)
|
||||
i.thingID = self.nextThing
|
||||
self.nextThing = _gm.GameMap.addThingRecursive(i.customValues, self.nextThing + 1)
|
||||
thing.addThing(i)
|
||||
del thing.tempInventory
|
||||
self.singletons = dict(data[singletons])
|
||||
self.singletons = list(data['singletons'])
|
||||
return data
|
||||
|
||||
def gameEventLoop(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue