Skip to content

$package

19 natives. Read-only natives only look things up; the rest change something. Parameter types use the language's names (Types).

despawn

$package.despawn(package: Reference, immediate: bool, only_ready: bool)

Destroy all entities owned by the given package, and destroy those entities' descendants. Note that there may exist entities from levels in the given package which are owned by other packages (these will not be destroyed).

ParameterTypeMeaning
packageReferenceReference to package file.
immediateboolIf true, entities are destroyed at the end of the event. Otherwise destroy waits to the next frame.
only_readyboolIf true, only spawned and ready entities will be considered.

destroy_level

$package.destroy_level(package: Reference, spare_children: bool, immediate: bool, only_ready: bool)

Destroy all entities from the primary level of the given package, and optionally destroy those entities' descendants. Note that this function is forceful; all of these entities are destroyed regardless of owning package.

ParameterTypeMeaning
packageReferenceReference to package file.
spare_childrenboolSuppress recursive destroy of entities parented to this level
immediateboolIf true, the level is destroyed at the end of the event. Otherwise destroy waits to the next frame.
only_readyboolIf true, only spawned and ready entities will be considered.

get_load_status

read-only
$package.get_load_status(package: Reference) -> int

Get the loading status of a package; loaded, unloaded, error.

ParameterTypeMeaning
packageReferenceReference to package file.

Returns int: A package status code.

get_name

$package.get_name(package: Reference) -> string

Get the name of a package.

ParameterTypeMeaning
packageReferenceReference to package file.

Returns string: The name of the package.

get_ref

read-only
$package.get_ref(package: Reference, type: string) -> Reference

Get a ref to the primary object in the package.

ParameterTypeMeaning
packageReferenceReference to package file.
typestringThe ref type e.g. 'type.vscript'.

Returns Reference: The ref.

get_save_status

$package.get_save_status(user: User, path: string) -> int

Get the status of a save operation; success, pending, error.

ParameterTypeMeaning
userUserUser initiating the save.
pathstringFile path to save.

Returns int: A save status code.

get_startup_package_names

read-only
$package.get_startup_package_names() -> list

Get a list of package names the user requested to be loaded on startup.

Returns list: List of package names to load on application startup.

get_startup_packages

read-only
$package.get_startup_packages() -> list

Get a list of packages the user requested to be loaded on startup.

Returns list: List of packages to load on application startup.

is_any_loading

read-only
$package.is_any_loading() -> bool

Determine if any package is actively loading.

Returns bool: True if a package is loading.

is_any_unloading

read-only
$package.is_any_unloading() -> bool

Determine if any package is actively unloading.

Returns bool: True if a package is unloading.

is_level_in_loaded_package

read-only
$package.is_level_in_loaded_package(level: Reference, package: Reference) -> bool

Returns whether a loaded package contains a level.

ParameterTypeMeaning
levelReferenceReference to level file.
packageReferenceReference to package file.

Returns bool: Returns the package is loaded and contains the level.

is_spawned

read-only
$package.is_spawned(package: Reference) -> bool

Return whether there exist in the world any entities owned by the given package. Note that there may exist entities from levels in the given package which are owned by other packages (these will not be considered).

ParameterTypeMeaning
packageReferenceReference to package file.

Returns bool: Returns true if any entities are spawned.

load

$package.load(package: Reference, local: bool, allow_load_while_pending_unload: bool)

Start loading all files inside a package.

ParameterTypeMeaning
packageReferenceReference to package file.
localboolWhether to load the package on this client only.
allow_load_while_pending_unloadboolAllow package to load even if some other package will unload sometime in the next snapshot_window frames.

load_from_saved

$package.load_from_saved(user: User, path: string) -> Reference

Start loading a previously saved level. See package.save().

ParameterTypeMeaning
userUserUser who initiated the save.
pathstringSave file name.

Returns Reference: A reference to the package.

prioritize_load

$package.prioritize_load(package: Reference)

Move this package to the front of the loading queue.

ParameterTypeMeaning
packageReferenceReference to package file.

save

$package.save(user: User, path: string, entities: list)

Save provided entities, including their mutable component state, to a level.

ParameterTypeMeaning
userUserUser initiating the save.
pathstringFile path to save.
entitieslistList of entities to save.

spawn_level

$package.spawn_level(package: Reference, parent: Entity, net_name: var, local_only: bool, mode: int, owner: User, immediate: bool) -> Entity

Create all entities in the primary level of the given package and return the root entity.

ParameterTypeMeaning
packageReferenceReference to package file.
parentEntityOptional entity used as reference for inherited functionality
net_namevarGenerally don't use. If specified, allows the engine to make certain network optimizations. Must be unique.
local_onlyboolIf true, the new entities will not be registered for network replication.
modeintUse k_entity_spawn_draw to force draw-only spawn, or use k_entity_spawn_logic to force logic spawn, otherwise use k_entity_spawn_default.
ownerUserOwning user, or nulluser if none.
immediateboolIf true, the level is spawned at the end of the event. Otherwise spawn waits to the next frame.

Returns Entity: Root of spawned entity tree.

unload

$package.unload(package: Reference)

Decrement the load count of a package. If the load count is 0 at the top of next frame, start unloading all files inside the package, destroy all entities owned by the package (see entity.get_owning_package) and those entities' descendants, and destroy all entities whose level data will be unloaded. Note that a level may be in multiple packages, so not all entities spawned from levels in the given package will necessarily be destroyed(i.e.an entity may be owned by a different package,and its data may remain loaded).

ParameterTypeMeaning
packageReferenceReference to package file.

wait

$package.wait(package: Reference) -> int

Wait for a package load or unload operation to complete.

ParameterTypeMeaning
packageReferenceReference to package file.

Returns int: A package status code.