pilotjohn Posted October 21, 2020 Report Posted October 21, 2020 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.
John Dowson Posted October 22, 2020 Report Posted October 22, 2020 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.
pilotjohn Posted October 22, 2020 Author Report Posted October 22, 2020 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?
John Dowson Posted October 22, 2020 Report Posted October 22, 2020 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.
pilotjohn Posted October 23, 2020 Author Report Posted October 23, 2020 I was confused between the offset... I see, thanks.
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