Asset(sourcePath, destinationPath)

new Asset(sourcePath, destinationPath)

assets are used to handle copying assets from mods into the game files to override or extend default
assets. For instance you could copy an image from your mods data folder to the pictures folder.

Parameters:
Name Type Description
sourcePath string

the path from the working dir of the storage manager to the file

destinationPath string

the path from the working dir of the storage manager to the destination of the file

Members

_force

whether to override any existing files automatically

Default Value:
  • true
Current Value:

destinationPath :string

The path that the source file will be copied to
note that this is the path from within the www/ folder

fileName :string

the name of the file within the path including extension

folderPath :string

assigned by the folder loader methods -- the real path to the source folder

imgType :Asset.IMG_FOLDERS

if this asset is an image this is its type of image

sourcePath :string

The path of the source file of the asset.
note that this is the path from within the www/ folder

type :Asset.TYPES

the type of this asset

Methods

assignOrReplace(element1, element2)

use Object.assign to assign members of element1 to element2 if both are obj
if not assign element2 to equal element1

Parameters:
Name Type Description
element1 Object | any

first element

element2 Object | any

first element

backupImage()

Create a backup for an existing image.

loadAsset()

load this asset into game files

loadData(partial)

load this asset as a data file

Parameters:
Name Type Default Description
partial boolean true

whether to treat this as a partial data file or not.

loadDataFolder()

loop through a folder with a matching file structure to /data and load all files

loadImage(force)

Load an image asset into game files

Parameters:
Name Type Default Description
force boolean false

whether to force overwrite the img

loadImgFolder(path,)

loop through a folder with a matching file structure to /imgs/ and load all files

Parameters:
Name Type Description
path, string

the path to the folder to load

replaceData(obj1, obj2)

replace any matching keys within obj2 recursively with obj1's values

Parameters:
Name Type Description
obj1 object

source object

obj2 object

target object
note: null is an object technically, so keep that in mind as if you are working on this function you need to know that.

restoreBackup()

Restores image from backup.

shouldForce() → {boolean}

check if this asset should forcibly overwrite any conflicting files

Returns:
boolean

unloadAsset()

unload this asset from game files

unloadImgFolder()

loop through a folder with a matching file structure to /imgs/ and load all files