Skip to content

Archives

Namespace

Archives

The Archives scripting namespace contains functions for managing archives.

Functions

Overview

Archive Management

All() -> Archive[] Create(formatId) -> Archive, string OpenFile(path) -> Archive, string Close(archive) -> boolean Close(index) -> boolean CloseAll()

Resource Archives

BaseResource() -> Archive BaseResourcePaths() -> string[] OpenBaseResource(index) -> boolean ProgramResource() -> Archive

Bookmarks

Bookmarks() -> ArchiveEntry[] AddBookmark(entry) RemoveBookmark(entry) -> boolean

Misc

FileExtensionsString() -> string RecentFiles() -> string[] EntryType(id) -> EntryType


All

Returns

  • Archive[]: An array of all currently open archives

Create

Creates a new archive of the format specified in formatId.

Parameters

Returns

  • Archive: The created archive, or nil if creation failed
  • string: An error message if creation failed

Notes

Currently only wad and zip formats are supported for creation.

Example

local archive, err = Archives.Create('wad')
if archive == nil then
    App.LogMessage('Error creating archive: ' .. err)
end

OpenFile

Attempts to open the archive file at path on disk.

Parameters

  • path (string): The full path (on disk) of the archive file to open

Returns

  • Archive: The opened archive, or nil if opening failed
  • string: An error message if opening failed

Close (1)

Closes the given archive.

Parameters

  • archive (Archive): The archive to close

Returns

  • boolean: false if archive is invalid or not currently open

Notes

Warning

Please be careful when using the Close* functions - attempting to access a closed archive from a script will currently cause a crash.


Close (2)

Closes the archive at index in the list of currently open archives (see All).

Parameters

  • index (integer): The index of the archive to close

Returns

  • boolean: false if the given index is invalid

CloseAll

Closes all currently open archives.


BaseResource

Gets the currently loaded base resource archive.

Returns

  • Archive: The currently loaded base resource archive

BaseResourcePaths

Gets all configured base resource archive file paths.

Returns

  • string[]: An array of configured base resource archive file paths

Notes

This is the list of base resource archive paths as seen in the base resource configuration dialog.


OpenBaseResource

Opens the base resource archive at index in the list of base resource archive file paths (see BaseResourcePaths).

Parameters

  • index (integer): The base resource path index to open

Returns

  • boolean: false if the given index was out of range

ProgramResource

Gets the program resource archive.

Returns

  • Archive: the program resource archive (either slade.pk3 or the res folder if you are running a dev build)

Bookmarks

Gets all currently bookmarked entries.

Returns

  • ArchiveEntry[]: An array of all currently bookmarked entries

AddBookmark

Adds entry as a bookmark.

Parameters


RemoveBookmark

Removes entry from the bookmarked entries list.

Parameters

Returns

  • boolean: false if the given entry was not currently bookmarked

FileExtensionsString

Gets an extension filter string for all supported archive file types.

Returns

  • string: The extension filter string for all supported archive file types

Notes

See UI.PromptOpenFile and the Open Archive example for more information.


RecentFiles

Gets all recently opened archive file paths.

Returns

  • string[]: An array of file paths to recently opened archives

EntryType

Gets the entry type with the given id.

Parameters

  • id (string): The id of the EntryType to get

Returns

  • EntryType: The entry type with the given id, or nil if no type has that id

Example

-- Will write 'Wad Archive' to the log
local type = Archives.EntryType('wad')
App.LogMessage(type.name)