Jump to content
The simFlight Network Forums
Sign in to follow this  
spokes2112

Help with ipc.ask in P3Dv4+

Recommended Posts

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

 


 

Share this post


Link to post
Share on other sites
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

 

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.