Skip to content

How to Write Scripts

Robert Jordan edited this page Aug 3, 2018 · 2 revisions

How to Write Scripts

<?xml version="1.0" encoding="UTF-8"?>
<TConvertScript>
  <Output Path="C:\Programs\Games\Steam\steamapps\common\Terraria\Content"/>
  <Restore Path="C:\Programs\Games\Steam\steamapps\common\Terraria\BackupContent"/>
  <Compress Value="False"/>
  <File Path="C:\Users\Onii-chan\Pictures\Terraria\Images\Armor_Body_4.png">
    <Out Path="Images\Armor_Body_4"/>
  </File>
  <Folder Path="C:\Users\Onii-chan\Pictures\Terraria">
    <Output Path="Images"/>
    <File Path="Hello.png" OutPath="Item_0" Compress="True"/>
    <File Path="World.bmp">
      <Out Path="Item_1"/>
      <Out Path="Item_2"/>
    </File>
  </Folder>
</TConvertScript>

Folders and the root TConvertScript are the main elements of a script. Here you can specify settings, list files and folders, or call backups or restores.

Folder Path: Subfolders and files are relative to the current folder path and do not modify the output path without an Output element.

Output Path: The output path, when specified is always relative to the previous element's output path. So if the output path is specified twice in a single folder, then the second path will not be combined with the first.

File Output: Output files do not require extensions. In fact, there's no point in listing them as they will always be changed to their respective output file.

TConvertScript & Folder Element

Attributes Description
Path (Folder only) Specify the path of the folder relative to the previous element's folder path.
Elements Description
Output Append to the previous element's output path or start a new one if one hasn't been specified yet.
Compress Specify if preceding image files will be compressed or not.
Premultiply Specify if alpha is premultiplied for images when converted to XNB.
Folder Specify a folder or subfolder to convert and extract files from.
File Specify a file to convert or extract.
Backup Backup to the current output path.
Restore Restore to the current output path.

Output Element

Append to the previous element's output path or start a new one if one hasn't been specified yet.

Attributes Description
Path (Required) Specify the path of the output relative to the previous element's output path.

File Element

Specify an input file and add outputs for it to be converted or extracted to.

Attributes Description
Path (Required) Specify the path of the input file, relative to the current folder path.
OutPath Specify a single path of the output file, relative to the current output path.
Compress Specify if the file should be compressed. (Image files only)
Premultiply Specify if alpha is premultiplied. (Image files only)
Elements Description
Output Append to the output path or start a new one if one hasn't been specified yet.
Compress Specify if preceding image files will be compressed or not.
Premultiply Specify if alpha is premultiplied for images when converted to XNB.
Out Specify the path of an output file, relative to the current output path.

Out Element

Specify an output for a file.

Attributes Description
Path (Required) Specify the path of the output file, relative to the previous element's output path.
Compress Specify if this output file should be compressed. (Image files only)
Premultiply Specify if alpha is premultiplied. (Image files only)

Backup Element

Backup the specified path to the current output path.

Attributes Description
Path (Required) Specify the path of the folder to backup from, relative to the previous element's folder path.

Restore Element

Restore the specified path to the current output path.

Attributes Description
Path (Required) Specify the path of the folder to restore from, relative to the previous element's folder path.

Compress Element

Change the default compress setting for converted images.

Attributes Description
Value (Required) Specify True or False to determine if preceding image files will be compressed.

Premultiply Element

Change the default compress setting for converted images.

Attributes Description
Value (Required) Specify True or False to determine if preceding image files will have their alpha premultiplied.