• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Question - Code [solved] Steam Workshop - files won't upload

hdarren

Member
I am trying to get Steam Workshop supported so people can upload their own custom racetracks. It manages to successfully create the workshop item, adds tags, sets the title and description, but for some reason it will not upload the preview image and file. The file always says 0.000MB and the preview image is as if it doesn't exist.

This is my code.

Code:
app_id = steam_get_app_id();
new_item = steam_ugc_create_item(app_id,ugc_filetype_community);

pth = working_directory + "workshop\\";
if global.var_LevelGameType = 1 {pth+="race\\";}
else if global.var_LevelGameType = 2 {pth+="speed\\";}
vFile = pth+global.var_LevelName+".rt";

vPreview = screen_save(pth+global.var_LevelName+".png");
scr_CreateSaveLevelDataFile(vFile);
Async - Steam
Code:
var event_id = async_load[? "id"];
if event_id == new_item
{
  var type = async_load[? "event_type"];
  if type == "ugc_create_item"
  {
    global.vPublish_ID = async_load[? "published_file_id"];
 
    var updateHandle = steam_ugc_start_item_update(app_id,global.vPublish_ID);
    steam_ugc_set_item_title(updateHandle,global.var_LevelName);
    steam_ugc_set_item_description(updateHandle,"Test.");
    steam_ugc_set_item_visibility(updateHandle,ugc_visibility_public);
    var tagArray;
    if global.var_LevelGameType = 1 {tagArray[0]="Race Track";}
    else if global.var_LevelGameType = 2 {tagArray[0]="Speed Way";}
    steam_ugc_set_item_tags(updateHandle,tagArray);
    steam_ugc_set_item_preview(updateHandle,vPreview);
    steam_ugc_set_item_content(updateHandle,vFile);
    requestId = steam_ugc_submit_item_update(updateHandle,"");
  }
}
The file and preview image are being correctly created in the AppData folder on my hard drive. I know that cloud saving is working because I have that already set up for my other save files and is set to easily accommodate the file sizes. I have also ticked and published the ISteamUGC box as instructed in the guide. I tried removing the "working_directory" from the paths but that doesn't work.

Can anybody help? :(
 
Last edited:

hdarren

Member
I've got the preview to show! I don't think the screen_save function returns anything so you have to manually set the path yourself. Like so.

Code:
screen_save(pth+global.var_LevelName+".png");
steam_ugc_set_item_preview(updateHandle,pth+global.var_LevelName+".png");
Weirdly though it seems I have to delete the file off my hard drive each time otherwise it doesn't upload.

//edit
oh great now nothing works! it just uploads an empty item with no description, title, etc, for f**ks sake why the documentation of this absolute GARBAGE and there's NO TUTORIALS OR WORKING EXAMPLS ANYWHERE
 
Last edited:

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
The thing that is immediately noticeable is that "content" should point to a directory, and the thumbnail is normally placed into that directory as well.

The other thing to mind is that if anything is wrong with the update request (e.g. a typo in a tag), Steam will just reject the whole thing, leaving you with just what you are seeing - an item that was created but not updated.

NO TUTORIALS OR WORKING EXAMPLS ANYWHERE
In the grandest feat of irony, despite people desiring Steam workshop support supposedly having at least some sort of a budget (it takes a half-decent game for workshop implementation to not be a waste of time after all), in the past half of decade there was not a single soul willing to pay for a clean written tutorial to be produced - if you search the forum, you can find a handful of questions on this exact thing with replies by me.
 

hdarren

Member
The thing that is immediately noticeable is that "content" should point to a directory, and the thumbnail is normally placed into that directory as well.
But how does it know what content file to upload? I'm trying to upload a .rt file which is basically just a text document that I have saved data into using ini_open()
 

hdarren

Member
In the grandest feat of irony, despite people desiring Steam workshop support supposedly having at least some sort of a budget (it takes a half-decent game for workshop implementation to not be a waste of time after all), in the past half of decade there was not a single soul willing to pay for a clean written tutorial to be produced - if you search the forum, you can find a handful of questions on this exact thing with replies by me.
Also YoYo should pay you to make a tutorial because the so called examples in the manual are either non-existent or garbage! I have searched the forums and there isn't explanation to be found. Most of them are unsolved and unanswered.
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
But how does it know what content file to upload? I'm trying to upload a .rt file which is basically just a text document that I have saved data into using ini_open()
It uploads everything that is in the directory. If you look at your workshop caches from other games, they are all directories, for which reason steam_ugc_get_item_install_info also gives you a directory - not a file path.

Also YoYo should pay you to make a tutorial because the so called examples in the manual are either non-existent or garbage!
I admire your optimism but I am not currently doing any work with YoYo so I highly doubt that this would happen too quickly. You can certainly file a bug report for the documentation being lacking though, I don't think anyone asking this question did.
 

hdarren

Member
It uploads everything that is in the directory. If you look at your workshop caches from other games, they are all directories, for which reason steam_ugc_get_item_install_info also gives you a directory - not a file path.
Thank you! For one brief moment it uploaded everything perfectly, preview and file! But then I decided to clean up the code a bit and now it's not working again even after changing it back lmao. It just uploads an empty item again now. Sigh.

This is my code now.

Code:
app_id = steam_get_app_id();
new_item = steam_ugc_create_item(app_id,ugc_filetype_community);

scr_CreateSaveLevelDataFile("Workshop\\Level.rt");
screen_save("Preview.png");
Async - Steam.

Code:
var event_id = async_load[? "id"];
if event_id == new_item
{
  var type = async_load[? "event_type"];
  if type == "ugc_create_item"
  {
    global.vPublish_ID = async_load[? "published_file_id"];
 
    var updateHandle = steam_ugc_start_item_update(app_id,global.vPublish_ID);
    steam_ugc_set_item_title(updateHandle,global.var_LevelName);
    steam_ugc_set_item_description(updateHandle,"");
    steam_ugc_set_item_visibility(updateHandle,ugc_visibility_public);
    var tagArray;
    if global.var_LevelGameType = 1 {tagArray[0]="Race Track";}
    else if global.var_LevelGameType = 2 {tagArray[0]="Speed Way";}
    steam_ugc_set_item_tags(updateHandle,tagArray);
    steam_ugc_set_item_preview(updateHandle,"Preview.png");
    steam_ugc_set_item_content(updateHandle,"Workshop");
    requestId = steam_ugc_submit_item_update(updateHandle,"");
  }
}
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
Thank you! For one brief moment it uploaded everything perfectly, preview and file! But then I decided to clean up the code a bit and now it's not working again even after changing it back lmao. It just uploads an empty item again now. Sigh.

This is my code now.

Code:
app_id = steam_get_app_id();
new_item = steam_ugc_create_item(app_id,ugc_filetype_community);

scr_CreateSaveLevelDataFile("Workshop\\Level.rt");
screen_save("Preview.png");
Async - Steam.

Code:
var event_id = async_load[? "id"];
if event_id == new_item
{
  var type = async_load[? "event_type"];
  if type == "ugc_create_item"
  {
    global.vPublish_ID = async_load[? "published_file_id"];
 
    var updateHandle = steam_ugc_start_item_update(app_id,global.vPublish_ID);
    steam_ugc_set_item_title(updateHandle,global.var_LevelName);
    steam_ugc_set_item_description(updateHandle,"");
    steam_ugc_set_item_visibility(updateHandle,ugc_visibility_public);
    var tagArray;
    if global.var_LevelGameType = 1 {tagArray[0]="Race Track";}
    else if global.var_LevelGameType = 2 {tagArray[0]="Speed Way";}
    steam_ugc_set_item_tags(updateHandle,tagArray);
    steam_ugc_set_item_preview(updateHandle,"Preview.png");
    steam_ugc_set_item_content(updateHandle,"Workshop");
    requestId = steam_ugc_submit_item_update(updateHandle,"");
  }
}
In spite of preview image being contained in the directory, path to it is not relative to the said directory. So "Workshop\\Preview.png".
 

hdarren

Member
In spite of preview image being contained in the directory, path to it is not relative to the said directory. So "Workshop\\Preview.png".
The preview image is being saved in the base directory, not the Workshop folder. Should I be saving the preview image into the Workshop folder too together with the level? I thought that might muck things up?
 

hdarren

Member
Oh wait I'm idiot. Apparently it can take around an hour for changes to the Steam Cloud settings to take affect. So I think the issue might be I changed one of the cloud save root paths to test things. I've set it back to what it was now so I'll come back and try it again tomorrow morning where hopefully everything will work again!

//edit
Yup working great now! Massive thanks to YellowAfterLife! Also I just realised this was posted in the wrong forum lmao.
 
Last edited:
Top