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 triggered to report the creation of the
item. The event will contain the following key/map values in the async_load ds_map:
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). |
Async ID
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.