Joan A Posted July 12, 2018 Report Posted July 12, 2018 Hi, After installing the new AS Airbus for P3D V4, I tried to load a Lua file to move the rudder with a joystick. This Lua plugin was made years ago by Enrique Vaamonde for the 32bit version of this aircaft. The plugin works well, but every time I press the buttons and the plugin is working I have hard stutters, (tried with gamepad and with keyboard keys also) only when it is applied. It has something to do with the change of 32 to 64 environment? It needs some kind of modification inside the Lua file? Many thanks Quote -- LUA Script for keyboard control of Aerosoft Airbus X Extended Rudder -- Version 2012121901 -- (C) Enrique Vaamonde - evaamo at gmail.com rudderSTEP = 2048 rudderPOS = ipc.readSW(0x66c0) if rudderPOS > 16383 then rudderPOS = 16383 end if rudderPOS < -16383 then rudderPOS = -16383 end --ipc.display("RUDDER: "..rudderPOS) --ipc.sleep(1000) function rudder_set(value) ipc.writeSW(0x66c0, value) ipc.control(64103, value) ipc.exit() end if ipcPARAM == 1 then rudder_set(0) end -- RUDDER LEFT if ipcPARAM == 2 and rudderPOS < 16383 then rudder_set(rudderPOS + rudderSTEP) end -- RUDDER RIGHT if ipcPARAM == 3 and rudderPOS > -16383 then rudder_set(rudderPOS - rudderSTEP) end
spokes2112 Posted July 14, 2018 Report Posted July 14, 2018 (edited) On 7/12/2018 at 3:09 PM, Joan A said: It needs some kind of modification inside the Lua file? Joan, That seems correct. This particular script is a "run once", meaning each time the command is given to move the rudder the script also kills ( ipc.exit() ) itself then reloading on the very next command, and over & over... Looking at the version number this was made back in 2012. Back then it was probably the only way to make this script work and is very inefficient. Similar to killing a windows program by using the Windows task manager and ending a process forcefully. Since then Pete has incorporated event "listeners" where the script is loaded via [Auto] or [Auto.<profile>], it stays running, listening for commands. I am assuming a rewrite would help alleviating the stutters. Here is a new script, not tested "yet" (a very busy morning) - -- USER ADJUSTMENT, AMOUNT TO MOVE RUDDER local rudderStep = 2048 -- END USER ADJUSTMENT local rudderPos = 0 function centerRudder(flag) ipc.writeSW(0x0BBA, 0) end function moveRudder(flag) rudderPos = ipc.readSW(0x0BBA) -- RUDDER LEFT if flag == 2 then rudderPos = rudderPos - rudderStep rudderPos = math.max(rudderPos, -16383) -- RUDDER RIGHT else rudderPos = rudderPos + rudderStep rudderPos = math.min(rudderPos, 16383) end ipc.writeSW(0x0BBA, rudderPos) end event.flag(1, "centerRudder") -- CENTER event.flag(2, "moveRudder") -- MOVE LEFT event.flag(3, "moveRudder") -- MOVE RIGHT STEPS 1) Get the lua running by either using [Auto], [Auto.<profile>] or a key command via the FSUIPC interface "Lua <lua name>" 2) Center rudder - Assign the command via the FSUIPC interface "LuaToggle <lua name>" with a parameter of 1, repeat is optional 3) Left rudder - Assign the command via the FSUIPC interface "LuaToggle <lua name>" with a parameter of 2, repeat is checked 4) Right rudder - Assign the command via the FSUIPC interface "LuaToggle <lua name>" with a parameter of 3, repeat is checked Hopefully this works for you. Will test later this afternoon when I return. If this new lua does not get rid of stutters then the AS Airbus is overloading simconnect in some fashion. Roman Edited July 15, 2018 by spokes2112 Updated to new code 1 1
Joan A Posted July 14, 2018 Author Report Posted July 14, 2018 Hi Roman, Many thanks, I didn't expect such a detailed explanation, even taking the time to modify the script. I would never have been able to do it myself. I really appreciate your help. I've been using FSUIPC for some time and I experimented with offsets but I really do not know anything about deeper knowledge of the coding capabilities that it offers. But I get what you are saying about the new efficient way of invoking it with events. I'll try tomorrow the script and let you know. Thank you!
spokes2112 Posted July 15, 2018 Report Posted July 15, 2018 Joan, You are welcome. I just hope I can help. BTW - I am testing in FSX with the stock MS B737 and the original code above just did not work. It has now been updated with new code. Some really weird things going on. Give that one a try instead. If the AS Airbus uses SDK compliant variables it should work. If they're using some highly custom coding then it may not.. Roman _________________________________________________________________________________________________________ Pete, Some really weird things going on here.. vers - 4.974b, tested on MS B738 0x0BBA - SW, Rudder control input: –16383 to +16383 0x0C0A - SW, Rudder input value, -16384 to +16383, if calibrated 0x332C - SW, Rudder Axis input value, post calibration, just before being applied to the simulation (if allowed to by the byte at offset 310A). 64103 - fsuipc rudder 65764 - rudder axis set 65696 - rudder set The joystick axis for rudder was removed in the axis assignment & joystick calibration pages to test - keep from interference. 1) The FSUIPC "internal" command 64103 doesn't seem to work at all regardless of any of the 3 read offsets listed above. (Big questions here!) Used at the end of function "moveRudder" -- ipc.control(64103, rudderPos) replacing the offset write as shown above, all other code was the same but trying all 3 read offsets. 2) The command 65764 is weird, for the 0x332C & 0x0BBA reads it seems the read gets reset to zero after the command, therefore travel is limited to -2048 to 2048. The read at 0x0C0A just gave completely unreliable results altogether. 3) With the command 65696, the reads at 0x0C0A & 0x332C seems the read gets reset to zero after the command, therefore travel is limited to -2048 to 2048, same as above with different reads while 0x0BBA gave completely unreliable results altogether. In the end just read & writes to 0x0BBA were used reliably... (so confused!) Roman 1
Joan A Posted July 15, 2018 Author Report Posted July 15, 2018 Hi Roman, Thank you again, I tried it but it does not do anything. Maybe I'm doing something wrong, but after replacing the script, and adding the plugin to the [Auto] section the plugin does not work. No action is shown in the FSUIPC console when buttons pressed. Just to add that with the original script the stutters were also happening with default aircraft. In fact I tried with one of the Lua plugin that comes with FSUIPC, the gradual braking and it also stutters when I trigger the button. This is happening in fresh install of Win10 with last updates and fresh install of P3D 4.3. It seems that all the Lua Plugins I try I have massive stuttering when applied. I'm going mad with this. Thank you.
spokes2112 Posted July 16, 2018 Report Posted July 16, 2018 Hi Joan, Just retried the lua code above to see if there was a copy/paste problem. No - works fine. Said before I am still on FSX with FSUIPC v4.974b, anyway there is a setting in this version to change the affinity mask for lua scripts - LuaAffinityMask=0 It was stated in the history document for 4.974 but nowhere else, maybe consult your documents and see if it it is available for v5.xxx. If available maybe give it a try. Good luck with you Roman
Joan A Posted July 16, 2018 Author Report Posted July 16, 2018 Hi Roman, Yes, it works! It does work with default aircraft without stuttering, but it behaves strangely with the AS Airbus, it works "partly", with FBW doing its stuff. Strange, because without events was working well despite stuttering. I'll keep testing anyway. Many thanks Roman, I really appreciated all of your help.
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