Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Files

Methods about the files of the open packs and the dependencies.

files.list

Lists the files of a source, sorted by path.

Params (ListFiles)

NameTypeRequiredDescription
sourceFileSourceyesSource to list.
path_prefixstringno, default ""Only files whose path starts with this are listed.
recursivebooleanno, default trueIf files in subfolders are listed. If false, the subfolders are listed instead.
file_typesarray of string or nullnoIf set, only files of these types are listed, like DB, Loc, Text, Image or RigidModel.
offsetintegerno, default 0Amount of files to skip.
limitinteger or nullnoMaximum amount of files to return. Defaults to 500.

Result (FileList)

NameTypeRequiredDescription
filesarray of FileEntryyesThe files in the page.
foldersarray of stringyesSubfolders directly under the prefix, with their full path. Only filled in non-recursive listings.
totalintegeryesAmount of files matching the request, in all pages.

files.create

Creates a new empty file in an open pack.

Params (CreateFile)

NameTypeRequiredDescription
packstringyesKey of the pack.
pathstringyesPath of the new file in the pack, like db/units_tables/my_mod or text/db/my_mod.loc.
kindNewFileKindyesType of the new file.

Result (FileEntry)

NameTypeRequiredDescription
pathstringyesPath of the file in its source.
file_typestringyesType of the file, like DB, Loc, Text or Image.

files.add_from_disk

Adds files and folders from disk to an open pack.

Params (AddFilesFromDisk)

NameTypeRequiredDescription
packstringyesKey of the pack.
pathsarray of stringyesPaths on disk of the files and folders to add.
folderstringno, default ""Folder of the pack to add them to. Empty for the root of the pack.
pack_pathsarray of string or nullnoPath in the pack of each entry of paths, in the same order, instead of putting them all in folder. For files, it’s their new path. For folders, it’s the folder their contents go to.
include_base_folderboolean or nullnoIf added folders keep their own name in the pack, instead of adding only their contents. Defaults to the server’s setting.
ignorearray of stringno, default []Files and folders under any of these paths are skipped.

Result (FilesAdded)

NameTypeRequiredDescription
addedarray of stringyesPaths in the pack of the added files.
not_addedarray of stringnoPaths of the files that couldn’t be added.
errorstring or nullnoLast error found while adding the files, if any.

files.copy

Copies files and folders from any source into an open pack, keeping their paths.

Params (CopyFiles)

NameTypeRequiredDescription
sourceFileSourceyesWhere to copy the files from.
pathsarray of stringyesPaths of the files and folders to copy.
packstringyesKey of the pack to copy them to.

Result (FilesAdded)

NameTypeRequiredDescription
addedarray of stringyesPaths in the pack of the added files.
not_addedarray of stringnoPaths of the files that couldn’t be added.
errorstring or nullnoLast error found while adding the files, if any.

files.delete

Deletes files and folders from an open pack.

Params (DeleteFiles)

NameTypeRequiredDescription
packstringyesKey of the pack.
pathsarray of stringyesPaths of the files and folders to delete.

Result (FilesDeleted)

NameTypeRequiredDescription
deletedarray of stringyesPaths of the deleted files.

files.rename

Renames or moves files and folders of an open pack.

Params (RenameFiles)

NameTypeRequiredDescription
packstringyesKey of the pack.
renamesarray of FileRenameyesRenames to apply.

Result (FilesRenamed)

NameTypeRequiredDescription
renamedarray of FileRenameyesOld and new path of each renamed file.

files.duplicate

Copies files of an open pack in the same pack, adding a number to their names.

Params (DuplicateFiles)

NameTypeRequiredDescription
packstringyesKey of the pack.
pathsarray of stringyesPaths of the files and folders to duplicate.

Result (FilesAdded)

NameTypeRequiredDescription
addedarray of stringyesPaths in the pack of the added files.
not_addedarray of stringnoPaths of the files that couldn’t be added.
errorstring or nullnoLast error found while adding the files, if any.

files.extract

Extracts files and folders of an open pack, the game files or the parent packs to disk.

Params (ExtractFiles)

NameTypeRequiredDescription
sourceFileSourceyesWhere the files are. The Assembly Kit tables can’t be extracted.
pathsarray of stringyesPaths of the files and folders to extract.
destinationstringyesFolder on disk to extract them to. Their paths in the source are kept under it.
as_tsvbooleanno, default falseIf tables are extracted as TSV files instead of binary ones.
tsv_keys_firstboolean or nullnoIf TSV files use the old column order, with keys first. Defaults to the server’s setting.

Result (FilesExtracted)

NameTypeRequiredDescription
extractedarray of stringyesPaths on disk of the extracted files.

file.read

Returns the contents of a file of any source.

Params (ReadFile)

NameTypeRequiredDescription
fileFileRefyesThe file.
formatReadFormatno, default "decoded"How to return the contents. Defaults to decoded.

Result (FileContents)

NameTypeRequiredDescription
file_typestringyesType of the file, like Text, Image or RigidModel.
contentsFileDatayesThe contents.

file.write

Replaces the contents of a file of an open pack.

Params (WriteFile)

NameTypeRequiredDescription
packstringyesKey of the pack.
pathstringyesPath of the file. With raw contents, the file is created if it doesn’t exist.
contentsFileDatayesThe new contents. Text contents only work on files that are text files.

Result (Done)

Empty object: {}.

animpack.list

Lists the files inside an AnimPack of any source.

Params (ListAnimPack)

NameTypeRequiredDescription
fileFileRefyesThe AnimPack.

Result (FileList)

NameTypeRequiredDescription
filesarray of FileEntryyesThe files in the page.
foldersarray of stringyesSubfolders directly under the prefix, with their full path. Only filled in non-recursive listings.
totalintegeryesAmount of files matching the request, in all pages.

animpack.add

Copies files of an open pack into an AnimPack of an open pack.

Params (AddToAnimPack)

NameTypeRequiredDescription
packstringyesKey of the pack with the AnimPack.
animpackstringyesPath of the AnimPack.
source_packstringyesKey of the pack to copy the files from.
pathsarray of stringyesPaths of the files and folders to copy.

Result (FilesAdded)

NameTypeRequiredDescription
addedarray of stringyesPaths in the pack of the added files.
not_addedarray of stringnoPaths of the files that couldn’t be added.
errorstring or nullnoLast error found while adding the files, if any.

animpack.extract

Copies files of an AnimPack of any source into an open pack.

Params (ExtractFromAnimPack)

NameTypeRequiredDescription
fileFileRefyesThe AnimPack.
pathsarray of stringyesPaths inside the AnimPack of the files and folders to copy.
packstringyesKey of the pack to copy them to.

Result (FilesAdded)

NameTypeRequiredDescription
addedarray of stringyesPaths in the pack of the added files.
not_addedarray of stringnoPaths of the files that couldn’t be added.
errorstring or nullnoLast error found while adding the files, if any.

animpack.delete

Deletes files from an AnimPack of an open pack.

Params (DeleteFromAnimPack)

NameTypeRequiredDescription
packstringyesKey of the pack with the AnimPack.
animpackstringyesPath of the AnimPack.
pathsarray of stringyesPaths inside the AnimPack of the files and folders to delete.

Result (Done)

Empty object: {}.

file.view_data

Returns a file decoded as a client opening it in a view needs it.

Meant for clients with views for each type of file. Others should use file.read.

Params (GetViewData)

NameTypeRequiredDescription
fileFileRefyesThe file.

Result (ViewData)

One of:

  • { "Decoded": … }: The decoded file, and its info.
    • Decoded ([any, any], yes)
  • { "AnimPack": … }: The info of the files of an AnimPack, and of the AnimPack itself.
    • AnimPack ([any, any], yes)
  • { "Video": … }: The info of a video, without its frames, and of the file.
    • Video ([any, any], yes)
  • { "Notes": … }: The notes of a pack, as markdown.
    • Notes (any, yes)
  • "Unsupported": The file is of a type that is not decoded.

files.info

Returns the info of files of an open pack, like their original pack and last modification time.

Meant for clients showing the files of a pack as a tree. Others should use files.list.

Params (GetFilesInfo)

NameTypeRequiredDescription
packstringyesKey of the pack.
pathsarray of string or nullnoPaths of the files. If not set, the info of every file of the pack is returned. Paths without a file are skipped.

Result (FilesInfo)

NameTypeRequiredDescription
filesarray of anyyesThe info of each file.

files.paste

Copies or moves files and folders of open packs into a folder of an open pack.

Each selected file or folder is pasted with its own name under the destination folder, not with its full path. Meant for clients with a clipboard. Others should use files.copy and files.rename.

Params (PasteFiles)

NameTypeRequiredDescription
sourcesmap of array of stringyesPaths of the files and folders to paste, by key of their pack.
cutbooleanyesIf the files are removed from their packs, instead of copied.
packstringyesKey of the pack to paste them into.
folderstringyesFolder of the pack to paste them into. Empty for the root of the pack.

Result (FilesPasted)

NameTypeRequiredDescription
addedarray of stringyesPaths of the files added to the target pack.
deletedmap of array of stringyesPaths of the files removed from each source pack, by pack key, if they were cut.
not_pastedarray of stringnoPaths of the files that couldn’t be pasted. Cut files that couldn’t be pasted are kept in their packs.
errorstring or nullnoLast error found while pasting the files, if any.

files.from_all_sources

Returns files and folders found in the open packs, the parent packs and the game files.

Meant for clients editing files of several sources at once, like the UI’s tools. Others should use file.read.

Params (GetFilesFromAllSources)

NameTypeRequiredDescription
pathsarray of anyyesPaths of the files and folders.
lowercase_pathsbooleanno, default falseIf the paths of the returned files are lowercased.

Result (FilesFromAllSources)

NameTypeRequiredDescription
filesanyyesThe files found, by path, for each source.

files.save_files

Adds files to an open pack, replacing the ones with the same path, optionally optimizing the pack after it.

Meant for clients editing files outside of the server, like the UI’s tools. Others should use file.write.

Params (SaveFiles)

NameTypeRequiredDescription
packstringyesKey of the pack.
filesarray of anyyesThe files, named with their path in the pack.
optimizebooleanno, default falseIf the pack is optimized with the optimizer options of the settings after adding the files.

Result (FilesChanged)

NameTypeRequiredDescription
addedarray of stringyesPaths of the added or edited files.
deletedarray of stringyesPaths of the deleted files.

file.open_external

Extracts a file of an open pack to a temporary folder, and opens it in the system’s default program for its type.

Params (OpenInExternalProgram)

NameTypeRequiredDescription
packstringyesKey of the pack.
pathstringyesPath of the file.

Result (ExternalFile)

NameTypeRequiredDescription
pathstringyesPath of the extracted file on disk.

file.save_external

Replaces a file of an open pack with the file on disk an external program edited.

Params (SaveExternalFile)

NameTypeRequiredDescription
packstringyesKey of the pack.
pathstringyesPath of the file in the pack.
external_pathstringyesPath of the edited file on disk.

Result (Done)

Empty object: {}.

Types

Type FileData

Contents of a file.

One of:

  • { "kind": "text", "text": … }: The text of a text file.
    • text (string, yes): The text.
  • { "kind": "decoded", "data": … }: The decoded file, as JSON, in the format file.read returns it.
    • data (any, yes): The decoded file.
  • { "kind": "raw", "base64": … }: The bytes of the file.
    • base64 (string, yes): The bytes, encoded in base64.

Type FileEntry

A file in a listing.

NameTypeRequiredDescription
pathstringyesPath of the file in its source.
file_typestringyesType of the file, like DB, Loc, Text or Image.

Type FileRef

A file in one of the sources.

NameTypeRequiredDescription
sourceFileSourceyesWhere the file is.
pathstringyesPath of the file in its source.

Type FileRename

A rename of a file or folder.

NameTypeRequiredDescription
fromstringyesCurrent path.
tostringyesNew path.

Type FileSource

Where a file is.

One of:

  • { "pack": … }: An open pack, by key.
    • pack (string, yes)
  • "game_files": The vanilla files of the selected game.
  • "parent_files": The files of the parent packs of the open packs.
  • "assembly_kit": The tables of the selected game’s Assembly Kit. Their paths are db/<table_name>/ak_data.

Type NewFileKind

Type of a new file.

One of:

  • { "type": "db", "table_name": …, "version"?: … }: An empty DB table.
    • table_name (string, yes): Name of the table, like units_tables.
    • version (integer or null, no): Version of the table. If not set, the version the table has in the game files is used, or the newest one if the game files are not loaded or don’t have the table.
  • { "type": "loc" }: An empty Loc table.
  • { "type": "text", "format"?: … }: An empty text file.
    • format (string or null, no): Format of the text, like Plain, Lua, Xml or Json. Defaults to Plain.
  • { "type": "anim_pack" }: An empty AnimPack.
  • { "type": "portrait_settings", "version": …, "copy_entries"?: … }: A portrait settings file, optionally with entries copied from the vanilla ones.
    • version (integer, yes): Version of the file format.
    • copy_entries (array of EntryCopy, no, default []): Vanilla entries to copy into the new file, with the ID each copy gets.
  • { "type": "vmd" }: An empty VMD (variant mesh definition) file.
  • { "type": "ws_model" }: An empty WSModel file.

Type EntryCopy

An entry copied from a vanilla file, with a new ID.

NameTypeRequiredDescription
fromstringyesID of the vanilla entry.
tostringyesID of the copy.

Type ReadFormat

How to return the contents of a file.

One of:

  • "decoded": The decoded file, as JSON. For DB and Loc tables, table.rows returns only the rows you need, and for images and other binary files raw is smaller.
  • "text": The text, for text files like scripts, XML or JSON files.
  • "raw": The bytes of the file, encoded in base64.