Get parameter name using the scripting API

I have a number of files I want to import to my project, and the main difficulty lies in setting up parameters for each track based on a configuration file. I create my parameters like this:

const parameters = [“A”, “B”, “C”, …]
var event = studio.window.browserCurrent();
parameters.forEach(function (parameter) {
event.addGameParameter({
name: parameter,
type: studio.project.parameterType.User,
min: 0,
max: 1
});
});

However, when importing files later, there’s no way to reference them by name:

var event = studio.window.browserCurrent();
var parameters = studio.project.model.GameParameter.findInstances();
parameters.forEach(function (parameter) {
console.log(parameter.name); // no such property on parameter
});

How do I know which parameter is which without hardcoding parameter GUIDs into my script? Remembering the parameter instances is a bit of a no-go since I want to create the parameters once and be able to reference them in subsequent script executions. Overall, the scripting API seems a bit lacking, is it even still supported?

Hello apk,

You can use console.log(parameter.presetOwner.name); to grab the parameter’s name.

The parameter system was altered slightly with the introduction of presets in 1.10 so there are some features that are in the parameter proxy (the parameter sheet that appears in the event), the game parameter (a parameter other than the timeline), and the parameter preset (the parameter as it appears in the presets browser).

We shall update our scripting API documentation to make these differences more obvious.

Thanks,
Richard

1 Like