Skip to main content
Guide menu

Lua scripts

Write small Lua programs that run inside TCS-NET to calculate, combine values and create virtual tags. For the Premium edition.

What Lua scripts are

Go to Configuration, Lua Script to write small Lua programs that run inside TCS-NET and work on tag values. The feature is in the Premium edition only; in Standard the tab shows a locked notice and stored scripts are kept.

A script

  • Name: chosen once, when you create the script.
  • How it runs: once when the script is loaded, or repeatedly at the interval you choose.
  • The editor gives you the frame of the program and a list of tags to pick from.
  • Test run and see the log right in the editor.
function Average.main(ctx)
  local a = tag.get("Cold room/Temp 1")
  local b = tag.get("Cold room/Temp 2")
  if a and b then
    tag.set("temp", (a + b) / 2)
  end
end

Virtual tags

In a script you read the value of a tag and publish the result as a virtual tag on the virtual Scripts device. A virtual tag works like any other tag: it keeps history, draws trends, takes alarm rules and goes on SCADA screens.

Safety

Scripts run inside a limited sandbox, so a faulty script cannot hang the system.

Not a substitute for control

Lua scripts cannot write to real devices yet; they only publish virtual tags. To control a machine, use Device control.