Skip to content

Commit

Permalink
#1322 Add matrix generator example Luau code
Browse files Browse the repository at this point in the history
  • Loading branch information
helgoboss committed Nov 12, 2024
1 parent 8aeb7ce commit edc0fa9
Showing 1 changed file with 54 additions and 0 deletions.
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,
}

0 comments on commit edc0fa9

Please sign in to comment.