steam_ugc_download

Download a preview image of a given UGC item.

Syntax:

steam_ugc_download(ugc_handle, dest_filename);


Argument Description
ugc_handle The unique handle for the preview to be downloaded.
dest_filename The file name to save the preview with.


Returns: Async ID


Description

With this function you can download a preview image for any given UGC item. The ugc_handle is the unique identifying value for the image (which you can get using the function steam_ugc_send_query()), and the destination filename is the name (and local path within the Steam sandbox) that you wish to give the image file when the download is complete.

When using this function it will trigger an Steam Asynchronous event to report the details of the image file requested containing the following key/value pairs in the async_load ds_map:

  1. "id" - The async ID returned by the calling function

  2. "result" - The result of the operation (a real value). This will either be the GML constant ugc_result_success or some other real number. So you should check for this constant to ensure that the call was successful, and if otherwise somthing has not worked correctly. The rest of the possible values returned are shown as the result of the Steam "EResult" value and you should see steamclientpublic.h in the SDK headers for all 89 possible values.

  3. "event_type" - This key will hold the value "ugc_download"

  4. "original_filename" - This key holds the original name of the image file on the server (a string)

  5. "dest_filename" - This key holds the image file name you passed in (a string)

  6. "ugc_handle" - This key holds the ugc_handle value that you passed in to the calling function


Extended Example:

In this example we first call the function and store the async ID value in a variable:

steam_get = steam_ugc_download(steam_handle, "\UGC\Preview_file.png");

This would then send off a file request to the Steam API, generating an async event which we would deal with as follows:

var event_id = async_load[? "id"];
if event_id == steam_get
   {
   var type = async_load[? "event_type"];
   if type == "ugc_download"
      {
      sprite_delete(preview_sprite);       preview_sprite = sprite_add(async_load[? "dest_filename"], 0, false, false, 0, 0);
      }
   }

The above code checks the event type and then creates a sprite from the downloaded image.


Back: Steam API - User Generated Content
Next: steam_ugc_create_item
© Copyright YoYo Games Ltd. 2018 All Rights Reserved