Detect format

This commit is contained in:
BCDeshiG 2022-09-07 20:16:00 +01:00
parent 695a03c089
commit 7fd8279d11
3 changed files with 97 additions and 4 deletions

44
testDEMO.way Normal file
View file

@ -0,0 +1,44 @@
Waypoint
{
origin = '705.8 99.7 120.0'
id = 1
special = door2
target = 2
target2 = 3
target3 =
target4 =
target5 =
target6 =
target7 =
target8 =
}
Waypoint
{
origin = '698.7 339.5 120.0'
id = 2
special =
target = 1
target2 = 3
target3 =
target4 =
target5 =
target6 =
target7 =
target8 =
}
Waypoint
{
origin = '322.7 122.8 120.0'
id = 3
special =
target = 1
target2 =
target3 =
target4 =
target5 =
target6 =
target7 =
target8 =
}

32
testPC.way Normal file
View file

@ -0,0 +1,32 @@
waypoint
{
id: 1
origin: '280.0 460.0 40.0'
door: tilt
targets:
[
2
3
]
}
waypoint
{
id: 2
origin: '160.0 450.0 40.0'
targets:
[
1
3
]
}
waypoint
{
id: 3
origin: '152.0 720.0 40.0'
targets:
[
1
]
}

View file

@ -16,9 +16,26 @@ def startConversion(inputFile, outputFile):
if not(outputFile.lower().endswith(".way")):
outputFile += ".way"
# Read in old waypoints
tempF = open(inputFile, "r")
oldWayFile = tempF.read()
tempF.close()
print(oldWayFile)
with open(inputFile, "r") as tempF:
oldWayFile = tempF.readlines()
# Check format
header = oldWayFile[0].strip("\n")
if header == "Waypoint": # PSP
print("PSP format detected")
elif header == "waypoint": # PC
print("PC format detected")
else: # Check if BETA or just random crap
where = header.strip("'").split() # Split xyz
# Should look something like [-40.5, 12.2, 8.0]
if len(where) != 3:
print("Invalid waypoint file") # Clearly not co-ords
else:
try: # Check if they're actual numbers
for i in range(len(where)):
float(where[i])
print("BETA format detected")
except ValueError:
print("Invalid waypoint co-ords")
parseArgs()