Reputation: 45
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?
Upvotes: 2
Views: 255
Reputation: 28940
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.
Upvotes: 4