mirror of
https://github.com/centau/vide.git
synced 2026-08-20 14:41:37 +00:00
Add aggregate initialization
This commit is contained in:
parent
be15f69522
commit
2aebaf5abb
9 changed files with 139 additions and 36 deletions
|
|
@ -28,15 +28,17 @@ Creates a new UI element, applying any given properties.
|
|||
|
||||
- **Property setting rules**
|
||||
|
||||
- If a table value is another table, that nested table is processed so that
|
||||
any properties inside that table are also applied to the instance just
|
||||
like the outer table.
|
||||
|
||||
- If a table index is a string:
|
||||
- If its value is a table then it will attempt to perform aggregate
|
||||
initialization.
|
||||
- If its value is a function then it will either bind that property to
|
||||
the function or connect it if the property type is a `RBXScriptSignal`.
|
||||
- If the value is not a function then the property will be set to that
|
||||
value.
|
||||
- If a table index is a number:
|
||||
- If its value is a table then that table will be recursively
|
||||
- processed just like the outer table.
|
||||
- If its value is a function then it will parent and bind any instances
|
||||
returned by that function as children.
|
||||
- If its value is an instance then it will be parented to the instance.
|
||||
|
|
|
|||
|
|
@ -54,3 +54,17 @@ create "TextButton" {
|
|||
end
|
||||
}
|
||||
```
|
||||
|
||||
You can also use a form of aggregate initialization to create datatypes instead
|
||||
of explicitly typing out the class name and constructor.
|
||||
|
||||
```lua
|
||||
create "Frame" {
|
||||
AnchorPoint = { 0.5, 1 },
|
||||
UDim2 = { 0.5, 0, 0.5, 0}
|
||||
}
|
||||
```
|
||||
|
||||
When a property is assigned a table, Vide will inspect the type of the property
|
||||
being assigned to, and call that type's default `new()` constructor with the
|
||||
values from the unpacked table.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue