Groups

Help creating logic scripts for Air Manager Instruments

Moderators: russ, Ralph

Post Reply
Message
Author
vangyver
Posts: 127
Joined: Sat Dec 05, 2015 8:30 am

Groups

#1 Post by vangyver »

Working on coding for groups. Can not seem to get it to work?

Code: Select all

-- Add images in Z-order --
img_add_fullscreen("KN 62A.png")

-- Add text  in Z-order --
txt_nm = txt_add("NM", "size:20px; font:GOST Common.ttf; color: #fb2c00; halign: left;", 135, 42, 50, 50)
txt_kt = txt_add("KT", "size:20px; font:GOST Common.ttf; color: #fb2c00; halign: left;", 322, 42, 50, 50)
txt_min = txt_add("MIN", "size:20px; font:GOST Common.ttf; color: #fb2c00; halign: left;", 470, 42, 50, 50)

-- Add a group --
group_textRMT = group_add(txt_nm, txt_kt, txt_min)

--subscribe callback --
function new_data_fsx(avionics, battery, generator, kn62OnOff)

     --make a boolean power variable based on state of avionics, battery, generator and kn62OnOff == 1
     local power = avionics >= 8 and (battery >= 8 or generator) and kn62OnOff == 1 
     
    if power then
        visible(group_textRMT, true)
    else
        visible(group_textRMT, false)
    end
end

fsx_variable_subscribe("L:kn62OnOff", "enum",
                       "ELECTRICAL AVIONICS BUS VOLTAGE", "Volts",
                       "ELECTRICAL BATTERY BUS VOLTAGE", "Volts",
                       "GENERAL ENG GENERATOR SWITCH:1", "Bool", new_data_fsx)
                       

vangyver
Posts: 127
Joined: Sat Dec 05, 2015 8:30 am

Re: Groups

#2 Post by vangyver »

Getting correct values as per image:
Groups.jpg

User avatar
Sling
Posts: 5237
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: Groups

#3 Post by Sling »

There is nothing wrong with the group part but you have the subscribed arguments in the wrong order in the callback.

Subscribe order is
Custom LVAR
Avionics volts
Battery volts
Gen switch

Callback order is
Avionics volts
Battery volts
Gen switch
Custom LVAR
Last edited by Sling on Sat Sep 18, 2021 7:19 am, edited 1 time in total.

vangyver
Posts: 127
Joined: Sat Dec 05, 2015 8:30 am

Re: Groups

#4 Post by vangyver »

Must be getting tired. I should of seen that. Thank You, Van

Post Reply