Script to add values to a User:Labeled parameter?

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!

Hi,

You can create a labeled parameter using:

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:

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

Hope this helps!