Accesing a file in a completely different area of the .love 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.
Post Reply
TrustyGun
Prole
Posts: 2
Joined: Sun Apr 23, 2017 9:28 pm

Accesing a file in a completely different area of the .love directory.

Post by TrustyGun »

First things first: the order of my work folder.

Image

What I am trying to do is access default.png from entity.lua. However, for the life of me, I can not figure out how.

Here's my current code; which currently doesn't work. As you can see, I have attempted to solve the issue by using the .. operator for lua. However, it doesn't work.

Code: Select all

Entity = Object:extend()

function Entity:new(img,x,y,xspeed,yspeed)
	self.img = love.graphics.newImage('../../assets/sprites/default.png')
	self.x = 0
	self.y = 0
	self.xspeed = 0
	self.yspeed = 0
end

function Entity:update(dt)

end

function Entity:draw()
	love.graphics.draw(img,x,y)
end
Any help would be appreciated!
alloyed
Citizen
Posts: 80
Joined: Thu May 28, 2015 8:45 pm
Contact:

Re: Accesing a file in a completely different area of the .love directory.

Post by alloyed »

As far as love is concerned, the working directory is _always_ the top of the game folder (or the save folder, or whatever). This means that "assets/sprites/default.png" should work, no matter what file it's written in.

EDIT: or it would, but your screenshot suggests it should actually be "assets/default.png" :p
TrustyGun
Prole
Posts: 2
Joined: Sun Apr 23, 2017 9:28 pm

Re: Accesing a file in a completely different area of the .love directory.

Post by TrustyGun »

Thank you. It works now. Also I feel slightly dumb for not knowing that :P
Post Reply

Who is online

Users browsing this forum: No registered users and 90 guests