Hi Reinhard,
Thanks very much for your reply. I guess you're saying that, performance-wise, many smaller scripts are better than one big one.
It's not just the 50+ scripts I'll have to write, though... it's the 6 additional entries that FSUIPC creates in the pull-down menu when one, single Lua script is put in the Modules folder (i.e., FSUIPC creates the additional LuaDebug___, LuaKill___, LuaSet___, Lua Clear___, LuaToggle___, and LuaValue___ for every Lua script). So, there'd be 300 (50 x 6) additional entries in the FSUIPC pull-down menu. It's not easy to scroll that massive pull-down menu, if one needs to make a change.
Here is a follow-up question:
For a double-pole, single-throw physical switch, I cannot use this "toggle" code, because the code can get out of sync with the switch position, depending on where the switch is when you start the software:
-- I cannot use this "toggle" code
function switch_On ()
ipc.writeLvar("FUEL_PUMP_sw7", 1)
end
function switch_Off ()
ipc.writeLvar("FUEL_PUMP_sw7", 0)
end
function switch_Toggle ()
if ipc.readLvar("FUEL_PUMP_sw7") == 0 then
switch_On ()
else
switch_Off ()
end
end
switch_Toggle ()
Instead, is there a way to write a single Lua script like this, where it references the joystick controller and the button:
-- Hard-code the switch position, instead of a toggle function
-- I realize I could have two separate Lua scripts, one for each
-- switch position, but combining them would make for fewer scripts
if [JOYSTICK1_BUTTON7] == 1 then
ipc.writeLvar("FUEL_PUMP_sw7", 1)
end
if [JOYSTICK1_BUTTON7] == 0 then
ipc.writeLvar("FUEL_PUMP_sw7", 0)
end
2)