Odyssee/project/assets-fx/converters.py

32 lines
865 B
Python
Raw Normal View History

2021-07-04 09:40:38 +02:00
import fxconv
def convert(input_name, output, params, target):
if params["custom-type"] == "map":
2021-07-04 09:40:38 +02:00
convert_map(input_name, output, params, target)
return 0
else:
return 1
def convert_map(input_name, output, params, target):
# Read informations
with open(input_name, "r") as file:
csv_data = file.read().splitlines()
walkable = [-1, 11, 12, 13, 14, 15, 16, 17, 18, 20, 24, 25, 26, 30, 31, 37, 43, 44, 45, 62, 63, 64]
2021-07-04 09:40:38 +02:00
# Convertion into bytes
tiles = bytes()
collision = bytes()
2021-07-04 09:40:38 +02:00
for line in csv_data:
for value in line.split(","):
value = int(value)
tiles += fxconv.u32(value)
2021-07-17 15:32:47 +02:00
collision += fxconv.u8(value in walkable)
2021-07-04 09:40:38 +02:00
data = fxconv.ObjectData()
data += tiles + collision
2021-07-04 09:40:38 +02:00
fxconv.elf(data, output, "_" + params["name"], **target)