ark1320 Posted 11 hours ago Report Posted 11 hours ago Hi John, Below are two tiny Lua scripts to calculate the total weight (e.g., landing weight) of a plane (Learjet in this case). If I run the scripts a number of times as the plane flies and burns off fuel, the first two-line script using an offset works reliably and always provides the correct updated weight. However, the second script that creates an Lvar in order to read the TOTAL WEIGHT Avar fails approximately 40 to 50 percent of the time. When it fails the script usually reports the initial value used when creating the Lvar (the 10361 value), or just doesn't update from the previous value. Using the sim's SimVar tool I monitored the TOTAL WEIGHT simvar and it always was updating as expected. I assume the (0x30C0) offset is using that simvar value. The main purpose of this post is to make sure I understand the Lvar creation process. It was this "Lvar script" that I tried first until seeing it was not working reliably. If the code in the Lvar script looks correct to you, then I would assume the sim has some kind of timing issue or bug. This happens in both MSFS2020 and MSFS2024. I know you are on Holiday and this issue can certainly wait until a convenient time. Thanks, Al ldg_wt = ipc.readDBL(0x30C0) -- get total weight ldg_wt = math.floor(ldg_wt_offset + 0.5) -- round to no decimal places ==================================================================================================== ipc.createLvar("L:Lear_LDG_Weight",10361) -- create Lvar, just using Lear's empty weight as the initial value ipc.reloadWASM() ipc.sleep(1000) ipc.execCalcCode(" (A:TOTAL WEIGHT, pounds) (>L:Lear_LDG_Weight) ") -- get current total weight ipc.sleep(100) ldg_wt = ipc.readLvar("L:Lear_LDG_Weight") ldg_wt = math.floor(ldg_wt + 0.5)
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