Hello.
I've been trying to learn the subtleties about how to save and import different data into my love projects. It seems that at least on Love iOS, love.filesystem can only read and write to the source folder which contains my .love file. I'd like to be able to read and write to other locations: on iOS the most convenient place to read and write from would be the source base directory which contains my .love file as that way I could have a common place to store data objects that I could share between .love files. However, since love.filesystem can't seem to read and write to the sourceBaseDirectory, I've been using the nativefs library to do so which works great. Yet, the nativefs library doesn't have any specific functions for handling images, and it seems that love.graphics.newImage, like the base love.filesystem is unable to read images from the sourceBaseDirectory. I was wondering if there was then some way I could use nativefs to import a graphics object (e.g. png) from my sourceBaseDirectory and then somehow have love.graphics.newImage be able to read that file I imported from a file into a variable using nativefs.
I appreciate any suggests the forum community might have.
Thank you.
Any intermediary love objects that will allow importing images from outside the Love source folder on iOS?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Citizen
- Posts: 55
- Joined: Sat Dec 03, 2022 7:52 pm
Re: Any intermediary love objects that will allow importing images from outside the Love source folder on iOS?
In love 12 you will be able to "connect" to your filesystem directory outside of source and save directories.
-
- Citizen
- Posts: 55
- Joined: Sat Dec 03, 2022 7:52 pm
Re: Any intermediary love objects that will allow importing images from outside the Love source folder on iOS?
Thanks for the heads up :-)
Re: Any intermediary love objects that will allow importing images from outside the Love source folder on iOS?
If you curious, here wiki page on how it will work https://love2d.org/wiki/love.filesystem.mountFullPath
I don't see any IOS builds in artefacts here https://github.com/love2d/love/actions for 12.0, so if you really want to try it out, you probably need to build wip love 12 from source yourself
I don't see any IOS builds in artefacts here https://github.com/love2d/love/actions for 12.0, so if you really want to try it out, you probably need to build wip love 12 from source yourself
- Kartik Agaram
- Prole
- Posts: 34
- Joined: Fri Apr 01, 2022 4:46 am
Re: Any intermediary love objects that will allow importing images from outside the Love source folder on iOS?
Here's a program that will load images from anywhere on your system, using the pure-Lua nativefs library (https://github.com/EngineerSmith/nativefs) Just include nativefs.lua in the .love file with the following main.lua:
Code: Select all
nativefs = require 'nativefs'
Image = nil
function love.load()
local filename = '/home/akkartik/Documents/akkartik2-sq.png'
local file_data = nativefs.newFileData(filename)
Image = love.graphics.newImage(file_data)
end
function love.draw()
if Image then
love.graphics.draw(Image)
end
end
-
- Citizen
- Posts: 55
- Joined: Sat Dec 03, 2022 7:52 pm
Re: Any intermediary love objects that will allow importing images from outside the Love source folder on iOS?
That worked perfectly, thanks!
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 5 guests