Skip to main content

Fields

name

Methods

getNumber

getNumber(name: string) -> Property<number>?
Looks up a numeric property by name. Returns a number property.
local vmi = context:viewModel()
if vmi then
  local score = vmi:getNumber('score')
  if score then
    print(score.value)
  end
end

getTrigger

getTrigger(name: string) -> PropertyTrigger?
Looks up a trigger property by name. Returns a PropertyTrigger.
local vmi = context:viewModel()
if vmi then
  local myTrigger = vmi:getTrigger('myTrigger')
  if myTrigger then
    mytrigger:fire()
  end
end

getString

getString(name: string) -> Property<string>?
Looks up a string property by name. Returns a DataValueString.
local vmi = context:viewModel()
if vmi then
  local heading = vmi:getString('heading')
  if heading then
    print(heading)
  end
end

getBoolean

getBoolean(name: string) -> Property<boolean>?
Looks up a boolean property by name. Returns a DataValueBoolean.
local vmi = context:viewModel()
if vmi then
  local darkMode = vmi:getBoolean('darkMode')
  if darkMode then
    print(darkMode)
  end
end

getColor

getColor(name: string) -> Property<Color>?
Looks up a color property by name. Returns a DataValueColor.
local vmi = context:viewModel()
if vmi then
  local primaryColor = vmi:getColor('primaryColor')
  if primaryColor then
    primaryColor.value = Color.rgba(255, 0, 0, 155)
  end
end

getList

getList(name: string) -> PropertyList?
Looks up a List property by name. Returns a PropertyList.
local vmi = context:viewModel()
if vmi then
  local enemies = vmi:getList('enemies')
  if enemies then
    enemies:pop()
  end
end

getViewModel

getViewModel(name: string) -> PropertyViewModel?

getEnum

getEnum(name: string) -> PropertyEnum?
Looks up an enum by name. Returns a PropertyEnum.
local vmi = context:viewModel()
if vmi then
    local textAlignment = vmi:getEnum('textAlignment')
end

instance

instance(instanceName: string?) -> ViewModel
Creates a new instance of the ViewModel. Pass instanceName to specify an existing instance from the file to use as template