spokes2112 Posted October 14, 2019 Report Posted October 14, 2019 Have a question with ipc.ask for P3Dv4. I am making a lua for some friends using P3D but am still living in the stone age with FSX. Will the following code work? Anything to add? After many emails back & forth, it not working, they are giving up on me.. 😠 The recommendation of using ipc.getdisplay also confuses me. I am assuming using this is just to check if there is another Lua Display open ? Tests fine in FSX with the green line display. It is a "one shot" lua, currently being tested via a keyboard start, eventually hoping to go to [auto] so when the aircraft is loaded the lua will show and ask. Thanks in advance, Roman -- QUIT IF NOT A DIAMOND DA20 AIRCRAFT local AircraftType = ipc.readSTR(0x3C00, 256) if string.match(AircraftType, "DA20-100_V3.7.air") == 0 then ipc.exit() end -- KEEP GOING local Katana_Options = " What would you like to do with the Katana today?\n Type in the selection number and hit enter.\n If you do not want wheel fairings, add 10 to the selected number. \n\n 1 = Parked\n 2 = Cold and Dark\n 3 = Pre Engine Start\n 4 = Taxi\n 5 = Pre Takeoff\n 6 = Climbing\n 7 = In Flight\n 8 = Descent\n 9 = Approach \n 0 = Nothing / Exit" local FSUIPCVersion = ipc.readUW(0x3306) FSUIPCVersion = string.format("%04X", FSUIPCVersion) FSUIPCVersion = tonumber(FSUIPCVersion) -- FOR P3Dv4 ONLY if FSUIPCVersion > 5000 then ipc.setdisplay(SET_PCTS, 37, 8, 26, 20) end -- FOR BOTH FSX+ and P3Dv4+ n = tonumber(ipc.ask(Katana_Options, WHITE)) -- TESTING WINDOW LOCATION IN FSX -- ipc.setowndisplay("TEST LOCATION IN FSX",37, 3, 26, 20) -- ipc.display(FSUIPCVersion, 1, 10) -- ipc.sleep(10000) -- POST "ASK" RESULT CODE CONTINUES, WORKS AS INTENDED
Pete Dowson Posted October 14, 2019 Report Posted October 14, 2019 1 hour ago, spokes2112 said: Will the following code work? Anything to add? After many emails back & forth, it not working, they are giving up on me.. 😠 Why not tell them to enable the Lua debug/trace option (in Logging) and return the logto you? 1 hour ago, spokes2112 said: Will the following code work? Anything to add? After many emails back & forth, it not working, they are giving up on me. So you say it works as you wanted on FSX but not on their P3D4.? Let's look at the code: -- QUIT IF NOT A DIAMOND DA20 AIRCRAFT local AircraftType = ipc.readSTR(0x3C00, 256) if string.match(AircraftType, "DA20-100_V3.7.air") == 0 then ipc.exit() end Two points there: 1. That looks like the whole AIR file name. Are you sure he has that version? Why not simply match the "DA20" part. 2. You check for == 0. But if it isn't found the result is nil. In Lua nil is not equal to 0, it's a "non-number" -- FOR P3Dv4 ONLY if FSUIPCVersion > 5000 then ipc.setdisplay(SET_PCTS, 37, 8, 26, 20) end What is this for? It affects an EXISTING window only. And I think Simconnect overrides positions these days. You could remove the whole check for P3D4. -- FOR BOTH FSX+ and P3Dv4+ n = tonumber(ipc.ask(Katana_Options, WHITE)) ipc.log("result = " .. n) That works fine -- I added the log entry so I could see the number entered. If your friend can't see the window it is probable that he has "Information text" unchecked in his P3d settings. this prevents all Simconnect messages (it is used when diverting them to a different PC using WideFS). Pete 1
spokes2112 Posted October 14, 2019 Author Report Posted October 14, 2019 Thanks Pete, All points rectified and working smoothly.. 👍 Roman
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