texfly Posted March 4, 2012 Report Posted March 4, 2012 Hello, I might be missing something but I can't make a simple script working with LUA. When I push a button on the GFP8 I want the pushback to start and the LED on. Button #8 and LED #8. In FSUIPC I see Joystick #101 and button #7 during the assignment, so I used those numbers for my script. When I push the button nothing happens! Any idea? The script is below... Thanks! ------------------------------------------------------ function PushBack(offset, value) model = GFP8 unit = 101 id = 7 gfd.SetBright(model, unit, 15) if value == 0 then gfd.SetLight(model, unit, id) else gfd.ClearLight(model, unit, id) end end function SetPushBack(model, unit) gfd.GetValues(model, unit) if gfd.TestButton(7) then ipc.writeUB("31F4",0) else ipc.writeUB("31F4",3) end end event.offset("31F0", "UB", "PushBack") event.gfd(GFP8, 101, "SetPushBack")
Pete Dowson Posted March 4, 2012 Report Posted March 4, 2012 Button #8 and LED #8. In FSUIPC I see Joystick #101 and button #7 during the assignment, so I used those numbers for my script. When I push the button nothing happens! You are mixing up two different things. the joystick numbers are arbitrarily assign numbers designed to be different from real joysticks, and to include a client PC differentiation when sent from a WideFS client (to allow the same types of GF units to be distributed on a Network). In the Lua GFD library the unit number used is the one assigned by GoFlight on that PC. Each different type (P8, T8, MCP, RP48, etc) starts at id = 0 and then upwards for as many of each type as you have connected. So if you only have one of each all the unit numbers are 0. If you have two P8s, one will be 0 and the other will be 1. You can use the GFDdisplay lua example to find out. The ID of the light may or may not be the same as the button it is next to. Obviously, in cases like the MCP, there's not necessarily one LED per button and they aren't always arranged together. In the case of the P8 I don't remember, but they probably do align. Regards Pete
texfly Posted March 4, 2012 Author Report Posted March 4, 2012 Thanks Pete. I will try it this morning. One more question: is there a way to reload FSUIPC without shutting FSX down? Basically I would like to make modifications and/or adding new LUA scripts while FSX is up and running.
Djeez Posted March 4, 2012 Report Posted March 4, 2012 You can assign a keypress to LuaKill <your script> and Lua <your script>. Then pressing those keys will restart your script. Regards, -Djeez.
texfly Posted March 4, 2012 Author Report Posted March 4, 2012 Thanks Djeez. Tha will do part of the trick...what about adding new LUA scripts? Do I need to restart FSX each time?
Pete Dowson Posted March 4, 2012 Report Posted March 4, 2012 Thanks Djeez. Tha will do part of the trick...what about adding new LUA scripts? Do I need to restart FSX each time? Djeez is correct, but you don't actually need to Kill" the Lua first -- when you re-execute it the previous one is automatically killed. You can add new macros, Lua scripts, edit the button, keys ad axis assignments and calibrations in the INI, at any time with FS running. You just need to go into the FSUIPC options and use the relevant Reload button. For macros and Lua scripts the reload on any of the Buttons, Keys or Axis tabs will re-index them. Regards Pete
texfly Posted March 4, 2012 Author Report Posted March 4, 2012 Great, it worked. One more question....can I use LUA to control a GoFlight panel (i.e. GFT8) connected to a remote pc? I can "see" the switches via WideFS/FSUIPC but I don't know which ID to assign in the code.
Pete Dowson Posted March 5, 2012 Report Posted March 5, 2012 Great, it worked. One more question....can I use LUA to control a GoFlight panel (i.e. GFT8) connected to a remote pc? I can "see" the switches via WideFS/FSUIPC but I don't know which ID to assign in the code. The Lua program must go into the same folder as WideClient, on the Client PC. It will run automatically when WideClient connects. If you've only got one T8 on that PC its ID will be 0, of course. Make sure you are using an up-to-date version of WideClient. Older versions did not support the GFD library. Regards Pete
texfly Posted March 5, 2012 Author Report Posted March 5, 2012 Pete, I have the latest FSUIPC/WideFS (registered). If I copy the LUA file in the Wideclient folder how do I call a function contained in that remote file? Is FSUIPC scanning the WideFS LUA files as well?
Pete Dowson Posted March 5, 2012 Report Posted March 5, 2012 If I copy the LUA file in the Wideclient folder how do I call a function contained in that remote file? Is FSUIPC scanning the WideFS LUA files as well? Client Lua plug-ins are just run automatically. If you need to talk to therm from the server you'd need to use offsets like the free user ones at 66C0-66FF. Looking back at your original Lua in this thread, it is event-driven in any case, not one with functions called from outside. Both the events you used there are supported identically in WideClient. What is this "function calling" you want to do? Pete
texfly Posted March 5, 2012 Author Report Posted March 5, 2012 Hi Pete, Let me go one step back with my question...can I link a .LUA file saved in the WideClient folder to a GFT8 button event connected to a remote PC? Does FSUIPC scan (and add in the .INI file) for all .LUA files including the ones stored remotely?
Pete Dowson Posted March 5, 2012 Report Posted March 5, 2012 Let me go one step back with my question...can I link a .LUA file saved in the WideClient folder to a GFT8 button event connected to a remote PC? Does FSUIPC scan (and add in the .INI file) for all .LUA files including the ones stored remotely? No no no! you are getting yourself all mixed up! I don't think you are reading what I am actually writing. :sad: The Lua plug-in to read and write the Goflight devices on your remote (client) PC RUNS on that remote PC! It doesn't NEED FSUIPC to scan it. What do you think FSUIPC would be doing with it? It has no need! Think about it! The WideClient program supports the Lua libraries you are using in your plug-in!!! Just put the Lua plug-in into the same folder as Wideclient on the PC to which that Goflight device is connected! Pete
texfly Posted March 5, 2012 Author Report Posted March 5, 2012 Thanks Pete and sorry for the confusion. The only think I wanted to do is using the script I published above (which works on a local GFT8 panel) with another GFT8 panel connected to a remote PC. I guess I just need to copy the script in the WideClient folder, configure the correct ID and it should work?
Pete Dowson Posted March 5, 2012 Report Posted March 5, 2012 The only think I wanted to do is using the script I published above (which works on a local GFT8 panel) with another GFT8 panel connected to a remote PC. Yes, that's what I thought. I guess I just need to copy the script in the WideClient folder, configure the correct ID and it should work? Yes, after you change it for a T8 (the earlier script was for a P8), and get the ID number correct (0 for the first T8, 1 for the second, and so on). Pete
texfly Posted March 5, 2012 Author Report Posted March 5, 2012 Pete, following up this conversation...if I have two GFT8 modules connected to the same remote PC, are they going to be assigned always the same ID? I appreciated all your help with this!
Pete Dowson Posted March 5, 2012 Report Posted March 5, 2012 Pete, following up this conversation...if I have two GFT8 modules connected to the same remote PC, are they going to be assigned always the same ID? One will be 0 the other will be 1, and I'm pretty sure the Goflight DLL IGFDEV.DLL) numbers them in the order Windows provides them in its list of USB devices. And I think that's based on a hardware scan. So unless you unplug things and plug trhem in again the IDs should remain stable. They certainly do here. If you do have cause to disconnect them and reconnect them, and they turn out to be the wrong way around, simply swap their USB connections over. 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