How to access a file inside another file

Hello everyone

so if I want to display an image I type this :

image1=display.newImageRect("1.jpg",imageWidth,imageHeight)

where I place the image in the same folder as main.lua,

but I want to put the image in a folder with main.lua called file1 for example and put the image in it

my question is how to access it, what should I type instead of

"1.jpg"

thanks in advance

image1=display.newImageRect("file1/1.jpg",imageWidth,imageHeight)

thanks :slight_smile:

Just to elaborate further, artwork and audio can be put into subfolders and referenced using “foldername/filename” 

However if you want to put other Lua scripts into a subfolder, then you require them using a “foldername.filename”

Lua files use “.” and other assets use “/”

--require a file called "myLuaFile.lua" which is in a folder called "myScripts" local myLuaFile = require("myScripts.myLuaFile") --load an image called "1.jpg" which is in a folder called "file1" local myImage = display.newImageRect("file1/1.jpg", imageWidth, imageHeight) --load a sound called "theSoundFile.mp3" which is in a folder called "audio" local mySound = audio.loadSound( "audio/theSoundFile.mp3" )
image1=display.newImageRect("file1/1.jpg",imageWidth,imageHeight)

thanks :slight_smile:

Just to elaborate further, artwork and audio can be put into subfolders and referenced using “foldername/filename” 

However if you want to put other Lua scripts into a subfolder, then you require them using a “foldername.filename”

Lua files use “.” and other assets use “/”

--require a file called "myLuaFile.lua" which is in a folder called "myScripts" local myLuaFile = require("myScripts.myLuaFile") --load an image called "1.jpg" which is in a folder called "file1" local myImage = display.newImageRect("file1/1.jpg", imageWidth, imageHeight) --load a sound called "theSoundFile.mp3" which is in a folder called "audio" local mySound = audio.loadSound( "audio/theSoundFile.mp3" )