FoliageList

Package: Libraries.Game.Graphics.Worlds · Inherits from: Libraries.Language.Object

A FoliageList is the list of foliage assets a terrain can be covered with, such as pines, rocks and grass, kept in its own file so terrains can share one. An asset's place in the list is its number, which TerrainFoliage stores with each copy, so reordering the list goes through SwapAssets here and in the terrain's foliage together. A list file is JSON whose "Format" is "Quorum Foliage List", with "Assets", an array of FoliageAsset entries. Model and picture paths in it are relative to the file.

Example Code

use Libraries.Game.Graphics.Worlds.FoliageList
use Libraries.Game.Graphics.Worlds.FoliageAsset
use Libraries.System.File

FoliageList list
FoliageAsset rock
rock:SetName("Rock")
rock:SetModelPath("Models/Rock.glb")
list:AddAsset(rock)
File file
file:SetPath("Scenes/Foliage/Terrain1.json")
list:Save(file)

Variables

  • integer MAXIMUM_ASSETS: The most assets a list can have.

Actions

AddAsset(Libraries.Game.Graphics.Worlds.FoliageAsset asset)

This action adds an asset at the end of the list. There can be MAXIMUM_ASSETS.

Parameters

Returns

integer: Its number, from 0.

FindAsset(text assetName)

This action returns the number of the asset with a name, or -1.

Parameters

  • assetName text: The name.

Returns

integer: Its number, or -1 if no asset has the name.

GetAsset(integer index)

This action returns one of the assets.

Parameters

  • index integer: Its number, from 0.

Returns

Libraries.Game.Graphics.Worlds.FoliageAsset: The asset.

GetAssetCount()

This action returns how many assets the list has.

Returns

integer: The count.

GetFile()

This action returns the file the list was loaded from or saved to.

Returns

Libraries.System.File: The file, or undefined for a list never saved.

GetName()

This action returns the list's name, such as "Forest".

Returns

text: The name.

Load(Libraries.System.File listFile)

This action reads a foliage list file.

Parameters

RemoveAsset(integer index)

This action removes an asset; the assets after it move down one place. It doesn't remove any copies from a terrain: TerrainFoliage's RemoveAsset does that.

Parameters

  • index integer: Its number, from 0.

Save(Libraries.System.File listFile)

This action writes the list to a file. The folder must exist.

Parameters

SetName(text value)

This action sets the list's name.

Parameters

  • value text: The name.

SwapAssets(integer first, integer second)

This action swaps two assets' places. Use TerrainFoliage's SwapAssets with it, so each copy keeps its asset.

Parameters

  • first integer: One asset's number.
  • second integer: The other's.

Inherited Actions

3 actions from Libraries.Language.Object