gsumner Posted November 22, 2013 Report Posted November 22, 2013 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 2transfer it to CRS 2 = OFFSET 943E size 2The lines of code ive written areMyData = 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 meThankyouGraham
Gypsy Baron Posted November 22, 2013 Report Posted November 22, 2013 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
gsumner Posted November 22, 2013 Author Report Posted November 22, 2013 Hi Offsets are from ifly737. Script will be called by a button push. Will try that space Thanks Graham
aua668 Posted November 22, 2013 Report Posted November 22, 2013 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
gsumner Posted November 23, 2013 Author Report Posted November 23, 2013 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
Pete Dowson Posted November 28, 2013 Report Posted November 28, 2013 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
gsumner Posted November 28, 2013 Author Report Posted November 28, 2013 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
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