Page 1 of 1

File error help?

Posted: Mon Oct 19, 2015 8:15 am
by chimmihc
Hello, I am new to love and simply trying to learn the API.

The error I am getting is saying the file does not exist, but I have done some checking and the file is there and the path is correct.

Code:

Code: Select all

math.randomseed(os.time()*3)
local print = require("output")
local code = require("encode")
local path = require("gameroot")

love.load = function()
	os.setlocale ("", "time")
	print(os.date("%c") .. "\n------------------------------\n")
	print(io.open(path .. "\\assets\\orange.png")) -- a simple check to make sure the path is correct, prints "file (0x07fef215c500)"
	print(pcall(function() return love.graphics.newImage(path .. "\\assets\\orange.png") end)) -- prints "false   Could not open file C:/Users/myaccountname/Documents\TestGame\assets\orange.png. Does not exist."
end

love.quit = function()
	print("\n------------------------------\n\n\n")
end
What I read on the wiki page said nothing about any special behavior with the path.

If it will help, this is the gameroot file source:

Code: Select all

local GameName = love.filesystem.getIdentity()
local FilePath = love.filesystem.getSourceBaseDirectory()
return FilePath .. "\\" .. GameName

And the project view looks like this:


Image

Re: File error help?

Posted: Mon Oct 19, 2015 1:27 pm
by Nixola
You don't need to provide the full path to any LÖVE function; the path they receive is relative to the project root. It should just be lg.newImage("assets/orange.png").
Welcome to LÖVE by the way! ^^

Re: File error help?

Posted: Mon Oct 19, 2015 3:59 pm
by bartbes
Nixola wrote:You don't need to provide the full path to any LÖVE function
And, as you've seen, you can't.

Re: File error help?

Posted: Mon Oct 19, 2015 5:08 pm
by chimmihc
Well that is good to know, many thanks.