Scripting question: setParameter

I am trying to understand how to set a Parameter via LUA script. It works for the “Level” in the program, but how do I write so I can set the Amp.Level? Do I need to find it in “Layer” and not in “Program”? A complete example would be appreciated as HALion scripting is new to me.

ins = this.program.instance
local program = ins:getProgram(1)
if program then
print(, "done")

Solved it myself. I opened Skylab and looked at the LUA file. They used a parameter called setParameterOfZones. So I arrived at this after some trial and error.

ins = this.program.instance
local program = ins:getProgram(1) -- Finds the Program

-- This Function sets a parameter of all zones
function setParameterOfZones(parameterName, value)
	local zones = this.parent:getLayer():findZones() -- Finds Zones in the Layer
	for i, zone in pairs(zones) do
		zone:setParameter(parameterName, value) -- Assigns the new Parameter value

if program then
-- program:setParameter("Level",-6.0) -- Use this if you want to adjust the Main Level
setParameterOfZones ("Amp.Level", -6.0) -- Use this if you want to adjust the Amplifier Level
print(, "done")

Hi @RikkShow

To use setParameter you need to get the element (zone, layer, effect, bus…) and then set the desired parameter. If you want to address multiple elements at the same time use loop like in your example.

The get functions like getZone, getLayer will return a single element object while find functions like findZones, findLayers will return array of objects.

To set the program level you probably don’t need the program instance and getProgram function. You could do it simply like:

this.program:setParameter("Level", 0)

Be careful when using this.program. When you export the program as HS layer and import it in HS the exported program becomes a layer in the new HS program. Calling this.program will get you different element than you might expect.

For this reason it’s better to address the elements relative to the script module. You can get the script module simply by using the keyword this.

Using the .parent property will return the parent element which is always a layer (or program as the topmost layer)

Using this.parent will return the parent layer of the script module. From there you can get the elements of the program tree using the get or find functions.

(First get the layer where the script module resides, then get the first sublayer and find zones inside that sublayer )

1 Like