Lua is a very powerful language, especially when considering arrays.
Arrays of nearly everything can be defined, including arrays of functions.
So a parametric "on the fly" creation of arrays of buttons/switches including animation can be done quite with a few lines of code.
here as an example a circuit breaker panel of 9 lines of 10 c/b defined in less than 130 lines of code for the Hotsatrt TBM 900.
with a simple table that contains the definition, legend, rating and relevant dataref
Code: Select all
-- Circuit breakers definition and location
-------------------------------------------------------------------------
function cb_definition()
--List of C/B
-- dataref, label line1, label,line2, amps rating, position x,position y
-- set "XX" as value for the Amps rating for no display of the C/B image and animation
-- but the legend can be set nontheless
---------------------------------------------------------------------------
cb[1][1]={"","","","XX",100,28}--empty
cb[1][2]={"","","","XX",220,28}--empty
cb[1][3]={"dataref FUEL1","","","7½",335,28}
cb[1][4]={"dataref COM1","","","20",498,28}
cb[1][5]={"dataref ","","","XX",592,28}--empty
cb[1][6]={"dataref ","","","3",675,28}
cb[1][7]={"dataref ENG1","","","3",845,28}
cb[1][8]={"dataref ENG2","","","35",1005,28}
cb[1][9]={"dataref FUEL1","","","XX",1100,28}--empty
cb[1][10]={"dataref FUEL2","","","XX",1230,28}--empty