Plague-fx/assets-fx/converters.py

29 lines
792 B
Python
Raw Normal View History

2021-05-25 13:24:48 +02:00
import fxconv
def convert(input_name, output, params, target):
if params["custom-type"] == "mutation-table":
2021-05-27 18:04:45 +02:00
convert_mt(input_name, output, params, target)
2021-05-25 13:24:48 +02:00
return 0
2021-05-29 16:44:46 +02:00
elif params["custom-type"] == "mutation":
convert_md(input_name, output, params, target)
return 0
2021-05-25 13:24:48 +02:00
else:
return 1
def convert_mt(input_name, output, params, target):
with open(input_name, "r") as file:
# Extract informations
lines = file.read().splitlines()
mutation_matrix = [i.split(" | ") for i in lines]
# Encode information into bytes
data = bytes()
2021-05-27 18:04:45 +02:00
for i in mutation_matrix:
for j in i:
data += fxconv.u32(int(j))
2021-05-25 13:24:48 +02:00
fxconv.elf(data, output, "_" + params["name"], **target)