Although I have had experience with many program languages over many years, I am new to Lua (and FSUIPC for that matter), but am rapidly becoming very frustrated. Yesterday morning I was able to run the following simple Lua script without error and assign a joystick button (via FSUIPC) to call it and it worked.
joy = 0 btn = 18 function TogglePitotHeat(j, b, du) -- Cancel event so we don't get called again for double press event.cancel("TogglePitotHeat") value = ipc.readUB(0x029C) if value == 1 then ipc.writeUB(0x029C,0) else ipc.writeUB(0x029C,1) end end event.button(joy, btn, 1, "TogglePitotHeat") [/CODE] However, I now keep getting the following error (which always gives the line the 'event.button' statement is on): [CODE] >lua -e "io.stdout:setvbuf 'no'" "TogglePitotHeat.Lua" lua: TogglePitotHeat.Lua:16: attempt to index global 'event' (a nil value) stack traceback: TogglePitotHeat.Lua:16: in main chunk [C]: ? >Exit code: 1 [/CODE] I have tried to search for help on this (both on internet and this forum), but although some results with similar symptoms were available, it seemed mainly due to coding errors. However, I even tried with the following code (as well as using the code from one of the FSUIPC example scripts) and get same result. [CODE] function setXpndr(J,b,du) -- do nothing end event.button(0,18,1,"setXpndr") [/CODE] It appears there is a link between Lua and FSUIPC missing and Lua cannot see the event library, but am unable to determine where to correct this. I have even un-installed and re-installed Lua (for Windows v5.1.4-46) to see if this would rectify the problem but no success. I realise this may need to be put on the Lua forums, but I am hoping someone here has come across the fix for this. Can anyone help (please!) as I am getting very frustrated! Dave