Skip to content

Using instance variables in actions and feedbacks in preset definition #120

Open
@wojtek14a

Description

@wojtek14a

Using instance variables is possible in style section of preset definition, it gets automatically updated with instance name. Using the same approach whilst defining actions and feedbacks would be useful as well.

One thing to consider is whether to implement it "as such" and always translate it into instance variable after detecting variable format or adding some other way of marking such option as variable in order to avoid translating something that the user didn't want to transform into variable (but would the user use variable format then?)

presets.push({
	type: 'button',
	category: `${String(i).padStart(3, '0')} - ${portName}`,

	name: `${portName} - talk to selected`,
	style: {
		text: `Talk to:\\n$(generic-module:port_${i}_selected_port)`,  // here it is possible to use instance variable
		size: 'auto',
		color: combineRgb(255, 255, 255),
		bgcolor: combineRgb(0, 0, 0),
	},
	steps: [
		{
			down: [
				{
					actionId: 'talk',
					options: {
						port: i,
						talk_to: "custom",
						custom_talk_to: `$(generic-module:port_${i}_selected_port)`, // here it is not possible to use instance variable
						mode: "toggle",
					},
				},
			],
			up: [],
			500: [
				{
					actionId: 'talk',
					options: {
						port: i,
						talk_to: "custom",
						custom_talk_to: `$(generic-module:port_${i}_selected_port)`, // here it is not possible to use instance variable
						mode: "off",
					},
				},
			],							
		},
	],
	feedbacks: [
		{
			feedbackId: 'is_talking',
			options: {
				port: i,
				talk_to: "custom",
				custom_talk_to: `$(generic-module:port_${i}_selected_port)`, // here it is not possible to use instance variable
			},
			style: {
				bgcolor: combineRgb(255, 0, 0),
			},
		},
	],
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions