Jump to content
The simFlight Network Forums

Keyboard NumPad entry for OBS or Heading Bug?


Recommended Posts

Is there anyway to use a keyboard NumPad entry to  enter a course setting in an OBS or Heading Bug?

In my P3D with FSUIPC I had lua scripts to accomplish this and just wondered if this is possible in MSFS with FSUIPC 7.

Link to post
Share on other sites
4 hours ago, danewatson said:

Is there anyway to use a keyboard NumPad entry to  enter a course setting in an OBS or Heading Bug?

In my P3D with FSUIPC I had lua scripts to accomplish this and just wondered if this is possible in MSFS with FSUIPC 7.

It should be possible to adapt your script for MSFS. There are issues with the SimConnect_Text function in the MSFS SDK, so the lua functions that use these will also have issues. You can use (or adapt) this user contribution to request user keyboard input in MSFS: 

 

John

Link to post
Share on other sites
On 1/8/2021 at 11:32 PM, danewatson said:

Is there anyway to use a keyboard NumPad entry to  enter a course setting in an OBS or Heading Bug?

In my P3D with FSUIPC I had lua scripts to accomplish this and just wondered if this is possible in MSFS with FSUIPC 7.

Below is a brief example of how to do what John has suggest above. Note however that this example uses the files ask_for_num() and get_asked_num() which are attached below. These are versions of the files ask_for_data() and get_asked_data() but don't work for letter characters, and as a result there is less delay in detecting an input since each time called get_asked_num() does not require establishing events for all the lowercase and uppercase letters. Using ask_for_data() and get_asked_data() would also work of course. Script get_asked_num() goes in the same folder as FSUIPC7.ini.

Note that whether using ask_for _data() or ask_for_num() you will have to edit the function definition to insert the path to your Lua files location.

Al

-- Get_CRS&HDG.lua

function ask_for_num(request_string)                                  -- use for number only data
         ipc.set("NUM_REQUEST", request_string)
         ipc.set("NUM_ANSWER", request_string)
         ipc.runlua("C:\\Users\\... your path to Lua files...\\get_asked_num.lua")     -- enter your path here
         repeat
           num_returned = ipc.get("NUM_ANSWER")
          ipc.sleep (100)
         until num_returned ~= request_string
         return num_returned
end

-- Example Main Program
while true do
  CRS1 =  ask_for_num("Enter 3 Digits for Course ")
  if CRS1 == "*" then                                                             -- * is error char
    ipc.sleep(100)
  else
   break

 end
end

ipc.writeUW(0x0C4E,CRS1 )


while true do
  HDG =  ask_for_num("Enter 3 Digits for Heading ")
  if HDG == "*" then                                                             -- * is error char
    ipc.sleep(100)
  else
   break
 end

end
HDG = math.floor(HDG*65536/360)         -- format for FSUIPC, no decimal places
ipc.writeUW(0x07CC,HDG )

ask_for_num_function_def.lua

get_asked_num.lua

  • Like 1
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...
×
×
  • 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.