Tarzan737 Posted December 19, 2010 Report Share Posted December 19, 2010 Hi!! Is it possible to combine a buttom acrion and a reading like led on in the same lua script? I mean!! When i press a buttom on mygfrp48 in this case I want to have a action (switch on) and led on And can i combine these2 in same lua so i can choose one line in dropdown list for this lua!! I have seen that there is some offsets with both write and read options!! //Tommy Link to comment Share on other sites More sharing options...
Pete Dowson Posted December 19, 2010 Report Share Posted December 19, 2010 Is it possible to combine a buttom acrion and a reading like led on in the same lua script? Of course. You can do almost anything you like in a Lua plug-in, if the facilities are there. I mean!! When i press a buttom on mygfrp48 in this caseI want to have a action (switch on) and led on Yes, that is easy. But if the switch can be programmed by normal assignment you might want to consider leaving that as such. Because if the LED is indicating the status of some condition you would want it to reflect that status even if the switch was in the wrong position (such as after loading a new flight, perhaps). And can i combine these2 in same lua so i can choose one line in dropdown list for this lua!! With LEDs indicating status you'd normally want these Event driven (usually by event.offset), so they'd actually be running the whole time -- maybe all inserted into the Lua called "ipcready.lua" which is automatically run when FS is ready to fly. But if you are happy having the LED merely reflect the switch position, go for it! I have seen that there is some offsets with both write and read options!! I'm not sure from what you previously say where offsets come into it. Is the switch action not for a normal FS control? Regards Pete Link to comment Share on other sites More sharing options...
Tarzan737 Posted December 19, 2010 Author Report Share Posted December 19, 2010 OK!! i have tried a lot of difference combinations now but i really dont know how to write... i have this for the led right now and works fine (project magenta mcp) function set_apFD(offset, value) if logic.And(value, 0x1000) ~= 0 then gfd.SetLight(GFRP48, 0, 7) else gfd.ClearLight(GFRP48, 0, 7) end end set_apFD( 0x04F0, ipc.readUW(0x04F0)) BUT!! how can i make the same led as button work together... cause now its only the led... is it like event.offset or event.button to use like event.button(174, 7 Set_apFD) or event.offset(5410 something..... and i tried that ipcready.lua but couldnt see that working.. the flight director is special cause i have to add one action in drop down list for PM FD1 on and the other in drop down list for PM FD1 off then i dont have any for the Lua script i got here to use the leds.. //Tommy Link to comment Share on other sites More sharing options...
Pete Dowson Posted December 20, 2010 Report Share Posted December 20, 2010 i have this for the led right now and works fine (project magenta mcp)function set_apFD(offset, value) if logic.And(value, 0x1000) ~= 0 then gfd.SetLight(GFRP48, 0, 7) else gfd.ClearLight(GFRP48, 0, 7) end end set_apFD( 0x04F0, ipc.readUW(0x04F0)) But in order for that to be useful you have to actually run the Lua plug-in. How are you doing that? What if the bit in offset 04F0 changes through some other action? Shouldn't your LED change too? As I explained earlier, you'd do better having it event driven on the offset changing, and saved as "ipcReady.lua" so that it gets run automatically, like so: function set_apFD(offset, value) if logic.And(value, 0x1000) ~= 0 then gfd.SetLight(GFRP48, 0, 7) else gfd.ClearLight(GFRP48, 0, 7) end end event.offset( 0x04F0, "UW", "set_apFD") BUT!! how can i make the same led as button work together... cause now its only the led... Assign the button to operate the PM FD by using FSUIPC assignments! That's what the Buttons & Switches tab in FSUIPC is all about! You CAN do it in Lua if your really insist, but I can't see why. (To send any controls you use the ipc.control function, with the control number and parameter. The control numbers for FS are listed in the List of FS Controls document installed in your FSUIPC Documents folder, and the added ones for FSUIPC are listed in the Advanced User's Manual -- you'll find the PM ones there). like event.button(174, 7 Set_apFD) or event.offset(5410 something..... For ths there's no need to use "event.button" because buttons create their own action, by assignment. That's what the "Buttons & Switches" tab in FSUIPC is for! The button event facility is for use with event-driven plug-ins which happen also to respond to button presses. and i tried that ipcready.lua but couldnt see that working.. It would run once and terminate because you had no event to make it stay running! the flight director is special cause i have to add one action in drop down list for PM FD1 onand the other in drop down list for PM FD1 off Fine. What's the problem with that? then i dont have any for the Lua script i got here to use the leds.. As I keep saying, you don't NEED to! The LED should be driven by the FD going on or off, NOT by the button. You need to separate the two in your mind. The indicators should indicate what is set and what is not set. The switches do the setting and unsetting, but their results are inside FS, or PM in this case. The two are joined by the offset, so it is the offset affected by the button and the LED affected by the offset. Pete Link to comment Share on other sites More sharing options...
Tarzan737 Posted December 20, 2010 Author Report Share Posted December 20, 2010 ok thanks pete!! i think you helped me a lot now... i will try later today and see if i understand... but run LUA plug in?? have i missed something (probably) i just took the lua files to the modules folder.. i will check that to.... Regards//Tommy Link to comment Share on other sites More sharing options...
Pete Dowson Posted December 20, 2010 Report Share Posted December 20, 2010 ..but run LUA plug in?? have i missed something (probably) i just took the lua files to the modules folder.. Having them in the modules folder makes them visible for assignment in the Buttons, Axes and Keys assignments drop-downs. They don't all run automatically! There are two which do run automatically just by being there - ipcInit (run when FSUIPC loads, before FS is ready) and ipcReady, which runs when FS is "ready to fly". This is as documented. To run others you either have to add them to [Auto] section(s) in the INI file -- a general one or one for each aircraft -- or assign a button, switch or key to them as "Lua ... " in the drop downs. They do not run automatically. Assigned Lua plugins are used for sepcific actions you want on a switch or key operation. For things you want running all the time, like monitoring conditions and operating lights or playing sounds, etc, you need to use ipcReady or the [Auto] facilities. Pete Link to comment Share on other sites More sharing options...
Tarzan737 Posted December 22, 2010 Author Report Share Posted December 22, 2010 Thank you!! i tried different set ups yesterday and now it works perfectly.... one thing that i see didnt work now instead is that the other buttons that is programmed with goflights software seems to have an affect on the leds i programmed with your program! like the yaw damper was programmed with goflight... but Autothrottle with your program and project magenta.. but when i extinguished yaw damper (or anyine else) the leds programmed with lua also died... but its not a problem for me... i use your program for everything.. it seems to be more stable... Thanks//Tommy Link to comment Share on other sites More sharing options...
Pete Dowson Posted December 22, 2010 Report Share Posted December 22, 2010 one thing that i see didnt work now instead is that the other buttons that is programmed with goflights software seems to have an affect on the leds i programmed with your program! Yes. Their software is not cooperative, unlike mine. Their LED states can only be set by writing all of them at once. GoFlight provide a facility to READ the LED states as well as WRITE them. FSUIPC's Lua reads the existing states of all of them before changing the ones you want to change and writing them all back. That preserves the states of those written by others, so -- cooperative. Unfortunately GoFlight's own software doesn't use the facilities GoFlight provides. The software assumes it is the only thing accessing the hardware and doesn't read them to preserve other settings. I have asked for this oversight to be remedied, but nothing happened. Regards Pete Link to comment Share on other sites More sharing options...
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