-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1322 Add matrix generator example Luau code
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
resources/main-presets/factory/generic/unsorted/generate-matrix.luau
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
local playtime = require("playtime") | ||
|
||
local column_count = 10 | ||
local row_count = 200 | ||
|
||
-- Build columns | ||
local columns = {} | ||
local clip_index = 0 | ||
for c = 0, column_count - 1 do | ||
local slots: { playtime.Slot } = {} | ||
for r = 0, row_count - 1 do | ||
if (c % 2 == 0 and r % 2 == 0) or (c % 2 == 1 and r % 2 == 1) then | ||
local slot = playtime.Slot { | ||
row = r, | ||
clips = { | ||
playtime.Clip { | ||
name = `Clip {c + 1}/{r + 1}`, | ||
color = playtime.ClipColor.PaletteColor { | ||
index = 5 + clip_index % 17, | ||
}, | ||
}, | ||
}, | ||
} | ||
table.insert(slots, slot) | ||
clip_index += 1 | ||
end | ||
end | ||
local column = playtime.Column { | ||
slots = slots or nil, | ||
} | ||
table.insert(columns, column) | ||
end | ||
|
||
-- Build rows | ||
local rows = {} | ||
for r = 1, row_count do | ||
local row = playtime.Row { | ||
name = `Scene {r}`, | ||
} | ||
table.insert(rows, row) | ||
end | ||
|
||
-- Build matrix | ||
local matrix = playtime.Matrix { | ||
columns = columns, | ||
rows = rows, | ||
} | ||
|
||
-- Return result | ||
return { | ||
kind = "ClipMatrix", | ||
version = "2.16.14", | ||
value = matrix, | ||
} |