Conversion to PSP format
This commit is contained in:
parent
79471ed2c3
commit
f7a15b23f0
24
waycon.py
24
waycon.py
|
@ -68,6 +68,8 @@ def startConversion(inputFile, outputFile, wayFormat):
|
||||||
# Print out waypoint for now I guess
|
# Print out waypoint for now I guess
|
||||||
if wayFormat == "BETA":
|
if wayFormat == "BETA":
|
||||||
saveBETA(wayArray, outputFile)
|
saveBETA(wayArray, outputFile)
|
||||||
|
if wayFormat == "PSP":
|
||||||
|
savePSP(wayArray, outputFile)
|
||||||
print("Conversion complete")
|
print("Conversion complete")
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
|
@ -150,4 +152,26 @@ def saveBETA(wayArray, outputFile):
|
||||||
# Fill out 'owner' fields just in case
|
# Fill out 'owner' fields just in case
|
||||||
[outF.write(waypoint["targets"][i] + "\n") for i in range(4)]
|
[outF.write(waypoint["targets"][i] + "\n") for i in range(4)]
|
||||||
|
|
||||||
|
def savePSP(wayArray, outputFile):
|
||||||
|
print("WARNING: PSP format is limited to 8 links per waypoint")
|
||||||
|
with open(outputFile, "w") as outF:
|
||||||
|
for waypoint in wayArray:
|
||||||
|
outF.write("Waypoint\n{\n") # Header
|
||||||
|
outF.write(f"origin = {waypoint['origin']}\n")
|
||||||
|
outF.write(f"id = {waypoint['id']}\n")
|
||||||
|
outF.write(f"special = {waypoint['door']}\n")
|
||||||
|
# Only do 1st eight links (Mapper may need to tweak waypoints)
|
||||||
|
numTargets = len(waypoint["targets"])
|
||||||
|
# Pad out list with '' for empty links
|
||||||
|
if numTargets < 8:
|
||||||
|
for i in range(8-numTargets):
|
||||||
|
waypoint["targets"].append("")
|
||||||
|
# Warn user if waypoint has too many links
|
||||||
|
if numTargets > 8:
|
||||||
|
print(f"Waypoint {waypoint['id']} has more than 8 links")
|
||||||
|
# Write waypoint links to file
|
||||||
|
outF.write(f"target = {waypoint['targets'][0]}\n")
|
||||||
|
[outF.write(f"target{i+1} = {waypoint['targets'][i]}\n") for i in range(1,8)]
|
||||||
|
outF.write("}\n\n") # Footer of waypoint
|
||||||
|
|
||||||
parseArgs()
|
parseArgs()
|
||||||
|
|
Loading…
Reference in New Issue