Skip to content

Asset

The asset object lets you load, edit and create game assets such as textures, meshes and materials

Methods

GetAssetFilePath

Returns the file path of an asset by its id

Args

id - The asset's id

print(asset:GetAssetFilePath(2050)) -- 2050 is the interface asset

SetAssetFilePath

Replaces an asset's file with a custom one

Warning

The replacement won't be visible immediately. The asset is reloaded when the game refreshes it (e.g. traveling to a station or changing system)

Args

  • id - The asset's id to replace
  • filepath - The path to your custom asset file
RegisterEvent("IsInMainMenu", function()
    asset:SetAssetFilePath(2050, "mods/my_mod/my_assets/custom_interface.aei")
end)

GetText

Returns a localized text string by its id

Args

id - The text string's id

print(asset:GetText(1059))

CreateTexture

Loads a texture from a file and returns its id

Args

filepath - The path to the texture file (.aei)

HookFunction("Globals::init", function(ctx)
    local diffuse = asset:CreateTexture("mods/my_mod/diffuse.aei")
end)

CreateMaterial

Creates a material from textures and returns its id

Args

  • diffuse - The diffuse texture id
  • normal - The normal texture id
  • shader - The shader id
HookFunction("Globals::init", function(ctx)
    local diffuse = asset:CreateTexture("mods/my_mod/diffuse.aei")
    local normal = asset:CreateTexture("mods/my_mod/normal.aei")
    local material = asset:CreateMaterial(diffuse, normal, 29)
end)

CreateMesh

Loads a mesh from a file and returns its id

Args

  • filepath - The path to the mesh file (.aem)
  • materialid - The material id to apply to the mesh
HookFunction("Globals::init", function(ctx)
    local material = asset:CreateMaterial(diffuse, normal, 29)
    local lod = asset:CreateMesh("mods/my_mod/model.aem", material)
end)