Jump to content
The simFlight Network Forums

A non Aircraft specific Question regarding MSFS Vars


Airbuspilot

Recommended Posts

There are two ways to set a simvar (or A-type variable0 that is not already held in an FSUIPC offset:

1. Use calculator code, e.g ipc.execCalcCode("50 (>A:LIGHT POTENTIOMETER:84, Number)")

2. Add the simvar to a free/spare FSUIPC offset, and use the provided lua offset functions to read/write to the offset.
How to add a simvar to a spare FSUIPC offset is described in the Advanced User guide.

John

Link to comment
Share on other sites

On 9/20/2023 at 4:21 PM, Airbuspilot said:

But what means the Word Number in the ipc.execCalcCode Command?

That is the type of the value you are setting, and should probably be Percent not Number in this case, i.e. ipc.execCalcCode("50 (>A:LIGHT POTENTIOMETER:84, Percent)"), or you could use Percent over 100 and adjust the parameter,  e.g.  ipc.execCalcCode("0.5 (>A:LIGHT POTENTIOMETER:84, Percent over 100)"). See the following page for a list of simulator variable units: https://docs.flightsimulator.com/html/Programming_Tools/SimVars/Simulation_Variable_Units.htm

Note that it may not be possible to set this value directly for this particular variable, or it may be settable but setting this may not have the desired affect. You would normally use the control (or K-type variable)LIGHT_POTENTIOMETER_SET (with an appropriate index) to change this..  For example, this is the calculator code to increase the panel brightness in the Bonanza G36:
                 (A:LIGHT POTENTIOMETER:3, Percent) 1 + 100 min 3 (>K:2:LIGHT_POTENTIOMETER_SET)

You can refer to the SDK documentation to see if a variable is settable (as well as its type). However, some variables - including LIGHT POTENTIOMETER, don't seem to be documented.

 

 

Link to comment
Share on other sites

Unfortunately i can't get any Efforts on the Potentiometer Settings.
I have searched in the Forums for several Solutions, but all i have tried doesn't work.
And to be honest - Some of the Solutions i have found are to complex for me to understand.
Maybe you can do a more in deep Explanation of the necessary Code please?

Joachim

Link to comment
Share on other sites

6 hours ago, John Dowson said:

Could you explain what you are trying to achieve? Which aircraft and what function?

It is the FBW A32NX. I want to set the Light Potetiometer:86 to a Value of 25. This is the Setting for the Overhead Integ Light.

 

6 hours ago, John Dowson said:

Have you looked to see if there is already a preset available?

I have seen this in some Threads, but i don't know exactly, what it means.

Link to comment
Share on other sites

1 hour ago, Airbuspilot said:

This is the Setting for the Overhead Integ Light.

There are two presets for this: A32NX_OH_INTEG_LIGHT_INC and A32NX_OH_INTEG_LIGHT_DEC. Why don't you use them? This is the calculator code for the inc:
    (A:LIGHT POTENTIOMETER:86,percent) 5 + 100 min 86 (>K:2:LIGHT_POTENTIOMETER_SET)
So it using index 86 (not 84), and reading the value from the simvar but using the event to set it. See the HubHop site if you haven't already (https://hubhop.mobiflight.com/presets/).
You can assign directly to MF presets in FSUIPC7. Make sure that you are using the latest version (7.3.23) as this has an additional facility/button (Find Preset) that makes finding presets a lot easier. Please see the Advanced User guide on using presets.

And for the glareshield (which uses 84), these presets are available: A32NX_LIGHTS_GLARESHIELD2_INCA32NX_LIGHTS_GLARESHIELD2_DECA32NX_LIGHTS_GLARESHIELD2_PERCENT
The last one is output only, and just reads the simvar LIGHT POTENTIOMETER:84.

John

Edited by John Dowson
glareshield added
Link to comment
Share on other sites

The Presets are a great Work. Finding and Binding them to a Button or Key in FSUIPC 7.3.23 is pretty easy.
But unfortunately this is not, what i need. I want to set a fixed Value i.E. to Potentiometer:86 via ipc.execCalcCode or any other Command in my Lua Script.
I tried this Command: ipc.execCalcCode("0.5 (>A:LIGHT POTENTIOMETER:86, Percent over 100)")
But that has no Effect.

Seems like i am unable to do, what i need and i have to set all those Potis by Mouse Clicks in the VC.
Thanks for your Help so far and have a nice Sunday.

Joachim

 

Link to comment
Share on other sites

22 minutes ago, Airbuspilot said:

I tried this Command: ipc.execCalcCode("0.5 (>A:LIGHT POTENTIOMETER:86, Percent over 100)")
But that has no Effect.

As I said, not all simvars (a-type variables) are settable directly. The MSFS SDK lists the available simvars and their settable status, but this one is not documented, so is probably settable. This is  why the presets only read this simvar and use the k-type variable, which is an event or control, to update.

As simvars can also be updated by sending the appropriate event. instead of updating directly, why not use:
    ipc.execCalcCode("50 (>K:2:LIGHT_POTENTIOMETER_SET)")

John

Link to comment
Share on other sites

16 hours ago, John Dowson said:

 ipc.execCalcCode("50 (>K:2:LIGHT_POTENTIOMETER_SET)")

That also has no Effect. Seems, this Technology is too high for me.
I put a new Line in the events.txt.
A32NX_OH_INTEG_LIGHT_25#(A:LIGHT POTENTIOMETER:86,percent) 25 (>K:2:LIGHT_POTENTIOMETER_SET)
This should set the Light Poti to 25. But how do i code this in my Lua Script?

Sorry that i stretch your Nervs with my Lack of Knowledge.

Joachim

Link to comment
Share on other sites

1 hour ago, Airbuspilot said:

I put a new Line in the events.txt.
A32NX_OH_INTEG_LIGHT_25#(A:LIGHT POTENTIOMETER:86,percent) 25 (>K:2:LIGHT_POTENTIOMETER_SET)
This should set the Light Poti to 25. But how do i code this in my Lua Script?

You should add your own presets to the myevents.txt file, not the events.txt file, as that will get replaced the next time you update.

Executing a preset is EXACTLY the same as executing the calculator code associated to the preset, so you can use either
    ipc.execPreset("A32NX_OH_INTEG_LIGHT_25")
or
    ipc.execCalcCode("(A:LIGHT POTENTIOMETER:86,percent) 25 (>K:2:LIGHT_POTENTIOMETER_SET)")

Note also that the '(A:LIGHT POTENTIOMETER:86,percent)' part is redundant, as this just reads the value and then that value is ignored. it is the same as just
    
ipc.execCalcCode("25 (>K:2:LIGHT_POTENTIOMETER_SET)")
as I wrote in my previous comment, and you have said that this doesn't work...

if you need calculator code for a specific function, you can ask about this on the MSFS2020 channel of the MobiFlight discord server. That is the community resource you should use for asking the community for the calculator code needed to implement a  specific function.

Link to comment
Share on other sites

Neither this 

5 hours ago, John Dowson said:

ipc.execPreset("A32NX_OH_INTEG_LIGHT_25")

nor that

5 hours ago, John Dowson said:

ipc.execCalcCode("(A:LIGHT POTENTIOMETER:86,percent) 25 (>K:2:LIGHT_POTENTIOMETER_SET)")

works in my Script.
I try to find a Solution in the Mobiflight Discord.
Thanks for your Attemts to help me.

Joachim

Link to comment
Share on other sites

First, can you try just assigning (a key or button) to the available  presets (that I mentioned earlier) for glareshield and/or o/h integ lights inc/dec (if you haven't already) - do they work for you?
Also make sure that you are also using the latest version of FSUIPC7, v7.3.23.

I will switch to the dev version and check this tomorrow and let you know if they work here.

If they work, it should be straightforward to use something similar on an axis/potentiometer, or to send/set a fixed value.

 

Link to comment
Share on other sites

19 hours ago, John Dowson said:

I will switch to the dev version and check this tomorrow and let you know if they work here.

I have checked the following presets in the A320-dev version and they all work (i.e. I can see the associated knob rotate):
    A32NX_LIGHTS_GLARESHIELD2_INC (*)
    A32NX_LIGHTS_GLARESHIELD2_DEC (*)
    A32NX_LIGHTS_GLARESHIELD3_INC
    A32NX_LIGHTS_GLARESHIELD3_DEC
    A32NX_OH_INTEG_LIGHT_INC
    A32NX_OH_INTEG_LIGHT_DEC
All except the first two (*) also control the brightness for what they are trying to control - with these I can't see any brightness changes (although the knob moves, but that is probably because I don't know where to look!

To set to a specific value using calculator code:

On 9/24/2023 at 1:50 PM, John Dowson said:

     ipc.execCalcCode("25 (>K:2:LIGHT_POTENTIOMETER_SET)")

this doesn't work. It seems that the 'K:2:LIGHT_POTENTIOMETER_SET' event needs 2 parameters (probably what the ':2:' indicates). So try this - it works here:
      ipc.execCalcCode("25 84 (>K:2:LIGHT_POTENTIOMETER_SET)")
So the 25 indicates the percentage, and the 84 the index of the LIGHT POTENTIOMETER simvar that the event is controlling. You can change these values to control the %age and the lights, where 84 indicate glareshield brightness, 87 FCU brightness,  86 the Overhead panel integrated light knob, 85 the pedestal light knob Integ brightness, 83 the  pedestal light knob Flood Captain, 90 right PFD brightness, etc

I knew some events can take two parameters - this was introduced in an update a few months ago, but I didn't know how you actually used them  in calculator code until now, so this has also been a valuable learning experience for me.

Hope this helps - let me know how you get on. If you can't get this to work, I will need to see your files - your FSUIPC7.log (with logging for Buttons & Keys and Events activated, as well as Debug level logging set in the WAPI) and FSUIPC7.ini files, together with your lua files.

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.