2

I have the following Lua table with information on a fixture that I'm trying to recall using a separate function.

This is the table:

Fixture = {
        Beam = {
            loaded_color = "Image 101",
            live_color = "Image 117",
            Colors = {
                White = "98.101",
                Red = "98.102",
                Orange = "98.103",
                Yellow = "98.104",
                FernGreen = "98.105",
                Green = "98.106",
                SeaGreen = "98.107",
                Cyan = "98.108",
                Lavender = "98.109",
                Blue = "98.110",
                Violet = "98.111",
                Magenta = "98.112",
                Pink = "98.113",
                CTO = "98.114",
                CTB = "98.115"
            }
        }
}

This is my function:

function color(type, color)
    color_load=gma.user.getvar('COLOR_LOAD')
    if color_load=='True' then
            var("LOADED_BEAM_COLOR", Fixture.type.Colors.color)
            cmd("Copy Image 84 At " .. Show.loaded_color_empty .. " /o")
            cmd("Copy " .. Show.Colors.color .. " At " .. Fixture.Beam.loaded_color)
    end
end

And this is how I'm calling the function: color('Beam', 'White')

I know the function can see the variable passed to it but I keep getting the error that the variable type and color are both nill, even if when they are printed from the same function they have a value. Any ideas on what is happening here?

1 Answer 1

4

Replace Fixture.type.Colors.color with Fixture[type].Colors[color]

You cannot use the dot syntax to index tables with variables.

Also you're not calling a value from a table here. You're attempting to index a table here.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! I knew it would be something to do with the dots but couldn't figure out what. Also thanks for the clarification on the terminology!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.