Skip to content

Commit

Permalink
Playtime: Add a simple Playtime main preset for generic grid controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
helgoboss committed Feb 13, 2024
1 parent 5e2a388 commit 676a711
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions resources/main-presets/factory/generic/grid/playtime.preset.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
--- name: Generic grid controller - Playtime
--- realearn_version: 2.16.0-pre.8
--- author: helgoboss
--- description: |
--- This main preset turns any grid-like controller into a device for doing very basic clip launching via Playtime.
---
--- This generic preset is intended to be used as fallback if no device-specific preset exists. It lacks features because it can't take advantage
--- of device-specific features.
--- used_schemes: [grid]
--- required_features: [playtime]

--!strict

-- Configuration

-- Requires

local realearn = require("realearn")

-- Constants

-- TODO This should be parameterized from the controller preset. One more reason to allow script parameterization :)

local column_count = 4
local row_count = 4

-- Mappings

local mappings = {}

-- For each slot
for col = 0, column_count - 1 do
for row = 0, row_count - 1 do
local mapping = realearn.Mapping {
name = `Trigger slot {col + 1}/{row + 1}`,
source = realearn.Source.Virtual {
character = "Button",
id = `col{col + 1}/row{row + 1}/pad`,
},
glue = {
feedback = realearn.Feedback.Text {
text_expression = "{{ target.slot_state.id }}",
color = realearn.VirtualColor {
prop = "target.slot.color",
},
},
},
target = realearn.Target.PlaytimeSlotTransportAction {
slot = realearn.PlaytimeSlotDescriptor.Dynamic {
column_expression = `control_unit_column_index + {col}`,
row_expression = `control_unit_row_index + {row}`,
},
action = "Trigger",
},
}
table.insert(mappings, mapping)
end
end

return realearn.Compartment {
mappings = mappings :: any,
custom_data = {
playtime = {
control_unit = {
column_count = column_count,
row_count = row_count,
},
},
},
}

0 comments on commit 676a711

Please sign in to comment.