Jump to content
The simFlight Network Forums

Recommended Posts

Posted

I have the following ipcReady.lua to switch my StreamDeck profiles based on aircraft (button layout).

function onload(offs, data)
  acft = ipc.readSTR(0x3D00, 256)
  ipc.log("loading StreamDeck profile for: "..acft)

  if string.match(acft, "XCub") then
    os.execute('start D:\\IslandJohn\\Scripts\\sd\\profile_msfs_xcub.ahk')
  else
    os.execute('start D:\\IslandJohn\\Scripts\\sd\\profile_msfs.ahk')
  end
end

event.offset(0x3F02, "UW", "onload")

This works well as it triggers right on the screen with the "Ready to Fly" button.

However it also seems to trigger after I'm in the aircraft (as I started a takeoff roll for example).

It also triggers on return to the main menu.

Is this expected? Is there a better offset to use? I can always just keep state for last loaded profile, just curious.
 

Posted
11 hours ago, pilotjohn said:

However it also seems to trigger after I'm in the aircraft (as I started a takeoff roll for example).

I'm not sure why this is - what is the FLT file loaded when this occurs (check your FSUIPC7.log)?

11 hours ago, pilotjohn said:

It also triggers on return to the main menu.

Yes, a flight file called flights\other\MainMenu.FLT is sent when MSFS enters the menus. I guess I could add some code to ignore this FLT file, and not update the offsets when this changes.

However, as your script acts on the value of offset 0x3D00 (the name of the current aircraft), why don't you just use that for your event? Your script would then fire only when the aircraft name changes.

 

Posted
3 hours ago, John Dowson said:

I'm not sure why this is - what is the FLT file loaded when this occurs (check your FSUIPC7.log)?

Yes, a flight file called flights\other\MainMenu.FLT is sent when MSFS enters the menus. I guess I could add some code to ignore this FLT file, and not update the offsets when this changes.

However, as your script acts on the value of offset 0x3D00 (the name of the current aircraft), why don't you just use that for your event? Your script would then fire only when the aircraft name changes.

 

You mean use 0x3F02 for the event trigger instead?

Posted
2 hours ago, pilotjohn said:

You mean use 0x3F02 for the event trigger instead?

No - as your event function reacts to changes to 0x3D00:

17 hours ago, pilotjohn said:

acft = ipc.readSTR(0x3D00, 256)

Why not use that, i.e.

event.offset(0x3D00, "STR", "onload")

The value will then also be passed to your function, so no need to read it.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • 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.