Load image not packed into .love/.exe

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
LetsOfBrains
Prole
Posts: 1
Joined: Wed May 10, 2017 1:57 pm

Load image not packed into .love/.exe

Post by LetsOfBrains »

I need to load images outside of .exe/.love file.
I'm trying to load image that lies next to .exe/.love.

Code: Select all

qwe = love.graphics.newImage( "24.png" ) --don't think you need a .love file for this
Getting an error, ofc. "Does not exist".
It load's if i pack it into .love, but it's useless.
Hopefully you understood this mess.
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Load image not packed into .love/.exe

Post by zorg »

Short answer: you can only read from the .love itself, and read from / write to the save directory, if you set the project's identity with either a conf.lua file, or the function love.filesystem.setIdentity. (you can drag files/folders from anywhere and use the love.filedropped and love.directorydropped callbacks though)

Long answer: lua's own io functions are able to access arbitrary locations, but it's not cross-platform and will be a pain to get to work right.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
slime
Solid Snayke
Posts: 3163
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Load image not packed into .love/.exe

Post by slime »

Check out the description and example in the love.filesystem.getSourceBaseDirectory wiki page.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 2 guests