-
Posts
2 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Gallery
Downloads
Posts posted by Dave Lewis
-
-
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
Lua/FSUIPC - attempt to index global 'event' (a nil value)
in FSUIPC Support Pete Dowson Modules
Posted
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