Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Help with a script

Featured Replies

I could use some help with this script. I'm not quite sure how to get it to work. I feel like I'm close and just missing the proper command.

I'm dealing with cowl flap positions, and two specific yet interrelated functions: the actual cowl flap position (L:CowlFlap1 thru L:CowlFlap4, range 0 (fully closed) to 100 (fully open)) and the cowl flap switch position (L:CowlFlap1SwitchPos thru L:CowlFlap4SwitchPos, position 0 (close), 1 (locked) and 2 (open)). I want to be able to with a press of a button or switch to command the cowl flaps to a 33% opening (ipc.writeLvar ("L:CowlFlap4", 33). Getting the cowl flaps to move is fairly simple and I get that to work without any problem. It is the next two that have me stumped.

First off, I want to have the cowl flaps actually move from wherever they currently are to the 33% setting, I also want the cowl flap switch to correspond with that adjustment. So, for instance, if the cowl flap is at 25%, the switch would move to the open position (2) as the cowl flaps gradually opened from 25% to 33%, and then the cowl flap switch would go to locked(1). And if the cowl flap position was 80%, the cowl flap switch would shift to the close position (0) as the cowl flaps gradually closed to the 33% position, at which point the cowl flap switch would retun to locked(1).

I can get the script to do most of this. However, at this point there is no "33%" position; the cowl flaps will move from low to 100%, or from high to 0%, and I think I know why: there is no "check" and thus stop for the counter. 

This is the partial script so far, for just cowl flap 1:

function CowlFlaps_TakeOff ()

i = ipc.readLvar ("AutoCoPilotCowl"); this determines if the AI copilot is controlling the cowl flaps and, if so, returns command to the RL pilot

if i==1 then
ipc.writeLvar ("AutoCoPilotCowl", 0)
ipc.sleep (1000)
OpenAllTakeoff ()
else
OpenAllTakeoff ()
end
end

function OpenAllTakeoff (); these control each of the four engines
OpenCowlTakeoff1 ()
OpenCowlTakeoff2 ()
OpenCowlTakeoff3 ()
OpenCowlTakeoff4 ()
end


function OpenCowlTakeoff1 (); this controls Engine #1's cowl flaps

a = ipc.readLvar ("L:CowlFlap1")
j = ipc.readLvar ("L:CowlFlap1SwitchPos")

if a < 33 then
a = a + 1
j = 2
elseif a > 33 then
a = a - 1
j = 0
else
a = 33
j = 1
end
ipc.writeLvar ("L:CowlFlap1", a)
ipc.writeLvar ("L:CowlFlap1SwitchPos", j)
ipc.sleep (50)

end
function OpenCowlTakeoff2 ()

end
function OpenCowlTakeoff3 ()

end
function OpenCowlTakeoff4 ()

end
 

  • Author

Never mind, I figured it out.

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.