Jump to content
The simFlight Network Forums

LUA Script MSFS left and right landing lights


Recommended Posts

Would like to assign one Joystick button each for the King Air's left and right landing lights.

In both MSFS and FSUIPC one can only assign landing lights on and off or the landing lights toggle. There are no separate commands for left and right landing lights like in the King Air.

Can that be done using a LUA script and if so can somebody assist me to write such script?

Thank you.

Roland 

Link to comment
Share on other sites

1 hour ago, alder said:

In both MSFS and FSUIPC one can only assign landing lights on and off or the landing lights toggle. There are no separate commands for left and right landing lights like in the King Air.

Can that be done using a LUA script and if so can somebody assist me to write such script?

The King Air has the following lvars that are settable and look like they should control the landing lights:
    LIGHTING_LANDING_1 
    LIGHTING_LANDING_2 
First, try setting them to 1/0 using the Add-ons->WASM->Set Lvars... menu option. If that works, then you can use the Adding Lvars to Offsets facility, no need to use lua. An example of how to do this is given in the Advance User guide, P43-44. You can also use a macro to toggle lvars if you prefer - see P35 of Advanced User guide.

John

Link to comment
Share on other sites

Hello again John,

Have added the following to my FSUIPC7.ini file

[LvarOffsets]
0=LIGHTING_LANDING_1
1=LIGHTING_LANDING_2

 

and both entries appear in FSUIPC's WASM menu. I have then tried to use the Set Lvars command but don't know what values to use. Is it 1 for Lighting_landing_1 and 0 for Lighting_landing_2? Have tried both values but the entries do not appear in FSUIPC's drop down list with the assignable button commands.

Any ideas?

Roland   

 

Link to comment
Share on other sites

44 minutes ago, alder said:

Have added the following to my FSUIPC7.ini file

[LvarOffsets]
0=LIGHTING_LANDING_1
1=LIGHTING_LANDING_2

As I said, please read the Advanced User guide. P43 and P44. I provide these manuals so that I do not have to explain the same thing for every user. Look at the example I give in the documentation:

Quote

[LvarOffsets.B747]
1=L:XMLVAR_YokeHidden1=UB0xA000

i.e. you have to give the type of the variable (in this case, UB, an unsigned byte) and the offset address to store the value (in this case, 0xA000).

50 minutes ago, alder said:

but the entries do not appear in FSUIPC's drop down list with the assignable button commands.

They don't appear there. You need to assign your button to Offset Byte Togglebits, giving the offset you are using together with 1 (or x1) as the parameter. As it says in the documentation...

Also note that, as lvars are aircraft specific, it is also better to add lvars to offsets in a LvarOffsets profile section really, but you can continue to use the general section for the time being, if you are not using profiles yet.

John

John

Link to comment
Share on other sites

Hello John,

 

Believe me, I have studied both manuals, it's npt that I am lazy----.

In the fields Offset and Parameter when assigning Offset bytes Togglebits to a button, what do you mean by "giving the offset you are using"? Is it the UB0xA000 like in your example for B747 and will it make a difference using 1 or x1 in the parameter field?

Thank you,

Roland

 

 

Link to comment
Share on other sites

25 minutes ago, alder said:

I have studied both manuals

If this is the case, then did you not see this:

Quote

Once you have created the section, you can add the lvars to the offsets you require by adding lines of the following
format to this section:
<
index>=<lvar name>=<size><offset>
where
-
index is the index number of the entry, starting from 0 with a max value of 1023 (i.e. maximum of 1024 entries)
-
lvar name is the name of the lvar, optionally preceded by 'L:'
-
size designates the size/type of the offset. This can be omitted and a size/type of 8 bytes/double will be used,
otherwise you can use the following designators and the lvar value (double) will be converted to the appropriate
size/type:

SB – signed byte (1 byte)
UB – unsigned byte (1 byte)
SW – signed word (2 bytes), use for signed short
UW – unsigned word (2 bytes), use for unsigned short
SD – signed double-word (DWORD) (4 bytes), use for signed int
UD – unsigned double-word (4 bytes), use for unsigned int
F – floating point number (4 bytes), use for float

 

?

27 minutes ago, alder said:

In the fields Offset and Parameter when assigning Offset bytes Togglebits to a button, what do you mean by "giving the offset you are using"? Is it the UB0xA000 like in your example for B747 and will it make a difference using 1 or x1 in the parameter field?

And why isn't this clear from the example I give in the documentation:

Quote

to assign a button/switch to control this lvar via the offset I have assigned (A000), I would assign to the control Offset
Byte Togglebits
, giving A000 as the offset and 1 (or x1) as the parameter.
 

?

I am sorry but I fail to understand why you are asking these questions when it should be clear from the documentation....

So, your lvaroffsets section should look like this (for example - you can use any offsets that are free for general use):

Quote

[LvarOffsets]
0=L:LIGHTING_LANDING_1=UB0xA000
1=L:LIGHTING_LANDING_2=UB0xA001

What that says is 'assign the lvar L:LIGHTING_LANDING_1 to offset 0xA000 as an unsigned byte, and also lvar L:LIGHTING_LANDING_2 to offset 0xA001 also as an unsigned  byte.

An then assign one button to the control Offset Byte Togglebits, giving A000 as the offset and 1 (or x1) as the parameter, and the other button to the same control, giving A001 as the offset and 1 (or x1) as the parameter. Exactly as the example given, except you are using 2 lvars and 2 offsets.

Why is this not clear from the Advanced user guide and the example given?

Maybe, if/when  the penny finally drops, you can create a FAQ entry (or User Contribution) explaining how to do this in language you understand, that may help others who have difficulty understanding the manuals.

John

Link to comment
Share on other sites

Thank you.

Have read the instructions in both manuals again and again and have tried to follow your comments/instructions in your most recent post, but all in vain.

I was aware that for MSFS2020 FSUIPC is not really necessary but still have purchased FSUIPC7 to have prop feather and sort of Beta range in the King Air. Fly nothing but the King Airs.

I am not new to FS, in fact I have owned the paid FSUIPC since the beginning and never ever had experienced such a struggle. For you and lots of others the manuals are clear enough, but not to me, sorry. I am not in computers and programming, I am only a user, but I do have a university degree in another sphere.

Are you 100% sure that one can use Lvars to assign left and right landing lights to separate buttons? Did you try that yourself?

Best,

Roland 

Link to comment
Share on other sites

1 hour ago, alder said:

Are you 100% sure that one can use Lvars to assign left and right landing lights to separate buttons? Did you try that yourself?

No I am not 100% sure, and I did not try this. You should always try/test lvars/hvars/calculator code before using, as I said in my first post:

On 11/15/2021 at 11:44 AM, John Dowson said:

First, try setting them to 1/0 using the Add-ons->WASM->Set Lvars... menu option. If that works, then you can use the Adding Lvars to Offsets facility

Did you not do this?
Have you installed the FSUIPC WASM module (that  provides access to lvars/hvars)?
Did you activate the WAPI? This needs to be done just the once if you want to use lvars/hvars.

1 hour ago, alder said:

Have read the instructions in both manuals again and again

Then I suggest you keep the manuals open and check things before asking for support. For example, you said:

8 hours ago, alder said:

Have added the following to my FSUIPC7.ini file

[LvarOffsets]
0=LIGHTING_LANDING_1
1=LIGHTING_LANDING_2

which is obviously the wrong syntax which even a brief check against the documentation would have told you....

1 hour ago, alder said:

For you and lots of others the manuals are clear enough, but not to me, sorry.

Well, obviously. But  from your questions it seems to me that you are not even looking at the manual. I gave both the syntax and an example on the manuals, and you seem to have missed both...

Anyway, I just checked those lvars in the King Air, which you should have done as suggested, and they are settable but have no affect. Even stranger, some of the standard landing light controls (Landing Lights Set, Landing Light Right, etc) get logged as completely different controls when sent to this a/c. Very strange.

There is also no MobiFlight preset for the King Air landing (or any other) lights, just presets for the AutoPilot (see https://hubhop.mobiflight.com/#/list).

So, in summary, I do not think this is currently possible. You could see if there is a mod available where this has been fixed, maybe try this one: https://uwajimaya.github.io/FS2020/

John

Link to comment
Share on other sites

14 minutes ago, John Dowson said:

There is one other thing that you can try....
Check to see if any of the controls in MSFS itself work. The default key for Landing Lights Right is shift + Ctrl + Num6, and for left is shift + ctrl + num4.
If they work, you can assign your buttons to the MSFS assigned key presses. 

These don't seem to work in the King Air either, sorry.

Link to comment
Share on other sites

Hello John,

Thank you for your assistance in this matter. The King Air is a mess and I honestly I am not surprised it doesn't work. Have already tried the default keys from day one and only because they don't work I was looking for a solution using FSUIPC. My hope is that Milviz or Flight1 will come up with a MSFS2020 payware King Air, but that looks like wishful thinking. 

That light mod you have posted the link for does nothing for the switches and things, it only uses different texture files for the lights to make them brighter or subtler.

Best,

Roland   

Link to comment
Share on other sites

Would be excellent if you could try that. As you know by now I have no clue what a calculator code is.

But if you send that event together, will it still be possible to assign individual buttons for left and right landing lights? I can assign the two as a combo in FSUIPC or MSFS with the LL on and off commands. What I am trying to achieve is the keep them separate but that´s not something coded into MSFS I guess.

The existing Landing Light left and right commands are not meant to turn them on or off. That steers them left and right or up and down and must be meant for choppers?

 

Link to comment
Share on other sites

3 hours ago, John Dowson said:

I do have one more idea - to set the lvar and send the Landing Lights Set event together (via calculator code). I will try this later.

Sorry, no luck with this - I can only turn both on or off, not individually.

I'm afraid it looks like this is not currently possible. I will raise a support request for this with Asobo.

John

Link to comment
Share on other sites

5 minutes ago, alder said:

At least to you they will listen. All my own requests have been ignored so far.

Don't be so sure! The same thing happens to the support requests/bugs I raise - they just seem to disappear into the Asobo systems with no way to track.
But at least it will be in there systems, although I doubt very much they will fix this. Asobo doesn't seem that interested in fixing things for external control, they seem to prioritize the visuals and the xbox controls...

John

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.