Download files straight from the game/program?
-
- Prole
- Posts: 5
- Joined: Wed Jun 20, 2018 12:46 am
Download files straight from the game/program?
I am new to the Love game creator, but not new to Lua. I want to make a game that will download the game files from GitHub or my website. Any help would be apricated!
- master both
- Party member
- Posts: 262
- Joined: Tue Nov 08, 2011 12:39 am
- Location: Chile
Re: Download files straight from the game/program?
Hi and welcome to the forums,
If you want to download files from another server you can use the socket http module that comes with Löve:
If you want to download files from another server you can use the socket http module that comes with Löve:
Code: Select all
local http = require "socket.http"
local logo
function love.load()
logo = http.request("https://love2d.org/style/logo.png")
logo = love.filesystem.newFileData(logo, "logo.png")
logo = love.graphics.newImage(logo)
end
function love.draw()
love.graphics.draw(logo)
end
-
- Prole
- Posts: 5
- Joined: Wed Jun 20, 2018 12:46 am
Re: Download files straight from the game/program?
Thanks, but I wanted to save it to the computer. I'll check the wiki, hopefully I find something there.
-
- Prole
- Posts: 5
- Joined: Wed Jun 20, 2018 12:46 am
Re: Download files straight from the game/program?
Alright, I found here where the data of the game is saved. I'll try copying the downloaded data where the data is saved to a %appdata%/MyGame or %appdata%/Testing file. Maybe this could help someone else who is looking on how to do this.
- master both
- Party member
- Posts: 262
- Joined: Tue Nov 08, 2011 12:39 am
- Location: Chile
Re: Download files straight from the game/program?
That's right, If you want to save the file you have to use love.filesystem.write:MarcoPolo0306 wrote: ↑Wed Jun 20, 2018 10:47 pm Alright, I found here where the data of the game is saved. I'll try copying the downloaded data where the data is saved to a %appdata%/MyGame or %appdata%/Testing file. Maybe this could help someone else who is looking on how to do this.
Code: Select all
local http = require "socket.http"
function love.load()
local logo = http.request("https://love2d.org/style/logo.png")
love.filesystem.write("logo.png", logo)
end
function love.draw()
local s = "Saved on "..love.filesystem.getSaveDirectory().."/logo.png"
love.graphics.print(s, 10, 10) -- /Users/Nico/Library/Application Support/LOVE/u/logo.png in my case
end
-
- Prole
- Posts: 5
- Joined: Wed Jun 20, 2018 12:46 am
Re: Download files straight from the game/program?
Alright, I've used that now, but whenever I try to change the directory that the file saves in, the file won't save whatsoever. Maybe the directory needs to be valid?
-
- Party member
- Posts: 234
- Joined: Mon Aug 29, 2016 8:51 am
Re: Download files straight from the game/program?
Read this:
https://love2d.org/wiki/love.filesystem
"Each game is granted a single directory on the system where files can be saved through love.filesystem. This is the only directory where love.filesystem can write files."
https://love2d.org/wiki/love.filesystem
"Each game is granted a single directory on the system where files can be saved through love.filesystem. This is the only directory where love.filesystem can write files."
-
- Prole
- Posts: 6
- Joined: Wed Oct 07, 2020 5:34 am
Re: Download files straight from the game/program?
Hi!
I wanted some more help regarding this topic! What if I want to save a zip, then unmount it?
Thanks,
I wanted some more help regarding this topic! What if I want to save a zip, then unmount it?
Thanks,
~Attachment Aditya
Re: Download files straight from the game/program?
You can just remove that file:
https://love2d.org/wiki/love.filesystem.remove
or unmount it:
https://love2d.org/wiki/love.filesystem.unmount
https://love2d.org/wiki/love.filesystem.remove
or unmount it:
https://love2d.org/wiki/love.filesystem.unmount
My boat driving game demo: https://dusoft.itch.io/captain-bradley- ... itius-demo
- zorg
- Party member
- Posts: 3465
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Download files straight from the game/program?
If the premise was that you just downloaded a zip, then you don't need to unmount it since you never mounted it in the first place.Attachment Studios wrote: ↑Sun Feb 21, 2021 4:01 pm Hi!
I wanted some more help regarding this topic! What if I want to save a zip, then unmount it?
Thanks,
If it was instead about mounting a zip, saving something into it (which i'm not sure is possible), then unmounting it, then that's a different thing.
Also, don't use love.filesystem.remove unless you want to actually delete the file.
Me and my stuff True 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.
Who is online
Users browsing this forum: Google [Bot] and 4 guests