File wont save [SLOVED]

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
zalander
Citizen
Posts: 75
Joined: Mon Jan 09, 2023 5:58 am
Location: India
Contact:

File wont save [SLOVED]

Post by zalander »

Hi there,
I have been recently working on a project but i encountered a problem where my file wont save here is the code :

Code: Select all

function love.load()
	--load stuff
end
function love.update()
	-- things
	if love.keyboard.isDown("return") then
            if love.filesystem.getInfo(game.file_n) then
                love.filesystem.write(game.file_n, game.txt)
            else
                love.filesystem.newFile(game.file_n..".lua")
                love.filesystem.write(game.file_n, game.txt)
            end
            love.event.quit()
        end
end
function love.draw()
	--draw stuff
end        
Last edited by zalander on Sun Jun 18, 2023 11:15 am, edited 1 time in total.
Using LOVE to make everything except games :crazy:

Code: Select all

astring = "pog"
print(astring)
--pog
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: File wont save

Post by zorg »

Did you forget the quotes around "game.txt"? I assume you want that as a filename and not a variable.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
zalander
Citizen
Posts: 75
Joined: Mon Jan 09, 2023 5:58 am
Location: India
Contact:

Re: File wont save

Post by zalander »

zorg wrote: Fri Jun 16, 2023 6:18 pm Did you forget the quotes around "game.txt"? I assume you want that as a filename and not a variable.
No its a variable
Using LOVE to make everything except games :crazy:

Code: Select all

astring = "pog"
print(astring)
--pog
User avatar
zalander
Citizen
Posts: 75
Joined: Mon Jan 09, 2023 5:58 am
Location: India
Contact:

Re: File wont save

Post by zalander »

I added this to the love.update function and it tells me that the file name is illegal or is insecure

Code: Select all

	if love.keyboard.isDown("return") then
            local success, message = love.filesystem.write(game.file_n, game.txt)
            if success then
                print("File saved successfully!")
            else
                print("Error saving file:", message)
            end
        end
Using LOVE to make everything except games :crazy:

Code: Select all

astring = "pog"
print(astring)
--pog
Andlac028
Party member
Posts: 174
Joined: Fri Dec 14, 2018 2:27 pm
Location: Slovakia

Re: File wont save

Post by Andlac028 »

What is the content of game.txt? Can you add also print for it?
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: File wont save

Post by zorg »

The naming was a bit confusing, since i assumed the second parameter was the filename when it wasn't;
what's in game.file_n ?
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
zalander
Citizen
Posts: 75
Joined: Mon Jan 09, 2023 5:58 am
Location: India
Contact:

Re: File wont save

Post by zalander »

zorg wrote: Sat Jun 17, 2023 8:02 am The naming was a bit confusing, since i assumed the second parameter was the filename when it wasn't;
what's in game.file_n ?
game.file_n contains a string which is the file name
Using LOVE to make everything except games :crazy:

Code: Select all

astring = "pog"
print(astring)
--pog
User avatar
zalander
Citizen
Posts: 75
Joined: Mon Jan 09, 2023 5:58 am
Location: India
Contact:

Re: File wont save

Post by zalander »

Andlac028 wrote: Sat Jun 17, 2023 6:23 am What is the content of game.txt? Can you add also print for it?
game.txt contains a string
Using LOVE to make everything except games :crazy:

Code: Select all

astring = "pog"
print(astring)
--pog
Andlac028
Party member
Posts: 174
Joined: Fri Dec 14, 2018 2:27 pm
Location: Slovakia

Re: File wont save

Post by Andlac028 »

zalander wrote: Sat Jun 17, 2023 4:32 am I added this to the love.update function and it tells me that the file name is illegal or is insecure

Code: Select all

	if love.keyboard.isDown("return") then
            local success, message = love.filesystem.write(game.file_n, game.txt)
            if success then
                print("File saved successfully!")
            else
                print("Error saving file:", message)
            end
        end
And what is the filename?
User avatar
zalander
Citizen
Posts: 75
Joined: Mon Jan 09, 2023 5:58 am
Location: India
Contact:

Re: File wont save

Post by zalander »

Andlac028 wrote: Sat Jun 17, 2023 2:19 pm
zalander wrote: Sat Jun 17, 2023 4:32 am I added this to the love.update function and it tells me that the file name is illegal or is insecure

Code: Select all

	if love.keyboard.isDown("return") then
            local success, message = love.filesystem.write(game.file_n, game.txt)
            if success then
                print("File saved successfully!")
            else
                print("Error saving file:", message)
            end
        end
And what is the filename?
The file name can differ as the user enters it.
Using LOVE to make everything except games :crazy:

Code: Select all

astring = "pog"
print(astring)
--pog
Post Reply

Who is online

Users browsing this forum: Google [Bot], Semrush [Bot] and 3 guests