Item

Reference

class Item
module:
findByName(name)

Find an object by name and return it

Parameters:

name (str)

Return type:

Object

findById(id)

Find an object by its id and return it

Parameters:

id (str)

Return type:

Object

create(type, attributes)

Create a new item of specified type from scratch without an underlying item.

Parameters:
  • type (str) – type of item to create.

  • attributes (table) – the attributes to use to create the item. Leave nil to use defaults.

Returns:

a promise resolving to the created item

Return type:

Promise

delete()

Delete an item. The item is only deleted if it is not referenced anymore. Furthermore, even after

the last reference of the item is gone, the garbage collector will remove it only after a certain period of time of no reference.

getId()

Return the ID of an item

Returns:

ID

Return type:

str

getName()

Return the name of an item

Returns:

Name

Return type:

str

getType()

Return the type of an item

Returns:

Type

Return type:

str

createMaterial(attributes)

Create a new material from scratch without an underlying item.

Parameters:

attributes (table) – the attributes to use to create the material. Leave nil to use defaults.

Returns:

the created material

Return type:

Material

fromHandle(handle)

Create a scene object by handle number. Used internally

Parameters:

handle (number)

setFieldValue(name, value)

Set a field of the item to a new value

Parameters:
  • name (str)

  • value (str)

setFieldColorValue(name, value)

Set a field of the item to a new color value

Parameters:
  • name (str)

  • value (Color)

setFieldNumberValue(name, value)

Set a field of the item to a new number value

Parameters:
  • name (str)

  • value (number)

setFieldEnumValue(name, value, refEnum)

Set a field of the item to a new enum value

Parameters:
  • name (str)

  • value (number)

  • refEnum (table) – reference enum table to verify value against

setFieldBooleanValue(name, value)

Set a field of the item to a new boolean value

Parameters:
  • name (str)

  • value (boolean)

getFieldValue(name)

Get an item field’s value

Parameters:

name (str) – name of the field

getFieldColorValue()

Get the value of an item’s field as color value

Returns:

value of the field

Return type:

Color

getFieldNumberValue()

Get the value of an item’s field as number value

Returns:

value of the field

Return type:

number

getFieldEnumValue()

Get the value of an item’s field as string value

Returns:

value of the field

Return type:

str

getFieldBooleanValue()

Get the value of an item’s field as boolean value

Returns:

value of the field

Return type:

boolean

getLinkItem(name)

Get a link of the item to a new value

Parameters:

name (str) – name of the link field

Returns:

handle of the linked item or nil if not set

Return type:

number

setLinkItem(name, item)

Set a link from the item

Parameters:
  • name (str) – name of the link field

  • item (str) – value can be either an item ID or an Item object

Examples