import os

script_dir = os.path.dirname(os.path.abspath(__file__))
lua_path = os.path.join(script_dir, "vex_cheat.lua")
header_path = os.path.join(script_dir, "CheatDLL", "vex_cheat_data.h")

if not os.path.exists(lua_path):
    print(f"Error: {lua_path} does not exist!")
    exit(1)

with open(lua_path, "rb") as f:
    data = f.read()

# Generate C++ hex byte array header
with open(header_path, "w") as f:
    f.write("#pragma once\n")
    f.write("inline const unsigned char vex_cheat_lua[] = {\n")
    f.write(", ".join(f"0x{b:02x}" for b in data))
    f.write("\n};\n")
    f.write(f"inline const unsigned int vex_cheat_lua_len = {len(data)};\n")

print(f"Successfully converted {lua_path} ({len(data)} bytes) to {header_path}")
