So I am trying to make an autopilot feature that will navigate to VOR stations. I have the following Lua code that pulls the table for the transmitter in the vessel NAV1 receiver.
I can print this table out to the screen using the annotation function:
I've verified this as a table using:
which returns 'table'. All well and good.
Now the problem - when I try to read any individual element in the table, the script crashes when I run Orbiter. None of the following will work (I've tried each of these individually while commenting out the other commands):
I can't see a thing wrong with anything I have done, but I simply can't extract any elements from the table. I'm really confused as to what is happening.
Any ideas?
Code:
hnav = vi:get_navsource(0)
nav_table = oapi.get_navdata(hnav)
I can print this table out to the screen using the annotation function:
Code:
note:set_text(nav_table)
I've verified this as a table using:
Code:
note:set_text(type(nav_table))
which returns 'table'. All well and good.
Now the problem - when I try to read any individual element in the table, the script crashes when I run Orbiter. None of the following will work (I've tried each of these individually while commenting out the other commands):
Code:
note:set_text(tostring(nav_table.type))
note:set_text(tostring(nav_table.ch))
note:set_text(tostring(nav_table.power))
note:set_text(tostring(nav_table.descr))
note:set_text(tostring(nav_table.lng))
note:set_text(tostring(nav_table.lat))
note:set_text(nav_table.type)
note:set_text(nav_table.ch)
note:set_text(nav_table.power)
note:set_text(nav_table.descr)
note:set_text(nav_table.lng)
note:set_text(nav_table.lat)
I can't see a thing wrong with anything I have done, but I simply can't extract any elements from the table. I'm really confused as to what is happening.
Any ideas?