Jump to content

FSFIan

Members
  • Posts

    1301
  • Joined

  • Last visited

  • Days Won

    7

Everything posted by FSFIan

  1. This may be one of those things that only work in single player or for the host in MP. I played around with getFuel() in a MP mission without problems, but I was the only player/host. If it turns out that getFuel() does not work in MP, I can forget about the mission idea I am working on right now :mad:
  2. Not every gauge is available for export through MonitorSetup.lua. To get something like the radar altimeter display or a specific engine instrument on another screen, you need an Export.lua file that exports this data (e.g. the position of the engine gauge needle) over a network connection and a separate program that recreates the gauge from that data and displays it. For the A-10C and Ka-50, you can use Helios. I remember reading on the forums that someone added P-51 support too, but I am not aware of anything that exists right now that works with the Mig-21. My own Export.lua project, DCS-BIOS (which is more targeted to getting data to physical panels) also does not have Mig-21 support at this time.
  3. First, look up how to get the MFCD display onto a second monitor (search for MonitorSetup.lua). Then check the link in my sig to find out how to make other indicators available for export with that method.
  4. Whenever I want to know how to do something in the mission scripting environment using Lua, my first stop is often this page on the hoggit wiki. It has links to the official scripting engine docs and the MiST documentation. After that (or from memory), I know which functions will possibly do what I want. I did not find a function that tells me the current mass of an aircraft, but I know that the results of calling unit:getDesc() will probably have something useful. Now I know where to start, but I still don't know how those results look like. While I could probably infer that after looking hard enough at the "Structures" section of Part 2 of the official docs, a quicker way is trial and error. Once I know where to look, most of the time the next step is to fire up the interactive Lua console of DCS Witchcraft (see link in my sig). So I open my witchcraft-enabled test mission and evaluate the following Lua code in the console ("A10C-1" is the group name of an A-10C I am sitting in): local g = Group.getByName("A10C-1") local u = g:getUnit(1) return u:getDesc() I get the following result: { "Hmax": 10000, "Kab": 0, "Kmax": 0.52999997138977, "NyMax": 5.9000000953674, "NyMin": -2, "RCS": 10, "VyMax": 30, "attributes": { "Air": true, "All": true, "Battle airplanes": true, "Battleplanes": true, "NonAndLightArmoredUnits": true, "NonArmoredUnits": true, "Planes": true, "Refuelable": true }, "box": { "max": { "x": 7.6860585212708, "y": 2.3696703910828, "z": 9.4541301727295 }, "min": { "x": -9.1228017807007, "y": -1.2815840244293, "z": -9.4672021865845 } }, "category": 0, "displayName": "A-10C", "fuelMassMax": 5029, "life": 32, "massEmpty": 11739, "massMax": 21081, "range": 1500, "speedMax": 236, "speedMax0": 236, "speedMax10K": 134, "tankerType": 0, "typeName": "A-10C" } So the first try is this: local u = Group.getByName("A10C-1"):getUnit(1) local KG_TO_LBS = 2.2046226 local mass = u:getDesc().massEmpty mass = mass + u:getFuel()*u:getDesc().fuelMassMax return mass * KG_TO_LBS That gives me 31428 lbs. According to the rearming dialog, my current total mass is 36651. But when I remove all bombs and gun ammo, the rearming dialog shows 31424 lbs -- close enough! So let's try to take the ammunition into account: local g = Group.getByName("A10C-1") local u = g:getUnit(1) return u:getAmmo() result: [ { "count": 1150, "desc": { "box": { "max": { "x": 0.025108814239502, "y": 0.15063416957855, "z": 0.64480221271515 }, "min": { "x": -44.163108825684, "y": -0.16146284341812, "z": -0.64507895708084 } }, "category": 0, "displayName": "30mm AP", "life": 2, "typeName": "weapons.shells.GAU8_30_AP", "warhead": { "caliber": 30, "explosiveMass": 0, "mass": 0.36, "type": 0 } } }, { "count": 6, "desc": { "RCS": 0, "altMax": 12000, "altMin": 100, "box": { "max": { "x": 1.0492290258408, "y": 0.044821295887232, "z": 0.13964723050594 }, "min": { "x": -1.1737260818481, "y": -0.27638137340546, "z": -0.14316475391388 } }, "category": 3, "displayName": "Mk-82", "life": 2, "typeName": "weapons.bombs.Mk_82", "warhead": { "caliber": 279, "explosiveMass": 72, "mass": 72, "type": 1 } } } ] Trying to calculate empty mass + fuel mass + ammo mass: local u = Group.getByName("A10C-1"):getUnit(1) local KG_TO_LBS = 2.2046226 local mass = u:getDesc().massEmpty mass = mass + u:getFuel()*u:getDesc().fuelMassMax if u:getAmmo() then for _, item in pairs(u:getAmmo()) do mass = mass + item.count*item.desc.warhead.mass end end return mass * KG_TO_LBS The result is 33293 lbs, which is still way off from the 36651 lbs it should be. My guess is that item.desc.warhead.mass is, as it says, only the mass of the warhead itself and does not include the rest of the bomb. If you require accurate values, I guess you could build a database of the warhead+rest-of-bomb mass through experimentation.
  5. I copied the event handling stuff from the first pygame beginner tutorial I came across. After reading the documentation for the pygame "event" module, the proper way to do things seems to be: loop through the results of pygame.event.get() and call pygame.event.pump() in the main loop I have updated my example on GitHub to handle events in this manner. I have also added example code that shows how to connect using UDP. UDP is the preferred method, because it does not care about the order in which things are started. Each UDPSender in BIOSConfig.lua and each TCP connection will add some small performance penalty, but I don't think a handful of them will make any noticeable difference. Performance-wise, the best option is multicast UDP, which also requires no configuration, but I would only rely on that as long as the receiving application is on the same computer as DCS.
  6. DCS-BIOS also runs a TCP server, which I connected to in my example. If you change the IP address to that of the DCS computer it should work. Alternatively, replace it with your already working UDP code and feed the incoming data to parser.processByte() one byte at a time.
  7. I may have confused "altitude in the editor" with "altitude in the mission file format". If you have set the helicopters to 200 ft AGL and they climb to more than 1500 ft, are you sure the "above 1500 ft" figure is given in AGL as well and not in MSL?
  8. IIRC all the altitudes in the editor are in meters (and speeds in km/h). Although 200 m equal 657 ft, so maybe there is some confusion about altitude MSL vs altitude above ground level involved as well.
  9. Just listened to Episode 6, great stuff! I explored a lot of the mission scripting environment out of curiosity, but never ended up making missions myself because I didn't really know what to build. After listening to this, I might give this a try again if I ever find the time. At the end you mentioned that you would really like a 3D editor. Are you aware of DCS Witchcraft? It's not a full-featured editor, but it does allow you to adjust positions of existing units and static objects in the 3D view. Skip to about 9:30 in the tutorial video to see it in action. In another project of mine, the browser-based mission planner, I explored the second thing you mentioned at the end -- planning your mission before you fly it. It works (you plan the mission, then download the modified .miz file), but I stopped working on it because I got frustrated with the limitations of the current scripting engine (no way to alter client waypoints during the mission). Although in combination with DCS-BIOS, you could think of a client app that would type it into your CDU for you... if only I didn't need to eat I could spend two or three years tinkering with DCS non-stop.
  10. I assume that -- like the rest of DCS -- the DLL is 64-bit and you are using a 32-bit Lua interpreter. Use "luae.exe" in the "bin" folder of your DCS: World installation. In that case, require("minizip") will also work in addition to require("lua-minizip").
  11. Only if you treat them as push buttons. You can program your Arduino board to push and release a joystick button (or send a "TOGGLE" action if you are using DCS-BIOS) every time the switch changes state. That will make your toggle switch work as long as it starts out "in sync" with the sim. I think the Leo Bodnar boards have a similar feature.
  12. Bonus points if they design it in a way so people who like to void warranties can make it into a HOTAS with a hacksaw, some hookup wires and a soldering iron!
  13. I was able to reproduce it here. Before sending it to the browser, the result of a Lua snippet is encoded in JSON format (see json.org). The problem is that the unit DB has numeric keys, and the only way to represent those in JSON is with an array, so you end up with an array with lots of null entries. The resulting JSON string is so huge (JSON-encoded mist.DBs.aliveUnits is about 14x larger than the result of mist.utils.tableShow(_G)!) that witchcraft simply chokes on it. I could not find out why exactly, but I assume there are a few algorithms behind all the string handling that run in at least O(n^2). Workaround: return mist.utils.tableShow(mist.DBs.aliveUnits) This uses MiST's own serialization function which actually knows how to properly serialize Lua objects. Returning objects works, too, as long as the object can be represented as JSON, which will work in most simple cases. The following things cannot be represented in JSON and require the use of mist.utils.tableShow or similar: tables that have both string and numeric keys functions userdata For tables with numeric keys which are not consecutive (i.e. mist.DBs.aliveUnits), mist.utils.tableShow is strongly recommended. By the way, _G is a special variable that represents the "global environment". It includes everything your script has access to. If you have not already, try "return mist.utils.tableShow(_G)", wait half a minute and be amazed :)
  14. Please clarify what you mean by "access" and provide exact steps to reproduce. I have dumped _G with witchcraft before ("return mist.utils.tableShow(_G)"), which of course implicitly accesses the real-time DBs. If you request a lot of data, it is normal for DCS to slow down (freeze) while witchcraft is serializing all that data to JSON to send to the browser. For a complete _G dump, that can take one or two minutes, but there will eventually be a response. (And then it takes a while for your browser to actually render that data, but at that point, DCS should be back to normal.)
  15. I have updated my example to show how to draw the CDU using Python 2 and pygame. To make it work, you need to copy C:\Program Files\Eagle Dynamics\DCS World\Mods\aircraft\A-10C\Cockpit\Resources\IndicationTextures\font_A-10_CDU.tga to the directory you start the script from. It should handle all the special symbols correctly (refer to this commit message for the exact mapping). Tested on 64-bit Linux with Python 2.7 and pygame 1.9.1 and on 64-bit Windows 7 using 32-bit Python 2.7 and the (32-bit) pygame 1.9.1 package from pygame.org.
  16. I think you want to check "visible before start" and "late activation" and then have a "group activate" trigger with an appropriate condition. (Disclaimer: This is untested, so it may or may not be complete bullshit. I have never built a real mission. Anything I think I know about mission building and triggers was learned by osmosis while researching the Lua scripting side of things for the various projects linked in my sig.)
  17. You can program a real toggle switch to send a "toggle" command each time it is flipped. If you do end up in a situation where the physical switch is out-of-sync with the virtual one, flip the virtual one with the keyboard to match them up. And as long as there is a separate action in DCS for each switch setting, you can also use switches that have more than two positions.
  18. Another way to get really high precision trim wheels is to cannibalize an old analog PS/2 mouse. The image below is from a project I did last year over the easter holidays. Unfortunately I lost the code a day later when my SSD died. I used it with the A2A P-51 in FSX and was easily able to trim into straight and level flight within +/- 10 fpm climb rate (the scroll wheel was used for rudder trim). Link to image: https://www.dropbox.com/s/xtz0vfub5opngeq/20130331_005.jpg?dl=0
  19. There is no difference if by "switch" you mean "push button". Things get interesting when you consider, for example, toggle switches. The CICU on/off switch in the A-10C is a good example. In the DCS options, there is only a "CICU on/off" keybinding. If you have a real toggle switch on your panel and your microcontroller detects that this was just switched to the "on" position, you want to tell DCS "put the CICU switch to ON" (and because the A-10C has a clickable cockpit, you can through Export.lua). If the A-10C were a FC3 aircraft, you could only tell DCS to "toggle the CICU switch", which would give the wrong result when the switch in the virtual cockpit was already on. The other major difference between FC3 and "clickable cockpit" aircraft is in the amount of available data. When you said "maybe add some LEDs", what exactly were you thinking about? Unfortunately, chances are that there is no way to get the status of an individual indicator light in a FC3 plane.
  20. The total resistance of your potentiometer does not matter. A pot has three contacts, which I will call 1, 2 (the ones on the end) and S (slider). Electrically, it looks like two resistors in series: 1 --- R1 --- S --- R2 --- 2 By moving the slider, you change how the total resistance of the pot is distributed over R1 and R2 (i.e. R1+R2 is the constant total resistance of your pot). When you wire up "1" to Vcc, "S" to your ADC and "2" to ground, R1 and R2 form a voltage divider, so only the relative resistance matters. The amount of turns you need to go through the entire range is a mechanical property of your potentiometer. The total resistance will influence how much current flows. Too low (less than 125 ohm) and you overload your Arduino pin which can only handle 40 mA, too high (probably more than several hundred kOhm) and your signal will pick up more noise. Any pot between 1k and 100k should be fine.
  21. You can connect an Arduino to any DCS aircraft. The level of interaction that is possible and the amount of effort it requires depends on your aircraft. For FC3-level aircraft, the amount of data you can get out of DCS through Export.lua is very limited (basics like pitch, bank, heading, altitude, but not the state of every single switch and indicator light). The commands you can send are generally limited to those you can also bind via the DCS options (as opposed to the "clickable cockpit" aircraft, where you can set the absolute state of most toggle switches even if the DCS options only have a "toggle" binding available). Where did you get the idea that the A-10C is the only aircraft that can be connected to an Arduino?
  22. Also, after you have pressed F7 (or F2 / F9 / whatever), you can press Ctrl+F11 to switch to the free flight camera at your current position (without jumping to an airport). This only works if the free flight camera is otherwise available (i.e. not disabled in the mission).
  23. It happens to me too occasionally (I am using Cap Loz' A-10C profile). Usually it stops after a few seconds. If it doesn't, I stop the profile and start it again and that takes care of it. I cannot remember a single occasion where it happened more than once per aircraft lifetime, so it's not a big deal. It also always happens after getting into the plane or starting the profile, not in the middle of a flight.
  24. Yes, Helios still works with current DCS versions. It was always free, now it is also open-source. For the A-10C, Cap Loz has made an excellent profile that I am using on a 23" 1920x1080 touch screen. I can now operate every control without the mouse. The profile includes modified Lua files to enable the export of the CMSP, CMSC, RWR, and Clock displays. They may not work with current DCS versions, I use the method linked in my sig instead.
×
×
  • Create New...