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


Forums

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

Categories

There are no results to display.


Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

Found 53 results

  1. 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")
  2. Hi all, I have a few technical questions before buying FSUIPC7 because I'm not sure about what I can acheive from FSUIPC7/LUA scripts regarding the SimConnect Indexed variables. As example, I take the Asobo Airbus A320 . Someone has already reported that Offset 07D4 [AP ALTITUDE VALUE] is not working. He gave up thinking it was a bug. I found that Offset 281C or 3102 [Master Battery Switch] are not working neither. After having looked into Microsoft SDK and SimConnect, I found that the A320 FCU AP Altitude is linked to an indexed SimVar [AUTOPILOT ALTITUDE LOCK VAR:3] It seems that FSUIPC7 is not natively looking at this SimVar. Both A320 Battery Push Buttons are a bit more tricky: For the left battery Push button: First, set SimVar BUS LOOKUP INDEX to value 10 Then the state of the left battery can be read at indexed SimVar BUS CONNECTION ON:6 For the right battery Push button: First, set SimVar BUS LOOKUP INDEX to value 11 Then the state of the right battery can be read at indexed SimVar BUS CONNECTION ON:6 So here are my questions : Q1. Is it possible from FSUIPC7 (I guess with Lua Scripts) to access the Indexed SimVars and map them to a free FSUIPC7 offset ? I know it *was* possible to access Local SimVars with Lua scripts, but I want to be sure that we can query the indexed variables, for instance like this : ipc.writeXXX("A:BUS LOOKUP INDEX", 10) LeftBattery = ipc.readXXX("A:BUS CONNECTION ON:6") ipc.writeXXX("A:BUS LOOKUP INDEX", 11) RightBattery = ipc.readXXX("A:BUS CONNECTION ON:6") Q2. Is it possible from FSUIPC7 to log all SimVars and Indexed SimVars ? (in order to identify which one is changing after a few clicks in the virtual cockpit) Oh god, the BUS LOOKUP UP thing is not going to help with this kind of feature... --- Regarding the Local SimVar, I understand that FSUIPC7 has no way to access them. And in fact, Microsoft SimConnect SDK does not provide a way to do this. The only workaround for now is to create a fake gauge and put the local SimVar in the Client Data Area. Then FSUIPC7 would be able to read/write the Local SimVar through the SimConnect SDK.
  3. This was done just to see if it could be made to work. ( too much coffee ☕, insomnia & boredom also contributed ) For the advanced FSUIPC user, gauge programmer, cockpit builder, lua tweaker etc.., a problem arises, at times, where the aircraft designer has code that constantly fires commands into the sim. 👎👎👎 When it comes time to do some logging, for instance, to see what control is being fired, on user input, is tough to find in the FSUIPC console window. The [General] "DontLogThese=" entry in the FSUIPC.ini does a fine job of blocking these. Of course, you could do a text log of the Events (non-axis controls), open the log and find the offending controls and then build up an entry for "DontLogThese=". This lua does it automatically and appends to a text file, appending it so you can have a library of the offending aircraft. An output example of my testing : NOTES : axis pan heading 66504 axis pan pitch 66503 mouse look toggle 66734 misc maddog 70646 --------------------------------------------- Fly The Maddog X MD-82 - North Central N760NC [General] DontLogThese=66557,66556,66523,66479,66478,66466,66463,66442,66239,65962,65836,65833,65832,65709,65708,65707, PMDG DC-6B PMDG House (N6PM | 2017) [General] DontLogThese=66818,66659,66508,66073,66060,65786, P-51D civ 'Providence Permittin' [General] DontLogThese=66508,66507,65764, Lockheed Constellation L049, C69 [General] DontLogThese=66507,65922,65921,65920,65919, 666 F-16D AK375 F [General] DontLogThese=66707,66073,66065,66057,66031, When needed : 1) Assign a temporary key to run the lua (as you named it) 2) Run it with the aircraft loaded, keeping your hands off of any controls ( axis or other ) 3) When its done, it will report so, making, or appending, a file named "NoLogReport.txt" in the modules folder (or wherever FSUIPC is installed) 4) Copy the aircraft's report and paste in to the FSUIPC.ini [General] section, replacing the line if already there. 5) In the FSUIPC UI, go to the Axis Assignment tab and click on Reload All Assignments. Done, the offending controls are now blocked. This was only tested in FSX, I would imagine it would still work from FS9 thru P3Dv4+. The lua : -- USER SETTINGS local startCtrl = 65537 -- THE STARTING CONTROL NUMBER TO BE SCANNED local endCtrl = 68309 -- THE ENDING CONTROL NUMBER TO BE SCANNED local runTime = 3 -- RUN THE CONTROL RECORDER FOR HOW MANY SECONDS, >= 2 (NOT REALLY LEGIT, THERE IS A "LOT" OF BACKED UP FUNCTION CALLS!) -- END USER SETTINGS local cntrlsOut = {} local doesContain = 0 local acftTitle = ipc.readSTR(0x3D00, 256) acftTitle = acftTitle:gsub('%z','') local outString = "\n\n" .. acftTitle .. "\n[General]\nDontLogThese=" function logControl(controlnum, param) doesContain = 0 for _, value in pairs(cntrlsOut) do if value == controlnum then doesContain = 1 end end if doesContain == 0 then table.insert(cntrlsOut, 1, controlnum) end end function countDown(timer) if runTime == 0 then file = assert(io.open("NoLogReport.txt","a+")) for i = 1, #cntrlsOut, 1 do outString = outString .. cntrlsOut[i] .. "," end file:write(outString) file:close() ipc.display("Modules\\NoLogReport.txt was created", 1) ipc.sleep(1000) -- !!! OPTION, OPEN UP THE REPORT.TXT AND FSUIPC.INI -- !!! UNCOMMENT & CHANGE THE PATHS OF YOUR PREFERRED EDITOR AND OUTPUT FILE(S) -- handle1, error1 = ext.runif("E:/Notepad++/notepad++.exe","G:/FSX/Modules/NoLogReport.txt") -- handle2, error2 = ext.runif("E:/Notepad++/notepad++.exe","G:/FSX/Modules/FSUIPC4.ini") -- !!! UNCOMMENT IF THE ABOVE DOES NOT WORK, PROVIDES ERROR DISPLAY -- ipc.display(handle1 .. error1 .. "\n" .. handle2 .. error2, 0, 5) -- ipc.sleep(5000) ipc.exit() end runTime = runTime - 1 end for i = startCtrl, endCtrl, 1 do event.control(i, "logControl") end event.timer(1000, "countDown") Roman
  4. Hi there, I am having a very strange problem with FSUIPC3 in FS2004. A few weeks ago, it suddenly decided to no longer load any of my LUA files. This problem came seemingly out of nowhere. It is not any one specific LUA file, but any LUA file at all. I have tried: Reinstalling FSUIPC Reinstalling FS2004 The specific LUA file I want to use is called FreezeAlt.lua and it looks like this: althi = ipc.readSD(0x574) altlo = ipc.readUD(0x570) while 1 do ipc.sleep(10) -- 10 mSecs = 100 times per sec ipc.writeUD(0x570,altlo) ipc.writeSD(0x574,althi) end I have also noticed after reinstalling FSUIPC, it has not generated an FSUIPC.ini file. Below is a screenshot from FS2004. The LUA module would normally show up above LuaKillAll. Any help is greatly appreciated. 🙂
  5. Hi all, I want to add two offsets to FSUIPC in order to save the value of two Q400 variable. These two offsets will be read by Spad.neXt. So I wrote a LUA script that reads variables value (could be 0 or 255) and writes they to FSUIPC offset 66C0 and 66C3. I need to read both variables continuously so I thought of writing a C# program that every 50ms would write to the 0x0D70 offset, and pass the Lua command with the name of my lua script. From what I understand when the 0x0D70 offset is written FSUIPC executes the indicated script via the indicated command, so I expect to have FSUIPC offset 66C0 and 66C3 filled every 50ms with the value of Q400's variables and ready for Spad.neXt. Any comment/criticism/suggestion about this flow? Cheers, Alessandro
  6. *** Moved from FAQ Support Forum *** Dear fellow simmers, it is a long time since I last modified my flight simulator setup, about 10 years and more! I had built my own console with switches and LEDs, to interface with FSX. It was working until now with FSX and Windows 7. I had programmed it myself using FSUIPC (4 I think) and Visual Basic. Now, just 2 weeks ago I installed Windows 10 and also P3D V4.5. When trying my old program (called RealSwitches) some switches still brought the correct reactions in P3D as they did before in FSX. For example gear up and down still worked. However many things are not working. So I decided to go ahead and write a new program for my old switch console. Reading the FSUIPC documentation I discovered Lua and did some experimenting with it. It generally works, and I tried some of the examples. But what I cannot get working is even the simplest routine using the Lua event library. No event fires. I tried for example timer events and key events. I thought maybe someone here knows or knows where to look. Here is my Lua code, which should just react on pressing the "V" key. From looking at the log file for the lua script I can see that the event function KeyReceived() is never called. The same was the case when I tried with timer events. ipc.display("eins") gCount = 10 ----------------------------------------------------- function KeyReceived() ipc.log("gotcha") gCount = gCount-1 end ------------------------- init ------------------------ event.key(TIC_MS, 86, 0, "KeyReceived") -- Key v (normally make screenshot) event.cancel("KeyReceived") ipc.sleep(50) event.key(TIC_MS, 86, 0, "KeyReceived") -- Key v (normally make screenshot) ---------------------------- loop, event handlers doing their job while gCount>0 do ipc.sleep(50) end ---------------------------- close sOutput = "Fertig" ipc.display(sOutput) ipc.exit() Any help would be most appreciated. Thank you Detlef
  7. 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]) if out == nil then -- NEW SECTION TO KEEP LUA ALIVE IN CERTAIN SITUATIONS out = "no value" end disp = disp .. monitor[i] .. " = " .. out .. "\n" i = i + 1 until i == size + 1 ipc.display(disp) ipc.sleep(50) end
  8. Hello, I am trying to extract variables from the P3DV4 and store them on a CSV. The given example works great for me. But when I try to write the code myself it doesn't work. Moreover, when I just copy paste the code with varied parameters I still get some error. I have attached the error below along with the code. Please do help me out. CODE-------------------------------------------------------------------------------------------------------------------------------------------- -- "Record to CSV" example data logging LUA plug-in, by Pete Dowson, September 2008 -- Open an exisitng "FSrecord.csv" 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("FSrecord.csv","a+")) -- write the CSV column headings f:write("\r\vs,mach,bank,BHP,ff,weight,alt,ias,tas,gs\n") -- note the elapsed mSecs count now so can provide relative mSec timing column time0 = ipc.elapsedtime() -- Loop until our Flag 0 is set (by assigned FSUIPC control) while not ipc.testflag(0) do -- Set the timestamp for this loop time = ipc.elapsedtime() - time0 -- Read all the data we want from FSUIPC mach = ipc.readUW(0x11C6) -- mach number vs = ipc.readSW(0x842) -- vertical speed bank = ipc.readSD(0x057C) -- bank angle bhp = ipc.readDBL(0x3820) -- Brake horse power ff = ipc.readDBL(0x0918) -- fuel flow in pounds per hour fw = ipc.readUD(0x1264) -- fuel quantity in gallons alt = ipc.readSD(0x3324) --altimeter reading in feet ias = ipc.readUD(0x02BC) --indicated airspeed --tas = ipc.readUD(0x02B8) --true airspeed --gs = ipc.readUD(0x02B4) --groundspeed ----------------------conversion----------------------- mach = mach / 20480 vs = vs * -3.28084 bank = bank * 360/ (4294967296) --conversion seems wrong bhp = bhp / 570 fw = fw * 6.17 ias = ias / 128 -- but only log this time IF we aren't in an FS menu, or loading scenery -- (check the "ready-to-fly" flag word at 3364) -- and provided we are not paused (flagged at 0264) if (ipc.readUW(0x3364) == 0) and (ipc.readUW(0x0264) == 0) then -- write a CSV line to the open file f:write(string.format("%d,%.3f,%.2f,%.2f,%.2f,%.2f,%d,%d\n",vs,mach,bank,bhp,ff,fw,alt,ias)) end -- 20 times per second, roughly (allow 2 mSecs overhead) ipc.sleep(48) end -- tidy up at end ... f:write("\n") f:close() -- end of example program ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------ERROR------------------------------------------------- ********* LUA: "parameters test1" Log [from FSUIPC version 5.103] ********* 886422 System time = 23/06/2019 08:16:21, Simulator time = 14:05:16 (19:05Z) 886422 LUA: beginning "G:\P3Dv4\New folder\Modules\parameters test1.lua" 886422 *** LUA Error: G:\P3Dv4\New folder\Modules\parameters test1.lua:1: unexpected symbol near 'ĂŻ' 886422 >>> Thread forced exit (ipc.exit or os.exit) <<< 886422 System time = 23/06/2019 08:16:21, Simulator time = 14:05:16 (19:05Z) ********* LUA execution terminated: Log Closed ********* *************************************__________________________________________************************************ Thanks in advance
  9. 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
  10. Hi, I searched the forum before I post and I saw that someone tried to communicate the Lua script and Arduino. We're sharing the same purposes. Let me say the problem I deal: For PMDG 737, I can control any button, switch in the simulation by sending data from Arduino to Lua script. Also, I have no problem to send data from Lua script to Arduino by using Lvar list in FSUIPC documents. However, I can't read the state of any warning light as Overheat Lights in the overhead panel. Only need to know, what should be the way of reading the state of lights in PMDG 737. If there is a small example or showing a way to go, I will be grateful 🙂
  11. Hello, i hope anyone can help. I am a starter in LUA, but i have to read a Bit out of a 2 Byte Offset. The Offset is 0x04F0 and i want to read Bit number 14 and 6. I tried local psCMD1 = ipc.readUB(0x4F0) for Bit 0 and it works, but how can i read Bit number 14 and 6 ? Pls, can anyone help her? Thanks Matthias
  12. Hello: I am just starting to scratch the surface of using Lua scripts with FSUIPC. I am trying to solve a problem with the Milviz C310 where the prop condition levers do not move into the feather range using my CH Products throttle quadrant. Despite accurate calibration, moving the hardware prop levers aft of the detents does not move the software levers into the feather range, nor does the prop feather animation get displayed. Instead, the Milviz C310 requires users to right-click the prop lever knobs to feather the props. My current calibration does work for other default and payware prop aircraft. In an effort to have the C310 props go into the feather range using my quadrant, I tried using the FSUIPC Axis Assignments GUI to stack two ranges to the prop levers, aft of the detents, to assign the commands: ~ PROP_PITCH1_SET (with a parameter of -1) ~ TOGGLE_FEATHER_SWITCH_1 After doing so, when I move the hardware prop lever aft of the detent, I can see the commands being set using the FSUIPC log as expected; but the animation in the sim does not move the condition levers to the feather range, and the prop feather animation is not displayed. On the Milviz support forum, the aircraft's developer provided a snippet of right mouse click event code that checks a boolean L variable called Prop1_Feathered. The Prop1_Feathered variable represents the feather animation. If the Prop1_Feathered variable is false, then PROP_PITCH1_SET is set to -1 and the TOGGLE_FEATHER_SWITCH_1 command is called, else the reciprocal values are set. This is done for both the left and the right engines. From Milviz: if{ (L:Prop1_Feathered,bool) ! if { 1 (>L:Prop1_Feathered,bool) -1 (>K:PROP_PITCH1_SET) (>K:TOGGLE_FEATHER_SWITCH_1) } els{ 0 (>L:Prop1_Feathered,bool) 0 (>K:PROP_PITCH1_SET) (>K:TOGGLE_FEATHER_SWITCH_1) } } So it seems I need to script the following: If prop 1 axis range is between two values (aft of hardware detent), then set variable L:Prop1_Feathered to true set PROP_PITCH1_SET -1 toggle TOGGLE_FEATHER_SWITCH_1 When leaving the prop 1 axis feather range (forward of hardware detent), then set variable L:Prop1_Feathered to false set PROP_PITCH1_SET 0 toggle TOGGLE_FEATHER_SWITCH_1 I'm not sure, but the latter part of the logic may not be necessary as I suspect that existing Milviz code will set the prop as soon as I move out of the feathered range - will need to test this. Based on what I've read, I think I am supposed to use the FSUIPC GUI to reference a script file, that I create in the Modules folder, that gets called when the axis range is entered or exited. I also suppose that my script file could have a function/method like FeatherProp(int) that accepts one variable: ~ int EngineNumber So my pseudo code might look something like this: FeatherProp(EngineNumber(int) { Feathered bool; if (EngineNumber == 1) { //Getting the current value of the Prop1_Feathered animation variable will likely look something like this Feathered = ipc.readLvar(“Prop1_Feathered”); //Setting the reciprical of the current “Prop1_Feathered” variable may look like this ipc.writeLvar("Prop1_Feathered", !Feathered); //Calling the Toggle Feather Switch command might look like this ipc.control("TOGGLE_FEATHER_SWITCH_1"); if(!Feathered) { //Setting the prop pitch might look like this ipc.control("PROP_PITCH1_SET", -1); } else { ipc.control("PROP_PITCH1_SET", 0); } } else { //Getting the current value of the Prop2_Feathered variable will likely look something like this Feathered = ipc.readLvar(“Prop2_Feathered”); //Setting the reciprocal of the current “Prop2_Feathered” variable may look like this ipc.writeLvar("Prop2_Feathered", !Feathered); //Calling the Toggle Feather Switch command might look like this ipc.control("TOGGLE_FEATHER_SWITCH_2"); if(!Feathered) { //Setting the prop pitch might look like this ipc.control("PROP_PITCH2_SET", -1); } else { ipc.control("PROP_PITCH2_SET", 0); } } } As you can see, I'm a C# developer, so my pseudo code looks nothing like Lua script yet, I still need to work that part out... I have a few questions regarding key concepts of Lua scripting: Generally speaking, am I on the right track from a conceptual standpoint? Can the variable L:Prop1_Feathered (mentioned by the aircraft's developer) be referenced by name in my script, or do I need to log the variables running in the sim and reference the variable using some returned int or hex that represents the L:Prop1_Feathered animation variable? How do I reference my script file using the FSUIPC GUI? Specifically, how do I call my script file's FeatherProp() method passing in the engine number parameter when my hardware prop lever is aft of the detent? On the Axis assignment tab? Am I using the correct IPC commands to read and set my L variable? Am I using the correct IPC commands to set my prop pitch values? Am I using the correct IPC commands to toggle my feather switches? Thank you for your patience as I try to code my first Lua script. Sincerely, Chris
  13. Hello, let me start by thanking Pete for his great work! :-) I am trying to replace the use of link2fs with lua-scripts. link2fs is great and it works but it seems to be no longer supported and while it finally seems to work with P3D V4 again, sooner or later it might cause problems. With the help of fess' and other examples online, I've written the following short script to adjust the QNH. I have verified using the link2fs traffic monitor that the arduino really sends "C25" and "C26" with linefeeds. The "Arduino_Data"-function also gets called, whenever I turn the rotary encoder. But that is as good as it gets. :-/ When I turn the rotary encoder slowly, nothing further happens. No datastring gets shown, nothing happens to the QNH. With the addition of the 50ms ipc.sleep before the datastring is read, the ipc.controls get executed when I turn the rotary encoder fast enough. (I assume that this happens when the com port buffer holds two Cxx-commands, because the datastring-readout that is shown in these case reads "C25C2", so one character is missing. When I am giving out the string length 'n', it is either 0, 5, 10 or 15. Something seems to quantize the datastring to multiples of 5. When I turn other encoders however, whose command is longer (e.g. "Y010"), n is 0, 6, 12, ... I've run out of ideas where the error might be and I'd be thankful for every suggetion where to look. Kind regards from Munich, Frank -------------------------------------------------------- --- VARIABLE INIT -------------------------------------- feet_per_meter = 3.28083989501312 port_number = "3" -- Change Port Number for your Arduino speed = 115200 handshake = 0 serial_wait = 20 -------------------------------------------------------- --- SERIAL COMMUNICATION INIT -------------------------- SwitchPanel_Com_Port = com.open("COM"..port_number, speed, handshake) if SwitchPanel_Com_Port == 0 then ipc.display("Could not open Switch Panel at Com Port"..port_number,5) --ipc.exit() else ipc.display("Switch Panel connected at Com Port "..port_number,5) end ipc.display("SwitchPanel script loaded", 10) -- TEMP -------------------------------------------------------- --- INPUTS --------------------------------------------- -------------------------------------------------------- function Arduino_Data(SwitchPanel_Com_Port, datastring, length) -- the code always gets here ipc.sleep(50) datastring = com.read(SwitchPanel_Com_Port,50,1) ipc.lineDisplay(datastring,-32) -- TEMP if (string.find(datastring, "C25")) then -- Increase QNH ipc.control(65883,0) end if (string.find(datastring, "C26")) then -- Decrease QNH ipc.control(65884,0) end --ipc.sleep(serial_wait) -- needed??? end -------------------------------------------------------- --- OUTPUTS -------------------------------------------- -------------------------------------------------------- function call_xpndr (offset, value) value = string.format("%04x", value) --ipc.display(value) com.write (Arduino_Com_Port, "=J"..value) end -------------------------------------------------------- --- EVENTS --------------------------------------------- -------------------------------------------------------- event.com(SwitchPanel_Com_Port, 50,1, "Arduino_Data") event.offset (0x0354, "UW", "call_xpndr") -- transponder
  14. Hello everyone,I made a Home cockpit real size of Cessna 182 and I would make my G1000 using FSUIPC to be compatible with A2A C182 Gauges.A2A use LVAR on their Aircrafts and especially on the Gauges, that's why my G1000 send me wrong values (For example, I have 1400 RPM on my G1000 when the Plane is at 2500 RPM).I'm not a LUA specialist and I'm cherching a LUA Pro that can help me on this code. We can speak about the Modality on MP.Waiting for your answers.Kind regardsLudo
  15. FSUIPC version 4972 Hi, I am trying to write to a local variable in CaptainSim's C130 in fsx using a Lua file. There's a switch in the VC that I want to automate. The FSUIPC log shows an error for this action: ipc.writeLVar("L:pRpm1ButtonPos",dummy) To make sure the variable exists I added a ReadLvar to the code. C130.lua 109 function rpmLow() 110 state=ipc.readLvar("L:pRpm1ButtonPos") 111 ipc.display("RPM: "..state,1) 112 dummy=1 113 ipc.writeLVar("L:pRpm1ButtonPos",dummy) 114 end 141 event.button("D", 5, 1, "rpmLow") The read works, the result 1 or 0 is showing in the display window according to the position of the switch in the virtual cockpit. Log: I don't understand what the "nil value' means here. How can I fix this? Thanks.
  16. Hi Pete, Been putzing around with a little trick found on FSDeveloper regarding corrected fuel flow & keeping turboprops running away during start and other conditions. It uses (>C:SIMVARS:TURB ENG CORRECTED FF:1, pounds per hour) through the XMLTools.dll interface. It works well but needs gauge coding per aircraft. I was trying to get this to work using lua by writing to 0x2020 (& the 3 others) so it could work globally on all turboprops. The feedback is --- doesn't work. The following code was inside of a while - do loop which does work perfectly but there was no return as wanted via logging. ipc.writeDBL(0x2020, 200) Tested some others too w/ ?-SimC in the write column - no go. I guess "it is what it is", just feedback is all. I know you're busy with all the P3Dv4 stuff, but if you ever get around to looking into it, getting the "Turbine Engine # corrected fuel flow" & "Reciprocating engine # starter torque" (another trick) working, both ?-SimC for writes, would be "the cat's meow" ;-) FSX Acceleration / FSUIPC v4.971b Regards, Roman
  17. 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
  18. 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
  19. 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
  20. 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
  21. 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
  22. 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.
  23. 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 ...
  24. 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 !
  25. 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
×
×
  • 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.