## [SOLVED] How do I import files from specific folder in the game directory?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
YounYokel
Prole
Posts: 33
Joined: Thu Oct 03, 2019 5:57 pm
Location: Kazakhstan

### [SOLVED] How do I import files from specific folder in the game directory?

Hello! It's quite weird for me, but when I'm setting the new font but I cannot import the font from a folder, I need to type the name only. If that file doesn't exists in the project folder, game will crash.

Code: Select all

local myFont = love.graphics.newFont( "fonts\opensans.ttf", 14 )

What should I do to allow the folders in my project?
Last edited by YounYokel on Thu Oct 10, 2019 4:37 pm, edited 1 time in total.

pgimeno
Party member
Posts: 2312
Joined: Sun Oct 18, 2015 2:58 pm

### Re: How do I import files from specific folder in the game directory?

Use / instead of \

YounYokel
Prole
Posts: 33
Joined: Thu Oct 03, 2019 5:57 pm
Location: Kazakhstan

### Re: How do I import files from specific folder in the game directory?

pgimeno wrote:
Wed Oct 09, 2019 6:23 pm
Use / instead of \
Oops. That was silly

HDPLocust
Citizen
Posts: 64
Joined: Thu Feb 19, 2015 10:56 pm
Location: Swamp
Contact:

### Re: [SOLVED] How do I import files from specific folder in the game directory?

You sould use [\\] (it's regular backslash character). Backslash is the escape character in lua strings:

Code: Select all

print("Backslash is here \\") --> Backslash is here \ 
Also multiline/unescaped strings can be achived with [[]] syntax:

Code: Select all

 print([[Backslash is here \]]) --> Backslash is here \ 
Backslash is used for some tasks, like using different types of quotes in string, or using special symbols:

Code: Select all

print("\33") --> !, 33-byte is "!" symbol
print("'singlequoted text' \"doublequoted text\"") -->'singlequoted text' "doublequoted text"

So it's just lua syntax.
Science and violence

pgimeno
Party member
Posts: 2312
Joined: Sun Oct 18, 2015 2:58 pm

### Re: [SOLVED] How do I import files from specific folder in the game directory?

It's not advisable to use \ for paths anyway if you want your code to run in multiple platforms.

raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

### Re: [SOLVED] How do I import files from specific folder in the game directory?

Also backslash will not work for zipped archives and by extension for fused games. In general you should just always use forward slash for file paths.

On a tangent, the "require" function doesn't work on file paths, it works on module names. So I recommend using dot notation there, just to avoid confusion.

### Who is online

Users browsing this forum: Bing [Bot] and 25 guests