Jump to content
The simFlight Network Forums

LUA - GoFlight ID


Recommended Posts

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")

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • 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.