I want to run the following code during every flight, independent of aircraft:
console.log(SimVar.GetSimVarValue("PLANE LONGITUDE", "degree longitude"))
It has to be JavaScript, I don’t want to use an external program to interact with SimConnect.
How can I accomplish this?
I have modified an InGamePanel to do this, but that only works when that panel is opened from the toolbar. How can I run this continuously during flight in the background?
My goal is to create a mod, which continuously saves the aircraft’s position and restores it, when starting a new flight.
Have you tried posting this on FSDeveloper?
I am overriding the ToolBar.js and ToolBar.html file in a custom add-on.
That way I can run any JS code in the background.
I’m still missing an event that I can intercept to run every frame though.
Something like Coherent.on("UPDATE_FRAME", () => { console.log('hello world') } would be nice but I don’t know what the events are called.
Why Javascript? IMHO this would be a job for a stand alone WASM module (which is also using SimConnect, but is running internally). With SimConnect you would get a callback every simulator frame or visual frame.
You can just use standard JS setInterval() with an interval of 0 passed in to run some code each frame.