Fragtality Posted Friday at 09:10 AM Author Report Posted Friday at 09:10 AM 6 hours ago, GASimPilot said: Thanks for the reply. I have been trying to get the lua scripting working, and I cannot figure out how to read "A:PLANE HEADING DEGREES MAGNETIC" successfully. It always comes back 0. Here is my script. It does write the 0 correctly to the Heading Bug. If you could point me to my error, I would greatly appreciate it. SimVar("A:PLANE HEADING DEGREES MAGNETIC") SimVar("K:HEADING_BUG_SET") function PFD_HDG_SYNC() local curhdg = SimRead("A:PLANE HEADING DEGREES MAGNETIC") SimCommand("K:HEADING_BUG_SET:" .. curhdg) end You're close ;D The Variable Syntax is the Same as used in the Actions, so it should be: SimVar("(A:PLANE HEADING DEGREES MAGNETIC, Degrees)") SimRead("(A:PLANE HEADING DEGREES MAGNETIC, Degrees)") What eventually could be an Issue is the Concatenation when the Value returned is not an Integer/whole Number. Maybe print the resulting Command to the lua.log to analyze if the Result is correct Log("K:HEADING_BUG_SET:" .. curhdg)
GASimPilot Posted Saturday at 12:54 AM Report Posted Saturday at 12:54 AM Thank you so much for your help! I got it working. The returned number was indeed a problem, and I had to handle it by rounding. I also had created my own logging but didn't include it in my function I posted. So using the one already there that you showed is easier and great to know about. I am posting the final function here in the hopes it helps someone else down the line. SimVar("(A:PLANE HEADING DEGREES MAGNETIC, Degrees)") SimVar("K:HEADING_BUG_SET") function PFD_HDG_SYNC() local curhdg = SimRead("(A:PLANE HEADING DEGREES MAGNETIC, Degrees)") curhdg = math.floor(curhdg + 0.5) Log("K:HEADING_BUG_SET:" .. curhdg) SimCommand("K:HEADING_BUG_SET:" .. curhdg) end
John Dowson Posted Saturday at 08:13 AM Report Posted Saturday at 08:13 AM Note that you can do such things using calculator code (or by defining a preset for the calculator code), e.g. (A:PLANE HEADING DEGREES MAGNETIC, Degrees) near (>K:HEADING_BUG_SET)
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