## [SOLVED]Displaying result for "love.filesystem.exists"

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
ntpspe
Prole
Posts: 31
Joined: Sun Aug 07, 2011 6:19 pm

### [SOLVED]Displaying result for "love.filesystem.exists"

Hello everyone.
I'm wanting to see if the conf.lua file is stored in the correct directory for editing, so:

I've used
config = love.filesystem.exists( "conf.lua" )
To check if it's there.
To display the result, I tried
love.graphics.print("Is the config there?: " .. config, 0, 80, 0)
But that's giving me an "Attempt to concatenate global variable "config" (boolean) error.

So how do I display the result of the check on screen?
Also, I've tried

Code: Select all

function checkconfig()
isitthere = "Unchecked"
config = love.filesystem.exists("conf.lua")
if config == "True" Then
isitthere = "Yep"
else
isitthere = "Nope"
end
end

EDIT: and obviously after I then try to do love.graphics.print(isitthere) with the same result as before, an error...
Last edited by ntpspe on Mon Aug 08, 2011 1:32 pm, edited 1 time in total.
slime
Solid Snayke
Posts: 2930
Joined: Mon Aug 23, 2010 6:45 am
Contact:

### Re: Displaying result for "love.filesystem.exists"

Code: Select all

local config = love.filesystem.exists( "conf.lua" )
love.graphics.print("Is the config there?: " .. tostring(config), 0, 80, 0)
In your second example, you were trying to compare the result of love.filesystem.exists (a boolean) with a string (not a boolean, and the boolean true/false has a lowercase first letter as well).
ntpspe
Prole
Posts: 31
Joined: Sun Aug 07, 2011 6:19 pm

### Re: Displaying result for "love.filesystem.exists"

Ah I see using "tostring" worked perfectly and I can just do "love.graphics.print("blah"..tostring(config)" now .

So am I correct in assuming by putting "tostring" makes the boolean variable a string variable for that print statement?
slime
Solid Snayke
Posts: 2930
Joined: Mon Aug 23, 2010 6:45 am
Contact:

### Re: Displaying result for "love.filesystem.exists"

ntpspe wrote:Ah I see using "tostring" worked perfectly and I can just do "love.graphics.print("blah"..tostring(config)" now .

So am I correct in assuming by putting "tostring" makes the boolean variable a string variable for that print statement?
Correct. You normally don't have to do that for numbers though, because it implicitly converts them to strings when you concatenate them together.
ntpspe
Prole
Posts: 31
Joined: Sun Aug 07, 2011 6:19 pm

### Re: Displaying result for "love.filesystem.exists"

Nice, thank you very much for your help

On another note (kinda going away from the topic, but still relevant)
Is there a way to get "love.filesystem.write" to write data to a specific line/column of the file?

For example, in the conf.lua there's " t.screen.fullscreen = false -- Enable fullscreen (boolean)"

So, basically I want

Code: Select all

function options()
*blahblahimagesandtext*
*button for fulscreen which toggles "clickedonfullscreen" to true/false*
if clickedonfullscreen == "true" then
love.filesystem.write(name, data, size)
(ONLY ON LINE 8 COLUMN 12 - for example)
end
end

If you understand my wording... I'm not too good with wording things on forums it seems >.<
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

### Re: Displaying result for "love.filesystem.exists"

That last example code you gave is not even nearly correct Lua, but to answer your question: no.

It is considered Bad to write to conf.lua, but if you really want to do it, you need to write the entire file.
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

### Re: Displaying result for "love.filesystem.exists"

Nor will it work.
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

### Re: Displaying result for "love.filesystem.exists"

bartbes wrote:Nor will it work.
Oh, right, since the write directory isn't set yet at the point that conf.lua is loaded.

ntpspe
Prole
Posts: 31
Joined: Sun Aug 07, 2011 6:19 pm

### Re: Displaying result for "love.filesystem.exists"

Robin wrote:That last example code you gave is not even nearly correct Lua.
You're very... critical.
So much for that...

A. I'm using this as a learning project, so of course I'm gonna make mistakes and ask stupid questions, and that's what forums are for.
B. It was a random not-worded-properly example to just get my meaning across :/
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

### Re: Displaying result for "love.filesystem.exists"

ntpspe wrote:You're very... critical.
I spoke the truth. I realise now that it might come across as a bit harsh. For that, I apologise.
ntpspe wrote:A. I'm using this as a learning project, so of course I'm gonna make mistakes and ask stupid questions, and that's what forums are for.
True. However, that does not mean we are happy with a lot of "stupid" questions. The thing is, whether a question can really be stupid is debatable, but either way, you should learn from the answers to not only your questions, but the questions of others as well.
ntpspe wrote:B. It was a random not-worded-properly example to just get my meaning across :/
Thinking before acting is a good thing.

For a bit of context: we used to be a very small, very friendly community. We still are unusually friendly for an internet based community, but the recent influx of young virgins (new lovers) has caused us to be a bit more on edge. They generally don't think before they act, and that is really annoying.