Page 2 of 2
Re: love.filesystem trouble, doesn't seem to work.
Posted: Fri Jan 29, 2010 9:46 pm
by Robin
bartbes wrote:If you enable the console, do you see any output?
If you don't know how to enable the console, see:
http://love2d.org/docs/love_conf.html
(In short: have a file called conf.lua containing
Code: Select all
function love.conf(t)
t.console = true
end
)
Re: love.filesystem trouble, doesn't seem to work.
Posted: Fri Jan 29, 2010 9:55 pm
by Clavus
bartbes wrote:If you enable the console, do you see any output?
Nope. The function just ends while evaluating the love.filesystem.write(CONFIG_FILE, DefaultConfigString()) part. It prints "a", but neither "b" nor "c".
Re: love.filesystem trouble, doesn't seem to work.
Posted: Sat Jan 30, 2010 10:14 am
by bartbes
And this code?
Code: Select all
local function LoadConfig()
local CONFIG_FILE = "config.txt" -->we don't use absolute paths, it's a myth, a bad one.
print("Attempting to load config")
print("File path: "..CONFIG_FILE)
local cfgfile = nil
if (love.filesystem.exists(CONFIG_FILE)) then
cfgfile = love.filesystem.newFile(CONFIG_FILE)
else
print("a")
if (love.filesystem.write(CONFIG_FILE, DefaultConfigString())) then
print("b")
cfgfile = love.filesystem.newFile(CONFIG_FILE)
else
print("c")
error("Can't read and/or create config.txt file.")
end
end
cfgfile:open("r") --> DON'T FORGET THIS
for k, v in pairs(cfgfile:lines()) do
print("Line "..k.." = "..v)
end
end
local function DefaultConfigString()
return [[m1 +primary
m2 +secondary
w +forward
a +left
d +right
s +back]]
end
Re: love.filesystem trouble, doesn't seem to work.
Posted: Sat Jan 30, 2010 9:10 pm
by mrklotz
bartbes wrote:The path is supposed to be extracted from your environment variables, try finding the one that points to C:\\Users and change it to C:\\Gebruikers. (though I must say I am horrified by them even thinking about localizing such paths, microsoft never ceases to amaze me)
The localization is actually just a link to the true "c:\users" folder, if you navigate via cmd-line and use dir you will see your users- Directory, it's the same thing in vista.
Win7 does use a diffrent layout for the folder structue for "my music" etc but even that is linked onto the older structure of vista.
tl;dr version:
It's the same thing using the loclaized folder name or the english "true name" of the folder, because the localized is just a link to the hidden folder named in english.
Re: love.filesystem trouble, doesn't seem to work.
Posted: Sun Jan 31, 2010 7:00 pm
by Clavus
bartbes wrote:And this code?
Nope, it still doesn't get to print("b") or print("c"). I think the fact that there's no save folder being created might play a large role.
Re: love.filesystem trouble, doesn't seem to work.
Posted: Wed Feb 03, 2010 10:15 am
by Clavus
Does anyone have a working example of saving files to the save folder? Maybe I can compare my code to that just to be sure.
Re: love.filesystem trouble, doesn't seem to work.
Posted: Wed Feb 03, 2010 11:52 am
by bartbes
Re: love.filesystem trouble, doesn't seem to work.
Posted: Wed Feb 03, 2010 2:21 pm
by Clavus
Thanks, that helped a lot. Got it working!
Code: Select all
print("Attempting to load config")
print("File path: "..CONFIG_FILE)
local cfgfile = nil
if (love.filesystem.exists(CONFIG_FILE)) then
cfgfile = love.filesystem.newFile(CONFIG_FILE)
else
cfgfile = love.filesystem.newFile(CONFIG_FILE)
cfgfile:open("w")
if (cfgfile:write(DefaultConfigString())) then
cfgfile:close()
cfgfile = love.filesystem.newFile(CONFIG_FILE)
else
error("Can't read and/or create config.txt file.")
end
end
lbp and lua 5.2
Posted: Thu Feb 04, 2010 7:21 am
by subrime
bartbes: looking through your lbp code a bit... did you know lua 5.2 is planning to drop setfenv?
Re: love.filesystem trouble, doesn't seem to work.
Posted: Thu Feb 04, 2010 2:48 pm
by bartbes
I know, I'm planning to drop lua 5.2
(but yeah, I knew)