Hello
I am facing issue while working on L3 Trilogy ESI-2000.
I have subscribtion to xpl altitude dataref, which calls the new_altitude function whenever the xplane altitude changes.
new_altitude function draws altimeter and QNH display
Now I have my change QNH change function which is called by a button. This function changes the QNH value, but I need to force it to call new_altitude function as well, in order to re-draw the altimeter with the new QNH. When x-plane is paused, altitude does not change, so new_altitude function is not being called again and again, so when in pause I change QNH, the altimeter is not re-drawn until I unpause.
Is there something like "call = new_altitude()" or so?
Best regards,
Pavel
How to call function from another function
How to call function from another function
Pavel Brodský
Prague, Czech Republic
Prague, Czech Republic
Re: How to call function from another function
You might be able to do just new_altitude()
But I'm not sure if that works because there's no variable... In 3.x you can use request_callback(name of your callback)
If I remember correctly though, it's not yet documented on the wiki...
But I'm not sure if that works because there's no variable... In 3.x you can use request_callback(name of your callback)
If I remember correctly though, it's not yet documented on the wiki...
Re: How to call function from another function
I tried new_altitude() as the first thing, but no success.
Would you recommend me switching to v3 beta now, and develop on that, or should I stick with v2? I need quite stable platform, no time to fight with bugs. How much usable v3 is, for daily serious development?
Pavel
Would you recommend me switching to v3 beta now, and develop on that, or should I stick with v2? I need quite stable platform, no time to fight with bugs. How much usable v3 is, for daily serious development?
Pavel
Pavel Brodský
Prague, Czech Republic
Prague, Czech Republic
Re: How to call function from another function
Hard to say. It's getting better (almost) every day, but there's bugs here and there. The only way to do it in 2.1.3 is to make everything global, place your txt_set, img_rotate, etc in for example:
And then call that gui_update function at various places, like in the callback from the sim and your custom function.
Code: Select all
function gui_update()
Your stuff
end
Re: How to call function from another function
Reply to myself:
Another function can be called by starting a timer with 0 delay which has callback of the another function.
Hint: dont forget to stop that timer somewhere
Pavel
Another function can be called by starting a timer with 0 delay which has callback of the another function.
Hint: dont forget to stop that timer somewhere
Pavel
Pavel Brodský
Prague, Czech Republic
Prague, Czech Republic
Re: How to call function from another function
Hello,
just reporting from V3 that request_callback(function_name) works perfectly and is extremly useful tool! Please document this on wiki for others, this is very important function (at least for me, as I am now doing all the menu logic in my EFIS). Example of usage is that I am using one function to control QNH setting while other function to draw altimeter. So I have added request_callback(new_altitude) at the end of my QNH setting function, which forces the altimeter to re-draw when QNH is changed. Thus altimeter reacts on QNH even with sim paused (which was not the case previously, because when sim is paused, altitude dataref does not change, so the subscribtion does not callback the altimeter function).
Pavel
Pavel Brodský
Prague, Czech Republic
Prague, Czech Republic
Re: How to call function from another function
I think Corjan wasn't sure if he really wanted this function, so that's why it's not on the wiki. I'm not sure what his opinion is right now.
Re: How to call function from another function
Why do you need a special function for a callback? You can just do function_name(). I use this all the time. You can pass arguments this way as well.
Air Manager panels at https://www.experimentalsimavionics.com
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D