Garry's Mod Wiki

Revision Difference

steamworks.Download#512430

<function name="Download" parent="steamworks" type="libraryfunc">⤶ <description>⤶ Downloads a file from the supplied addon and saves it as a .cache file in garrysmod/cache folder.⤶ ⤶ This is mostly used to download the preview image of the addon, but the game seems to also use it to download replays and saves.⤶ ⤶ In case the retrieved file is an image and you need the <page>IMaterial</page>, use <page>Global.AddonMaterial</page> with the path supplied from the callback.⤶ </description>⤶ <realm>Client and Menu</realm>⤶ <args>⤶ <arg name="workshopPreviewID" type="string">The Preview ID of workshop item.</arg>⤶ <arg name="uncompress" type="boolean">Whether to uncompress the file or not, assuming it was compressed with LZMA.&amp;amp;lt;br&amp;amp;gt;&#xA;You will usually want to set this to true.</arg>⤶ <arg name="resultCallback" type="function">The function to process retrieved data. The first and only argument is a string, containing path to the saved file.</arg>⤶ </args>⤶ </function>⤶ ⤶ <example>⤶ <description>Downloads and saves icon of Gm_construct_Beta Steam Workshop addon.</description>⤶ <code>⤶ steamworks.FileInfo( 21197, function( result )⤶ steamworks.Download( result.previewid, true, function( name )⤶ print( name )⤶ end) ⤶ end)⤶ </code>⤶ <output>Something like this will be printed into console: cache/559813303754221947.cache</output>⤶ ⤶ </example>