Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Every Translator script contains a component contains an entrypoint, the main.lua module.

This module containing contains the main () functionFunctions.

When you start a component, the Translator runs all through the code entire script in the main.lua module — this only occurs once when the component starts. When . Every time a running component receives a message, only the main () function is called.

This affects the way you use variables as they One thing to note is that variables are initialized at different times depending on where they are declared.

  • Variables declared outside the main() function are initialized once when the component is started.

  • Variables declared within the main() function are initialized every time a message is processed by the Translatorrunning component.

Tip

Keep main.lua short and sweet! main.lua should be a treated like a table of contents, all the major activities or functions should live in local modules or libraries and be called by the main() function.