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.

Holding control for certain time in LUA

Featured Replies

I am trying here to do small LUA scripts, after reading a lot about LUA, am still unable to do it.

 

The APU selector switch in 777 has off, on and start positions; in real life you should switch to Start for 5 seconds then release the switch which will go back to on. I am trying to simulate that.

 

I did the following code:

function APU_SEL_SWITCH_start_seq ()
	APU_SEL_SWITCH_start ()
	ipc.sleep (5000)
	APU_SEL_SWITCH_on ()
end

however, in above code there is no any hold for the Start position, the ipc.sleep is just to give a break of 5 seconds.

 

could any one help me with the hold code?

Jehad Hamdan

Hi Rabso

 

The ipc.sleep function is used a delay of n 1/1000s to allow actions to complete before continue with the next instruction. It does not cause the previous function to continue to operate. Are you asking before the start_seq is not on long enough to correctly start the engines or are you looking for accuracy of the simulation?

 

The easiest way to do this is to set the OnPress and OnRepeat to the 'start' function and the 'set' to the OnRelease. You would then hold the button pressed for the prerequisite 5s.

Andrew Gransden

Scotland, UK

LINDA Support/Developer - VATSIM and BAVirtual - Airbus Flyer

i7 1TB SSD GTX980 - FSX/P3D - Aerosoft Airbus A318/A319/A320/A321 - FS2Crew

  • Author

yes am looking for accuracy of the simulation.

 

I am aware of the OnPress and OnRepeat then OnRelease, but this is only applicable for buttons where I am using switch in my Warthog throttle.

 

The idea is when I move the APU switch of my warthog to on, LUA will turn the 777 APU to start for 5 seconds then back to On

Jehad Hamdan

  • Author

Scotflieger, I have done the trick :Big Grin:

 

here is my code to share with all:

function APU_SEL_SWITCH_start_sequence()
    time1 = ipc.elapsedtime()

    while true do
        time2 = ipc.elapsedtime() - time1
	if time2 >= 2000 then
            break
        else
            APU_SEL_SWITCH_start ()
        end
    end

    APU_SEL_SWITCH_on ()
end

to explain,

- time1 will note the function start time

- entering a loop to keep the APU selector on Start position as long the time difference time between time2 and time1 less than 2 seconds.

- time2 will keep increasing as long the loop is going on.

- once difference time be more than 2 seconds, the loop will break, and then APU selector will go to On.

Jehad Hamdan

Create an account or sign in to comment

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.