downloader.gd 567 B

1234567891011121314151617181920212223242526
  1. extends HTTPRequest
  2. var kinds = {
  3. "height": "http://imbrium.mit.edu/DATA/SLDEM2015/TILES/FLOAT_IMG/%s",
  4. "color": ""
  5. }
  6. func ensureFolder(kind):
  7. var dir = Directory.new()
  8. dir.open("user://")
  9. if not dir.dir_exists(kind):
  10. dir.make_dir(kind)
  11. func load(file, kind):
  12. if not kinds.has(kind):
  13. print("don't know kind %s"%kind)
  14. return
  15. ensureFolder(kind)
  16. var url = kinds[kind]%file
  17. download_file = "user://%s/%s".format([kind, file])
  18. # Perform a GET request.
  19. var error = request(url)
  20. if error != OK:
  21. push_error("An error occurred in the HTTP request.")