Properties
A property is the script's setting: it shows in the component's form in the editor, and every component gives it its own value.
/// Closing may pass midnight.
property closesAt: time = 03:00 "Closes"
property speed: float = 1.0 "Speed · Hz" range 0.1 to 5 step 0.1
property onColor: color = #ffd878 "Colour when on" was "color"
group "Opening hours"
property opensAt: time = 18:00 "Opens"
end
Form
property name: type = default ["label"] [range a to b] [step s] [hidden] [was "oldName"]
- The label is the name in the form; without one the property's name shows. The
///comment above it becomes its tooltip. range a to bandstep sbound a number field and set its step.hiddenkeeps the property out of the form.was "oldName"declares a rename: values components gave under the old name move to the new one. A rename is a data migration (Saving and migration), so renaming in the editor does not writewasfor you.group "Name" … endgathers properties under a titled group in the form.
Types
Properties take the types the editor can show: bool int float string time color. A
duration property comes in the next version.
Where the value comes from
A property's value is resolved in this order, each overriding the one before:
- the default in the script;
- the component's value in the package (
values: only what differs from the default is written); - the value of the placed instance in the scene (a placement's own values; coming to the editor).
- The default is an expression of literals and operators only.
- A property is read-only while the script runs and is not saved; for state that changes, use memory.