Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Two totally different issues in one post. Need help for both. (FSX sp2 + registered FSUIPC 4.743)

Lua window

I am trying to position the Lua window somewhere conveniently on the screen, but I cannot get the 'State, x,y,cx,cy = ipc.getdisplay()' routine to log the default values in the logfile. I am always getting 0's for all (5) variables.

As a shortcut, I tried to use "random" figures in 'ipc.setdisplay(x,y,cx,cy)' but the window does not change its place (I am using as a starting point the figures in "Window.LUA display" section of FSUIPC4.ini).

Most probably I mess up the syntax. Could anyone please advise on correct use?

Rudder assignment

I failed to find a solution through the FSUIPC documentation, as it seems to be more than I can chew.

I use Saitek X52 and ProFlightRudder pedals. I am trying to find a way of using the joystick twitching for steering while on ground, and the pedals only in flight. Default FSX setup of course does not permit that, as the pedals are assigned as rudder.

Is there any way to do this using FSUIPC functionality?

Posted

Lua window

I am trying to position the Lua window somewhere conveniently on the screen, but I cannot get the 'State, x,y,cx,cy = ipc.getdisplay()' routine to log the default values in the logfile. I am always getting 0's for all (5) variables.

As a shortcut, I tried to use "random" figures in 'ipc.setdisplay(x,y,cx,cy)' but the window does not change its place (I am using as a starting point the figures in "Window.LUA display" section of FSUIPC4.ini).

Most probably I mess up the syntax. Could anyone please advise on correct use?

The syntax looks okay. I can try it here if you paste in your Lua program, or at least the smallest part which demonstrates your problem.

Rudder assignment

I failed to find a solution through the FSUIPC documentation, as it seems to be more than I can chew.

I use Saitek X52 and ProFlightRudder pedals. I am trying to find a way of using the joystick twitching for steering while on ground, and the pedals only in flight.

Did you not find the boxed section in the Axis Assignments section of the FSUIPC user guide? Search on "tiller" and you'll find it directly.

Pete

Posted (edited)

ipcXXXReady.txt

Lua Window

pls see attached file (saved as .txt in order to be uploadable). Besides the window positioning, everything else is working as advertised. I call the routine with a keypress.

I have included both the lines I used to log the default window coordinates and the line to define new position. Both unsuccessful.

I also try to get IAS at 50ft logged and displayed, but need more studying and trials, so it is not included in this version.

Tiller

I really feel embarrassed. I found the pages you pointed and all is fine now. I also visited my ophthalmologist; all is not fine in this front.

Edited by abax2000
Posted

Lua Window

pls see attached file (saved as .txt in order to be uploadable). Besides the window positioning, everything else is working as advertised. I call the routine with a keypress.

I have included both the lines I used to log the default window coordinates and the line to define new position. Both unsuccessful.

Okay. Here's what I found.

1. The ipc.getdisplay function can return incorrect values initially -- until the window is sized by hand, or maybe by sizing the FS window itself. This is when it is docked. I think it is okay when it is undocked. This is strange, so I will investigate this and fix it when I can -- maybe next week now.

2. Your ipc.setdisplay(2000, 2000, 3537, 2435) seems to require a very large display screen indeed. The window is getting displayed off screen. I have two 1920 x 1200 displays side by side, making 3840 x 1200, so even on those your window is way off below them both and of a size which can't be handled. With a docked window, in any case, the position is relative to the FS window which makes it even more impossible.

Did you not realise these numbers are in screen pixels?

I'll certainly look for and fix problem 1, but you need to select more reasonably values for your ipc.setdisplay call.

Regards

Pete

Posted

You are right in that I had not realised that the figures are in screen pixels.

I run FSX in windowed mode on a 1920*1080 monitor. So, I corrected the script as follows:

function logvs(off, val)

if val ~= 0 then

-- if on ground flag just set, get VS, convert it and log it

vs = ipc.readSD(0x030C)

vs = vs * 60 * 3.28084 / 256

ipc.log("Vertical speed at touchdown = " .. vs)

gs, tas, ias = ipc.readStruct(0x02B4, "3UD")

ias = ias / 128

ipc.log("IAS at touchdown = " .. ias)

ipc.display ("Vertical speed at touchdown = " .. vs.."\nIAS at TD ="..ias)

ipc.setdisplay(240, 240, 226, 112)

end

end

-- set to call above routine whenever "on ground" flag changes

event.offset(0x0366, "UW", "logvs")

I tried different numbers and different positions within the script of ipc.setdisplay with no luck; still the LuaWindow pops up at the default position at the center of the windscreen.

The .ini file records the following if that helps:

[Window.LUA display]

Docked=7413, 3273, 3537, 2435

Undocked=875, 874, 250, 110

Posted

Docked=7413, 3273, 3537, 2435

Undocked=875, 874, 250, 110

Your revised version works fine here.

Delete at least the Docked line in the CFG file, which is obviously the result of one of the earlier tests. I suspect that is resulting in the window not being created and therefore not being movable either.

Pete

Posted (edited)

Steps taken:

1. Deleted both lines of Window.Lua display in .ini file. I just left the section header [Window.Lua display].

2. Fired up FSX.

3. Lua window pops up (as in previous tests), but again in the middle of the windscreen.

4. The .ini file now records:

[Window.LUA display]

Docked=7413, 3273, 3537, 2435

I run the same test deleting the whole [Window.Lua display] section (including the header) with the same results. The only difference was that the section was added at the end of the .ini file.

Edited by abax2000
Posted

I run the same test deleting the whole [Window.Lua display] section (including the header) with the same results. The only difference was that the section was added at the end of the .ini file.

I think you'll need to wait till I can fix the original problem, then -- I'm afraid not till next week.

Don't know why it affects you this way but not me. maybe it's a difference between full screen and windowed mode FS? I've not had time to test all modes.

Pete

Posted

OK, I will certainly survive till then.

JFYI, I did a quick test in full screen mode but still unsuccessful (window pops but in default position).

I think, in either mode, if you move or size it manually first, thereafter it obeys the setdisplay. Moving or sizing it seems to fix the bad values. Once the entry in the CFG file is reasonable, it works -- so you could, instead, edit the CFG file entries to be reasonable.

I think that's why I've not seen anything wrong after that first test I did -- the CFG file has good values in it now.

Pete

Posted

So it seems. I made one run where the window poped up in the middle and I randomly moved+resized by hand, then exited flight. When I retested the window was properly sized and positioned (according to values in .lua).

Thanx Pete.

Posted

So it seems. I made one run where the window poped up in the middle and I randomly moved+resized by hand, then exited flight. When I retested the window was properly sized and positioned (according to values in .lua).

I spent a while today looking for some sort of bug in FSUIPC, without success. Here's what i think happened in your case:

Your original (?) code sequence for the display was:

ipc.display ("Vertical speed at touchdown = " .. vs.."\nIAS at TD ="..ias)

State,x,y,cx,cy = ipc.getdisplay()

ipc.setdisplay(2000, 2000, 3537, 2435)

If I try this with a "virgin" FSX -- one not having seen a Lua display before -- I get the State, x, y, cx, cy to be all zero initially.

I believe this is because at the time the "ipc.getdisplay" function is called, the window has not actually yet been drawn. Then the "ipc.setdisplay" may move/size the Window, if now drawn.

If I change the above sequence to:

ipc.display ("Vertical speed at touchdown = " .. vs.."\nIAS at TD ="..ias)

ipc.sleep(50)

State,x,y,cx,cy = ipc.getdisplay()

ipc.setdisplay(2000, 2000, 3537, 2435)

then it all works as I'd expect. The initial values you then get for State, x, y, cx, cy are for the default position and size (NOT the top left or "home" position, incidentally).

By experiment I discovered, on my PC at least, that a "sleep" of at least 20 milllisecs is needed to guarantee getting a proper result.

I'm not sure at present what, exactly, to do about this. I can think of three possiiblities:

1. Leave it as it is and just document that the display may not exist immediately after the 'setdisplay' call.

2. After a "setdisplay" call, wait (i.e. do not return to the Lua execution) until the display actually exists and/or is updated..

3. If when a "getdisplay" or "setdsplay" call occurs the display does not exist, wait up to something safely above 20 miilliseconds for it to appear before returning all zeroes if it doesn't.

I'm inclined to implement solution 2 as both the others still exhibit a degree of uncertainly. In most programming you'd expect the window to exist when the function returns. Here it's all a bit asynchronous because the window is not really created by the Lua thread but by a request to FSX. It is an FSX window, and I don't actually get a handle to it -- all I can do is find it as for any other window.

Regards

Pete

Posted

Bingo.

I tried different sequences of the statements, but never thought the delay issue.

As for documenting it, just my two cents ...having in mind novice/inexperienced users like myself:

  1. It is minor glitch because of synch issues between Lua code and FSX
  2. Always put 'getdisplay' and 'setdisplay' statements after a 'display' command.
  3. You will most probably need to add a time delay (ipc.sleep) between 'display' and ('getdisplay' or 'setdisplay'). Something more or equal to 20 millisecs is recommended. That is because 'display' goes through FSX, so there is a relative delay compared to Lua execution; so you need to give time to ('getdisplay' or 'setdisplay') to have something to read/edit (e.g. with no delay used, 'getdisplay' will return 0 values, as the window is not yet there to be measured)
  4. The first two figures returned by 'getdisplay' refer to xxx point of the Lua window, while the latter two to the size of the window (all in screen pixels).
  5. If you still have problems, reposition and resize the default Lua window manually and rerun the Lua code containing the 'getdisplay' and/or 'setdisplay' commands.

I don't know if it is too many words, but I think is understandable by the non-programmer/occasional user.

vbr

Posted

As for documenting it, just my two cents ...having in mind novice/inexperienced users like myself:

Yes, thanks for your suggested documentation. I've experimented with an implementation of my solution #2, and I think that might be better -- no need then for any user complications.

So far it works perfectly and i really can't see any disadvantages, so I'll probably go with it, pending more tests next week. I'm away from tomorrow morning till Monday in any case.

Regards

Pete

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • 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.