Detlef_747 Posted April 1, 2022 Report Posted April 1, 2022 Hi, I have started to write a simple variable tracker for Lvars and Hvars. Starting from the Lua examples log lvars.lua and record to csv.lua I managed to generate a .csv file in the format I need. I noticed that there are these library functions: ipc.readLvar("name") and ipc.readLvarSTR("name) Trying with the FlyByWire A320 for FS2020 I found no STR variable at all Is that just the aircraft or am I doing something wrong? -- By using "assert" you get an error message if this fails f = assert(io.open("am_fs2020_vars.csv","w")) -- write the CSV column headings -- possible Types: L (for Lvars), H (for Hvars) -- poosible Subtypes: F (for float), S (for string), U (for unknown) default is F --f:write("\r\nType,Subtype,Name\n") f:write("Type,Subtype,Name,Value\n") ipc.log("Searching for Lvars") count = 0 for id=0, 65535 do name = ipc.getLvarName(id) if id == nil then break end subtype = "U" value = ipc.readLvar(name) if value ~= nil then subtype = "F" else value = ipc.readLvarSTR(name) if value ~= nil then subtype = "S" end end count = count+1 f:write(string.format("L,%s,%s,", subtype, name)) if subtype == "F" then f:write(string.format("%0.6f", value)) elseif subtype == "S" then f:write(string.format("(((%s)))", value)) else f:write("(((unknown)))") end f:write("\n") end ipc.log(count .. " Lvars found.") -- write a CSV line to the open file f:write(string.format("A test: %02.4f\n", 3)) -- tidy up at end ... f:write("\n") f:close() And some more questions: 1) There are no STR variables for Hvars, right? 2) Is there a way to find out the unit, that an Lvar is using? E.g. ft or degrees or bar... ? 3) Is there a way to see what are output, what are input variables? Thank you Detlef
John Dowson Posted April 1, 2022 Report Posted April 1, 2022 17 minutes ago, Detlef_747 said: I found no STR variable at all Is that just the aircraft or am I doing something wrong? Probably just the aircraft, and most (if not all) aircraft probably don't use strings for lvars. All lvars are actually treated internally as 64-bits/ 8-byte values. The STR functions are just provided for convenience. But note that your else clause to read the lvar using ipc.readLvarSTR will never be reached. Even if the lvar was actually holding a string value, the ipc.readLvar would still read the value and return the string interpreted as a floating point number. You really need to know that the lvar is holding a string value before using that function. 20 minutes ago, Detlef_747 said: 1) There are no STR variables for Hvars, right? There are no values associated with hvars - you can only activate them. 20 minutes ago, Detlef_747 said: 2) Is there a way to find out the unit, that an Lvar is using? E.g. ft or degrees or bar... ? Nope. Lvars should be documented with the aircraft and provide this sort of information, but very few aircraft (if any...) provide such documentation. 22 minutes ago, Detlef_747 said: 3) Is there a way to see what are output, what are input variables? Not that i know of, except by trying to set / change the value and then reading to see if it contains the value you set. But, if the value is not set it could also possibly be due to the current aircraft state. John
Detlef_747 Posted April 2, 2022 Author Report Posted April 2, 2022 Quote But note that your else clause to read the lvar using ipc.readLvarSTR will never be reached. Even if the lvar was actually holding a string value, the ipc.readLvar would still read the value and return the string interpreted as a floating point number. You really need to know that the lvar is holding a string value before using that function. Hi John, I see. Thank you for explaining, and also your further comments. 20 hours ago, John Dowson said: There are no values associated with hvars - you can only activate them. "Activate" means trigger an event? Is it the same as an event? Only it is called Hvar in this case? Sorry, if a silly question. Thank you Detlef
John Dowson Posted April 2, 2022 Report Posted April 2, 2022 4 hours ago, Detlef_747 said: "Activate" means trigger an event? Is it the same as an event? Only it is called Hvar in this case? Sorry, if a silly question. Not a silly question, but more one for Asobo.... As far as I know, hvars are 'html variables', which can only be triggered/activated. Like events, but events are associated with the model, hvars with the interface/UI. But events can also take a parameter. As far as I am aware, there is no value associated with a hvar. John
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