How do I append to a new line using love.filesystem.append?

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.
Post Reply
User avatar
Bogdan705
Prole
Posts: 15
Joined: Sun Aug 05, 2018 9:04 pm

How do I append to a new line using love.filesystem.append?

Post by Bogdan705 »

I am making a random color generator where no two colors are the same. I am having problems with appending to a new line. I've tried using this advice : https://www.reddit.com/r/love2d/comment ... _log_file/, but adding "\n" at the beginning or end of the string does nothing. So my question is, how do I append to a new line?
By the way, here is the code that does the appending :

Code: Select all

local string = tostring(generated_color[1]) .. "," .. tostring(generated_color[2]) .. "," .. tostring(generated_color[3]) .. "\n"
love.filesystem.append("colors.txt",string)
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: How do I append to a new line using love.filesystem.append?

Post by zorg »

the \n is still there, saved into the file; the thing is, line breaks differ per OS; windows uses both carriage return and line feed in that order, so you would need to insert \r\n instead of just \n... (linuxes/unices use just \n, and old macos used just \r, idk if OS X uses \n or not though)

that said, in most cases, people indeed just use \n and use a text/code editor that has an option (or auto-detection) regarding what character is used for newlines.
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.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 3 guests