Love2D I/O to any 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.
dvdfu
Prole
Posts: 7
Joined: Sun Sep 27, 2015 6:22 pm

Love2D I/O to any directory?

Post by dvdfu »

Hey everyone, I'm trying to develop a texture atlas packer (https://github.com/dvdfu/packer) for Love2D.

I read in sprites from a source directory and export them packed as an atlas. I'm using Love2D itself to build the tool since there are convenient image APIs (e.g. love.graphics.draw, Image:encode).

As far as I understand, Love2D can only read from the game project folder and the save directory, and can only save to the save directory. Is there a way to bypass these restrictions for my purposes? For example, using native Lua methods to write files from a program executing in Love? If so, are they compatible with Love2D's FileData object types? I'm wondering what my options are.

Thanks!
User avatar
josefnpat
Inner party member
Posts: 955
Joined: Wed Oct 05, 2011 1:36 am
Location: your basement
Contact:

Re: Love2D I/O to any directory?

Post by josefnpat »

dvdfu wrote:Hey everyone, I'm trying to develop a texture atlas packer (https://github.com/dvdfu/packer) for Love2D.
Awesome! I dislike TexturePacker immensely, and have been using urraka's texpack. I encourage you to check it out to see a very well made CLI texture packer.

https://github.com/urraka/texpack
dvdfu wrote:As far as I understand, Love2D can only read from the game project folder and the save directory, and can only save to the save directory. Is there a way to bypass these restrictions for my purposes? For example, using native Lua methods to write files from a program executing in Love? If so, are they compatible with Love2D's FileData object types? I'm wondering what my options are.
While it is encouraged to use love.filesystem.*, because this isn't a game, I would suggest looking into Lua's IO module. It will do what you need.

http://lua-users.org/wiki/IoLibraryTutorial
Missing Sentinel Software | Twitter

FORCIBLY IGNORED.
<leafo> when in doubt delete all of your code
<bartbes> git rm -r *
<bartbes> git commit -m "Fixed all bugs"
<bartbes> git push
User avatar
Tanner
Party member
Posts: 166
Joined: Tue Apr 10, 2012 1:51 am

Re: Love2D I/O to any directory?

Post by Tanner »

josefnpat wrote:I dislike TexturePacker immensely, and have been using urraka's texpack.
Not to hijack this thread but I'm curious what shortcomings you found in TexturePacker? I've used it for a number of professional projects with teams of 5 to 10 people as well as for a bunch of solo game jams and I've only ever liked what it does.
Skeletonxf
Citizen
Posts: 87
Joined: Tue Dec 30, 2014 6:07 pm

Re: Love2D I/O to any directory?

Post by Skeletonxf »

This should be what you want: https://m.reddit.com/r/love2d/comments/ ... mpact=true

I haven't personally used it yet however
User avatar
josefnpat
Inner party member
Posts: 955
Joined: Wed Oct 05, 2011 1:36 am
Location: your basement
Contact:

Re: Love2D I/O to any directory?

Post by josefnpat »

Tanner wrote:
josefnpat wrote:I dislike TexturePacker immensely, and have been using urraka's texpack.
Not to hijack this thread but I'm curious what shortcomings you found in TexturePacker? I've used it for a number of professional projects with teams of 5 to 10 people as well as for a bunch of solo game jams and I've only ever liked what it does.
Sure thing! Keep in mind that I used this software years ago, and the current version may be different.

Honestly, the features and the UI interface is very good. It's also very nice that you can script it into workflows (e.g. makefiles!)

The problem is the DRM that it implements:

* the demo times out
* the demo has nagware
* the demo cripples the output atlases
* it calls home when it starts (starting the software without internet sucks)
* the license only lasts for one year
* You are limited to how many computers you can run it on

Other problems include:

* Being proprietary (obviously this is subjective)
* Cost
* OK Linux compatibility

For me, the most important features include:

* padding (texpak --padding)
* size limitation (texpack --size)
* json output (default)
* Trim (texpack --trim ... I had to request this one! urraka was so nice to do this for me)
* cli workflow integration with makefiles

Urraka's tool has each of these features, and of course it's FOSS!

You can see my integration in "Get Off, Cat!": https://github.com/josefnpat/LD34/blob/ ... tesheet.sh
Missing Sentinel Software | Twitter

FORCIBLY IGNORED.
<leafo> when in doubt delete all of your code
<bartbes> git rm -r *
<bartbes> git commit -m "Fixed all bugs"
<bartbes> git push
User avatar
Tanner
Party member
Posts: 166
Joined: Tue Apr 10, 2012 1:51 am

Re: Love2D I/O to any directory?

Post by Tanner »

Ah, fair enough. I was so wow'd by it when I first used it that I got the company I was working for to buy it for the team and then I got used to it. FOSS all the way, though, I agree.
dvdfu
Prole
Posts: 7
Joined: Sun Sep 27, 2015 6:22 pm

Re: Love2D I/O to any directory?

Post by dvdfu »

Tanner wrote:
josefnpat wrote:I dislike TexturePacker immensely, and have been using urraka's texpack.
Not to hijack this thread but I'm curious what shortcomings you found in TexturePacker? I've used it for a number of professional projects with teams of 5 to 10 people as well as for a bunch of solo game jams and I've only ever liked what it does.
Personally speaking, aside from not being FOSS, TexturePacker also doesn't directly support Love2D and doesn't work for Ubuntu 32-bit (as far as I can tell). It's pretty situational for me, plus I thought making my own would be a little fun.
Skeletonxf wrote:This should be what you want: https://m.reddit.com/r/love2d/comments/ ... mpact=true

I haven't personally used it yet however
This looks exactly like what I'd need! Will look into it, thanks.
dvdfu
Prole
Posts: 7
Joined: Sun Sep 27, 2015 6:22 pm

Re: Love2D I/O to any directory?

Post by dvdfu »

Running into some more problems.

MiniFS is built on top of LuaFileSystem, which is installed through luarocks. It seems like libraries installed through luarocks can't be required through Love2D's runtime without some hacks...that I'd rather not use if I want this packer to be accessible to other developers. Using Lua's default IO also seems like a lot of work to get basic methods like getFiles() working.

Any work arounds? I couldn't find anything through Google.
Skeletonxf
Citizen
Posts: 87
Joined: Tue Dec 30, 2014 6:07 pm

Re: Love2D I/O to any directory?

Post by Skeletonxf »

I thought this was the entire file available with no further dependencies: https://gitlab.com/Zatherz/minifs/blob/ ... minifs.lua
Edit: ooooh nvm
bobbyjones
Party member
Posts: 730
Joined: Sat Apr 26, 2014 7:46 pm

Re: Love2D I/O to any directory?

Post by bobbyjones »

You can include luafilesystem with your .love I forget the exact place you have to put it, but I know on Windows it has to be next to the .exe. what I did the one time attempted to use luafilesystem was steal the binaries from zerobrane. Hopefully slime or bartbes will post next to explain how to distribute binaries with the .love. on Linux you will just have to tell the user to install luafilesystem.
Post Reply

Who is online

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