-
Notifications
You must be signed in to change notification settings - Fork 0
/
bugfree.py
executable file
·46 lines (32 loc) · 1.06 KB
/
bugfree.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python
import starbound
import re
import sys
from itertools import chain
from bugs import bugs
def listSpawnTypes(world):
spawnTypes = [biome['spawnProfile']['spawnTypes'] for biome in world.info.metadata['worldTemplate']['regionData']['biomes']]
spawnTypes = set(chain(*spawnTypes))
spawnTypes = [name.lower() for name in spawnTypes]
return spawnTypes
def openWorld(path):
world = open(path, "rb")
world = starbound.World(world)
return world
def filterBugs(spawnTypes):
return list(filter(lambda bug: bug['name'].lower() in spawnTypes, bugs))
def main():
if len(sys.argv) != 2:
print("Usage: <path>")
return
world = sys.argv[1]
world = openWorld(world)
spawnTypes = listSpawnTypes(world)
bugs = filterBugs(spawnTypes)
name = re.sub('\^.*?;', '', world.info.name)
x, y, _ = world.info.coords
print(f"{name} ({x}, {y})")
for bug in bugs:
print(f"#{bug['id']}\t- {bug['name']} found in {bug['biome']} during {bug['time']}")
if __name__ == '__main__':
main()