Jump to content
The simFlight Network Forums

Recommended Posts

Posted

What am I doing wrong?

I am trying to execute a valid preset by writing it into the 7C50 offset:

 cmd=string.sub(input,1,6)   -- rotaries 6 char
     for i = 1, 4, 1 do
        if (cmd == MCProt[i]) then     -- detects OK
        ipc.log(MCProt[i])   -- debug OK
        ipc.log(MCPpresets[i])  -- debug OK
        ipc.writeSTR(0x7C50, MCPpresets[i], 21)
        end
     end

The offset does not get executed although it works perfectly when linked to a physical button.  I have tried with length restriction (to get rid of the ending 00 code) and without.  I have also tried replacing spaces with underscores (as published in Hubhop).

This is what gets logged when I alternate between two commands:

  187266 LUA.3: WT CJ4 AP ALT VAR INC
   187282 WRITElua 7C50,  21 bytes: 57 54 20 43 4A 34 20 41 50 20 41 4C 54 20 56 41  WT CJ4 AP ALT VA
   187282                           52 20 49 4E 43                                   R INC
   192532 LUA.3: ALTinc
   192547 LUA.3: WT CJ4 AP ALT VAR INC
   195828 LUA.3: ALTinc
   195844 LUA.3: WT CJ4 AP ALT VAR INC
   197250 LUA.3: ALTinc
   197266 LUA.3: WT CJ4 AP ALT VAR INC
   198766 LUA.3: ALTinc
   198766 LUA.3: WT CJ4 AP ALT VAR INC
   200547 LUA.3: ALTinc
   200563 LUA.3: WT CJ4 AP ALT VAR INC
   202844 LUA.3: ALTdec
   202860 LUA.3: WT CJ4 AP ALT VAR DEC
   202875 WRITE repeated 5 times
   202875 WRITElua 7C50,  21 bytes: 57 54 20 43 4A 34 20 41 50 20 41 4C 54 20 56 41  WT CJ4 AP ALT VA
   202875                           52 20 44 45 43                                   R DEC
   208578 LUA.3: ALTdec
   208594 LUA.3: WT CJ4 AP ALT VAR DEC
   211032 LUA.3: ALTdec
   211047 LUA.3: WT CJ4 AP ALT VAR DEC
   212750 LUA.3: ALTdec
   212766 LUA.3: WT CJ4 AP ALT VAR DEC
   214735 LUA.3: ALTinc
   214750 LUA.3: WT CJ4 AP ALT VAR INC
   214766 WRITE repeated 3 times
   214766 WRITElua 7C50,  21 bytes: 57 54 20 43 4A 34 20 41 50 20 41 4C 54 20 56 41  WT CJ4 AP ALT VA
   214766                           52 20 49 4E 43                                   R INC

 

Thanks for your help.

Philippe

Posted

I cannot see any preset being logged there - as the documentation states:

Quote

To call a preset, first write the preset parameter (if needed) to offset 0x7C80 as a 32-bit integer value, then write the preset name, preceded by 'P:' to offset 0x7C50.

Also, most presets to not include spaces (but some do!) - they use underscores '_'. These are replaced by spaces to display in the FSUIPC drop-down menus. So, this one:
   208594 LUA.3: WT CJ4 AP ALT VAR DEC
should be P:WT_CJ4_AP_ALT_VAR_DEC

You can see the correct preset name in the events.txt file (or look in the MF Hun Hop site).

John

Posted

Thank you, John, for your quick answer which explains it all.

I had not found the documentation for this and had just used info gleaned in some threads, which did not specify that P: prefix.  I now see some other ones where it is clearly indicated.  My bad!

I knew about the underscores.

Thanks again and best regards,

Posted
12 hours ago, 3greens said:

I had not found the documentation for this

For offsets, please see the FSUIPC7 Offset Status document - the state and use of offsets is shown in that document. As 0x7C50 is also used for setting lvars, activating hvars and executing calculator code, the prefix is needed so that FSUIPC knows how to interpret the following string.

Cheers,

John

  • 10 months later...
Posted

How can I get this Function to work....


function M500_HDG_set ()
        ipc.execPreset(P:AS1000_PFD_HEADING_SYNC, 0x7C50)
end
 

 

Well, all I'm trying to do is have the 'Heading Sync'  as a short button press in a file based on  'TripleUseButton.lua'   and relevant Presets assigned to  Long Press and Double press.....

 

Thanks...

Posted
49 minutes ago, aerostar17 said:

How can I get this Function to work....


function M500_HDG_set ()
        ipc.execPreset(P:AS1000_PFD_HEADING_SYNC, 0x7C50)
end

Please consult the documentation before posting - from the Lua Library reference document:

Quote

ipc.execPreset(“presetName”, param)

so it would be: ipc.execPreset("AS1000_PFD_HEADING_SYNC", 0)

John

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.