help with scriping again

Help creating logic scripts for Air Manager Instruments

Moderators: russ, Ralph

Post Reply
Message
Author
smartarze
Posts: 9
Joined: Sat May 02, 2020 3:24 am

help with scriping again

#1 Post by smartarze »

Still new and learning, when I try to combine several functions into 1 script, both switches operate the same led, even tho i'm selecting differnt pins on the arduino. Probably something stupid I'm doing but can someone show me how I'd put the following 2 bits of script into 1 please.

Code: Select all

-- This function will be called when new data is available from X-plane
function auto_throttle(auto_throttle_lt)
print("auto_throttle: " .. auto_throttle_lt)
local auto_throttle_lt_on = fif(auto_throttle_lt == 1, true, false)
hw_output_set(outp_id, auto_throttle_lt_on)
end

function capt_fd(capt_fd_lt)
print("capt_fd: " .. capt_fd_lt)
local capt_fd_lt_on = fif(capt_fd_lt == 1, true, false)
hw_output_set(outp_id, capt_fd_lt_on)
end

-- subscribe X-plane datarefs on the zibo
xpl_dataref_subscribe("laminar/B738/autopilot/autothrottle_arm_pos", "FLOAT", auto_throttle)
xpl_dataref_subscribe("laminar/B738/autopilot/flight_director_pos", "FLOAT", capt_fd)

outp_id = hw_output_add("auto_throttle_lt", false)
outp_id = hw_output_add("capt_fd_lt", false)

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

Re: help with scriping again

#2 Post by Sling »

Hi,

A simple fix. You must use unique node id’s. So perhaps outp_id and outp_id2 in your case. Each callback then just refers to its unique output id.

You can also combine the subscribes and use a single callback with 2 arguments. See subscribing to multiple datarefs on the wiki for examples if you don’t understand what this means.

Good luck

Tony

smartarze
Posts: 9
Joined: Sat May 02, 2020 3:24 am

Re: help with scriping again

#3 Post by smartarze »

Now working Tony, thanks so much. Can't believe what a simple answer it was. Wasted nearly a full day yesterday trying to figure it out.

Post Reply