Hi,
I’m trying my best to understand how to use lua for my pmdg js 41 and I’ve gotten some knowledge with regards to it. However, I'm having trouble using the ipcready.lua script. When trying to figure out how to activate the parking brake and turn on a led , I found this provided by Pete to another use:
function set_brake(offset, value)
if value == 32767 then
gfd.SetLight(GFP8, 1, 7)
else
gfd.ClearLight(GFP8, 1, 7)
end
end
event.offset(0x0BC8, "SW", "set_brake")
I changed it to work with my go flight hw and it works when it’s the only thing in the ipcready.lua script. However, if I add anything else to it, it doesn’t work (see below, which includes a script that someone made for thePMDG js41 – it also works when it’s by itself, but not with the above script). I’m sure it’s user error, but cant’ figure out what I’m doing wrong. Any help would be appreciative.
prevHDG = -1
prevSPD = -1
prevALT = -1
while 1 do
HDG = ipc.readLvar ("L:HDGBug")
if HDG ~= prevHDG then
stringHDG = string.format("%03d", HDG)
gfd.setDisplay(GFMCP,0,1,stringHDG)
prevHDG = HDG
end
SPD = ipc.readLvar ("L:IASBug")
if SPD ~= prevSPD then
stringSPD = string.format("%03d", SPD)
gfd.setDisplay(GFMCP,0,2,stringSPD)
prevSPD = SPD
end
ALT = ipc.readLvar ("L:AltSelAlt")
if ALT ~= prevALT then
stringALT = string.format("%05d", ALT)
gfd.setDisplay(GFMCP,0,4,stringALT)
prevALT = ALT
end
ipc.sleep(50)
end
function set_brake(offset, value)
if value == 32767 then
gfd.SetLight(GFP8, 1, 7)
else
gfd.ClearLight(GFP8, 1, 7)
end
end
event.offset(0x0BC8, "SW", "set_brake")