Josh Posted November 14, 2023 Share Posted November 14, 2023 AmbientCG has about 3000 PBR materials and a simple REST web API. List categories: https://ambientcg.com/api/v2/categories_json List files in category: https://ambientcg.com/api/v2/full_json?include=imageData,downloadData&category=PavingStones These URLs can be loaded with FetchURL. There is a JSON parsing library included in the Scripts/System folder, dkjson.lua. This is used by the debugger. I have not used it myself for anything. More docs here: https://docs.ambientcg.com/api/v2/ Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted November 14, 2023 Author Share Posted November 14, 2023 Example: local json = require 'System/dkjson' local s = FetchUrl("https://ambientcg.com/api/v2/categories_json") local t = json.decode(s) if type(t) == "table" then local n for n = 1, #t do if (type(t[n]) == "table") then if type(t[n]["categoryName"]) == "string" then Print(t[n]["categoryName"]) end end end end Download and extract: DownloadFile("https://ambientcg.com/get?file=PavingStones137_1K-JPG.zip", GetPath(PATH_DESKTOP).."/test.zip" ) local pak = LoadPackage(GetPath(PATH_DESKTOP).."/test.zip") if pak then local dir = pak:LoadDir("") local n for n = 1, #dir do if pak:FileType(dir[n]) == 1 then pak:ExtractFile(dir[n], GetPath(PATH_DESKTOP).."/"..dir[n]) end end pak:Close() end Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted November 17, 2023 Author Share Posted November 17, 2023 Updated example that uses LoadTable() instead of the Lua JSON parser: local s = FetchUrl("https://ambientcg.com/api/v2/categories_json") local t = LoadTable(s) if type(t) == "table" then local n for n = 1, #t do if (type(t[n]) == "table") then if type(t[n]["categoryName"]) == "string" then Print(t[n]["categoryName"]) end end end end Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted November 18, 2023 Author Share Posted November 18, 2023 The Lua debugger is actually using Lua socket, not libcurl. A couple of things to note: Curl (curl.exe) is now included standard on WIndows 10 and 11. Having libcurl.dll in the application's root directory will cause the Steam build to crash, presumably because the Steamworks API is using a different version of the DLL: https://steamcommunity.com/groups/steamworks/discussions/0/6699728899096777474/ Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.