Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #converter_v2.py
- import os
- import shutil
- from pathlib import Path
- destination_dir = 'noload__obj_to_txt'
- module_name = "MODULE_statim_vehicle"
- print(f"\n\nPython .obj converter to GMOD StarfallEx include structure to avoid using server meshes hosting. Usage: put this script to folder with your .obj meshes and call it. Script will convert all existing .obj files in current directory and put it via starfallEx structure inside inner directory called as variable module_name ({module_name})\n\n")
- script = """
- --@name """ + module_name + """
- --@shared
- -- powered by python obj module generator by artybyte (2024)
- local MODULE = { }
- """
- Path(module_name).mkdir(parents=True, exist_ok=True)
- for filename in os.listdir('.'):
- if filename.endswith('.obj'):
- file_name = os.path.basename(filename)
- file_name = file_name.__str__()
- with open(filename) as f:
- file = f"""
- --@name {file_name}
- --@shared
- local model = [[{f.read()}]]
- return model
- """
- mdl = open(f"{module_name}/{file_name}.txt", "w")
- mdl.write(file)
- mdl.close()
- script = script + f"""
- --@include {module_name}/{file_name}.txt
- local model_ = require('{module_name}/{file_name}.txt')
- MODULE["{file_name}"] = model_
- """
- script += "\n\n\n"
- script += "return MODULE"
- f = open(f"{module_name}/entry_point.txt", "w")
- f.write(script)
- f.close()
- print(f"Conversion done successfully inside folder {module_name}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement