Jump to content
The simFlight Network Forums

Search the Community

Showing results for tags 'lua'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Product Support Forums
    • FSUIPC Support Pete Dowson Modules
    • MyTraffic Support Forum
    • FeelThere Support Forums
    • FS Commander Support Forum
    • FScene Support Forum
    • Taburet & DanVFR Support Forum
    • Flying W Simulation
    • AConstable Traffic Sounds Support Forum
    • CLS Support
    • Fabio Merlo Products Support Forum
    • Elite-Air Studio Support Forum
    • Nikola Jovanovic Support Forum
    • iBlueYonder Support
    • Intrasystems Support Forum
    • FSPS Support Forum (LEGACY)
  • simFlight DE
    • FS Software
    • FS Hardware
    • FS MAGAZIN Forum
  • simRussia
  • FSUIPC Client DLL for .NET


  • Community Calendar


There are no results to display.

Found 43 results

  1. Hi Pete One of my users has been reporting issues with FSUIPC5 when changing aircraft when multiple LUA files are in use. The user is using the Lua file multiaxis.lua which allows axes to be swapped when a joystick button is pressed. The command is communicated via the offset 0x66C0). There appears to be a conflict with LINDA when called, normally, via ipcready.lua and the [auto] section loading Lua multiaxis. Renaming ipcready.ipc prevents the crash but this means that LINDA LUA modules not being loaded. [auto] 1=lua multiaxis [LuaFiles] 1=ipcReady 2=linda 3=AirbusX_Thr1 4=AirbusX_Thr2 5=FSUIPC5_test 6=Multiaxis [Axes] 0=JX256,F,L5:V,0,0,0 -{TO SIM: luaValue Multiaxis }- [Buttons] PollInterval=25 ButtonRepeat=20,10 1=R2,4,Cx42000BC0,xC0010100 -{offset sword decrement, offset 0BC0 (Decr=256, Limit=-16383)}- 2=R2,5,Cx32000BC0,x3FFF0100 -{offset sword increment, offset 0BC0 (Incr=256, Limit=16383)}- 3=P3,3,Cx030066C0,x0000FA88 -{offset dword set, offset 66C0}- 4=U3,3,Cx030066C0,x000100E3 -{offset dword set, offset 66C0}- With P3Dv4, LINDA 3.0.2 and Multiaxis.lua running, P3Dv4 crashes on aircraft change with the Event Viewer (see attached) showing a crash in FSUIPC5.dll. I am not sure whether this problem is associated with the LUA thread management changes you made earlier. These tests were carried out with FSUIPC 5.112. The user also reported the same crash with FSUIPC4 4.971 (log attached). FSUIPC5.ini FSUIPC5-crashOnAircraftChange.log Multiaxis.lua MULTIAXIS_crash.txt FSUIPC4_Crash_LINDA_302_FSUIPC_471.log
  2. I am running FSUIPC 5 1.03g, registered. I am trying to run a LUA script (via Key Presses section) that I used with P3Dv3 that controls my PMDG 737NGX home made overhead panels, etc. in P3Dv4. I exclusively use UDP to communicate between Arduinos and FSUIPC which uses Lua Sockets. I now get the LUA error: I am assuming this is because I have not compiled a 64 bit version of LUA. I installed the 32 bit version a long time ago and I muddled my way through it with Luarocks version 5.1.x, I believe. My question is, am I on the right path in believing that I need to figure out how to compile it again with 64 bit? I am not very strong on these sorts of things and I can't find any clear cut ways to do it on my Win7-64 box. The searches I am coming up with are all over the map on ways to do it. Has anyone done this yet that could advise on what I need to do or point me to a URL that explains the best way? Thanks in advance, Dustin
  3. Hello Peter How do i write hid buffer in lua script?...My problem is I want to get AP altitude value then write that value into HID buffer using lua. HID buffer will update 7 segment display by pic microconroller. thanks
  4. Hi Pete or any other LUA Guru, I've now converted to P3DV4 and I'm running FSUIPC 5.103g . A lua script I used in FSX successfully to play a video doesn't seem to respond. I'm using the ext.shell in the lua library. video, error = ext.shell("L:\\1.mp4", "EXT_FOCUS") ( As I said, this worked in FSX) the log showed no errors, but the video didn't play. ********* LUA: "test" Log [from FSUIPC version 5.103g] ********* 13259554 System time = 16/07/2017 14:37:18, Simulator time = 11:37:18 (21:37Z) 13259554 LUA: beginning "L:\Prepar3D v4\Modules\test.lua" 13259554 LUA: L:\Prepar3D v4\Modules\test.lua:2 13259554 LUA: Global: ipcPARAM = 0 13259617 >>> Thread forced exit (ipc.exit or os.exit) <<< 13259617 System time = 16/07/2017 14:37:18, Simulator time = 11:37:18 (21:37Z) ********* LUA execution terminated: Log Closed ********* so I tried making .bat file called video1.bat with simply "L:\1.mp4" in it. then changed the lua code to: video, error = ext.run("L:\\video1.bat") and it worked. I also tried: video, error = ext.run("L:\\1.mp4", "EXT_FOCUS") with no luck but also no errors recorded. Just wondering if I'm doing something wrong or what else I should look into. I can stick with the .bat file since it works, but it doesn't allow for the command line parameters to adjust the video window. Thanks for your help. -Jim
  5. Hi Pete I have started to see a repeating LUA Error Invalid Argument when running LINDA LUA code to start a second module using the LUA function ipc.runlua(path) (where path is \linda\system\init). 944344 LUA.1: LINDA:: [START] Path = linda/system/init 944625 LUA: "C:\FSX\Modules\linda/system/init.lua": killed 944860 *** LUA Error: cannot open : Invalid argument 1001125 LUA: "linda.lua": killed 1001125 LUA.0: [START] *********************** STARTING LINDA *********************** This could come down to sequencing where the ipc.runlua() is being caused before FSUIPC has actioned the LauKill() function although the kill command is passed before the run command. It appears that the kill command is being delayed. The LuaKill is called from the LINDA GUI followed by a RunLua(linda). Linda.lua calls the following (executed via the GUI) to FSUIPC: path = ipc.get("PATH_SYS") .. "init" where PATH_SYS = linda/system/ if file_exists(path .. '.lua') then ipc.runlua(path) else _log('[START] Unable to find INIT.LUA - Try Restarting') end When the restart is run a second time init.lua is dead and there is no error. We are seeing with 4.964, 4.968 and 5.103. Has anything change in recently? What delay should be built in to ensure the first command is completed before the second is sent? We have not seen this problem until the last month or so. It is only now that I have pinned down the cause. FSUIPC4.log-Invalid Argment.txt FSUIPC4 .log-Invalid Argument2
  6. Hello, Compiled lua files give me an error "Bad header in precompiled chunk" with P3D4 and FSUIPC 5.103. Source LUA files are OK. Everything was OK with P3D3 and FSUIPC4 : both sources and compiled files were executed. I tried x86 and x64 versions of luac53, no change, still the same error. Any idea on how to execute compiled lua scripts in P3D4 is welcome, thanks in advance and sorry for my English ... Regards, Frederic
  7. Hi Pete I am analysing the Control values used by FSLabs A320X to operate various switches for LINDA. For most they use FSX Control ROTOR_BRAKE (66587) but for others they use control 196881. I am using the LUA function ipc.control(value, param) to send commands into the simulator. The value of 66587 (ROTOR_BRAKE) is no problem but I am not sure that control values outside the normal range (e.g. 196881) are transmitted. Under FSUIPC Options and Settings users can set a custom control value from 65536 to 131070 (x10000 to x1FFFE). Does this upper limit apply to the LUA ipc.control(value, param)? I need to send params in the range 0x00010000 to 0x00FF0000. When I do send the control ipc.control(196881, xxxxxxx), I see in fsuipc4.log the line "FS Control Sent: Ctrl=196881. param:xxxxxxx" which suggests the control is sent but I am not seeing the expected effect. Any comments would be welcome. I am currently, using FSUIPC4 4.968 and P3Dv3.4 but the question equally applies to FSUIPC5.
  8. Hello, I am a registered user of FSUIPC and WIDEFS for 11 years, and I thank Pete very much for this extremely complete software. The operation of WideFS is still operational with P3D-V4. Bravo. I bought an FSUIPC5 key as soon as it was available, and everything works perfectly with P3D-V4. Now, here is my problem : I own an MCF + EFIS from CPFlight. It worked perfectly with the supplied driver, as well as the (Expensive) software from FS-Labs. Unfortunately , the FS-Labs software is a 32 bits version, and there is no planned version for compatibility with P3D-V4. So I looked for another solution, and by reading the important documentation provided with FSUIPC, I discovered that there was everything necessary to direct control for my hardware. So I started using LUA plug-ins, helped by the many examples provided. Great job, Pete ... Very well explained and very complete. Unfortunately, I am not able to make a simple com.write () ... I run P3D-V4 with the following LUA script, associated with a keyboard key ("A") : MCP-747.lua : ----------------------------------------------- -- Commande du MCP-747 de CP-Flight avec LUA ----------------------------------------------- speed = 38400 -- Vitesse du port USB handshake = 0 -- No handshake MCP = com.open("com6", speed, handshake) if MCP == 0 then ipc.log("Pas trouvé de MCP-747 de CP-Flight") ipc.exit() end ipc.log("Port USB ouvert") n = com.write (MCP, "Q001") ipc.log(n) When I execute the script ("A" key from the keyboard), the LLUA log (MCP747.log) gives this: ********* LUA: "MCP-747" Log [from FSUIPC version 5.101] ********* 256825 System time = 21/06/2017 11:42:37, Simulator time = 14:44:36 (12:44Z) 256825 LUA: beginning "M:\P3D-V4-0\Modules\MCP-747.lua" 256825 LUA: M:\P3D-V4-0\Modules\MCP-747.lua:5 256825 LUA: Global: ipcPARAM = 0 256825 LUA: M:\P3D-V4-0\Modules\MCP-747.lua:6 256825 LUA: Global: speed = 38400 256825 LUA: M:\P3D-V4-0\Modules\MCP-747.lua:8 256825 LUA: Global: handshake = 0 256903 LUA: M:\P3D-V4-0\Modules\MCP-747.lua:10 256903 LUA: Global: MCP = 5029216692 256903 LUA: M:\P3D-V4-0\Modules\MCP-747.lua:15 256903 LUA: Port USB ouvert 256903 LUA: M:\P3D-V4-0\Modules\MCP-747.lua:17 256903 LUA: M:\P3D-V4-0\Modules\MCP-747.lua:19 256919 LUA: Global: n = 0 256919 LUA: 0 256919 >>> Thread forced exit (ipc.exit or os.exit) <<< 256919 System time = 21/06/2017 11:42:37, Simulator time = 14:44:36 (12:44Z) ********* LUA execution terminated: Log Closed ********* The trace of the serial port (COM6) by the "Advanced Serial Port Monitor" software gives this : <20170621114237.550 SYS> COM est ouvert <20170621114237.550 SYS> Taille de queue entrée/sortie 1024/1024 <20170621114237.550 SYS> Unable to add string #8 <20170621114237.553 SYS> Débit en bauds 38400 <20170621114237.556 SYS> RTS activé <20170621114237.559 SYS> DTR activé <20170621114237.562 SYS> Bits de données=8, Bits d'arrêt=1, Parité=None <20170621114237.562 SYS> Configurer charactères : Eof=0x00, Error=0x00, Break=0x00, Event=0x00, Xon=0x11, Xoff=0x13 <20170621114237.565 SYS> Handflow : ControlHandShake=(DTR_CONTROL), FlowReplace=(TRANSMIT_TOGGLE, RTS_CONTROL), XonLimit=896, XoffLimit=512 <20170621114237.565 SYS> Purger le port série : RXABORT, RXCLEAR <20170621114237.983 SYS> Purger le port série : RXABORT, RXCLEAR <20170621114238.101 SYS> COM est fermé There is nothing writen on the Com6 ! Using the MCP test software, with the same "Advanced Serial Port Monitor" : <20170621114831.512 SYS> COM est ouvert <20170621114831.515 SYS> Taille de queue entrée/sortie 1024/512 <20170621114831.515 SYS> Purger le port série : RXABORT, RXCLEAR, TXABORT, TXCLEAR <20170621114831.515 SYS> Unable to add string #8 <20170621114831.518 SYS> Débit en bauds 38400 <20170621114831.524 SYS> RTS désactivé <20170621114831.530 SYS> DTR activé <20170621114831.533 SYS> Bits de données=8, Bits d'arrêt=1, Parité=None <20170621114831.533 SYS> Configurer charactères : Eof=0x1A, Error=0x00, Break=0x00, Event=0x00, Xon=0x11, Xoff=0x13 <20170621114831.539 SYS> Handflow : ControlHandShake=(DTR_CONTROL), FlowReplace=(), XonLimit=256, XoffLimit=256 <20170621114831.540 TX> Q001<NUL>Q001<NUL> <20170621114831.612 RX> KCPF<NUL>CPMCP747_100<NUL>CHIAVE0310013<NUL>MOD485EFI1<NUL>K037<NUL>K041<NUL>K017<NUL>K019<NUL>V06 359<NUL>S003<NUL>M001<NUL>K072<NUL>K075<NUL>V0900<NUL> <20170621114844.218 RX> K025<NUL> <20170621114844.218 TX> L0125 <20170621114845.089 RX> K024<NUL> <20170621114845.089 TX> L0124 <20170621114846.026 RX> K026<NUL> <20170621114846.027 TX> L0126 I do not understand where I was wrong ! Can anyone help me ? PS : I am from Paris (France) so, please, excuse my bad English ...
  9. Hello i have some questions as i am not sure about it. I bought fsuipc as i would like to make some development for myself but not using simconnect. * i am very interested with LUA, but seems i am wrong with it : i thought that for instance i can create a simobject (ex: ai plane, ...) with lua or even interact with L:variables of AI objects but not found Something in the documentation that i can do (it seems that i can interact only with my plane) * if i can't do what i want with LUA, can i do this with for instance VB.net ? or i need to use Something else ? Thanks a lot !
  10. Hey guys, I need some help with my lua script which reads a FSUIPC offset. Its not working as intended and I'm not sure why Essential I need a message to be displayed when I switch the Landing Lights ON. But I only want this to happen when I am airborne, not on the ground. To check this I read the FSUIPC offset 0366 to see if the plane is airborne. However I must have coded the ipc.readSW(offset) incorrectly, because the wrong message is being displayed even when I am on the ground. Here is the code: function runMessage(event, param) local gnd = ipc.readSW(0366) if (gnd == 1) then ipc.display("you are on the ground and the offset was read correctly", 1, 0 ) return end if (gnd == 0) then ipc.display("Landing Lights ON: .. message here", 1, 0 ) return end end event.control(66059, "runMessage") -- lights on Thanks
  11. Hi Pete, this is about the problem of the misalignment of the Saitek trim wheel when disengaging the autopilot. As soon as you move the trim wheel the airplane bounces up or down related to the absolute position of the trim wheel. That is well known to all users of a trim wheel and really miserable. I found in a X-Plane forum an idea which leads imho to a really handy and reasonable workaround to avoid that problem: i wrote a lua to deal with the problem. what it does: in AP mode the trim wheel disconnect from the trim axis in non AP mode the trim wheel connects. in most cases the trim wheel will be physically in the wrong pos in relation to the ac trim axis, so if you move the wheel and he is out of sync, you get a display on the left side of your screen. red if out of sync, green when in sync. both values are visible so you can move the wheel to the correct ac setting. only then the wheel axis connects to the ac trim axis and you can use it. its possible you have to alter some settings due to different screen res. For me this would be a great solution to get rid of the trim wheel problem. Is it possible to realize that in FSX using a LUA? And at least a question to the community: is there anybody who is able to write that LUA and would like to do that? Thanks for your support, Juergen
  12. Hi folks, I am trying change altitude on MCP by rotary encoder, unfortunately I am not sure if I send to ipc.control correct data ipc.control(70032, altitude) value in altitude is correct, I have there (100,200....1000,1100.......12000....) It works only for first three hundred, and then even though I change altitude value by rotary, the value on MCP will not change. Could someone help me? Thank you. EDIT: I tried to send it real altitude /100. This works fine, but only for increasing altitude. If I turn with rotary to anti-clockwise position, the value is decreasing, but altitude on MCP in FSX is still increasing. EDIT2: Solved, I don't know why, but if I send there ipc.control(70032, 536870912) it is decreasing. EDIT3: Sorry, I have one more problem. When I send there real altitude, it is increasing till 35700. Why? I also noticed when I quick turning with rotary the value which I send to ipc.control is e.g. 2100 but it sets only 2000.
  13. Some lua for PoKeys folks

    Hi folks, here some lua function to operate your pokeys card, only for ethernet version (Pokeys57E) Enjoy --Function: Create a pokeys handle variable --Call: Provide not mandatory 'bDisplayError' as 'false' if don't want to display error -- Otherwise it will be displayed in simulator --Returns: 'nil' if error, otherwise returns a valid handler function createPokeysObject(bDisplayError) local oObj if bDisplayError == nil then bDisplayError = true end oObj = luacom.CreateObject("pokeysDevice_DLL.pokeysDevice") if oObj == nil then ipc.log("POKEYS ERROR - Unable to create the pokeysDevice_DLL object") if bDisplayError == true then ipc.display("POKEYS ERROR - Unable to create the pokeysDevice_DLL object") end end return oObj end --Function: Connect to an ethernet pokeys card --Call: Provide cIP as string i.e. "" --Returns: 'true' if connection made successfully, otherwise 'false' function connectToPokeys(cIP) local isConnected = oCard:ConnectToNetworkDevice(cIP) if isConnected == false then ipc.log("POKEYS ERROR - Unable to connect to pokeys card at " .. cIP) end return isConnected end --Function: Obtain an IP address from the card serial number --Call: Provide the card serial number as integer --Returns: 'nil' if error or card not found, otherwise returns a valid ip address as string function getPokeysIPAddrFromSN(nSerialNumber) local cIPReturn = nil local oDevices = createPokeysObject() if oDevices == nil then return nil end oDevices:StartEthernetDiscovery() ipc.sleep(1500) oDevices:StopEthernetDiscovery() local iNumDevices = oDevices:GetNumberOfDetectedNetworkDevices() if (iNumDevices > 0) then ipc.log("I've found " .. iNumDevices .. " Pokeys ethernet cards in the network") else ipc.log("No Pokeys ethernet cards found in the network") return nil end local ipAddresses = oDevices:GetNetworkDevicesAddressses() for nCard = 1, iNumDevices do serialNumber = 0 versionMajor = 0 versionMinor = 0 oDevices:ConnectToNetworkDevice(ipAddresses[nCard]) oDevices:GetDeviceIDEx(serialNumber, versionMajor, versionMinor) ipc.log("Card " .. nCard .. ", serial number " .. serialNumber .. ", version major " .. versionMajor .. ", version minor ".. versionMinor) if (serialNumber == nSerialNumber) then ipc.log("Found requested serial number " .. serialNumber .. " with IP address " .. ipAddresses[nCard]) cIPReturn = ipAddresses[nCard] return cIPReturn end oDevices:DisconnectDevice() end if (cIPReturn == nil) then ipc.log("No Pokeys ethernet card found matching the requested serial number " .. nSerialNumber) end return cIPReturn end
  14. Hi All. I've developed this script to perform a cold an dark startup and to issue key presses if the hat switch is moved. The keys then change cameras defined in EzCam Views. In the main section I enable a series of button events and key events. This is fine when I select an aircraft for the first time, but if I change aircraft after that, I get a crash to desktop. The only solutions to this CTD are either to use Lua Kill All at the end of every flight or to remove the lines between startColdAndDark(0, 0, 0) and setowndisplay("PRE-FLIGHT BRIEFING", 5, 10, 30, 25). It seems that the Lua thread is not terminating on change of aircraft for some reason, (possibly a problem on Windows 10?). Is there any kind of destructor method I can use to kill lua automatically if I change aircraft? Thanks Pontius. hat_fore_and_aft.lua
  15. Hello, I am trying to read a joystick's axis in a lua script. My controllers have letters assigned and the axis is recognised in the FSUIPC tab as Joy "A" axis "X" (screenshot). When I run my script this line alway returns 16191 no matter what: m = ipc.axis("A", "X") I even tried using 0 as joystick number and reading other axises (?) but the result is the same. I have seen this in use e.g. the smooth brake lua script but what am I doing wrong here? Thanks! Code: function readX() m = ipc.axis("A", "X") strDisplay = m.." " m = ipc.axis("A", "Y") strDisplay = strDisplay..m.." " m = ipc.axis("A", "Z") strDisplay = strDisplay..m.." " m = ipc.axis("A", "R") strDisplay = strDisplay..m.." " m = ipc.axis("A", "U") strDisplay = strDisplay..m.." " m = ipc.axis("A", "V") strDisplay = strDisplay..m.." " ipc.display(strDisplay) end event.timer(1000, "readX") Log: 1637027 LUA.0: Waiting for an event in "C:\FSX\Modules\pwr.lua" 1638026 LUA.0: Timer event: calling "readX" in "C:\FSX\Modules\pwr.lua" 1638026 LUA.0: C:\FSX\Modules\pwr.lua:8 1638026 LUA.0: C:\FSX\Modules\pwr.lua:9 1638026 LUA.0: C:\FSX\Modules\pwr.lua:11 1638026 LUA.0: Global: strDisplay = 16191 1638026 LUA.0: C:\FSX\Modules\pwr.lua:12 1638026 LUA.0: C:\FSX\Modules\pwr.lua:14 1638026 LUA.0: Global: strDisplay = 16191 16191 1638026 LUA.0: C:\FSX\Modules\pwr.lua:15 1638041 LUA.0: C:\FSX\Modules\pwr.lua:17 1638041 LUA.0: Global: strDisplay = 16191 16191 16191 1638041 LUA.0: C:\FSX\Modules\pwr.lua:18 1638041 LUA.0: C:\FSX\Modules\pwr.lua:20 1638041 LUA.0: Global: strDisplay = 16191 16191 16191 16191 1638041 LUA.0: C:\FSX\Modules\pwr.lua:21 1638041 LUA.0: C:\FSX\Modules\pwr.lua:23 1638041 LUA.0: Global: strDisplay = 16191 16191 16191 16191 16191 1638041 LUA.0: C:\FSX\Modules\pwr.lua:24 1638041 LUA.0: C:\FSX\Modules\pwr.lua:26 1638041 LUA.0: Global: strDisplay = 16191 16191 16191 16191 16191 16191 1638057 LUA.0: C:\FSX\Modules\pwr.lua:27 1638057 LUA.0: Waiting for an event in "C:\FSX\Modules\pwr.lua" 1639040 LUA.0: ended "C:\FSX\Modules\pwr.lua" FSUIPC4.ini
  16. Hi all I'm a long-term Pete Dowson admirer and user of his wonderful program, I know is needless to say after all this time, but FSUIPC and the integration with LUA is simply extraordinary. I am building a home cockpit and I chose the Pokeys board for my MIP (ethernet), throttles (USB) and recently also overhead (ethernet version). With LUA and IPC controls and pokeys.dll I managed to have a great deal of systems working with default B737/800 so I'm very happy with that, and this site helped me a lot to find examples and solutions for almos every problem. Also Pete's documentation was so good and clear, even though I had to overload my poor brain to get started at the beginning. Now I decided to post a message because I cannot really solve this issue by myself. My code, launched by ipcready as documented, works perfectly, no errors, all running smoothly. Randomly though, I realize that the code has stopped working because there is no reaction to variables change or switches changes etc. I see the log file and there is no message of any kind regarding errors or other issues. Is there a way to understand what problem is causing the code to stop, or to trace the errors in a deeper log? It happens both with the MIP code and with the OVERHEAD code (based on ethernet pokeys) but never with the throttles (USB pokeys) but the net is stable, I changed switches, cables, etc, but all other net devices seem to work. Can someone (hopefully Pete!) help me ? Best regards Massimo
  17. Screenshot Lua Script

    This Lua file invokes the Print Screen button passing the clipboard to IrfanView.exe and, by using IrfanView's powerful command line options, processes the pasted file to an output .jpg modified as wanted. --[[ NOTES - USE WITH [AUTO] IN .INI TO START WITH FS - ASSIGN IN FSUIPC AS "LuaSet <Saved Name>" WITH A PARAMETER OF 1 - HTTP://WWW.IRFANVIEW.COM/ - SEE "I_OPTIONS.TXT" OR "I_VIEW32.CHM|OVERVIEW|COMMAND LINE OPTIONS" FOR COMMAND LINE DESCRIPTIONS. - EXAMPLE OF "SS_$U(%d%b%y_%H%M%S).jpg" IN OPTIONS = "SS_20Oct15_112307.jpg" - !!! IMPORTANT !!! - CHANGE "IV_Path" AND "IV_Options" TO OWN INSTALLATION AND REQUIRED OPTIONS - COMMAND OPTION "/convert=" WILL AUTOMATICALLY SHUT DOWN IRFRANVIEW AFTER PROCESSING - BECAUSE PRINT SCREEN IS INVOKED IN LUA, OWNED BY FS, IT CAPTURES ONLY THE ACTIVE MAIN WINDOW, IE FS. - !!! NOW MODIFIED FOR BETTER BEHAVIOUR - SEE COMMENTS IN "TRIGGERS SECTION" BELOW FOR OTHER ASSIGNEMENT OPTIONS END NOTES ]] sound.path("C:/Windows/Media") local flagged = 0 -- !!! IMPORTANT !!! - CHANGE THE FOLLOWING 2 LINES TO SUIT !!! local IV_Path = "E:/IrfanView/i_view32.exe" -- !!! IMPORTANT !!! - USE DOUBLE BACKSLAHES FOR OUTPUT PATH local IV_Options = "/clippaste /crop=(1443,62,1357,684) /sharpen=20 /jpgq=100 /convert=D:\\My Pictures\\FS_SCREENSHOTS\\PP_OUTPUT\\SS_$U(%d%b%y_%H%M%S).jpg" -- /crop=(13,62,1357,684) -- /crop=(1443,62,1357,684) -- PRESS PRINT SCREEN KEY, RUN IRFRANVIEW (SELF STOPPING), PASTE CLIPBOARD, OPTIONS PROCESSING, CREATE JPG & RETURN FOCUS TO FS function PrtScn(x, y, move, flags) flagged = ipc.testflag(1) if flags == 16 or flags == 32 or flags == 64 or flagged then ext.focus(0) -- REGAIN OWNERSHIP OF FS - FSX ONLY!!! x, y, xr, yr, xp, yp = mouse.getpos() mouse.move(66, 0, 2) mouse.click(0) mouse.move(xr, yr, 1) -- END FSX ONLY ipc.clearflag(1) ipc.control(1070, 300) -- WAIT FOR "PRTSCN" TO PROCESS, ADJUST HIGHER IF NOT PICKING UP FS WINDOW ipc.sleep(100) handle, error = ext.shell(IV_Path, IV_Options) if handle ~= 0 and error == 0 then sound.play("Windows Default", 0, 100, -1) end ext.focus(0) end end -- TRIGGERS SECTION -- SETFLAG TRIGGER, FOR JOY OR KEYS THROUGH FSUIPC ASSIGNMENTS event.flag(1, "PrtScn") -- MOUSEWHEEL CLICK - FSUIPC V4 ONLY! DISABLED FOR FSUIPC MOUSE LOOK FUNCTION USE -- event.mousemiddletrap("PrtScn") -- MOUSEWHEEL LEFT / RIGHT - FSUIPC V4 ONLY! DOES NOT WORK WITH MY MOUSE, USED KEYSEND MACRO IN MOUSE SOFTWARE -- event.mousehoriz("PrtScn")
  18. I'm trying to make a lua script that checks the FSX time against the current UTC time and then sets the FSX time to the real UTC time if it isn't already there. So, for example, if I load the default flight and set the time to "dusk" and that UTC time is not accurate, it will update the time to the current UTC time. This is the first time I have ever touched LUA, so I don't know what I am doing. The only programming I have done is in PHP. I came up with this after some googling, but it isn't working, so I am trying to figure out what I am doing wrong. Any help is appreciated! -- FSX UTC Time Synch -- Novbember 2015 -- V 1.0 -- ## Sets FSX Time to UTC ############### while 1 do simHour = ipc.readUB("023B") simMinute = ipc.readUB("023c") Hour = os.date("!%H") Minute = os.date("!%M") if simHour ~= Hour then ipc.writeUB("023B", Hour) end if simMinute ~= Minute then ipc.writeUB("023c", Minute) end ipc.sleep(120) end
  19. Pete, Just noticed something when trying to use the numpad enter key using event.key in lua. IIRC there was something about this in the forum but through searches couldn't find it. This works just fine for repeats - event.key(135, 8, 5, "KeyStroke") For a single shot, this works only 1 time when lua is first loaded and the enter key is used. It doesn't "listen" for it afterwards. Unless.... The enter key is pressed and held logging repeating keypresses. Then, it will work just 1 time afterwards until repeated. (a repeating keypress as a "listener" reset) All other keys on numpad work just fine. Single shot use, the one that doesn't seem to work properly - event.key(135, 8, 1, "KeyStroke") Strange thing though. When logging keys for the numpad enter key this is it's output for a single click / release. KEYDOWN & KEYUP don't match. HMMM???? 3056715 KEYDOWN: VK=135, Waiting=0, Repeat=N, Shifts=0 3056715 .. Key not programmed -- passed on to FS 3056902 KEYUP: VK=13, Waiting=0 Through the FSUIPC interface it picks up the keydown, not keyup, but keeps on listening. [Keys]21=135,8,L8:T,0,L8:K,0 9333696 KEYDOWN: VK=135, Waiting=0, Repeat=N, Shifts=0 9333696 LUA.4: "KeyTune.lua": Flag 0 toggled 9333696 .. This key is programmed in FSUIPC4 'Keys' options 9333696 LUA.4: Lua Flag event: calling "KeyStroke" in "G:\FSX\Modules\KeyTune.lua" 9333696 LUA.4: G:\FSX\Modules\KeyTune.lua:9 9333712 LUA.4: G:\FSX\Modules\KeyTune.lua:10 9333712 LUA.4: G:\FSX\Modules\KeyTune.lua:11 9333712 LUA.4: G:\FSX\Modules\KeyTune.lua:12 9333743 LUA.4: G:\FSX\Modules\KeyTune.lua:14 9333758 LUA.4: Waiting for an event in "G:\FSX\Modules\KeyTune.lua" 9333852 KEYUP: VK=13, Waiting=0No lua kill afterwards but it keeps listening for downpress. Just wondering.. Could go another route but was really hoping on using event.key v4.947d on FSX accel boxed.
  20. I have always wanted to have a "quick and dirty" way to monitor specific L:VARs without installing a new gauge and trying to find the ones needed by scrolling etc. Perfect for things like programming sub-systems and such. It's a 3 step process. Run "LVARS_2_TXT.lua" to get the full list (output = "ALL LVARS.txt") of L:VARs currently loaded by the selected aircraft. It's a "run once" lua but, one can use it multiple times if multiple aircraft projects are being done as it appends to the file. (creates a master list) -OR- Run the FSUIPC command "List local panel variables" to do the same and written to the FSUIPC log (Formatting necessary!) , without using "LVARS_2_TXT.lua" - The former provides a pre-formatted, easy to use output. Pick the LVARs needed to monitor and copy them over into the array in "LVAR_SPECIFIC.lua". NOTE - The output in "ALL LVARS.txt" are pre-formatted for an easy copy --> paste. See notes in lua. Note - The lua display will truncate anything after 1023 characters so if this starts happening reorder your list in priority order. Run "LVAR_SPECIFIC.lua" to monitor your selected L:VARs. LVARS_2_TXT.lua -- "LVARS_2_TXT" Loaded LVARs writer, by Roman Stoviak, September 2015 -- Open an exisitng "All LVARS.txt" file to append to, or create it if it doesn't exist. -- It will go into the Modules folder because I've not included a full path (like "C:\....") -- By using "assert" you get an error message if this fails f = assert(io.open("ALL LVARS.txt","a+")) -- get aircraft name and air file name air, title = ipc.readStruct(0x3C00, "256STR", "256STR") air = air:gsub('%z','') title = title:gsub('%z','') -- write the text headings f:write("_______________________________________________________________\nTITLE, AIR FILE\n" .. title .. ", " .. air .. "\n_______________________________________________________________\n") i = 0 while i < 65536 do name = ipc.getLvarName(i) if name ~= nil then f:write("\"" .. name .. "\",\n") i = i + 1 else break end end -- tidy up at end ... f:write("\n____________________ END OF LIST ____________________\n\n") f:close() ipc.display("A pre-formatted L:VARs list has been created as FSX/Modules/ALL LVARS.txt", 0, 3) ipc.sleep(3000) -- end of program LVAR_SPECIFIC.lua Note - The lua below has the array preloaded with L:VARs "test1" thru "test4" as an example. -- "MONITOR SPECIFIC LVARS" fsuipc display, by Roman Stoviak, September 2015 --[[ NOTES - Enter each L:VAR to monitor by getting the "preformated" list provided by "LVARS_2_TXT.lua". Each L:VAR name MUST be surrounded in quotes and followed by a comma for each the array entry(s). One could use a single line for each L:VAR -or- Place all the L:VARs inline. EX. separate lines "test1", "test2", "test3", "test4", EX. same line "test1","test2","test3","test4", PLACE THE L:VAR LISTING IN THE ARRAY BELOW BETWEEN THE 2 COMMENTS CONTAINING "!!!!!" END NOTES ]] local monitor = { -- COMMENT !!!!! START ARRAY ON NEXT LINE !!!!! "test1", "test2", "test3", "test4", -- COMMENT !!!!! END ARRAY !!!!! } local size = table.getn(monitor) while 1 do local i = 1 local out = "" local disp = "" repeat out = ipc.readLvar(monitor[i]) disp = disp .. monitor[i] .. " = " .. out .. "\n" i = i + 1 until i == size + 1 ipc.display(disp) ipc.sleep(50) end
  21. This will permit you to trigger whatever sounds you wish with joystick buttons. I wanted to help others in the future, who may wish to accomplish in their cockpits, what I have. Therefore, I put together a short step by step instruction document in PDF format. See attached, Michael Lehkamp Sound Scripting in LUA.pdf
  22. MOVED FROM "USER CONTRIBUTIONS" SUBFORUM so it might attract answers ... Because I am trying to understand the scenary I did: Is something wrong in this diagram?
  23. Here is a Lua file that progressively apply and/or disengage brakes, adjustable in both directions, for those who only have a button for brakes. [iNSTALLATION] FS closed Copy the complete code block below, paste it into an empty .txt file & rename it Smooth_Brake.Lua Place the above file in the FS/Modules folder Add the following to the [Auto] section of the FSUIPC(4).ini file - X=Lua Smooth_Brake - Where X is the next available number in the [Auto] section. (pg. 42 - FSUIPC4 for Advanced Users.pdf) Comment out ( ; ) or remove the original brake button listing in the [buttons] section. Start FS Make sure the button is not programmed through the FS assignments dialog. For a simple, non-complex assignment to the joystick button see the picture below. For a complex assignment see pg. 22 - FSUIPC4 for Advanced Users.pdf - Using something similar to this for a button press - xx=CP(-0,11)0,0,CL6:S,211 and this for release - xx=CU(-0,11)0,0,CL6:C,211. Where 6 is the numbered lua under the [LuaFiles] section of FSUIPC(4).ini in my case as an example. Use the FSUIPC facility, "Reload Buttons", from the user interface in the Buttons tab to confirm assignment. Adjust user settings to ones own liking. Assign a keyboard key to reload the file using Lua Smooth Brake as the control sent to use for reloading tuning modifications. One can use the Logging facilities in FSUIPC, using the right hand side of the dialog (FSX + only), using 0BC4, 0BC6 & 0BC8 with a type of U16, display to FS Window, to help in adjusting user settings. The above settings result in this - 1=P0,0,CL6:S,211 2=U0,0,CL6:C,211 [uSAGE] Basically all this does is gradually increase (depending on settings) the brake strength as the assigned brake button is pushed. It also works in reverse, on brake disengagement. One could, for instance press the brake button for only 1 second and after that toggle the brakes on & off at a repetitive rate to keep, lets say, ~ 50% brake strength. It's much better than full on or full off. The settings as given below give around a 2.75 second span between brakes off to full brake strength. Smooth_Brake.Lua - --------------------- USER SETTINGS rate_on = 300 -- RATE AT WHICH BRAKES ARE APPLIED minimum = 3500 -- MINIMUM BRAKES ON FIRST APPLY = REQUIRED PERCENT * 16384 rate_off = 300 -- RATE AT WHICH BRAKES ARE RELEASED dis_pbrake = 1 -- DISENGAGE PARKING BRAKE ON BRAKE APPLICATION? REQUIRES A REAPPLY FOR BRAKE ACTIVATION! diff_brake_override = 0 -- !!!! GIVES AN ALTERNATE DIFFERENTIAL BRAKE AXIS PRIORITY OVER BRAKES -- EXAMPLE - THE "T_FLIGHT HOTAS" ALTERNATE AXIS ON THROTTLE SECTION -- SEE PG.1 "FSUIPC LUA LIBRARY" - "n = ipc.axis(joynum, "axis")" FOR MORE INFORMATION. --------------------- END USER SETTINGS function stop() brake = ipc.readUW(0x0BC4) -- Get Parking Brakes If Button Pressed And Parking Brake Disengage Is Active if ipc.testflag(211) == true and dis_pbrake == 1 then p_brake = ipc.readUW(0x0BC8) -- Disengage Parking Brakes If Set if p_brake == 32767 then ipc.control(65752, 0) end end -- Brakes On while brake < 16383 and ipc.testflag(211) == true do -- Differential Braking Override if diff_brake_override == 1 then -- REQUIRES CUSTOM ATTRIBUTES FOR SPECIFIC HARDWARE special = ipc.axis(0,"S") if special > 1000 or special < -1000 then brake = 0 break end end brake = math.min(16384, brake + rate_on) brake = math.max(minimum, brake) brake_shift = logic.Shl(brake, 16) + brake ipc.writeUD(0x0BC4, brake_shift) end -- Brakes Off while brake > 0 and ipc.testflag(211) == false do -- Differential Braking Override if diff_brake_override == 1 then -- REQUIRES CUSTOM ATTRIBUTES FOR SPECIFIC HARDWARE special = ipc.axis(0,"S") if special > 1000 or special < -1000 then brake = 0 break end end brake = brake - rate_off brake = math.max(0, brake) brake_shift = logic.Shl(brake, 16) + brake ipc.writeUD(0x0BC4, brake_shift) end end event.flag(211, "stop")
  24. Hi Pete, everyone, I'm having a problem triggering sound files using LUA. For example: 1. I have a wav file called firebell.wav 2. It is located in the root of drive D 3. FS9 is also located on drive D ( D:\Flight Simulator 9 ) 4. My LUA file is titled "firebell.lua" and is located in the FS9 modules folder So I load FS9 and go into the FSUIPC GUI, click on buttons, and press the button I want to trigger the wav file. It reads location in FSUIPC as 5,0. Next switch 5,1, next switch 5,2 and so on. So once I press the switch I want to associate with the wav file (5,1), I place a check in the "Select for FS Control" box. I then scroll down until I see the "firebell lua" and select it. I then hit ok and exit FSUIPC. I re-boot FS and push the switch. NOTHING. No sound file play. I've done this over and over placing the sound files on the C drive, FS9/sound directory etc. etc. - No luck Below is the contents of my LUA file. Any help appreciated. Mitch Sound.play("D:\\firebell.wav")
  25. Hello fellow simmers! I've been using lua in my FSX projects for some time now, and I love it. Simple yet powerful. Thank you Pete for implementing lua in fsuipc. But I can't really find a way to develop with it efficiently. While developing I often bind the lua scripts to be executed by key presses (often the numeric keys). And I use tail to keep an eye on the log file. This approach works but it feels a bit clumsy. Is there a better way of doing this? How do you develop? Do you have any tips, ideas or suggestions how one can develop more efficiently? Any thoughts on this Pete Dowson (or anyone)?