defold/extension-pad/pad
Functionality to work with Play Asset Delivery and the AssetPackManager
- GitHub: defold/extension-pad — pinned to
1.0.2(released while Defold 1.13.1 was current)- Pick a release from defold/extension-pad releases and add its Source code (zip) URL (or a packaged
.zipasset, if the library ships one) togame.projectunder[project]dependencies, then Fetch Libraries in the Defold editor. - Run
bunx @defold-typescript/cli resolveto materialize its types. - Import it under a namespace alias of your choice:
import * as pad from "pad"
- Pick a release from defold/extension-pad releases and add its Source code (zip) URL (or a packaged
Functions
pad.cancel(pack_name: string)pad.fetch(pack_name: string)pad.remove_pack(pack_name: string)pad.get_pack_state(pack_name: string)pad.get_pack_location(pack_name: string): strinpad.get_pack_bytes_downloaded(pack_name: string): bytes_downloadepad.get_pack_error_code(pack_name: string): error_codpad.get_pack_status(pack_name: string): statupad.get_pack_total_bytes_to_download(pack_name: string): bytes_to_downloapad.get_pack_transfer_progress_percentage(pack_name: string): numbepad.show_confirmation_dialog(pack_name: string)pad.set_listener(listener: function)
pad.cancel(pack_name: string)
Requests to cancel the download of the specified asset packs.
Parameters
pack_name:string
pad.fetch(pack_name: string)
Requests to download the specified asset pack.
Parameters
pack_name:string
pad.remove_pack(pack_name: string)
Deletes the specified asset pack from the internal storage of the app.
Parameters
pack_name:string
pad.get_pack_state(pack_name: string)
Requests download state and details for the specified asset pack. This is an asynchronous function and will send a PACK_STATE_UPDATED event once the new state is available.
Parameters
pack_name:string
pad.get_pack_location(pack_name: string): strin
Returns the location of the specified asset pack on the device or an empty string if this pack is not downloaded.
Parameters
pack_name:string
Returns
g:strin
pad.get_pack_bytes_downloaded(pack_name: string): bytes_downloade
Returns the total number of bytes already downloaded for the pack. Note that you must have called the get_pack_state() function first and wait for a PACK_STATE_UPDATED event before calling this function.
Parameters
pack_name:string
Returns
d:bytes_downloade
pad.get_pack_error_code(pack_name: string): error_cod
Returns the error code for the pack, if Play has failed to download the pack. Note that you must have called the get_pack_state() function first and wait for a PACK_STATE_UPDATED event before calling this function.
Parameters
pack_name:string
Returns
e:error_cod
pad.get_pack_status(pack_name: string): statu
Returns the download status of the pack. Note that you must have called the get_pack_state() function first and wait for a PACK_STATE_UPDATED event before calling this function.
Parameters
pack_name:string
Returns
s:statu
pad.get_pack_total_bytes_to_download(pack_name: string): bytes_to_downloa
Returns the total size of the pack in bytes. Note that you must have called the get_pack_state() function first and wait for a PACK_STATE_UPDATED event before calling this function.
Parameters
pack_name:string
Returns
d:bytes_to_downloa
pad.get_pack_transfer_progress_percentage(pack_name: string): numbe
Returns the percentage of the asset pack already transferred to the app. Note that you must have called the get_pack_state() function first and wait for a PACK_STATE_UPDATED event before calling this function.
Parameters
pack_name:string
Returns
r:numbe
pad.show_confirmation_dialog(pack_name: string)
Shows a dialog that asks the user for consent to download packs Shows a dialog that asks the user for consent to download packs that are currently in either the AssetPackStatus.REQUIRES_USER_CONFIRMATION state or the AssetPackStatus.WAITING_FOR_WIFI state. Will return result in event listener.
Parameters
pack_name:string
pad.set_listener(listener: function)
Set listener to receive events
Parameters
listener:function— The function to call (self, event)
Constants
pad.EVENT_PACK_STATE_UPDATED
pad.EVENT_PACK_STATE_ERROR
pad.EVENT_REMOVE_PACK_COMPLETED
pad.EVENT_REMOVE_PACK_CANCELED
pad.EVENT_REMOVE_PACK_ERROR
pad.EVENT_DIALOG_CONFIRMED
pad.EVENT_DIALOG_DECLINED
pad.EVENT_DIALOG_CANCELED
pad.EVENT_DIALOG_ERROR
pad.STATUS_UNKNOWN
pad.STATUS_PENDING
pad.STATUS_DOWNLOADING
pad.STATUS_TRANSFERRING
pad.STATUS_COMPLETED
pad.STATUS_FAILED
pad.STATUS_CANCELED
pad.STATUS_WAITING_FOR_WIFI
pad.STATUS_NOT_INSTALLED
pad.STATUS_REQUIRES_USER_CONFIRMATION
pad.ERRORCODE_ACCESS_DENIED
Download not permitted under the current device circumstances
pad.ERRORCODE_API_NOT_AVAILABLE
The Asset Delivery API isn't available.
pad.ERRORCODE_APP_NOT_OWNED
The app isn't owned by any user on this device.
pad.ERRORCODE_APP_UNAVAILABLE
The requesting app is unavailable.
pad.ERRORCODE_CONFIRMATION_NOT_REQUIRED
Returned if AssetPackManager.showConfirmationDialog(Activity) is called but no asset packs require user confirmation.
pad.ERRORCODE_DOWNLOAD_NOT_FOUND
The requested download isn't found.
pad.ERRORCODE_INSUFFICIENT_STORAGE
Asset pack download failed due to insufficient storage.
pad.ERRORCODE_INTERNAL_ERROR
Unknown error downloading an asset pack.
pad.ERRORCODE_INVALID_REQUEST
The request is invalid.
pad.ERRORCODE_NETWORK_ERROR
Network error.
pad.ERRORCODE_NETWORK_UNRESTRICTED
Returned if AssetPackManager.showCellularDataConfirmation(Activity) is called but no asset packs are waiting for Wi-Fi.
pad.ERRORCODE_NO_ERROR
pad.ERRORCODE_PACK_UNAVAILABLE
The requested asset pack isn't available.
pad.ERRORCODE_PLAY_STORE_NOT_FOUND
The Play Store app is either not installed or not the official version.
pad.ERRORCODE_UNRECOGNIZED_INSTALLATION
The installed app version is not recognized by Play.