How to call function from another function

Help creating logic scripts for Air Manager Instruments

Moderators: Ralph, russ

Post Reply
Message
Author
User avatar
brodhaq
Posts: 14
Joined: Wed Jun 29, 2016 4:13 pm

How to call function from another function

#1 Post by brodhaq » Wed Oct 11, 2017 2:13 pm

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
Pavel Brodský
Prague, Czech Republic

User avatar
Ralph
Posts: 1227
Joined: Tue Oct 27, 2015 7:02 pm

Re: How to call function from another function

#2 Post by Ralph » Wed Oct 11, 2017 3:37 pm

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...

User avatar
brodhaq
Posts: 14
Joined: Wed Jun 29, 2016 4:13 pm

Re: How to call function from another function

#3 Post by brodhaq » Wed Oct 11, 2017 4:13 pm

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
Pavel Brodský
Prague, Czech Republic

User avatar
Ralph
Posts: 1227
Joined: Tue Oct 27, 2015 7:02 pm

Re: How to call function from another function

#4 Post by Ralph » Wed Oct 11, 2017 8:54 pm

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:

Code: Select all

function gui_update()
Your stuff
end
And then call that gui_update function at various places, like in the callback from the sim and your custom function.

User avatar
brodhaq
Posts: 14
Joined: Wed Jun 29, 2016 4:13 pm

Re: How to call function from another function

#5 Post by brodhaq » Fri Oct 13, 2017 7:15 pm

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
Pavel Brodský
Prague, Czech Republic

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest