MrFunreal

L4D1 make multi-chunk pak01 for mods.

Sep 12th, 2021 (edited)
723
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.59 KB | None | 0 0
  1. #What folders to look for, and pack into the pak01 vpk set.
  2. target_folders = [ "materials", "models", "resource", "scripts", "media", "missions", "particles", "scripts", "maps", "expressions", "scenes" ]
  3. #What files to look for, in the aforementioned folders.
  4. file_types = [ "vmt", "vtf", "mdl", "phy", "vtx", "vvd", "ani", "pcf", "vcd", "txt", "res", "vfont", "cur", "dat" , "bik", "mov", "bsp", "nav", "lst", "lmp", "vfe", "nut", "nuc" ]
  5. #which vpk.exe to use. do not use \! CHANGE THIS TO YOUR VPK.EXE LOCATION
  6. vpk_path = "F:/Programme/SteamLibrary/steamapps/common/left 4 dead/bin/vpk.exe"
  7.  
  8. #Script Begins Here.
  9. #Do not edit anything here except the "pak01" on the very last line.
  10.  
  11. #FIRST DELETES LEFTOVER VPK FILES
  12. import os
  13. directory = "."
  14.  
  15. files_in_directory = os.listdir(directory)
  16. filtered_files = [file for file in files_in_directory if file.endswith(".vpk")]
  17. for file in filtered_files:
  18.     path_to_file = os.path.join(directory, file)
  19.     os.remove(path_to_file)
  20.  
  21. #PACKING STUFF
  22. import os,subprocess
  23. from os.path import join
  24. response_path = join(os.getcwd(),"vpk_list.txt")
  25.  
  26. out = open(response_path,'w')
  27. len_cd = len(os.getcwd()) + 1
  28.  
  29. for user_folder in target_folders:
  30.     for root, dirs, files in os.walk(join(os.getcwd(),user_folder)):
  31.         for file in files:
  32.             if len(file_types) and file.rsplit(".")[-1] in file_types:
  33.                 out.write(os.path.join(root[len_cd:].replace("/","\\"),file) + "\n")
  34.  
  35. out.close()
  36.  
  37. #the "pak01" here specifies the multi-chunk vpk names. Could be changed to "pak02" or "hl2_textures", or whatever
  38. subprocess.call([vpk_path, "-M", "a", "pak01", "@" + response_path])
Add Comment
Please, Sign In to add comment