Hi everyone,
I am coming here to ask for guidance as a newbie in writing a lua script that would accomplish a very simple task.
My intention is to have a lua script that would check whether the engine anti ice in four engine aircraft (FBW A380 ) is ON, and if so then either leave it ON or turn it OFF based on which button I press. My current script doesn't seem to work, and I get the following error in the FSUIPC7.log
18391 *** LUA Error: E:\FSUIPC7\LuaFiles\FBW_TEST.lua:3: '<name>' expected near '"XMLVAR_MOMENTARY_PUSH_OVHD_ANTIICE_ENG1_PRESSED"'
My LUA script is the following:
function engantiice()
val1 = ipc.readLvar(L:"XMLVAR_MOMENTARY_PUSH_OVHD_ANTIICE_ENG1_PRESSED")
val2 = ipc.readLvar(L:"XMLVAR_MOMENTARY_PUSH_OVHD_ANTIICE_ENG2_PRESSED")
val3 = ipc.readLvar(L:"XMLVAR_MOMENTARY_PUSH_OVHD_ANTIICE_ENG3_PRESSED")
val4 = ipc.readLvar(L:"XMLVAR_MOMENTARY_PUSH_OVHD_ANTIICE_ENG4_PRESSED")
if val1 == 1 then ipc.execPreset("A380X_OH_ANTIICE_ENG1_TOG", 0) end
if val2 == 1 then ipc.execPreset("A380X_OH_ANTIICE_ENG2_TOG", 0) end
ipc.sleep(700)
if val3 == 1 then ipc.execPreset("A380X_OH_ANTIICE_ENG3_TOG", 0) end
if val4 == 1 then ipc.execPreset("A380X_OH_ANTIICE_ENG4_TOG", 0) end
end
Could anyone explain to me in a very simplified language on what am I doing wrong here? Please note I am far away from being a programmer of any kind. I am just trying to learn this.
I have watched some videos on how to write a conditional LUA script but those are never ever dealing with flight sim and variables etc, so it's difficult for me to put in perspective when it comes flight sim and its related differences.
I would appreciate if someone could chime in and say what's wrong above?
Thank you so much,
Balint Szarka