From 676a711e9e3f63bb4b97d8e2706c53f193152c63 Mon Sep 17 00:00:00 2001 From: Benjamin Klum Date: Tue, 13 Feb 2024 17:31:25 +0100 Subject: [PATCH] Playtime: Add a simple Playtime main preset for generic grid controllers --- .../factory/generic/grid/playtime.preset.luau | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 resources/main-presets/factory/generic/grid/playtime.preset.luau diff --git a/resources/main-presets/factory/generic/grid/playtime.preset.luau b/resources/main-presets/factory/generic/grid/playtime.preset.luau new file mode 100644 index 000000000..14399f626 --- /dev/null +++ b/resources/main-presets/factory/generic/grid/playtime.preset.luau @@ -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, + }, + }, + }, +}