better LuaUserData error handling and add Steam.GetWorkshopCollection
This commit is contained in:
@@ -4,6 +4,8 @@ local AddCallMetaTable = LuaSetup.AddCallMetaTable
|
||||
local CreateStatic = LuaSetup.CreateStatic
|
||||
local CreateEnum = LuaUserData.CreateEnumTable
|
||||
|
||||
require("DefaultLib/Utils/SteamApi")
|
||||
|
||||
defaultLib["Byte"] = CreateStatic("Barotrauma.LuaByte", true)
|
||||
defaultLib["UShort"] = CreateStatic("Barotrauma.LuaUShort", true)
|
||||
defaultLib["Float"] = CreateStatic("Barotrauma.LuaFloat", true)
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
local descriptor = LuaUserData.RegisterType("Barotrauma.LuaCsSteam")
|
||||
|
||||
LuaUserData.AddMethod(descriptor, "GetWorkshopCollection", function (id, callback)
|
||||
id = tostring(id)
|
||||
|
||||
Networking.RequestPostHTTP("https://api.steampowered.com/ISteamRemoteStorage/GetCollectionDetails/v1/", function (result)
|
||||
local data = json.parse(result)
|
||||
|
||||
if data.response.collectiondetails.children == nil then
|
||||
callback()
|
||||
return
|
||||
end
|
||||
|
||||
local workshopItems = {}
|
||||
|
||||
for key, value in pairs(data.response.collectiondetails[1].children) do
|
||||
table.insert(workshopItems, value.publishedfileid)
|
||||
end
|
||||
|
||||
if callback then
|
||||
callback(workshopItems)
|
||||
end
|
||||
end,
|
||||
"collectioncount=1&publishedfileids[0]=" .. id,
|
||||
"application/x-www-form-urlencoded")
|
||||
end)
|
||||
Reference in New Issue
Block a user