Page 1 of 1

LOVEDownloader - A download library

Posted: Sun Dec 08, 2013 7:24 pm
by Joemag
LOVEDownloader is a library that let you download files very easy and with seeing the progress.

A documentation is on Github: https://github.com/Joemag/LOVEDownloader


Demo 0.8.0: https://www.dropbox.com/s/sefd8vo83kcu6 ... ample.love
Demo 0.9.0: https://www.dropbox.com/s/ax9o12sc2q3c0 ... ample.love
hGJI0MO.png
hGJI0MO.png (7.41 KiB) Viewed 1258 times

Download
LOVEDownloader_0.8.0.zip
(6.94 KiB) Downloaded 341 times
LOVEDownloader_0.9.0.zip
(7.02 KiB) Downloaded 433 times
Very easy

Code: Select all

LOVEDownloader = require('LOVEDownloader')

function love.load()
    file = LOVEDownloader.download("http://www.randomnumber.org/randdata/1MB_200409232104.dat", "file.dat", {
        update = function(per, down, size)
            print(per, down, size)
        end
    })
    file:start() -- Start download
end
function love.update()
    file:update()
end
function love.draw()
    love.graphics.print(math.floor(file.progress*100) .. "%", 10, 10)
    if file.success then
        print("success")
    end
end

Re: LOVEDownloader - A download library

Posted: Sun Dec 08, 2013 8:01 pm
by Davidobot
Looks very interesting, I'll be sure to try it out! :awesome:

Re: LOVEDownloader - A download library

Posted: Mon Dec 09, 2013 6:59 pm
by MPQC
Can't check the source now, but curious. Does it download the file to the love save path, or its current directory?

Re: LOVEDownloader - A download library

Posted: Mon Dec 09, 2013 8:41 pm
by Joemag
MPQC wrote:Can't check the source now, but curious. Does it download the file to the love save path, or its current directory?
It uses love.filesystem, so it downloads to the loves save directory. But if you want to download to another directory, you can replace love.filesystem.newFile() with io.open() in thread.lua

Re: LOVEDownloader - A download library

Posted: Mon Dec 09, 2013 8:51 pm
by MPQC
Makes sense. Could be quite useful as an auto updater.

Re: LOVEDownloader - A download library

Posted: Wed Dec 11, 2013 8:16 am
by Kyle
Can it do image files?

Also, the HTTP lib you have for luasocket is included in LOVE, I think.

Re: LOVEDownloader - A download library

Posted: Wed Dec 11, 2013 9:45 pm
by Joemag
Kyle wrote:Can it do image files?

Also, the HTTP lib you have for luasocket is included in LOVE, I think.
Yes, you can download images. Example:

Code: Select all

downFile = LOVEDownloader.download("http://example.com/image.png", "imgs/image.png")
The http lib is included in LÖVE, but I modified it to get the size without connecting twice.

Re: LOVEDownloader - A download library

Posted: Wed Dec 11, 2013 10:25 pm
by Kyle
Ah, cool! I already have my HTTP connections threaded, but I'll check out your modification because that sounds like something I could use. I'll have approximately 200,000 512x512 images in my game and something tells me people won't want those all at once :P

Re: LOVEDownloader - A download library

Posted: Fri Dec 13, 2013 3:24 am
by Mermersk
Very nice! I can see this being very useful in the future. Maybe this could be used when making a game with someone that doesn't live anywhere close to you.