Fixed prefabs not correctly loading in containers. Made looking in containers more practical.

This commit is contained in:
Patrick Marsee 2021-11-14 23:43:38 -05:00
parent 358c28d410
commit 9251886638
2 changed files with 28 additions and 3 deletions

View file

@ -309,11 +309,15 @@ list of lists of tuples."""
return nextThing
elif isinstance(container, dict):
for i in container:
if isinstance(container[i], _gt.Prefab):
container[i] = GameMap.resolvePrefab(prefabs, container[i])
nextThing = GameMap.addThingRecursive(GameMap.resolvePrefab(prefabs, container[i]), prefabs, nextThing)
return nextThing
elif isinstance(container, list):
for i in container:
nextThing = GameMap.addThingRecursive(GameMap.resolvePrefab(prefabs, i), prefabs, nextThing)
for i in range(len(container)):
if isinstance(container[i], _gt.Prefab):
container[i] = GameMap.resolvePrefab(prefabs, container[i])
nextThing = GameMap.addThingRecursive(container[i], prefabs, nextThing)
return nextThing
else:
return nextThing

View file

@ -497,7 +497,28 @@ Player is modified through side-effect."""
del instr[1]
thingName = ' '.join(instr[1:])
if len(thingName) == 0:
print(f"{self.gameBase.player.name} looks at nothing.")
# Print the lists of items again.
longestLen = 0
for i in player.thingNames:
if len(i) > longestLen:
longestLen = len(i)
if longestLen > 0:
inv = player.inventory # do this assignment because player.inventory is O(n)
print('{{0:<{0}}}{1}'.format(max(6, longestLen+2), "Container:").format("Inv:"))
i = 0
while i < len(inv) and i < len(cont):
print('{{0:<{0}}}{1}'.format(longestLen+2, cont[i].name).format(inv[i].name))
i += 1
while i < len(inv):
print(inv[i].name)
i += 1
while i < len(cont):
print(' '*(longestLen+2) + cont[i].name)
i += 1
else:
print('Container:')
for i in cont:
print(i.name)
else:
# Check the container first.
for i in range(len(cont)):