HammeriteAssetLibrary

Core: files, names and extension. Inherits RefCounted

Where a NAME becomes a model, a sound - a resource of one kind (#87).

A map records names, and the game says where names are found: directories to search, and sources of its own (add_source()) for whatever does not live under res:// at all - a mod's folder of raw files loaded at runtime. Sources are asked first, in the order they were added, so a mod can stand in for something the game ships under the same name.

What is found is remembered. A name found to be nothing is searched for again from the next frame on, so a file that arrives later - a download, a mod installed while the game runs - is found without anyone clearing anything.

Properties

TypeNameDefault
String[]search_paths

Methods

ReturnsMethod
voidadd_search_path(directory: String)
voidadd_source(find: Callable, list: Callable = Callable())
voidclear_cache()
voidclear_sources()
HammeriteAssetLibrarycreate(type: StringName, extensions: PackedStringArray, convert: Callable = Callable()) static
PackedStringArrayfiles_in(directory: String, extensions: PackedStringArray) static
boolhas(name: StringName)
boolhas_sources() const
PackedStringArraylist_names() const
StringNamename_of(resource: Resource) const
Resourceresolve(name: StringName)

Property descriptions

search_paths

var search_paths: String[]

Directories searched after the sources, in order: the first hit wins. Assigned or edited in place, the next lookup searches afresh.

Method descriptions

add_search_path()

func add_search_path(directory: String) -> void

Search directory after the search paths there are, as get_search_paths() does.

add_source()

func add_source(find: Callable, list: Callable = Callable()) -> void

find takes a name, as a String, and returns the resource, or null when this source has no such thing. list returns the names it has, for whoever offers a choice of them.

clear_cache()

func clear_cache() -> void

Forget every remembered answer, so names are looked up afresh. Changing get_search_paths() and adding or clearing sources do this already, and a name found to be nothing is looked for again on the next frame; what is left is a file found once that has since changed on disk.

clear_sources()

func clear_sources() -> void

Drop every source add_source() registered and forget every remembered answer. A game that added sources calls it on exit; the Hammerite autoload does so for HammeriteModelLibrary.get_library().

create()

static func create(type: StringName, extensions: PackedStringArray, convert: Callable = Callable()) -> HammeriteAssetLibrary

type is the class what is found must be, extensions the files tried for a name that has none of its own, in order. convert, given something found that is not a type, returns one made from it or null - a model library makes a mesh of an imported scene. A native object is made without arguments, so this is what HammeriteAssetLibrary.new(type, extensions, convert) was.

files_in()

static func files_in(directory: String, extensions: PackedStringArray) -> PackedStringArray

The files in directory with one of extensions, by the names they were authored under. An exported game has no foo.png, only the foo.png.import pointing at what it was imported to - and a text resource leaves foo.tres.remap - so a listing that took the directory at its word found nothing to offer at all.

has()

func has(name: StringName) -> bool

Whether name resolves to something. Resolves it, and remembers the answer, as resolve() does.

has_sources()

func has_sources() -> bool

Whether any source add_source() registered is still held. What a game checks on its way out, since a source is its Callable (see clear_sources()).

list_names()

func list_names() -> PackedStringArray

Every name the sources and search paths hold, each once, in the order they are asked.

name_of()

func name_of(resource: Resource) -> StringName

What resource was found as, or empty for one this library did not find.

resolve()

func resolve(name: StringName) -> Resource

The resource called name, or null when neither a source nor a search path has one. A res:// or uid:// path, as an inspector's file picker writes, is taken as the file it names when no source answers for it.

Hammerite 2.0 · built from 6d57ab2d, 2026-10-17