# Script to add values to a User:Labeled parameter?

**URL:** <https://qa.fmod.com/t/script-to-add-values-to-a-user-labeled-parameter/22744>\
**Category:** FMOD Studio\
**Tags:** studio-scripting-api\
**Created:** [March 28, 2025, 10:35pm UTC](https://qa.fmod.com/t/script-to-add-values-to-a-user-labeled-parameter/22744 "2025-03-28T22:35:47Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![getman.josh](https://avatars.discourse-cdn.com/v4/letter/g/6de8d8/32.png) [@getman.josh](https://qa.fmod.com/u/getman.josh)\
**Post date:** [March 28, 2025, 10:35pm UTC](https://qa.fmod.com/t/script-to-add-values-to-a-user-labeled-parameter/22744/1 "2025-03-28T22:35:47Z")

</div>

Hi everyone!

I’ve got a very long list of values in a spreadsheet that I’d like to be able to make into values in a user:labeled parameter and I’m wondering if it can be done with a script. I’ve tried reading through the scripting examples and the API reference but my programming knowledge is not strong. I am hoping there’s someone on here much smarter than me who can tell me if this is possible and how to do it.

thanks in advance!

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [March 31, 2025, 4:35am UTC](https://qa.fmod.com/t/script-to-add-values-to-a-user-labeled-parameter/22744/2 "2025-03-31T04:35:37Z")

</div>

Hi,

You can create a labeled parameter using:

```js
var event = studio.window.browserCurrent()
var labeledParam = event.addGameParameter({ 
            name: "NewLabeledParam", 
            type: studio.project.parameterType.UserEnumeration, 
            enumerationLabels: labels, 
            min: 0, 
            max: labels.length 
        });

```

The `labels` variable I am using is an array that I created, but this is where you will get the data from your spreadsheet:

```js
var labels = ["One", "Two", "Three"]

```

Hope this helps!

---

<div class="post-metadata">

**Author:** ![getman.josh](https://avatars.discourse-cdn.com/v4/letter/g/6de8d8/32.png) [@getman.josh](https://qa.fmod.com/u/getman.josh)\
**Post date:** [April 1, 2025, 11:33pm UTC](https://qa.fmod.com/t/script-to-add-values-to-a-user-labeled-parameter/22744/3 "2025-04-01T23:33:04Z")

</div>

Hey Connor!  
First off, thanks for the reply and the help. I’m running this in the console and it’s creating a labeled parameter but the values of the labels are still the default Value A, Value B, Value C. Am I doing something wrong or misunderstanding your advice? Thanks again!!

var event = studio.window.browserCurrent()

var labels = [“One”, “Two”, “Three”];

var labeledParam = event.addGameParameter({

```
        name: "NewLabeledParam", 

        type: studio.project.parameterType.UserEnumeration, 

        enumerationLabels: labels, 

        min: 0, 

        max: labels.length 

    });

```

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [April 2, 2025, 6:13am UTC](https://qa.fmod.com/t/script-to-add-values-to-a-user-labeled-parameter/22744/4 "2025-04-02T06:13:07Z")

</div>

No worries, happy to help!

Testing your code it looks ok:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/8/82862a46d2ed57c09a976ec0a1b69e1f25717e97.png)  
Could I get a screenshot of the parameter if you try to edit it:  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/4/4faceb878065e393676024152824e23af63f1509.png)

---

<div class="post-metadata">

**Author:** ![getman.josh](https://avatars.discourse-cdn.com/v4/letter/g/6de8d8/32.png) [@getman.josh](https://qa.fmod.com/u/getman.josh)\
**Post date:** [April 2, 2025, 7:59pm UTC](https://qa.fmod.com/t/script-to-add-values-to-a-user-labeled-parameter/22744/5 "2025-04-02T19:59:48Z")

</div>

Hmmm that’s interesting! Attaching screenshot in this message

 ![Parameter and Code](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/8/8117c4a423719a7741faf72e1fb37b22a27c92cf.jpeg)  
I’m also in 2.02.20 if that has any impact on things…

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [April 4, 2025, 1:11am UTC](https://qa.fmod.com/t/script-to-add-values-to-a-user-labeled-parameter/22744/6 "2025-04-04T01:11:51Z")

</div>

Ah, 2.02.20 was the missing piece. I was able to reproduce the issue.

Is it possible to update to 2.02 latest? The issue is no longer present.

---

<div class="post-metadata">

**Author:** ![getman.josh](https://avatars.discourse-cdn.com/v4/letter/g/6de8d8/32.png) [@getman.josh](https://qa.fmod.com/u/getman.josh)\
**Post date:** [April 4, 2025, 9:31pm UTC](https://qa.fmod.com/t/script-to-add-values-to-a-user-labeled-parameter/22744/7 "2025-04-04T21:31:16Z")

</div>

Aaahh ok I’m glad we got to the bottom of it. This is for a project I’m already in the middle of so I’m hesitant to update for its’ builds… we’ll see how fearless I’m feeling. Either way this will be SUPER useful moving forward. Much much appreciated!

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [April 6, 2025, 10:09pm UTC](https://qa.fmod.com/t/script-to-add-values-to-a-user-labeled-parameter/22744/8 "2025-04-06T22:09:20Z")

</div>

Totally understandable.

If you do decide to update please let us know if we can assist further!

---

<div class="post-metadata">

**Author:** ![Johanenglund](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@Johanenglund](https://qa.fmod.com/u/Johanenglund)\
**Post date:** [April 9, 2025, 12:34pm UTC](https://qa.fmod.com/t/script-to-add-values-to-a-user-labeled-parameter/22744/9 "2025-04-09T12:34:16Z")

</div>

Thanks @Connor_FMOD, I got inspired 😄 But how do I close the modalDialogWindow.,this.dialog,close returns undefined?

```auto
studio.menu.addMenuItem({
    name: "NOM\\Add Labelled Param",
    execute: function () {
        var labelsText = "";
        var paramName = "";
        

            studio.ui.showModalDialog({
            windowTitle: "Add Labelled Parameter",
            widgetType: studio.ui.widgetType.Layout,
            layout: studio.ui.layoutType.GridLayout,
            sizePolicy: studio.ui.sizePolicy.Expanding,
            windowWidth: 400,
            windowHeight: 100,
            items: [
                {
                    widgetType: studio.ui.widgetType.Label,
                    column: 0,
                    row: 0,
                    text: "Parameter Name:",
                    alignment: studio.ui.alignment.AlignTop | studio.ui.alignment.AlignLeft
                },
                {
                    widgetType: studio.ui.widgetType.LineEdit,
                    column: 0,
                    row: 1,
                    text: "",
                    sizePolicy: studio.ui.sizePolicy.Expanding,
                    onTextEdited: function () {
                        paramName = this.text();
                    }
                },
                {
                    widgetType: studio.ui.widgetType.Label,
                    column: 0,
                    row: 2,
                    text: "Enter comma-separated labels:",
                    alignment: studio.ui.alignment.AlignTop | studio.ui.alignment.AlignLeft
                },
                {
                    widgetType: studio.ui.widgetType.LineEdit,
                    column: 0,
                    row: 3,
                    text: "",
                    sizePolicy: studio.ui.sizePolicy.Expanding,
                    onTextEdited: function () {
                        labelsText = this.text();
                    }
                },
                {
                    widgetType: studio.ui.widgetType.PushButton,
                    column: 0,
                    row: 4,
                    text: "Create Labeled Parameter",
                    onClicked: function () {
                        var labels = labelsText.split(",").map(function(label) {
                            return label.trim();
                        }).filter(function(label) {
                            return label.length > 0;
                        });

                        if (labels.length === 0) {
                            studio.system.message("Please enter at least one valid label.");
                            return;
                        }

                        if (!paramName || paramName.trim().length === 0) {
                            studio.system.message("Please enter a valid parameter name.");
                            return;
                        }

                        var event = studio.window.browserCurrent();
                        if (!event) {
                            studio.system.message("No event selected in the browser.");
                            return;
                        }

                        try {
                            event.addGameParameter({ 
                                name: paramName.trim(),
                                type: studio.project.parameterType.UserEnumeration, 
                                enumerationLabels: labels, 
                                min: 0, 
                                max: labels.length - 1
                            });

                             studio.system.message("Labeled parameter added with labels: " + labels.join(", "));
                            
                            
                            
                        } catch (e) {
                            studio.system.message("Error adding parameter: " + e.message);
                        }
                    }
                }
            ]
        });
    }
});

```

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [April 9, 2025, 11:57pm UTC](https://qa.fmod.com/t/script-to-add-values-to-a-user-labeled-parameter/22744/10 "2025-04-09T23:57:35Z")

</div>

This is an awesome script thank you for sharing!! At the end of the `onClicked: function{}` just add `this.closeDialog();`

```js
onClicked: function() {
    // ALL THE CODE INBETWEEN
    this.closeDialog();
}

```

Please let me know if I can help with anymore scripts!

---

<div class="post-metadata">

**Author:** ![Johanenglund](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@Johanenglund](https://qa.fmod.com/u/Johanenglund)\
**Post date:** [April 10, 2025, 12:17pm UTC](https://qa.fmod.com/t/script-to-add-values-to-a-user-labeled-parameter/22744/11 "2025-04-10T12:17:21Z")

</div>

Thanks @Connor_FMOD works like a charm! Not sure why I didn’t get this to work earlier but some foolishness on my part most likely.

Script here plus some bank organising scripts also. [https://github.com/nightonmars/FMOD-Organisation-scripts](https://github.com/nightonmars/FMOD-Organisation-scripts)

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [April 15, 2025, 12:01am UTC](https://qa.fmod.com/t/script-to-add-values-to-a-user-labeled-parameter/22744/12 "2025-04-15T00:01:25Z")

</div>

Good to hear it worked!

That is awesome, thank you for sharing those! I would be happy to share some scripts that I have made as well?

---

<div class="post-metadata">

**Author:** ![Johanenglund](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@Johanenglund](https://qa.fmod.com/u/Johanenglund)\
**Post date:** [April 17, 2025, 8:48am UTC](https://qa.fmod.com/t/script-to-add-values-to-a-user-labeled-parameter/22744/13 "2025-04-17T08:48:00Z")

</div>

Please!! Actually, it’d be great to see a script sub-channel in the forum. I’ve had people reach out to me on Airwiggles about FMOD scripting, but I’m just a happy tinkerer, and a place with actual insight would be awesome!

---

<div class="post-metadata">

**Author:** ![deHaan](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/dehaan/32/68_2.png) [@deHaan](https://qa.fmod.com/u/deHaan)\
**Post date:** [April 21, 2025, 7:06am UTC](https://qa.fmod.com/t/script-to-add-values-to-a-user-labeled-parameter/22744/14 "2025-04-21T07:06:28Z")

</div>

That is a great idea. I have a few super useful scripts a got from people sharing them, but just because I was lucky to spot them/know the people. Would be awesome to have something a bit more public, a bit like ReaPack is for Reaper

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [April 22, 2025, 10:36pm UTC](https://qa.fmod.com/t/script-to-add-values-to-a-user-labeled-parameter/22744/15 "2025-04-22T22:36:39Z")

</div>

I will pass on your suggestions. I will try get those scripts up as soon as I can!
