A Python library to parse Gbx files, used in TMTrackNN and other projects of mine that involve extracting useful data from Gbx files.
(For more documentation, refer to the docstrings in the source files.)
from pygbx import Gbx, GbxType
g = Gbx('A01-Race.Challenge.Gbx')
challenge = g.get_class_by_id(GbxType.CHALLENGE)
if not challenge:
quit()
print(f'Map Name: {challenge.map_name}')
print(f'Map Author: {challenge.map_author}')
print(f'Environment: {challenge.environment}')
Map Name: A01-Race
Map Author: Nadeo
Environment: Stadium
from pygbx import Gbx, GbxType
g = Gbx('A-0.Challenge.Gbx')
challenges = g.get_classes_by_ids([GbxType.CHALLENGE, GbxType.CHALLENGE_OLD])
if not challenges:
quit()
challenge = challenges[0]
for block in challenge.blocks:
print(block)
Name: StadiumRoadMainStartLine
Rotation: 0
Position: [16, 1, 13]
Flags: 0b1000000000000
Name: StadiumRoadMainGTDiag3x2Mirror
Rotation: 0
Position: [15, 1, 14]
Flags: 0b1000000000000
Name: StadiumRoadMainFinishLine
Rotation: 0
Position: [15, 1, 17]
Flags: 0b1000000000000
...
from pygbx import Gbx, GbxType
g = Gbx('A04_5_77.Replay.Gbx')
ghost = g.get_class_by_id(GbxType.CTN_GHOST)
if not ghost:
quit()
print(f'Race time: {ghost.race_time}')
print(f'Num respawns: {ghost.num_respawns}')
print(f'Game version: {ghost.game_version}')
print(f'Map UID: {ghost.uid}')
Race time: 5770
Num respawns: 0
Game version: TmForever.2.11.26
Map UID: QQFcGaqYWgge5qyiErMR1KJgeuk