steam_ugc_create_item

Syntax:

steam_ugc_create_item(consumer_app_id, file_type);


Argument Description
consumer_app_id The unique App ID for your game on Steam.
file_type One of the available file type constants (listed below).


Returns: Async ID


Description

This function is used to prepare the Workshop API and generate a published file ID for the item to be added. The function must be called before doing anything else with the item to be uploaded, as you will be required to use the unique published ID value that it returns in the Steam Async Event for updating. To use this function, you need to supply the Steam App ID for your game, and the use one of the following constants for the file_type argument:

Constant Description
ugc_filetype_community This is used to create files that will be uploaded and made available to anyone in the community.
ugc_filetype_microtrans This is used to describe files that are uploaded but intended only for the game to consider adding as official content.



When using this function it will return an async ID value which can then be parsed when the Steam Asynchronous event is triggerd to report the creation of the item. The event will contain the following key/map values 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_create_item"

  4. "legal_agreement_required" - Will be true or false (see the Steam docs for more details)

  5. "published_file_id" - This key holds the unique published ID for the item




Extended Example:

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

var app_id = steam_get_app_id();
new_item = steam_ugc_create_item(app_id, ugc_filetype_community);

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

var event_id = async_load[? "id"];
if event_id == new_item
   {
   var type = async_load[? "event_type"];
   if type == "ugc_create_item"
      {
      global.Publish_ID = async_load[? "published_file_id"];
      }
   }

The above code checks the event type and if it is "ugc_create_item" then it retrieves the published file ID and stores it in a global variable for future reference.