-
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add AssetServiceUtils package with additional API calls
- Loading branch information
Showing
8 changed files
with
188 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
## AssetServiceUtils | ||
|
||
<div align="center"> | ||
<a href="http://quenty.github.io/NevermoreEngine/"> | ||
<img src="https://github.com/Quenty/NevermoreEngine/actions/workflows/docs.yml/badge.svg" alt="Documentation status" /> | ||
</a> | ||
<a href="https://discord.gg/mhtGUS8"> | ||
<img src="https://img.shields.io/discord/385151591524597761?color=5865F2&label=discord&logo=discord&logoColor=white" alt="Discord" /> | ||
</a> | ||
<a href="https://github.com/Quenty/NevermoreEngine/actions"> | ||
<img src="https://github.com/Quenty/NevermoreEngine/actions/workflows/build.yml/badge.svg" alt="Build and release status" /> | ||
</a> | ||
</div> | ||
|
||
Provides a wrapper for AssetService's async calls | ||
|
||
<div align="center"><a href="https://quenty.github.io/NevermoreEngine/api/AssetServiceUtils">View docs →</a></div> | ||
|
||
## Installation | ||
|
||
``` | ||
npm install @quenty/assetserviceutils --save | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "assetserviceutils", | ||
"tree": { | ||
"$path": "src" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"name": "@quenty/assetserviceutils", | ||
"version": "1.0.0", | ||
"description": "Provides a wrapper for AssetService's async calls", | ||
"keywords": [ | ||
"Roblox", | ||
"Nevermore", | ||
"Lua", | ||
"AssetService", | ||
"Promise" | ||
], | ||
"bugs": { | ||
"url": "https://github.com/Quenty/NevermoreEngine/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/Quenty/NevermoreEngine.git", | ||
"directory": "src/assetserviceutils/" | ||
}, | ||
"funding": { | ||
"type": "patreon", | ||
"url": "https://www.patreon.com/quenty" | ||
}, | ||
"license": "MIT", | ||
"contributors": [ | ||
"Quenty" | ||
], | ||
"dependencies": { | ||
"@quenty/loader": "file:../loader", | ||
"@quenty/promise": "file:../promise" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
--[=[ | ||
Utility methods involving the AssetService | ||
@class AssetServiceUtils | ||
]=] | ||
|
||
local require = require(script.Parent.loader).load(script) | ||
|
||
local AssetService = game:GetService("AssetService") | ||
|
||
local Promise = require("Promise") | ||
|
||
local AssetServiceUtils = {} | ||
|
||
--[=[ | ||
Retrieves the assetIds for a package | ||
@param packageAssetId number | ||
@return Promise<table> | ||
]=] | ||
function AssetServiceUtils.promiseAssetIdsForPackage(packageAssetId) | ||
assert(type(packageAssetId) == "number", "Bad packageAssetId") | ||
|
||
return Promise.spawn(function(resolve, reject) | ||
local result | ||
local ok, err = pcall(function() | ||
result = AssetService:GetAssetIdsForPackage(packageAssetId) | ||
end) | ||
|
||
if not ok then | ||
warn(err) | ||
return reject(err) | ||
end | ||
if typeof(result) ~= "table" then | ||
return reject("Result was not an table") | ||
end | ||
|
||
resolve(result) | ||
end) | ||
end | ||
|
||
--[=[ | ||
Gets the places and their name for the current game. | ||
@return Pages | ||
]=] | ||
function AssetServiceUtils.promiseGamePlaces() | ||
return Promise.spawn(function(resolve, reject) | ||
local pages | ||
local ok, err = pcall(function() | ||
pages = AssetService:GetGamePlacesAsync() | ||
end) | ||
|
||
if not ok then | ||
warn(err) | ||
return reject(err) | ||
end | ||
if not (typeof(pages) == "Instance" and pages:IsA("Pages")) then | ||
return reject("pages was not an table") | ||
end | ||
|
||
resolve(pages) | ||
end) | ||
end | ||
|
||
--[=[ | ||
Details for a specific bundle item | ||
@interface BundleDetailsItem | ||
.Id number -- Item's id | ||
.Name string -- Item name | ||
.Type string -- Item Type eg: "UserOutfit" or "Asset" | ||
@within AssetServiceUtils | ||
]=] | ||
|
||
--[=[ | ||
Details for the bundle | ||
@interface BundleDetails | ||
.Id -- Bundle Id (passed in as an argument) | ||
.Name string -- Bundle name | ||
.Description string -- Bundle description | ||
.BundleType string -- Bundle Type. eg. BodyParts or `AvatarAnimation|AvatarAnimations` | ||
.Items { BundleDetailsItem } -- An array of ValueTable objects | ||
@within AssetServiceUtils | ||
]=] | ||
|
||
--[=[ | ||
Gets the bundle details | ||
@param bundleId number | ||
@return BundleDetails | ||
]=] | ||
function AssetServiceUtils.promiseBundleDetails(bundleId) | ||
assert(type(bundleId) == "number", "Bad bundleId") | ||
|
||
return Promise.spawn(function(resolve, reject) | ||
local result | ||
local ok, err = pcall(function() | ||
result = AssetService:GetBundleDetailsAsync(bundleId) | ||
end) | ||
|
||
if not ok then | ||
warn(err) | ||
return reject(err) | ||
end | ||
if typeof(result) ~= "table" then | ||
return reject("Result was not an table") | ||
end | ||
|
||
resolve(result) | ||
end) | ||
end | ||
|
||
return AssetServiceUtils |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "node_modules", | ||
"globIgnorePaths": [ "**/.package-lock.json" ], | ||
"tree": { | ||
"$path": { "optional": "../node_modules" } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.