stefangr Posted Wednesday at 01:15 PM Report Posted Wednesday at 01:15 PM Hi guys, I have been converting my Skalarki driven home cockpit from P3D/JeeHell to MSFS2024/Prosim recently. JeeHell had provided quite a few offset variables, so I was able to read those offsets (ipc.Read) to find out which LEDs on overhead were active etc. I read those values with a Lua script running under FSUIPC. Prosim does not provide offsets, but a big list of "variables" according to their SDK (e. g.: I_MIP_AUTOBRAKE_MAX_L). I am not sure if or how I can read these variables with my Lua script. I don't think these are LVars, as I do not see them in a list of Lvars as shown by Axis and Ohs. Does anyone have a hint for me on how to read these variables in a Lua script? Thanks for your help Stefan
John Dowson Posted Wednesday at 02:39 PM Report Posted Wednesday at 02:39 PM 1 hour ago, stefangr said: Prosim does not provide offsets, but a big list of "variables" according to their SDK (e. g.: I_MIP_AUTOBRAKE_MAX_L). I am not sure if or how I can read these variables with my Lua script. I don't think these are LVars, as I do not see them in a list of Lvars as shown by Axis and Ohs. It all depends on what variable types they are. They won't be simvars, or A-type variables, as these are only defined by MSFS/Asobo. They could be lvars, hvars or input events (also known as b-vars). First, with the aircraft loaded, try listing the available lvars (Add-ons->WASM->List Lvars). Do you see them listed? You can also try listing the available Input Events (Log->List Input Events) - do you see them there? Note that MSFS2024 also has a new type of lvar (local variable), called 'scoped lvars'. There is currently no way to discover such vriables, but you can update them using calculator code. To read them, you would need to use calculator code to write the value to a standard lvar, and then read that. See If it is a scoped lvar, it may also be available as an Input Event, so please make sure you check there.
stefangr Posted Wednesday at 03:55 PM Author Report Posted Wednesday at 03:55 PM Thanks John, for your help. I checked as you suggested, the variables are not shown in the List of Lvars, and also not as Input Events. I double checked with Prosim support, and they suggest using MobiFlight. According to them, MobiFlight can obviously read the Prosim variables (around 4300 btw). I will have a look into Mobiflight now (despite the fact I do not want to access any hardware since I own Skalarki which is working fine with Prosim), but maybe there is a chance to convert some Prosim variables into Offsets which I then can use in my Lua script. Best regards Stefan
John Dowson Posted Wednesday at 04:11 PM Report Posted Wednesday at 04:11 PM But what type of variables are they? Are they scoped lvars? 10 minutes ago, stefangr said: According to them, MobiFlight can obviously read the Prosim variables (around 4300 btw). Then they are probably scoped lvars. MobiFlight will read these by executing a calculator code script and getting the value in the response. In FSUIPC, I do not provide/allow for a response from executing calculator code. 8 minutes ago, stefangr said: but maybe there is a chance to convert some Prosim variables into Offsets which I then can use in my Lua script. Again, this depends on the variable type. If they are scoped lvars, you can only get the value, and add this to an offset, by writing/copying the value of the scoped lvar to a standard lvar, and then read or add this to an offset. You would need to update the value of the lvar (from the scoped lvar) at regular intervals (e.g. at 6Hz) as well, so that the lvar holds the current value of the scoped lvar. You can do this using a lua script.
John Dowson Posted yesterday at 03:53 PM Report Posted yesterday at 03:53 PM @stefangr Is this clear for you? I can provide a sample lua script for the I_MIP_AUTOBRAKE_MAX_L variable, if it is a scoped lvar, if you need this. Let me know. John
stefangr Posted 9 hours ago Author Report Posted 9 hours ago Thanks John, for your help. I think I understand the general principle. Meanwhile I tried a bit around with Mobiflight on Wednesday, I was able to read the Prosim variables, but had no success in writing them into an offset. But it was my first try with Mobiflight at all. If I could create a solution without Mobiflight and with reading and converting these variables just within a Lua script, that would be the best, since I am within the Lua script anyway with my "addon". So if you could provide a sample lua script, that would be very much appreciated. Thanks Stefan
John Dowson Posted 6 hours ago Report Posted 6 hours ago First, to update the scoped lvar, you need to create a preset in the myevents.txt file (create this if you don't yet have one): //ProSim/A320 ProSim737_MIP_AUTOBRAKE_MAX#$Param (>L:1:I_MIP_AUTOBRAKE_MAX_L) then assign to that with an appropriate parameter value. To add this to an offset (for reading only - writing/updating won't work), create a lua script to copy the value of the scoped lvar to a standard lvar, and add the standard lvar to an offset. The lua script to keep the lvar in sync with the scoped lvar is as follows: -- function to copy the value of the scoped lvar to the standard lvar function updateLvar(time) ipc.execCalcCode("(L:1:I_MIP_AUTOBRAKE_MAX_L) (>L:I_MIP_AUTOBRAKE_MAX_L") end -- Create an lvar to hold the value of the scoped lvar -- Note that if you want to do this for multiple scoped lvars, better to create the lvars using calculator code, e.g. -- ipc.execCalcCode("(L:1:I_MIP_AUTOBRAKE_MAX_L) (>L:I_MIP_AUTOBRAKE_MAX_L") -- for each lvar, and then call -- ipc.reloadWASM() -- This is because using ipc.createLvar will also force a reload, and you don't want to do this after creating -- each lvar - best just to do it once after all the lvars have been created. -- But as we are only currently doing this for one scoped lvar, we will use the ipc.createLvar function. ipc.createLvar("I_MIP_AUTOBRAKE_MAX_L") -- wait until the new lvar has been received ipc.sleep(250) -- Start a timer function to keep the lvar in sync with the scoped lvar event.timer(150, "updateLvar") The script should be auto-started in your profile [Auto.xxx] section (where xxx is the profile name).You can then add the lvar to an offset in the usual way, e.g. Quote [LvarOffsets.xxx] 1=L:I_MIP_AUTOBRAKE_MAX_L=UB0xA000 John
stefangr Posted 5 hours ago Author Report Posted 5 hours ago Thanks, John, I will try that. Just one thing about the entry in myevents.txt: //ProSim/A320 ProSim737_MIP_AUTOBRAKE_MAX#$Param (>L:1:I_MIP_AUTOBRAKE_MAX_L) Is "ProSim737_MIP_AUTOBRAKE_MAX" just a name I will give and which has to be unique if I want to trace several variables, and this name does not have to be same as the variable name (of course it should be similar to be able to find things)?
John Dowson Posted 5 hours ago Report Posted 5 hours ago Just now, stefangr said: Is "ProSim737_MIP_AUTOBRAKE_MAX" just a name I will give and which has to be unique if I want to trace several variables, and this name does not have to be same as the variable name (of course it should be similar to be able to find things)? Yes - its just a name (string) attached to the calculator code - you can use whatever is appropriate. You can also give a fixed value rather than using a parameter ($Param) if you prefer, and have several presets each setting a different fixed value. John 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now