1.71 ResourcePack .621 1.71.1 ResourcePack.DebugGetLoadError .621 1.71.2 ResourcePack.GetLoadProgress .622 1.71.3 ResourcePack.GetLoadState .623 1.71.4 ResourcePack.IsLoading .623 1.71.5 ResourcePack.Load .624 1.71.6 ResourcePack.Unload .62 ResourcePack ResourcePack.DebugGetLoadError Brief Get the error code for a load error. Definition RpLoadError ResourcePack.DebugGetLoadError( ResourcePack pack ) Arguments pack - Resource Pack object. Return Values An RpLoadError value indicating the reason for the load failure RpLoadError.None - no error RpLoadError.MountFail - object package could not be mounted RpLoadError.OfflineFail - offline object could not be loaded RpLoadError.DownloadFail - download of object package failed RpLoadError.ResourcesFail - resources XML did not load or parse correctly RpLoadError.ResourceAddFail - one of the object resources did not load RpLoadError.LocalisationFail - localization XML did not load or parse correctly RpLoadError.CreateDefFail - object definition could not be created RpLoadError.ObjectDefFail - object XML did not load or parse correctly RpLoadError.CreateFail - object create failed RpLoadError.MakeFail - object type could not be found RpLoadError.Component - one of the components failed to load (should not occur for RPs) RpLoadError.NotAResourcePack- load references an object that is not an RP RpLoadError.PermissionDenied - either requesting object or RP doesn't list object in permissions Description If GetLoadState indicates an error has occurred, this function can be used to retrieve the error state. This function is not available in live content and is not intended for display to a user, but can assist when developing the script. Examples myResPack = ResourcePack.Load( DEADBEEF-00000000-00000000-00000000 ) if (not myResPack) then local e = myResPackGetLoadError() end while (myResPackGetLoadState() ~= RpLoadState.Loaded and myResPackGetLoadState() ~= RpLoadState.Error) do coroutine.yield() end if (myResPackGetLoadState() == RpLoadState.Error) then local e = myResPackGetLoadError() end See Also • ResourcePack.GetLoadState • ResourcePack. Load ResourcePack.GetLoadProgress Brief Get the progress percentage of the current load state. Definition number ResourcePack.GetLoadProgress( ResourcePack pack ) Arguments pack - Resource Pack object. Return Values A number in the range [ 0, 1 ] representing the proportion of the current load state that is complete. Description The Downloading and Loading states will each take a period of time to complete. A script should indicate to the user the progress of these steps individually so the load process is clearly understood. If this function is called for other states the value is likely to be fixed at 0 or 1 and should not be displayed to the user. Examples if ( loadState == RpLoadState.Downloading ) then myDownloadProgressBarGuiSetProgress( myResPackGetLoadProgress() 100.0 ) elseif ( loadState == RpLoadState.Loading ) then myLoadProgressBarGuiSetProgress( myResPackGetLoadProgress() 100.0 ) end See Also • ResourcePack.GetLoadState • ResourcePack.Load ResourcePack.GetLoadState Brief Get the current load state of a ResourcePack. Definition RpLoadState ResourcePack.GetLoadState( ResourcePack pack ) Arguments pack - Resource Pack object. Return Values A RpLoadState enum indicating the current load state RpLoadState.Created RpLoadState.Queued RpLoadState.Downloading RpLoadState.Loading RpLoadState.Loaded RpLoadState. Error Description The load of a ResourcePack is an asynchronous process which may take some time to complete. This function will indicate the current state of the ResourcePack load. Once the Loaded status is returned the object is ready to use. If this function indicates Error, the script can use GetLoadError to find out why the load failed. The Downloading and Loading states can be further queried for their progress using the GetLoadProgress function. Examples while (myResPackGetLoadState() ~= RpLoadState.Loaded and myResPackGetLoadState() ~= RpLoadState.Error) do coroutine.yield() end if (myResPackGetLoadState() == RpLoadState.Error) then print(ResourcePack failed to load!) end See Also • ResourcePack.Load • ResourcePack.GetLoadProgress ResourcePack.IsLoading Brief Returns true if resource pack is currently downloading or loading. Definition ResourcePack.IsLoading(ResourcePack pack) Arguments pack - The ResourcePack object. Return Values True if the resource pack is download or loading, false otherwise. Description This function will check the load state and indicate whether the resource pack is downloadingloading. Resource packs that have completed loading or failed to load will return false. Examples ! if (myResPackIsLoading()) then RenderProgressBar(myResPackGetLoadState(), myResPackGetLoadProgress()) — user function end See Also • ResourcePack.GetLoadState ResourcePack.Load Brief Creates a ResourcePack and starts downloading the object. Definition ResourcePack ResourcePack.Load( string objectld, number memorySlotld = 0 ) Arguments objectld - ID of resource pack object to load.memorySlotld - ID number of memory slot to load the resource pack into. Return Values A new ResourcePack object, or nil if object not found or could not be loaded. Description Initiates a background load of the specified ResourcePack object. The object ID must relate to a ResourcePack object for which this object has load permission, other object IDs will be refused. The load is asynchronous, so the script should query the progress using GetLoadState and GetLoadProgress, and display appropriate feedback to the user while the load process is taking place. If nil is returned the object ID is likely to be invalid, and the load request should not be retried. The script should call Unload when the ResourcePack is no longer required, ensuring that no resources remain in use. Examples myResPack = ResourcePack.Load( 11111111-11111111-11111111-11111111 ) if (not myResPack) then print(Error loading resource pack!) return end See Also • ResourcePack.GetLoadState • ResourcePack.GetLoadProgress • ResourcePack.Unload ResourcePack.Unload Brief Unloads the ResourcePack and all associated resources. Definition ! ResourcePack.Unload( ResourcePack pack ) Arguments pack - Resource Pack object. Return Values None. Description Unloads the ResourcePack object and all resources referenced by it. Note that the script should ensure that no resources owned by the ResourcePack remain in use by PS Home as the client will not check for this. The ResourcePack Lua object remains valid and can be used to load a new ResourcePack. Garbage collected ResourcePack Lua objects will call this function automatically. Examples ! if (loadingNextLevel) then myResPackUnload() j end See Also • ResourcePack. Load