# Buggy code
def write_config(resx, resy):
    wrd = bpy.data.worlds["Arm"]
    p = arm.utils.get_fp() + "/Bundled"
    if not os.path.exists(p):
        os.makedirs(p)
    output = {}
    output["window_mode"] = get_winmode(wrd.arm_winmode)
    output["window_w"] = int(resx)
    output["window_h"] = int(resy)
    output["window_resizable"] = wrd.arm_winresize
    output["window_maximizable"] = wrd.arm_winresize and wrd.arm_winmaximize
    output["window_minimizable"] = wrd.arm_winminimize
    output["window_vsync"] = wrd.arm_vsync
    rpdat = arm.utils.get_rp()
    output["window_msaa"] = int(rpdat.arm_samples_per_pixel)
    output["window_scale"] = 1.0
    output["rp_supersample"] = float(rpdat.rp_supersampling)
    rp_shadowmap_cube = int(rpdat.rp_shadowmap_cube) if rpdat.rp_shadows else 0
    output["rp_shadowmap_cube"] = rp_shadowmap_cube
    rp_shadowmap_cascade = arm.utils.get_cascade_size(rpdat) if rpdat.rp_shadows else 0
    output["rp_shadowmap_cascade"] = rp_shadowmap_cascade
    output["rp_ssgi"] = rpdat.rp_ssgi != "Off"
    output["rp_ssr"] = rpdat.rp_ssr != "Off"
    output["rp_bloom"] = rpdat.rp_bloom != "Off"
    output["rp_motionblur"] = rpdat.rp_motionblur != "Off"
    output["rp_gi"] = rpdat.rp_voxelao
    output["rp_dynres"] = rpdat.rp_dynres
    with open(p + "/config.arm", "w") as f:
        f.write(json.dumps(output, sort_keys=True, indent=4))


# Traceback (FileNotFoundError)
location: <unknown location>:-1
Error: Traceback (most recent call last):
File "C:\Users\nobody\Documents\ArmorySDK//armory/blender\arm\props_ui.py", line 457, in execute
make.play()
File "C:\Users\nobody\Documents\ArmorySDK//armory/blender\arm\make.py", line 462, in play
build(target=runtime_to_target(), is_play=True)
File "C:\Users\nobody\Documents\ArmorySDK//armory/blender\arm\make.py", line 346, in build
export_data(fp, sdk_path)
File "C:\Users\nobody\Documents\ArmorySDK//armory/blender\arm\make.py", line 155, in export_data
write_data.write_compiledglsl(defs + cdefs, make_variants=has_config)
File "C:\Users\nobody\Documents\ArmorySDK//armory/blender\arm\write_data.py", line 440, in write_compiledglsl
with open(arm.utils.build_dir() + '/compiled/Shaders/compiled.inc', 'w') as f:
FileNotFoundError: [Errno 2] No such file or directory: 'build_0untitled/compiled/Shaders/compiled.inc'

location: <unknown location>:-1

# Fixed code
def write_config(resx, resy):
    wrd = bpy.data.worlds["Arm"]
    p = os.path.join(arm.utils.get_fp(), "Bundled")
    if not os.path.exists(p):
        os.makedirs(p)

    rpdat = arm.utils.get_rp()
    rp_shadowmap_cube = int(rpdat.rp_shadowmap_cube) if rpdat.rp_shadows else 0
    rp_shadowmap_cascade = arm.utils.get_cascade_size(rpdat) if rpdat.rp_shadows else 0

    output = {
        "window_mode": get_winmode(wrd.arm_winmode),
        "window_w": int(resx),
        "window_h": int(resy),
        "window_resizable": wrd.arm_winresize,
        "window_maximizable": wrd.arm_winresize and wrd.arm_winmaximize,
        "window_minimizable": wrd.arm_winminimize,
        "window_vsync": wrd.arm_vsync,
        "window_msaa": int(rpdat.arm_samples_per_pixel),
        "window_scale": 1.0,
        "rp_supersample": float(rpdat.rp_supersampling),
        "rp_shadowmap_cube": rp_shadowmap_cube,
        "rp_shadowmap_cascade": rp_shadowmap_cascade,
        "rp_ssgi": rpdat.rp_ssgi != "Off",
        "rp_ssr": rpdat.rp_ssr != "Off",
        "rp_bloom": rpdat.rp_bloom != "Off",
        "rp_motionblur": rpdat.rp_motionblur != "Off",
        "rp_gi": rpdat.rp_voxelao,
        "rp_dynres": rpdat.rp_dynres,
    }

    with open(os.path.join(p, "config.arm"), "w") as configfile:
        configfile.write(json.dumps(output, sort_keys=True, indent=4))