Fritz Posted March 23, 2011 Report Posted March 23, 2011 The Wilco Airbus is working with many internal variables. My interface software works only with offsets. Now I want to assign an internal variable (for example FT_IgnitionSwitch) to an unused offset. I want to achieve if the Switch is pressed, the value of the offset (eg, on = 1) is transferred to the internal Vaiable (FT_IgnitionSwitch = 1). If this is pssible, how must the Sysntax in Lua look like? Thanks for any help.
Pete Dowson Posted March 23, 2011 Report Posted March 23, 2011 The Wilco Airbus is working with many internal variables. My interface software works only with offsets. Now I want to assign an internal variable (for example FT_IgnitionSwitch) to an unused offset. I want to achieve if the Switch is pressed, the value of the offset (eg, on = 1) is transferred to the internal Vaiable (FT_IgnitionSwitch = 1). If this is pssible, how must the Sysntax in Lua look like? What are those "internal variables"? Do you mean "L:Vars"? If so, then you can read them and test them via FSUIPC macros but only write them via Lua plug-ins. To use an offsert you'd need a Lua plug-in running which is triggered by a change in your user offset (one of 66C0-66FF), via the "event.offset" function, to send the value to the L:Var via the "ipc.writeLvar" function. Regards Pete
Fritz Posted March 24, 2011 Author Report Posted March 24, 2011 Yes, I mean L:FT_IgnitionSwitch. Thanks for the quick help but unfortunately I fail at the correct syntax. What is wrong here? -- Ignition Switch function IgnitionSwitch(offset, val) if ipc.readUD(0x66C0) == 1 then ipc.writeLvar("L:FT_IgnitionSwitch", 1) else if ipc.readUD(0x66C0) == 0 then ipc.writeLvar("L:FT_IgnitionSwitch", 0) end end event.offset(0x66C0, "UD", "L:FT_IgnitionSwitch")
Pete Dowson Posted March 24, 2011 Report Posted March 24, 2011 Yes, I mean L:FT_IgnitionSwitch. Thanks for the quick help but unfortunately I fail at the correct syntax. What is wrong here? -- Ignition Switch function IgnitionSwitch(offset, val) if ipc.readUD(0x66C0) == 1 then ipc.writeLvar("L:FT_IgnitionSwitch", 1) else if ipc.readUD(0x66C0) == 0 then ipc.writeLvar("L:FT_IgnitionSwitch", 0) end end event.offset(0x66C0, "UD", "L:FT_IgnitionSwitch") You are telling the event.offset function that your function for processing offset 66C0 is called "L:FT_Ignitionswitch", but it is in actual fact called "IgnitionSwitch" as you can see just above. You can also simplify your code considerably. The value of the offset is provided in the function as parameter 'val' so you can use that directly, instead of reading it again. Additionally, since it is the value you want to write you can write it directly. So: -- Ignition Switch function IgnitionSwitch(offset, val) ipc.writeLvar("L:FT_IgnitionSwitch", val) end event.offset(0x66C0, "UD", "IgnitionSwitch") Regards Pete
Fritz Posted March 25, 2011 Author Report Posted March 25, 2011 First of all thank you for your help and for your patience. What I intend to do does not work because the internal variable triggers anything. So then I tried it with a mouse macro. With this I can trigger the Ignitionswitch, but must use an offset whitch I have to mapped to the macro. Now then if for example Offset 66C0 == 1 then execute the macro "Ignitionswitch". Is that also possible in Lua by event?
Pete Dowson Posted March 25, 2011 Report Posted March 25, 2011 What I intend to do does not work because the internal variable triggers anything. Sorry, by "triggers anything" do you mean "triggers nothing"? Otherwise I don't understand. So, how did you arrive at this name "L:FT_IgnitionSwitch". If it does nothing I'm not sure why you came up with it? So then I tried it with a mouse macro. With this I can trigger the Ignitionswitch, Ah, so it doesn't use L:Vars after all? Didn't you use the "Log panel Lvars" control to get a list first? Was the L:Var a guess, or from a different aircraft? Each aircraft designer devises his own names. but must use an offset whitch I have to mapped to the macro.Now then if for example Offset 66C0 == 1 then execute the macro "Ignitionswitch". Is that also possible in Lua by event? Yes, as before except instead of ipc.writeLvar you would use the ipc.macro function. Regards Pete
Fritz Posted March 25, 2011 Author Report Posted March 25, 2011 Yes, I mean nothing and it is also true that I have the internal variable from the log lvars.lua. I replaced ipc.writeLvar with ipc.macro. The Name of the Macro is IgnitionSwitch.MCRO. Now the Lua script looks like this: - Ignition Switch IgnitionSwitch function (offset, val) ipc.macro("L:IgnitionSwitch") end event.offset (0x66C0, "UD", "IgnitionSwitch) I see In the log that the value of offset 66C0 is set from 0 to 1 by operate the switch. The macro is not able to run. Is the ipc.macro line not correct?
Pete Dowson Posted March 26, 2011 Report Posted March 26, 2011 Yes, I mean nothing and it is also true that I have the internal variable from the log lvars.lua. Maybe there's another L;var which actually does the job? I replaced ipc.writeLvar with ipc.macro. The Name of the Macro is IgnitionSwitch.MCRO.Now the Lua script looks like this: - Ignition Switch IgnitionSwitch function (offset, val) ipc.macro("L:IgnitionSwitch") end event.offset (0x66C0, "UD", "IgnitionSwitch) If you've called the macro IgnitionSwitch.MCRO, why are you referring to "L:IgnitionSwitch" in the Macro function? The L: prefix was valid for L:Vars because that's how FS names them. You didn't name the macro that way -- and in fact you cannot because ':' is not allowed in filenames, it is used only after the drive name in paths. Pete
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