Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Hello,

in fsuipc I have assigned LUA script buttons. The buttons have the "Control to repeat while held" option selected. When using these buttons, the FPS drops from 30 to ~ 7 !!! which is very tedious. This happened after installing the latest version of FSUIPC 4.974. On version 4.858 LUA worked correctly. I use FSX and B737 PMDG

 

I am asking for help because it is impossible to fly :(

Sample LUA file:
ipc.control (70481,2147483647)
ipc.sleep (400)

Regards,

Dominik

Posted

Hi,

Quote

in fsuipc I have assigned LUA script buttons.

do you mean to run those Lua scripts? If so, I think what happens is that you start that Lua script and before it stops because of the ipc.sleep you already start a new one. Each Lua file runs on its own thread and that takes resources. Did you check if the FSX load on the processor extreme increases that might prove that? Pete might correct me here if I'm wrong.

Thomas

Posted
2 hours ago, Dominik said:

The buttons have the "Control to repeat while held" option selected. When using these buttons, the FPS drops from 30 to ~ 7 !!! which is very tedious.

As well as what Thomas says, this is quite possible with a Lua being constantly loaded and deleted. Each Lua is another thread, running in a processor, and creating and deleting threads takes time. Instead of this:

3 hours ago, Dominik said:

ipc.control (70481,2147483647)
ipc.sleep (400)

use an Event to detect a Lua Flag being set (assign to Lua flag, and toggle it), then put yourr ipc.control call in a function and call it withe an event.flag. Get the Lua plug-in preloaded by using an [Auto] section in the INI file.

Of course, your true application must be more complicated than just the one ipc.control, because for that you'd just assign directly.

Incidentally, I don't see the point of the ipc.sleep(400). Your repeat is happening (by default) at 20 per second (50 mSecs), so all out of them are simply terminating and restarting the thread, as Thomas said. Why have repeat if you want to slow it down to only 5 actions every 2 seconds (which would work in any case)? You might as well simply press your button or key several times.

3 hours ago, Dominik said:

This happened after installing the latest version of FSUIPC 4.974. On version 4.858 LUA worked correctly. I use FSX and B737 PMDG

Sorry, too much has changed in the 6 years (!!!) since 4.858  that I cannot comment on that. I expect thinmgs have been made to work properly or better, but perhaps just not as you expected. Check the History document to see for yourself.

Pete

 

 

Posted
7 hours ago, Pete Dowson said:

Incidentally, I don't see the point of the ipc.sleep(400).

 

I use push buttons to switch radio frequency and autopilot settings (altitude, HDG IAS, etc.) Without sleep function, this data changes too quickly and it is difficult to hit the right value. Slowing down in LUA with the Sleep function it worked great.

8 hours ago, Thomas Richter said:

 Did you check if the FSX load on the processor extreme increases that might prove that? Pete might correct me here if I'm wrong.

Yes, I checked the processor load, the CPU load did not increase.

 

I understand that FSUIPC is working properly and that LUA script FPS will be smaller due to looping
 

Regards.

Dominik

Posted
2 hours ago, Dominik said:

I use push buttons to switch radio frequency and autopilot settings (altitude, HDG IAS, etc.) Without sleep function, this data changes too quickly and it is difficult to hit the right value. Slowing down in LUA with the Sleep function it worked great.

But each time the button repeat occurs, within a certain allowed time (66 mSecs by default) the Lua thread is forcibly terminated if it hasn't done so by itself, and re-loaded, recompiled and restarted. The time allowed for it to terminate by itself is set by

LuaRerunDelay=66

in the [General] section of the INI file.

So, your button is repeating at 20 times per second (default joystick scan rate -- same as keyboards) and so the Lua is being terminated and restarted well before the 400 mSecs is elapsed. On average you'll succeed in slowing down the repeat rate by the 16 mSecs plus the time to terminate, reload, recompile and restart, but it won't be by 400 mSecs.

You'd be better off NOT using repeat, but having a loop until you detect that the button is released. So even if you assign direct to the Lua plug-in rather than use an event as I suggested, try it as follows:

1. Assign "press" to the plug-in, but NOT repeating
2. Assign LuaSet to the button release, with a flag number (eg 0)
3. Revise your plug-in like this:
 

while 1 do
    ipc.clearflag(0)
    ipc.control (70481,2147483647)
    ipc.sleep (400)
    if ipc.testflag(0) then ipc.exit() end
end

This way it is loaded once, and the timing of your increment/decrement actions is fully controlled.

Pete

 

Posted

Hello,
Thank you for your reply and help. The script works almost well, the data changes at a good speed, the sleep function works, FPS do not fall, but after releasing the button, the data changes. The loop works all the time.
I changed the code to:

 

while 1 do
    ipc.control (70481,2147483647)
    ipc.sleep (400)
end
 

and in fsuipc I set the LuaKill to work after releasing the button.
Now it works very well.
Why does the loop still work on your code when you release the button?

Regards,

Dominik.

 

Posted
1 hour ago, Dominik said:

and in fsuipc I set the LuaKill to work after releasing the button.
Now it works very well.

That will work but it very "unfriendly", killing threads is only a last measure.

1 hour ago, Dominik said:

Why does the loop still work on your code when you release the button?

Because of this line:

if ipc.testflag(0) then ipc.exit() end

It will exit and therefore terminate normally if the Flag (flag 0 in this case) is set. You need to assign the button release to "LuaSet" with the Lua name and 0 as a parameter!

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.