Page 1 of 1

Gather files from another folder

Posted: Wed Oct 30, 2019 7:16 pm
by Char Jones
Hello, new around here and I just have one question.
I have the folder structure like this to keep my files organized:

root
+ src
* player.lua
+ assets
* img
- panda.png
+ main.lua

But I want to retrieve the 'panda.png' from player.lua like love.graphics.newImage('./../assets/img/panda.png') but tells me the file doesn't exists, there's a special way to do it?
Thanks in advance

Re: Gather files from another folder

Posted: Wed Oct 30, 2019 8:53 pm
by Jasoco
I'm not completely sure how to read your folder structure. Use the Code tags to format it with spaces denoting folders so it's easier.

Code: Select all

main.lua
img/
  panda.png
src/
  player.lua
(Is that close to what you have it set up as?)

Anyway, is the image file not loading when you put the path in? It's relative. With the root folder where the main.lua file is being the top of the structure. So if that image is just in a folder called img at the root of the project then it would just be "img/panda.png". (Or if it's img inside assets then it's "/assets/img/panda.png") You don't need the ../ stuff.