| 1.70 Resource .609 |
| 1.70.1 Resource.CancelRequest .609 |
| 1.70.2 Resource.DebugDumpToTty .610 |
| 1.70.3 Resource.DebugSave .611 |
| 1.70.4 Resource.Exists.611 |
| 1.70.5 Resource.Find .612 |
| 1.70.6 Resource.GetData .612 |
| 1.70.7 Resource.GetDownloadProgress .613 |
| 1.70.8 Resource.GetName .614 |
| 1.70.9 Resource.GetStatusCode .614 |
| 1.70.10 Resource.GetSystemResource .615 |
| 1.70.11 Resource.IsLoaded .616 |
| 1.70.12 Resource.IsLoading .616 |
| 1.70.13 Resource.Release .617 |
| 1.70.14 Resource.Request .618 |
| 1.70.15 Resource.RequestSecure .618 |
| 1.70.16 Resource.RequestTexture .619 |
| 1.70.17 Resource.Run .620 |
| 1.70.18 Resource.StartLoading .620 |
|
|
| Resource |
| Resource.CancelRequest |
| Brief |
| Cancels a pending resource request. |
| Definition |
| ! Resource.CancelRequest( Resource resource ) |
| Arguments |
| resource - The resource to cancel the request for. |
| Return Values |
| None. |
| Description |
| Cancels a pending resource request. |
| Examples |
| ! Resource.CancelRequest( res ) |
| See Also |
| � Resource. Request |
| Resource.DebugDumpToTty |
| Brief |
| Debug function to dump a resource content and/or metadata to TTY. |
| Definition |
| ! Resource.DebugDumpToTty(Resource resource) |
| Arguments |
| resource - The resource to dump. |
| Return Values |
| None. |
| Description |
| Dumps available information about the resource contents to TTY. File resources will be dumped in their entirety, binary resources will have any |
| available human-readable metadata dumped. Note all resource types are currently supported, presently files/xml and textures are. This function is |
| only available if the debug flag is set on the Lua component, and is not available to live content. |
| Examples |
| url = "http://www.example.com/data.xml" |
| xmlDatal = Resource.Request( url, "file" ) |
| xmlDatal:DebugDumpToTty() |
| See Also |
| � Resource.DebugSave |
| Resource.DebugSave |
| Brief |
| Debug function to save a resource to the home directory. |
| Definition |
| boolean Resource.DebugSave(Resource resource, string filename) |
| Arguments |
| resource - The resource to dump.filename - The filename to use (including extension). |
| Return Values |
| True on success or false on failure. |
| Description |
| Dumps the contents of a resource to the home directory supplied via Target Manager. The operation is synchronous so be aware that large files |
| may involve a long pause. Currently only file/xml is supported. This function is only available if the debug flag is set on the Lua component, and is |
| not available to live content. |
| Examples |
| ! url = "http://www.example.com/data.xml" |
| | xmlDatal = Resource.Request( url, "file" ) |
| ! xmlDatal:DebugSave("debugXml.xml") |
| See Also |
| � Resource.DebugDumpToTty |
| Resource.Exists |
| Brief |
| Check if a specified resource exists in the object or a loaded resource pack. |
| Definition |
| boolean Resource.Exists(string resourceName, ResourcePack resourcePack = nil) |
| Arguments |
| resourceName - Name of the resource to search for.resourcePack - A loaded ResourcePack object to search in. |
| Return Values |
| True if the resource is present in the object or resource pack, or false otherwise. |
| Description |
| Checks for a named resource in the current object or a loaded resource pack. |
| Examples |
| I if (Resource.Exists("gun")) then |
| gunEntity:SetModel("gun") |
| | end |
| See Also |
| � Resource.Find |
| Resource.Find |
| Brief |
| Finds the specified resource. |
| Definition |
| ! Resource Resource.Find( string resourceName, ResourcePack pack = nil ) |
| Arguments |
| resourceName - The name of the resource to find.pack - ResourcePack from which to load the resource. Must be fully loaded. |
| Return Values |
| The Resource object. |
| Description |
| Finds the specified resource. The resource name is the name set for a resource in the FiDK's Object Editor application. Alternatively, the resource |
| name can be the name set for a scripted asset in the FiDK�s Scene Editor application. If the resource is not found an error occurs. |
| Examples |
| ! res = Resource.Find( "laserGun" ) |
| ! print( Resource.GetName( res ) ) |
| See Also |
| None |
| Resource.GetData |
| Brief |
| Depending on the type of resource it returns the corresponding object such as a texture. |
| Definition |
| variant Resource.GetData( Resource resource ) |
| Arguments |
| resource - The resource to query. |
| Return Values |
| Depending on the type of resource it returns the corresponding object. |
| Description |
| Depending on the type of resource it returns the corresponding object such as a texture. Supported resource types are: |
| Texture |
| SoundBank |
| SoundStream |
| Texture |
| Repertoire |
| Examples |
| texture = Resource.GetData( textureRes ) |
| textureWidth = Texture.GetWidth( texture ) |
| textureHeight = Texture.GetHeight( texture ) |
| See Also |
| � Resource. Request |
| � MemoryContainer.Create |
| Resource.GetDownloadProgress |
| Brief |
| Retrieve the download progress of a resource request. |
| Definition |
| number Resource.GetDownloadProgress( Resource resource ) |
| Arguments |
| resource - A requested resource that is currently loading. |
| Return Values |
| A number between 0 and 1 representing the download progress. |
| Description |
| If the resource is not downloading 0 will be returned, or if it is fully downloaded 1 is returned. The IsLoading and IsLoaded functions should be |
| preferred if simply checking for the load state. Note that the progress is the download progress only, other tasks may need to be performed after |
| downloading and so the download progress may return 1 while IsLoaded is still false. Only when IsLoaded returns true is the load complete. Also |
| note that a resource may be locally cached, and scripts should not assume that all requests will result in a download. |
| Examples |
| function OnUpdateO |
| if (resource:IsLoading()) then |
| local progress = resource:GetDownloadProgress() |
| if (progress == 0) then |
| print("Requesting.. . ") |
| elseif (0 < progress and progress > 1) then |
| print("Downloading. . ." ) |
| RenderProgressBar(progress) |
| else |
| print("Processing. . ." ) |
| end |
| end |
| end |
| See Also |
| � Resource. Request |
| � Resource. IsLoading |
| � Resource. IsLoaded |
| Resource.GetName |
| Brief |
| Returns the resource name. |
| Definition |
| 1 string Resource.GetName( Resource resource ) |
| Arguments |
| resource - The resource to query. |
| Return Values |
| The resource name. |
| Description |
| Returns the resource name. This function should only be used for resources obtained from a call to Resource.Find. |
| Examples |
| ! res = Resource.Find( 'laserGun' ) |
| ! print( Resource.GetName( res ) ) |
| See Also |
| � Resource.Find |
| Resource.GetStatusCode |
| Brief |
| Retrieve the status code for a requested resource download. |
| Definition |
| number Resource.GetStatusCode(Resource resource) |
| Arguments |
| resource - A requested resource that is currently loading. |
| Return Values |
| A status code (see below). |
| Description |
| For FITTP downloads, the status code will reflect the FITTP response status code, such as 404 in the case of file not found. The status code can |
| be used to determine the cause of failure in the case that lsLoaded() == false and IsLoadingQ == false, which indicates an error has occurred. If |
| no status code is available 0 is returned. Note that calling GetStatusCode in cases other than load failure is not guaranteed to produce an |
| expected result. |
| Examples |
| resource = Resource.Request("http://www.example.com/myXmlFile.xml", "xml") |
| resourceDone = false |
| function OnUpdateO |
| if (resource and not resourceDone) then |
| if (resource:IsLoaded()) then |
| � use resource |
| resourceDone = true |
| elseif (not resource:IsLoading()) then |
| � error case: resource is not loaded but also not loading |
| local code = resource:GetStatusCode() |
| if (code == 404) then |
| print("File has gone missing!") |
| else |
| print("HTTP download fail:", code) |
| end |
| resourceDone = true |
| else |
| print("Progress:", resource:GetDownloadProgress()) |
| end |
| end |
| end |
| See Also |
| � Resource. Request |
| � Resource.GetDownloadProgress |
| Resource.GetSystemResource |
| Brief |
| Get a system resource for use by the script. |
| Definition |
| Resource Resource.GetSystemResource( SysResources resourceld ) |
| Arguments |
| resourceld - ID of system resource to load (see details). |
| Return Values |
| The resource object. |
| Description |
| Some resources are loaded by the client and are available to all scripts. These resources will be treated as dynamically loaded (similarly to |
| Resource.Request) but will be shared with the client and not require downloading. The available resource IDs are: |
| � SysResources.TexPsStoreLogo |
| Examples |
| resource = Resource.GetSystemResource( SysResources.TexPsStoreLogo ) |
| if (resource:IsLoaded()) then |
| local tex = resource:GetData () |
| Renderer.DrawRect2d( renderer, Vector4.Create( 0, 0 ), Vector4.Create( 200, 50 ), Vector4.Create( |
| 1, 1, 1, 1 ), tex ) |
| end |
| See Also |
| � Resource. Request |
| � Resource.Find |
| Resource.IsLoaded |
| Brief |
| Returns true if the resource has been loaded successfully. |
| Definition |
| boolean Resource.IsLoaded( Resource resource ) |
| Arguments |
| resource - The resource to query. |
| Return Values |
| true if the resource has been loaded successfully and false otherwise. |
| Description |
| Returns true if the resource has been loaded successfully. |
| Examples |
| local isLoaded = Resource.IsLoaded( res ) |
| See Also |
| Resource. IsLoading |
| Resource.IsLoading |
| Brief |
| Returns true while the resource is loading. |
| Definition |
| ! boolean Resource.IsLoading( Resource resource ) |
| Arguments |
| resource - The resource to query. |
| Return Values |
| true if the resource is still loading or being requested and false otherwise. |
| Description |
| Returns true while the resource is loading. |
| Examples |
| ! local isLoading = Resource.IsLoading( res ) |
| See Also |
| � Resource. IsLoaded |
| Resource.Release |
| Brief |
| Releases the specified resource. |
| Definition |
| ! Resource.Release( Resource resource ) |
| Arguments |
| resource - The resource to be released. |
| Return Values |
| None. |
| Description |
| Releases the specified resource. |
| Examples |
| res = Resource.Find( 'laserGun' ) |
| Resource.Release( res ) |
| See Also |
| � Resource.Find |
| Resource.Request |
| Brief |
| Requests a new resource. |
| Definition |
| Resource Resource.Request( string|Screenshot content, string type, HttpPostData postData = nil, string |
| memory = nil, boolean useHttpCompression = false, boolean readBodyOnErrorStatus = false ) |
| Arguments |
| content - The URL of the resource to request or a Screenshot object.type - The type of resource to request. Can be one of the following: |
| "file" |
| "texture" |
| "soundstream"postData - Optional. Post data to send up to the server when making a request.memory - Optional. Valid values are 'host' or |
| 'main'.useHttpCompression - Boolean, indicates if HTTP compression should be used.readBodyOnErrorStatus - Boolean, indicates if the |
| response body should be read if the status code indicates a problem (e.g. for a '410 gone�, the body may be used to communicate a reason). |
| Return Values |
| A handle to the requested resource, or nil if the resource request failed (vOI .45+). |
| Description |
| Requests a new resource. Only HTTP/HTTPS downloads are currently supported. Note that images loaded as textures do not currently have |
| control over the compression or resizing of the image for use by PS Home, and as a result may display at a lower quality than the source image. If |
| you wish to control the conversion options used when creating the texture, see Resource.RequestTexture. |
| Examples |
| � Example 1: HTTP download of XML |
| url = "http://www.example.com/data.xml" |
| xmlDatal = Resource.Request( url, "file" ) |
| � Example 2: HTTPS download of XML generated by a server-sidew script |
| url = "https://www.example.com/script.php" |
| xmlData2 = Resource.Request( url, "file", postData, 'host' ) |
| � Example 3: After taking a screenshot load it up as a texture |
| if screenshot:Succeeded() == true then |
| screenShotTexture = Resource.Request( screenshot, "texture" ) |
| end |
| � Example 4: HTTP download of a texture |
| url = "http://www.example.com/texture.dds" |
| xmlDatal = Resource.Request( url, "texture" ) |
| See Also |
| � Screenshot.Create |
| � Resource.RequestTexture |
| � Resource.RequestSecure |
| Resource.RequestSecure |
| Brief |
| Requests a secure resource. |
| Definition |
| Resource Resource.RequestSecure( string contentld, string type, boolean global = false, MemoryType |
| memType = MemoryType.Main, boolean useHttpCompression = false, boolean readBodyOnErrorStatus = false ) |
| Arguments |
| contentld - The ID (filename) of the secure resource to request. Note that as this call will |
| ultimately result in an HTTPS request, the contentld is case-sensitive.type - The type of resource to request. Can be one of the following: |
| "file"global - Request the non-region-specific resource.memType - Memory type to allocate for the resource.useHttpCompression - Boolean, |
| indicates if HTTP compression should be used.readBodyOnErrorStatus - Boolean, indicates if the response body should be read if the status |
| code indicates a problem (e.g. for a '410 gone', the body may be used to communicate a reason). |
| Return Values |
| A handle to the requested resource, or nil if the resource request failed. |
| Description |
| Requests a new secure resource. There are two secure storage locations, one for the user's current region and one for all regions. Specifying the |
| global flag will request the non-region-specific file rather than the current region's file. If the secure service is not available this function will return |
| nil, scripts should handle this case gracefully. |
| Examples |
| � retrieve the global (non-region-specific) version of myfile.xml from secure storage |
| xmlData = Resource.RequestSecure( "myfile.xml", "file", true ) |
| See Also |
| � Resource. Request |
| Resource.RequestTexture |
| Brief |
| Request a new resource. |
| Definition |
| Resource Resource.RequestTexture( string|Screenshot content, TextureOptions options = |
| TextureOptions.Default ) |
| Arguments |
| content - The URL of the resource to request or a Screenshot object.options - The texture load options to use. Can be combined with the + |
| operator. The options available are |
| TextureOptions.Default - the standard options, as per Resource.Request. |
| TextureOptions.NoCompression - do not DXT compress the texture |
| TextureOptions.NoMipmaps - do not generate mipmaps for the texture |
| TextureOptions.NoSizeLimit - do not cap the major dimension of the texture to 512 texels |
| TextureOptions.NoPow2 - do not convert the major dimension of the texture to a power of 2 in size |
| TextureOptions.Image - all of the above 4 options combined |
| Return Values |
| A handle to the requested resource, or nil if the resource request failed. |
| Description |
| Requests a new texture resource. Only HTTP/HTTPS downloads are currently supported. The default texture load options can cause an image to |
| lose quality due to compression, size limiting and resizing. A script can use this function to specify the exact texture load options to use if required. |
| In normal cases without strict quality requirements, Resource.Request should be preferred. |
| Examples |
| fullscreenImage = Resource.RequestTexture("http://www.mywebsite.com/HDBackground.jpg", |
| TextureOptions.Image) |
| hiResTexture = Resource.RequestTexture("http://www.mywebsite.com/HiResTexture.png", |
| TextureOptions.NoSizeLimit) |
| myScreenshot = Resource.RequestTexture(screenshotObject, TextureOptions.NoSizeLimit + |
| TextureOptions.NoCompression + TextureOptions.NoPow2 + TextureOptions.NoMipmaps) |
| See Also |
| � Resource. Request |
| Resource.Run |
| Brief |
| Executes the specified resource as a Lua script. |
| Definition |
| Resource.Run( string resourceName, ResourcePack pack = nil ) |
| Resource.Run( Resource fileResource ) |
| Arguments |
| resourceName - The name of the resource. The type of the resource must be 'lua'.resourcePack - The ResourcePack to search for the specified |
| resourceName, if desired.fileResource - The resource to run. The type of the resource must be 'lua'. |
| Return Values |
| None. |
| Description |
| Executes the specified resource as a Lua script. |
| Examples |
| Resource.Run( "utils.lua" ) |
| See Also |
| � LoadLibrary |
| Resource. StartLoading |
| Brief |
| Starts loading the resource if it is not already loaded. |
| Definition |
| ! boolean Resource. StartLoading ( Resource resource, number memorySlotld ) |
| Arguments |
| resource - The resource to be loaded.memorySlotld - The id of the memory slot to use or 0 for the default budget |
| Return Values |
| true if successful and false otherwise. |
| Description |
| Starts loading the resource if it is not already loaded. If a callback is specified, it will be passed a boolean value indicating whether the load |
| succeeded. |
| Examples |
| res = Resource.Find( 'laserGun� ) |
| Resource.StartLoading( res ) |
| res2 = Resource.Find( 'mapSection2' ) |
| Resource.StartLoading( res2, 2 ) � load into memory slot 2 |
| See Also |
| None |
|
|