This are the Support Forums for FSUIPC and related products.
These forums replace the old support forums which have been running for 20+ years. The old forums contain a wealth of information on all FSUIPC products, but are now no longer available.
Please note that you will need to Register and Login to post for support, and also to download attachments. You can view these forums without registering.
Support is also available via Discord. Please use the following invite link to join the FSUIPC Discord server:
https://discord.gg/zjwUTrxmmE
[Solved] error reading a SimVar
When running a "simple" lua test script (starting automatically with MSFS 2024), I keep getting the following error :-
*** LUA Error: C:\FSUIPC7\Aircraft_heading.lua:9: attempt to call field 'readSimVar' (a nil value)
The portion of the script that is involved is :-
-- Function to update heading display
function showHeading()
-- Read heading (directional gyro) from MSFS 2024 (radians)
heading = ipc.readSimVar("HEADING INDICATOR", "Radians")
if heading == nil then
ipc.display("Camera heading not available", 1)
return
end
Is the "ipc.readSimVar()" function still valid in lua with MSFS 2024?
(I realise there are problems with the display function but I'm not getting that far!)
Dave Nash
When copying the script the carriage return/line feeds seem to have been lost in the process of posting! Apologies
First, please format code (using the '<>' code format), e.g.
-- Function to update heading display
function showHeading()
-- Read heading (directional gyro) from MSFS 2024 (radians)
heading = ipc.readSimVar("HEADING INDICATOR", "Radians")
if heading == nil then
ipc.display("Camera heading not available", 1)
return
endThis makes it a lot easier to read/understand!
Posted by: @dafyddmsfsIs the "ipc.readSimVar()" function still valid in lua with MSFS 2024?
There has never been such a lua function. Please consult the FSUIPC Lua Library document for available functions.
The only way to read a simvar is via the FSUIPC offsets, i.e. the simvar needs to be held in an offset, and you use one of the ipc.readXX functions to read it (where XX is the size/type of the offset).
As the HEADING INDICATOR simvar is not currently held in any offset, although PARTIAL PANEL HEADING maybe available in offset 3BE0, but I am not sure about this as the document states ' FS2002 and FS2004 only' so please check.
Otherwise, you can add any simvar to a free/spare FSUIPC offset, and then read it from there. To add a simvar to an offset, see the section 'Adding Simulator variables (simvars) to FSUIPC offsets' on page 35 of the FSUIPC7 Advanced User guide.
John
