King Air C90 Annunciator Panel

Help creating logic scripts for Air Manager Instruments

Moderators: russ, Ralph

Message
Author
User avatar
jph
Posts: 2856
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: King Air C90 Annunciator Panel

#11 Post by jph »

Ccard3dev wrote: Mon Jan 10, 2022 3:05 pm Hello!

I am brand new to Lua, so I don't have any idea what that code is you sent lol.

What I can say though is in the C90_sys.lua file there is a section called:
"CREATE READ-ONLY CUSTOM DATAREFS"

If you scroll down there is a section with all the annunciators listed as such:
C90DR_lighting_annun_dc_gen_L = create_dataref("laminar/c90/lighting/annun/dc_gen_L", "number")

So here is an example of how to use this in AirManager (and bear in mind I'm sure there are more efficient ways to program this but I am a beginner so I did what I could lol):

Code: Select all

--defines background image with all annunciators off
offimg = img_add_fullscreen("OFF.PNG")

--defines illuminated image, cropped to just the L DC Gen
lgenimg = img_add("ON.PNG", 0, 0, 1280, 90)
viewport_rect(lgenimg, 0,31,85,28)
visible(lgenimg, false)

--turns on the illuminated image for L DC Gen when the sim says it should be on
-- for this aircraft all the annunciators are 0 = off 1 = on
 function lgen_callback(lgen)
     if (lgen == 1) then visible(lgenimg, true) else visible(lgenimg, false) end
 end

-- links to data ref
  xpl_dataref_subscribe("laminar/c90/lighting/annun/dc_gen_L", "int", lgen_callback)
Hi, no worries. that is all great info. In fact it has made me start looking at some of the other aircraft (LUA sections) in XP and there is some really neat stuff in there.
I missed the custom data ref section ! doh :) .. Will go back and look again. Keep up the great work. The 737 annunciators have interesting features also as the coding was 3 years younger than the C90. Great references. Joe
Joe. CISSP, MSc.

User avatar
jph
Posts: 2856
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: King Air C90 Annunciator Panel

#12 Post by jph »

Hi @Ccard3dev
As an update and on further perusal of the XP lua repositories - I am certainly ok with the use of datarefs etc within AM, that isn't an issue, it was more regarding some of the nuances of the actual LUA code as used in the Laminar aircraft that you highlighted and the relationship to overall datarefs both inbuilt and custom..
On further inspection, I found the appropriate functions to which I referred, and also the allocation of the datarefs (thanks for the pointer !) which are almost - if not all - standard XP with custom refs made by Boolean association of the standard refs.
I have to thank you for pointing out these files as they are written by professional lua coders, are PROPERLY and very well commented and do not try to compress code into 'super optimised' - but usually only self gratifying and utterly pointless in terms of REAL WORLD operational speed. They and are a fantastic resource.
Based on these files for various Laminar aircraft and I will stick with them (Laminar true professionals!) as the documentation, shear quality and readability of the Laminar coders is a stable reference model. I believe there is a treasure trove of learning in there for LUA overall that surpasses a lot of AM instrument code - depending on the source - and in use with the LUA.org documentation is a veritable goldmine. Obviously, at the end of the day this all has to be applied to AM!. but for learning LUA in general ? freeking amazing - a bit chicken and egg ;) - but amazing.. :)
Joe.
Last edited by jph on Tue Jan 11, 2022 2:51 pm, edited 2 times in total.
Joe. CISSP, MSc.

User avatar
Keith Baxter
Posts: 4685
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: King Air C90 Annunciator Panel

#13 Post by Keith Baxter »

Hi @Ccard3dev

I got a lot more fancy. :lol:

Anyway, just to show you what can be done in AM. My teach's @Ralph and @Corjan will have a big smile. Yup, me using all the features Corjan kindly implemented for ME :mrgreen:
Yes SI guys I am buttering yous up. Cause I want my extra characters for the MAX ;)

King Air C90 - Annunciator Panel .siff
(90.65 KiB) Downloaded 97 times

Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

User avatar
jph
Posts: 2856
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: King Air C90 Annunciator Panel

#14 Post by jph »

Keith Baxter wrote: Tue Jan 11, 2022 2:39 pm I got a lot more fancy. :lol:

Anyway, just to show you what can be done in AM. My teach's @Ralph and @Corjan will have a big smile. Yup, me using all the features Corjan kindly implemented for ME :mrgreen:
Yes SI guys I am buttering yous up. Cause I want my extra characters for the MAX ;)
Keith
you old butt licking goat ;) :lol: - I think they probably did it because you simply wore them down with your tenacity and pounding with a larger metaphorical hammer like Thor and they had to give in or start taking more anti depressants :mrgreen:
Keith Baxter wrote: Tue Jan 11, 2022 2:39 pm Cause I want my extra characters for the MAX ;)
aren't Toto, Christian and 'sir' lewis' enough characters for Max ? :)
Joe. CISSP, MSc.

Post Reply