Any intermediary love objects that will allow importing images from outside the Love source folder on iOS?

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
SugarRayLua
Citizen
Posts: 55
Joined: Sat Dec 03, 2022 7:52 pm

Any intermediary love objects that will allow importing images from outside the Love source folder on iOS?

Post by SugarRayLua »

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.
User avatar
GVovkiv
Party member
Posts: 683
Joined: Fri Jan 15, 2021 7:29 am

Re: Any intermediary love objects that will allow importing images from outside the Love source folder on iOS?

Post by GVovkiv »

In love 12 you will be able to "connect" to your filesystem directory outside of source and save directories.
SugarRayLua
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?

Post by SugarRayLua »

Thanks for the heads up :-)
User avatar
GVovkiv
Party member
Posts: 683
Joined: Fri Jan 15, 2021 7:29 am

Re: Any intermediary love objects that will allow importing images from outside the Love source folder on iOS?

Post by GVovkiv »

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
User avatar
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?

Post by Kartik Agaram »

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
SugarRayLua
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?

Post by SugarRayLua »

That worked perfectly, thanks! 😊👍
Post Reply

Who is online

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