December 17, 201510 yr 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
December 17, 201510 yr 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
December 17, 201510 yr 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
December 22, 201510 yr 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