Difference between revisions of "Workshop Browser"
(→Ark) |
|||
Line 41: | Line 41: | ||
'''Operating System:''' Any | '''Operating System:''' Any | ||
− | '''Description:''' Extract .z and update GameUserSettings.ini | + | '''Description:''' Extract .z, copy to ShooterGame/Content/Mods and update GameUserSettings.ini |
'''Script Engine:''' IronPython | '''Script Engine:''' IronPython | ||
'''Event:''' After Workshop Content Installed | '''Event:''' After Workshop Content Installed |
Revision as of 22:44, 3 June 2019
Configure the Workshop Browser
Go to Settings > Games > select the game > Steam Settings. Set the following values:
- Store Id - Set the game's id in the Steam store.
- Stop before installing Workshop content - Specify if you want to stop the service before installing content.
- Skip Workshop download - If enabled the content is not downloaded automatically. Use this option if the game can download content automatically.
- Workshop file format - Format used on the file id. For example if the file id needs @ at the beginning use @![FileId]
- Workshop file separator - Specify the characters used to separate file ids. Use ![NewLine] to separate with a new line character.
Script Events
- After Workshop Content Installed
- Occurs after the content has been downloaded.
- Available objects:
- ThisServer, ThisGame, ThisUser, ThisService
- Available Variables:
- FileId - The id of the Workshop content that was installed.
- FileIds - A list of currently installed file ids formatted and separated according to the game's configuration. It includes the file id that is being installed.
- FileIdsArray - An array of currently installed file ids. It includes the file id that is being installed.
- InstallPath - The folder where the content is downloaded. For example: ServiceRoot/steamapps/Workshop/content/STOREID/FILEID
- FileUrl - Url to download the file. If the content has more than 1 file this value is blank.
- FileName - The filename according to the Steam API. The value is relative to the install path. If the content has more than 1 file this value is blank. For example: mymaps/aim_ak47_training_csgo.bsp
- FileNameNoPath - The filename without any paths. If the content has more than 1 file this value is blank. For example: aim_ak47_training_csgo.bsp
- FileNameSavePath - The full path where the single file is downloaded. For example ServiceRoot/steamapps/Workshop/content/STOREID/FILEID/mymaps/aim_ak47_training_csgo.bsp
- After Workshop Content Uninstalled
- Occurs after the content has been uninstalled.
- Available objects:
- ThisServer, ThisGame, ThisUser, ThisService
- Available Variables:
- FileId - The id of the Workshop content that was installed.
- FileIds - A list of currently installed file ids formatted and separated according to the game's configuration. It does not include the file id that is being uninstalled.
- FileIdsArray - An array of currently installed file ids. It does not include the file id that is being uninstalled.
- InstallPath - The folder where the content is located. For example: ServiceRoot/steamapps/Workshop/content/STOREID/FILEID
- FileUrl - Url to download the file. If the content has more than 1 file this value is blank.
- FileName - The filename according to the Steam API. The value is relative to the install path. If the content has more than 1 file this value is blank. For example: mymaps/aim_ak47_training_csgo.bsp
- FileNameNoPath - The filename without any paths. If the content has more than 1 file this value is blank. For example: aim_ak47_training_csgo.bsp
- FileNameSavePath - The full path where the single file is downloaded. For example ServiceRoot/steamapps/Workshop/content/STOREID/FILEID/mymaps/aim_ak47_training_csgo.bsp
Sample Scripts
Ark
These scripts require Python 2.7 installed in the default location. Update as needed.
Operating System: Any Description: Extract .z, copy to ShooterGame/Content/Mods and update GameUserSettings.ini Script Engine: IronPython Event: After Workshop Content Installed Ignore execution errors Unchecked
Script:
import clr clr.AddReference("INIFileParser") from System.IO import Directory, File, Path, SearchOption from System import Environment, PlatformID, String from IniParser import FileIniDataParser from IniParser.Model import IniData import sys if Environment.OSVersion.Platform == PlatformID.Win32NT : sys.path.append("C:\\Python27\\Lib") else : sys.path.append("/usr/lib/python2.7") ######################################## # https://github.com/TheCherry/ark-server-manager # ######################################## import struct import zlib import sys def str_to_l(st): return struct.unpack('q', st)[0] def z_unpack(src, dst): with open(src, 'rb') as f_src: with open(dst, 'wb') as f_dst: f_src.read(8) size1 = str_to_l(f_src.read(8)) f_src.read(8) size2 = str_to_l(f_src.read(8)) if(size1 == -1641380927): size1 = 131072L runs = (size2 + size1 - 1L) / size1 array = [] for i in range(runs): array.append(f_src.read(8)) f_src.read(8) for i in range(runs): to_read = array[i] compressed = f_src.read(str_to_l(to_read)) decompressed = zlib.decompress(compressed) f_dst.write(decompressed) ########################################### ########################################### ########################################### # Only extract files the correct folder depending on operating system oseditor="WindowsNoEditor" if Environment.OSVersion.Platform == PlatformID.Win32NT else "LinuxNoEditor" noeditor=Path.Combine(InstallPath, oseditor ) # Extract and delete all .z files for zfile in Directory.GetFiles(noeditor, "*.z", SearchOption.AllDirectories): file=Path.Combine(Path.GetDirectoryName(zfile), Path.GetFileNameWithoutExtension(zfile)) z_unpack(zfile, file) Script.WriteToConsole("Extracted " + file) File.Delete(zfile) File.Delete(zfile + ".uncompressed_size") # Move folder to correct location modfolder=Path.Combine(ThisService.RootDirectory, String.Format("ShooterGame/Content/Mods/{0}", FileId)) Directory.Move(Path.Combine(InstallPath, oseditor), modfolder) # Update ini file serveros = "WindowsServer" if Environment.OSVersion.Platform == PlatformID.Win32NT else "LinuxServer" inifile = Path.Combine(ThisService.RootDirectory, String.Format("ShooterGame/Saved/Config/{0}/GameUserSettings.ini", serveros)) ini = FileIniDataParser() data = ini.ReadFile(inifile) data["ServerSettings"]["ActiveMods"] = FileIds ini.WriteFile(inifile, data)