darraghd493

synurlasset - A URL wrapper for getsynasset

Feb 24th, 2023 (edited)
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.55 KB | None | 0 0
  1. --[[
  2.     geturlasset by dd493
  3.    
  4.     A URL wrapper for getsynasset.
  5.  
  6.     Documentation:
  7.         - geturlasset(string url)
  8.             Returns a Content string using the given URL.
  9.    
  10.     Updates:
  11.         1.0 Release
  12. ]]
  13.  
  14. local cache = {}
  15. function geturlasset(url)
  16.     if cache[url] then return cache[url] end
  17.        
  18.     local file = "temp/" .. tostring(os.time()) .. ".png"
  19.     makefolder("temp")
  20.     writefile(file, game:HttpGet(url, true))
  21.    
  22.     local asset = getsynasset(file)
  23.     cache[url] = asset
  24.     return asset
  25. end
  26.  
  27. return geturlasset
Advertisement
Add Comment
Please, Sign In to add comment