Page 1 of 1

[SOLVED] "Could not set write directory" even when t.identity is set

Posted: Mon Sep 02, 2019 7:45 pm
by Aitch
I know similar questions have already been answered many times, so apologies if I could have found my answer in any of them. The solution for all the similar questions seemed to be either "don't set the save directory to something out of the default", or, "set t.identity in conf.lua", both of which do not cause this in my project.

Code: Select all

t.identity = "Puyo_Chains"
Save code: Binser is a table serializer

Code: Select all

print(love.filesystem.write("Puyo_Chains/" .. save_name .. ".txt", binser.serialize(grid.grid())))
I also tried saving this but it did not work either:

Code: Select all

print(love.filesystem.write("test.txt", "test"))
At first I thought it might be an issue with LOVE trying to save in a directory it did not have permission to, but I ran

Code: Select all

love.filesystem.getSaveDirectory( )
and it returned the /AppData/LOVE directory. (Now that I think of it, shouldn't it have returned /AppData/LOVE/Puyo_Chains?)

This was meant to just be a personal project so the controls aren't intuitive. I've included a controls file.

Re: "Could not set write directory" even when t.identity is set

Posted: Mon Sep 02, 2019 9:08 pm
by Sasha264
Welcome! :awesome:
  • First: In the main.lua -> function init () you have this line: love.filesystem.setIdentity("")
    It is not supposed to be here, you already successfully set identity in the conf.lua
    After removing that line test save love.filesystem.write("test.txt", "test") will work.
  • Second: Before saving to the subfolder you need to make sure this folder exists:

    Code: Select all

    function save_file ()   
        if love.filesystem.getInfo("Puyo_Chains") == nil then
            love.filesystem.createDirectory("Puyo_Chains")
        end
        print(love.filesystem.write("Puyo_Chains/" .. save_name .. ".txt", binser.serialize(grid.grid())))
    end
    After that your real save will work.
  • Third: Maybe you don't need another one Puyo_Chains directory inside Puyo_Chains dyrectory inside love home.
    So your save function will be just:

    Code: Select all

    function save_file ()   
        print(love.filesystem.write(save_name .. ".txt", binser.serialize(grid.grid())))
    end

Re: "Could not set write directory" even when t.identity is set

Posted: Mon Sep 02, 2019 9:29 pm
by Aitch
Perfect! Thank you!