Grenton Lua: syntax and pitfalls in practice
Grenton scripts are Lua with extensions that Object Manager preprocesses at deploy time. The key one is ->, which reads a feature, writes a feature, or calls a method or script. Most hard bugs come from cross-CLU calls, semicolons and comments.
-> chains
The target is a CLU name or an object on the script's home CLU. Two-level chains, CLU->Object->Feature, work too. Built-in namespaces such as SYSTEM use a dot. The names CLU01, Lampa and sScena are examples.
-- read a feature, write a feature
local value = CLU01->Lampa->Value
CLU01->Lampa->Value = 1
-- call a method or a script
CLU01->sScena(2)
-- built-ins use a dot
SYSTEM.Wait(500)Using . or : on a Grenton object is an error, as is -> on a built-in namespace. Omitted arguments are legal, because Grenton applies defaults. Events such as OnClick are wired in the project configuration, not in script text. User features belong to a specific CLU and must already be defined.
The cross-CLU trap: local variables
This is one of the hardest bugs to find on site. The right-hand side of a write to another CLU, and the arguments of a call on another CLU, are evaluated on that target CLU. A script's local variable doesn't exist there, so the value never arrives, and the script reports no error:
local v = 1
CLU02->Lampa->Value = v
CLU02->sScena(v)Literals and -> references work, such as CLU02->Lampa->Value = 1 or CLU02->sScena(CLU01->vTmp). If the value is computed locally, pass it through a user feature:
CLU01->vTmp = v
CLU02->Lampa->Value = CLU01->vTmpSemicolons and comments
- No semicolons. Grenton's Lua parser rejects
;at line ends, as a statement separator and in table constructors. Use commas in tables. - No
->in comments. Object Manager's preprocessor treats the arrow as a command before Lua removes the comment. Write "to" instead. - No comment at the end of an assignment. The preprocessor wraps the right-hand side and appends a closing parenthesis that
--would hide. Put the comment on the line above. Comments after ordinary Lua statements and complete Grenton calls are safe.
-- set the lamp
CLU01->Lampa->Value = 1What OMP Studio checks
| Check | Example |
|---|---|
| Unknown CLU, object, feature or method | A typo in CLU01->Lampa->Valeu |
| Write to a read-only feature | Assigning to a feature with set="false" in firmware |
| Undefined user feature | CLU01->vFoo when it lives on another CLU |
| Local variable in a cross-CLU operation | CLU02->sScena(v) |
| Call arguments | Too many arguments, or a value outside the enum |
| Wrong separator | . or : instead of -> |
| Semicolons and Lua syntax | ; at the end of a line |
Checks run as you type, and the Problems panel covers every script in the project. Grenton's official object and function reference is on the Grenton support site. You can see the rules in the demo, and AI agents get them through omps lint, covered in Grenton and AI.
Common questions
Why doesn't my value reach another CLU?
Most often you are passing a local variable. It is evaluated on the target CLU, where it doesn't exist. Use a literal, or a user feature with a -> reference.
Can I use semicolons in Grenton Lua?
No. Grenton's Lua parser rejects them entirely, including in table constructors.
How do I call a script from another script?
Through the CLU and script name, for example CLU01->sScena(2).