Jump to content

Recommended Posts

I am still trying to see if I can optimise my code (clutter wise and not speed wise).

I have absolutely no lags or stutters whatsoever. I will upload as soon as I feel it is worthy of sharing.

 

Share this post


Link to post
Share on other sites
6 hours ago, jfjoubert said:

I am still trying to see if I can optimise my code (clutter wise and not speed wise).

I have absolutely no lags or stutters whatsoever. I will upload as soon as I feel it is worthy of sharing.

 

So we have a winner here :)

Share this post


Link to post
Share on other sites

NOTE : to declutter the code you can transform

if os.clock() > r_trigger_start_time +1 then
w_acft_flap = 0.5
end 

into

if os.clock() > r_trigger_start_time +1 then w_acft_flap = 0.5 end 

Share this post


Link to post
Share on other sites
34 minutes ago, XPJavelin said:

NOTE : to declutter the code you can transform

if os.clock() > r_trigger_start_time +1 then
w_acft_flap = 0.5
end 

into

if os.clock() > r_trigger_start_time +1 then w_acft_flap = 0.5 end 

Thanks - and with all the thinking my brain can do, I do not know why i've done it as per my original note. 

Just putting some more lines together in my lunch (for my shutdown routine) looks much neater per your suggestion :- (I've intentionally put the same time on some actions - I want my first officer using all fingers when he can! :) 

 

if r_includeIRS then 
if os.clock() > r_trigger_start_time + 1 then w_acft_irsL = 0 end
if os.clock() > r_trigger_start_time + 2 then w_acft_irsR = 0 end 
end 

if os.clock() > r_trigger_start_time + 4 then w_acft_fuelLfwd = 0 end
if os.clock() > r_trigger_start_time + 4 then w_acft_fuelLaft = 1 end -- leave on for apu 
if os.clock() > r_trigger_start_time + 5 then w_acft_fuelRfwd = 0 end
if os.clock() > r_trigger_start_time + 5 then w_acft_fuelRaft = 0 end

if os.clock() > r_trigger_start_time + 6 then w_acft_winheat_l_side = 0 end
if os.clock() > r_trigger_start_time + 6 then w_acft_winheat_l_fwd = 0 end
if os.clock() > r_trigger_start_time + 7 then w_acft_winheat_r_side = 0 end
if os.clock() > r_trigger_start_time + 7 then w_acft_winheat_r_fwd = 0 end
if os.clock() > r_trigger_start_time + 8 then w_acft_pitot_a = 0 end
if os.clock() > r_trigger_start_time + 9 then w_acft_pitot_b = 0 end

if os.clock() > r_trigger_start_time + 10 then w_acft_hydELEC2 = 0 end
if os.clock() > r_trigger_start_time + 11 then w_acft_hydELEC1 = 0 end

if os.clock() > r_trigger_start_time + 14 then w_acft_seatbelt = 0 
if os.clock() > r_trigger_start_time + 15 then w_acft_beaconLIGHT = 1

 

Share this post


Link to post
Share on other sites

The problem with the above code is that you cannot have it in a function which is only executed once... you will never get to most of the steps.

The current code has a conditional check for PREFLIGHT to see that preflightproc_trigger == 0 and beforestartproc_trigger == 0 and OXYTEST == 1

Now this means that the actual code inside the function will only execute once. On the second pass all the above variables will not meet the condition again. So you will never get to os.clock() > r_trigger_start_time + 4 and further.

So one possible solution is to change the conditional check to make sure that the code inside the function is repeated until all steps have been completed. This is what is adding to the clutter because now you have to make sure that you don't repeat a previously executed step and and that all steps are still done in the right order.

Anyhow, I will upload my lua file (once done) with my modified code for the PREFLIGHT procedure and you guys can then have a look to see if it's not too much clutter in the code.

 

  • Upvote 1

Share this post


Link to post
Share on other sites
1 hour ago, jfjoubert said:

The problem with the above code is that you cannot have it in a function which is only executed once... you will never get to most of the steps.

The current code has a conditional check for PREFLIGHT to see that preflightproc_trigger == 0 and beforestartproc_trigger == 0 and OXYTEST == 1

Now this means that the actual code inside the function will only execute once. On the second pass all the above variables will not meet the condition again. So you will never get to os.clock() > r_trigger_start_time + 4 and further.

So one possible solution is to change the conditional check to make sure that the code inside the function is repeated until all steps have been completed. This is what is adding to the clutter because now you have to make sure that you don't repeat a previously executed step and and that all steps are still done in the right order.

Anyhow, I will upload my lua file (once done) with my modified code for the PREFLIGHT procedure and you guys can then have a look to see if it's not too much clutter in the code.

 

Mmm :huh: Well said.

Share this post


Link to post
Share on other sites

As promised...

IMPORTANT NOTE TO ALL: This file is not a complete replacement for the original code from @XPJavelin. It simply shows a way of applying some randomness in the procedure steps.

Please also note:

  • The code was only modified for the PREFLIGHT Procedure (start with OXYGEN test switch)
  • You can easily change the min and max time (in seconds) for the random delay in the code
  • I re-enabled some of the datarefs and made some "readonly" to be able to do some conditional checks
  • If you don't know FlyWithLUA or LUA or you don't care about the underlying code then wait for an official update from @XPJavelin
  • This will only happen if @XPJavelin wants to incorporate this into his code

@XPJavelin I did add comments as far as possible to the code so hopefully it will make sense. Shout if anything is unclear.

IXEG_proc.lua

Edited by jfjoubert
  • Like 1

Share this post


Link to post
Share on other sites

thanks @jfjoubert,I will investigate your work, in the mean time, I was working on a revision of my script to include after landing flow with and without APU.

I also added altitude constraint for flaps retraction, compatible with the go around triggers,  and runway Entry procedure is triggered by left inboard landing light instead of left outboard.

Both as suggested by @blocks_off

Share this post


Link to post
Share on other sites
3 hours ago, jfjoubert said:

The problem with the above code is that you cannot have it in a function which is only executed once... you will never get to most of the steps.

Yes that is true of the code I posted earlier, but not if taking this into account i.e. it's part of a function as described here.

 

2 hours ago, XPJavelin said:

Mmm :huh: Well said.

As above

Share this post


Link to post
Share on other sites

@blocks_off Correct me if I'm wrong but won't your code execute the same steps multiple times until the 22 seconds have passed and r_trigger_shooting_approaches is set to false?

It should work if you conditionally check each item and only set it once like this:

if os.clock() > r_trigger_start_time +1 then
	if w_acft_flap ~= 0.5 then w_acft_flap = 0.5 end
end 

Otherwise you might end up hearing all the click sounds in the cockpit when switches are set to a specific position, even though they might already be in that position from a previous loop through the function.

Anyway, it could work. I just felt like typing a lot of code... ;)

Share this post


Link to post
Share on other sites

Hi @jfjoubert

You are correct with what you say and it is great fun testing when you move a switch to a different position, then it moves it back :) but i digress..... I do not hear repeated clicks, there are a few steps where I check for the state and then only set if it is not in the correct position for that routine such as gear handle, start switches.

I've had a quick look at your code, and as much as I like the randomness idea, I will park it for now :) Well done though with that achievement... did you drink a lot of your favorite drink whilst writing it ;) ?

Thanks for your reply and interest

-Carl

Edited by blocks_off

Share this post


Link to post
Share on other sites

I am looking for something simple in my code.

It was very convenient to read the FCOM and just translate in a few command lines, in a very straighforward way. I am not sure I am ready to sacrifice simplicity for human delay of actions.

12 hours ago, jfjoubert said:

if os.clock() > r_trigger_start_time +1 then if w_acft_flap ~= 0.5 then w_acft_flap = 0.5 end end

I like that way of doing however.

I will think about it.

In the mean time, I was thinking of implementing a GUI menu to set options (F30 of F40, with or without APU...)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×