32 lines
918 B
Python
32 lines
918 B
Python
import sys, os
|
|
import argparse
|
|
from datetime import datetime
|
|
import json
|
|
import math
|
|
|
|
# Check if the script is run with the correct arguments
|
|
parser = argparse.ArgumentParser(description="Generate chunk header files")
|
|
parser.add_argument('--output', required=True, help='Dir to output headers')
|
|
parser.add_argument('--input', required=True, help='Input JSON file from tiled')
|
|
args = parser.parse_args()
|
|
|
|
# Ensure outdir exists
|
|
outputDir = args.output
|
|
os.makedirs(outputDir, exist_ok=True)
|
|
|
|
# Create world directory if it does not exist
|
|
worldDir = os.path.join(outputDir, "world")
|
|
os.makedirs(worldDir, exist_ok=True)
|
|
|
|
# Some vars used during printing
|
|
now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
|
|
|
# Read the input JSON file
|
|
inputFile = args.input
|
|
if not os.path.isfile(inputFile):
|
|
print(f"Error: Input file '{inputFile}' does not exist.")
|
|
sys.exit(1)
|
|
|
|
with open(inputFile, 'r') as f:
|
|
data = json.load(f)
|
|
|