Dev » Lua API » materialdef
← Back to all classes

materialdef

Definitions & Systems 3 Properties 4 Methods

materialdef

The materialdef class represents physical and visual materials in Stranded III (e.g. wood, stone, flesh, metal, foliage), used for impact sounds, particle FX, and crafting recipes.

Overview

Properties (3)

Property Type Summary
id string Material identifier string.
index number Internal material index.
isValid boolean Checks if material definition is valid.

Methods (4)

Method Signature Returns Summary
materialdef.exists(id) boolean Checks if a material definition exists.
materialdef.get(val) materialdef Looks up a material definition.
materialdef.getFromTexture(textureName) materialdef Looks up a material definition associated with a texture file name.
materialdef.getList() table Returns all registered material definitions.

Detailed Reference

# id PROPERTY
materialdef.id
Material identifier string.
Parameters
None
Returns
string

Material string identifier.

Description

Unique identifier such as "wood", "stone", "flesh", "metal".

# index PROPERTY
materialdef.index
Internal material index.
Parameters
None
Returns
number

Internal integer index.

Description

Fast integer lookup index.

# isValid PROPERTY
materialdef.isValid
Checks if material definition is valid.
Parameters
None
Returns
boolean

True if valid material definition.

Description

Returns true if the material definition exists.

# exists METHOD
materialdef.exists(id)
Checks if a material definition exists.
Parameters
ParameterTypeDefaultDescription
idstring

Material ID.

Returns
boolean

True if material exists.

Description

Returns true if id is registered.

# get METHOD
materialdef.get(val)
Looks up a material definition.
Parameters
ParameterTypeDefaultDescription
valstring|number|materialdef

Material ID, index, or instance.

Returns
materialdef

Material descriptor.

Description

Returns the material definition matching the specified ID string or integer index.

# getFromTexture METHOD
materialdef.getFromTexture(textureName)
Looks up a material definition associated with a texture file name.
Parameters
ParameterTypeDefaultDescription
textureNamestring

Texture file name.

Returns
materialdef

Material definition mapped to the texture.

Description

Resolves the material definition associated with a texture name.

# getList METHOD
materialdef.getList()
Returns all registered material definitions.
Parameters
None
Returns
table

1-based array of all materialdef instances.

Description

Returns a table containing all registered physical materials.