Dave Lewis Posted January 12, 2013 Report Share Posted January 12, 2013 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 = 0btn = 18function TogglePitotHeat(j, b, du)-- Cancel event so we don't get called again for double pressevent.cancel("TogglePitotHeat")value = ipc.readUB(0x029C)if value == 1 thenipc.writeUB(0x029C,0)elseipc.writeUB(0x029C,1)endendevent.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 nothingendevent.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 Link to comment Share on other sites More sharing options...
Dave Lewis Posted January 14, 2013 Author Report Share Posted January 14, 2013 Having spent the last couple of days trying to fix this... reinstalled LUA4Win/SciTE (more than once) reinstalled MS C++ runtimes (saw a thread where this help in similar case) reinstalled FSUIPC4 disabled/enabled firewall set environment path variables for LUA4Win/SciTE to point to \Modules directory and much more... Even thought about installing the whole shebang (i.e. FSX/FSUIPC/Lua, etc) on old XP PC to see if it was a Win 7 (64-bit) issue. However now my I/O card has arrived I need to move on (life is too short) so have given up trying to fix this problem! Instead although still using SciTE to edit the Lua scripts, I am now using ipc.log statements to debug via FSUIPC. So now looking to create a radio stack controller using BU0836X card and Lua scripts... Phase 1: Xponder - set xpondr code using 10 (i.e. 0-9) push buttons arranged in keypad format. Phase 2: COM1/COM2 - set frequencies using dual rotary encoder to set frequency integer/decimal Phase 3: NAV1/NAV2 - as above, etc... Dave Link to comment Share on other sites More sharing options...
Pete Dowson Posted January 14, 2013 Report Share Posted January 14, 2013 However, I now keep getting the following error (which always gives the line the 'event.button' statement is on): >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]If you execute a Lua program externally to FSUIPC, as you seem to be doing here, and it tries calling built-in FSUIPC libraries such as event and ipc, then naturally you will get this error. The libraries added by FSUIPC are specific to FSUIPC and its interface into FS. They are NOT part of the standard Lua library package! 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. FSUIPC Lua libraries are internal to FSUIPC and the FS process. You cannot access them from a completely separate process in a completely separate virtual machine!Pete Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now