Jump to content
The simFlight Network Forums

SibWIngs AN-2: LVars associated with inertial clutch switch


Recommended Posts

Captains,

 

I'm close to finish my first ever LUA script which is dedicated to beautiful but grumpy "Annushka". :)

 

It was made possible thanks to precious advices I got from Pete, Paul (Gypsy Baron), LINDA Tracer and already covers almost ALL buttons, knobs, and switches found in the cockpit. But it can do more, particularly put the aircraft in a complete Cold & Dark situation and initiate the auto-start procedure (for lazy guys like me!).

 

There is only one problem though and I would like to hear your advice again. The final stage of auto-start procedure requires inertial clutch switch put to charging (LMB click), then wait until the charger noise stabilizes and ampermeter shows not less than 8 amps, and switch it to the right (RMB click) with magneto set to 1+2 mode immediately after engine is started. The following piece of code tries to accomplish this task:

 



local i = 0
local clutch = "L:AN2_inertial_clutch"
local soundSet = "L:play_sound"
local magneto = 0x0892
 
if ipc.readLvar(clutch) == 0  then
ipc.writeLvar(clutch,1)             -- inertial clutch switch CHARGE (LMB click)
ipc.writeLvar(soundSet,10)
 
i = 3
 
while i > 0 do
ipc.control(66740,1)             -- manual pump switch x3 times
ipc.writeLvar(soundSet,52)
ipc.sleep(1500)
i = i - 1
end
 
if ipc.readUD(0x08F8) > 0 then             -- while fuel pressure is OK...
ipc.control(66300)
ipc.writeLvar(clutch,-1)             -- put inertial clutch switch to ON (RMB click)
ipc.sleep(500)
end
 
if ipc.readUW(magneto) == 0 then
ipc.control(66400,3)             -- set magneto to 1+2
ipc.writeLvar(soundSet,13)
ipc.display("Magneto: SET TO 1+2")
ipc.sleep(1000)
end
 
end


 

Here is the photo of the switch:

 

post-16558-0-21297300-1442919941.png

 

But in fact changing L:Var "AN2_inertial_clutch" to -1 (note the minus sign!) yields nothing... :( When I do this with mouse, the engine starts OK but programmatically it's not possible... yet! The switch doesn't animate, nor it returns the requested value (-1).

 

I have tried to trace the L:Vars associated with the clutch switch but I cannot see them in event log. So, I thought maybe you can advice what other variables might be initiated during the startup so that the script can do everything without any user (mouse) interaction?

 

Thanks!

 

Rustam

Link to comment
Share on other sites

Does the switch respond and annimate to the parameters of 0 and 1?

 

When debugging issues like this I assign a button/switch temporarily to the L:Var in question (You may need to create

an MCRO file with an entry to define the L:Var and use SET as the function) The L:Var should then be present

in the FSX Commands list of the Buttons & Switches menu.

 

I simply set/change the parameter via the menu then 'Reload all..' and press the assigned switch or burron and observe

the results. Although 3 position switches with a center 'off' are most frequently coded to us 1, 0, -1 parameters this may

be an oddball. Try 0, 1 and 2 to see if that works.

 

Anyhow, unless there is some other dependancy in the code for that switch position to function, using the

above method to try different parameters should give you some insight into the issue.

 

 Paul

Link to comment
Share on other sites

 

 

Does the switch respond and annimate to the parameters of 0 and 1?

 

Yes, the assigned button activates both positions (0 for neutral and 1 for charging) well. But smth gets wrong at charging stage unless I switch to position 1 with mouse. The L:Var "AN2_inertia" should increase gradually adding ~0.15 at each charging step, whereas with LUA script switching from 0 to 1 sky-rockets the value to >1000... Switching to position -1 with LUA is... impossible at all!

 

 

When debugging issues like this I assign a button/switch temporarily to the L:Var in question (You may need to create

an MCRO file with an entry to define the L:Var and use SET as the function) The L:Var should then be present

in the FSX Commands list of the Buttons & Switches menu.

 

I simply set/change the parameter via the menu then 'Reload all..' and press the assigned switch or burron and observe

the results.

 

Roger that... If I understood you correctly I can achieve the same with LINDA Tracer - it has a facility where you can change a value of the L:Var in question "on the fly". Will try that again to debug.

 

 

Although 3 position switches with a center 'off' are most frequently coded to us 1, 0, -1 parameters this may

be an oddball. Try 0, 1 and 2 to see if that works.

 

Thanks for a tip!!!

 

 

 

Anyhow, unless there is some other dependancy in the code for that switch position to function...

 

That's my nightmare... I expressed the same concern about the code at SibiWings forum, so I strongly hope to get a reasonable answer from the developers.

 

Paul, thanks again for your time and understanding!!!

Link to comment
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
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.