Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Hi,

My MCP has only 1 crs selector and I would like to set both CRS 1 and 2 without showing the panel on my screen. Ive written a LUA file for this but my coding is very basic and Im going wrong somewhere.

Here is what my button press should do:-

read the value of CRS 1 = OFFSET 9434 size 2
transfer it to    CRS 2 = OFFSET 943E size 2

The lines of code ive written are

MyData = ipc.readUW(0x9434)
ipc.writeUW("943E",MyData)

it doesnt work though. Im sure Im missing something obvious or barking up the wrong tree altogether.

Can someone correct me

Thankyou

Graham

Posted

How are you calling that Lua script? Are you using the event.key function?

 

Does your script define this code in a

 

function

..

..

end

 

context?

 

I'm not certain if a space is required in the ("943E",MyData) but you might insert one

in any case. ("943E", MyData)

 

Just curious, I don't see those offsets in the "FSUIPC Offsets Status" pdf file. Where did you get them from.

 

  Paul

Posted

MyData = ipc.readUW(0x9434)

ipc.writeUW("943E",MyData)

 

 

Why don't you use the same syntax for the hex value in both statements? First is right. Second one should read:

 

ipc.writeUW(0x943E,MyData)

 

like above. Beside these syntax errors: As mentioned above, you must activate this code. Otherwise it will never execute. Either by registering an event of the offset of CRS1 or if you only want to have it synchronized on demand then by registering a button to trigger this piece of code.

 

And as I don't own the iFly: Are both offsets R/W or maybe only R/O ?

 

Rgds

Reinhard

Posted

Ive actually ended up using this

 

CrsOne = ipc.readUW(0x9434)
CrsTwo = ipc.readUW(0x943E)

while CrsOne ~= CrsTwo do
      ipc.writeUW("9400", 199) -- this line increments crs2 by 1 then the next line reads the new value
      ipc.sleep(200)
      CrsTwo = ipc.readUW(0x943E)
    end

 

I'm sure its not efficient code and Pete feel free to correct me when you return from your well earned break. It works however.

 

Graham

Posted

I'm sure its not efficient code and Pete feel free to correct me when you return from your well earned break. It works however.

 

Use the event system for much greater efficiency:

 

I don't know iFly, but if writing to the CRS offsets changes them, rather than using the INCremental method you are using, then:

function copycrs(off, val)
    ipc.writeUW(0x943E,val)
end

event.offset(0x9434, "UW", "copycrs")

Of course if you are only able to use increments that you will need to do your loop in function "copycrs", but you need not read the value of 0x9434 again as that is supplied as 'val'.

 

Assuming you save this as CopyCrs.lua, just get this running by this in your FSUIPC INI file:

 

[Auto]

1=Lua CopyCrs

 

or, if only for a specific aircraft or profile,

 

[Auto.<profile name>]

1=Lua CopyCrs

 

Pete

Posted

Hi Pete welcome back. Hope you enjoyed your break.

I did consider using an event offset. A few years ago I was fortunate to get 10 hours one to one instruction in a full size 737 sim with an instructor. He was a bit old school and insisted the fo should be on raw data especially on sids and stars so the PF had a secondary reference should something fail at a critical time. This of course means vors tuned and courses set. Needing 2 different course settings would mean the offset. Method wouldn't allow this. I will try to tidy up the loop method a bit though.

Thanks

Graham

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.