Jump to content

A bit of my progress in learning DCS and a few questions


Recommended Posts

Hey guys,

 

Lately I've been learning the process of modding for DCS and I got very interested based on what seems possible to do so far. The video below is a partial illustration of what I've been learning so far, a quick test of a HUD with an early implementation of a pitch ladder, with some indicators so I can test it's precision.

 

 

 

I've been reading many forum threads, specially the Wunderluft and the F-104, but, when it comes to visualizing exactly what functions, variables, etc. are accessible by code, I feel I'm still not able to see the big picture.

 

Probably because I'm not experienced with Lua, my experience with modding was many many years ago with Unreal Tournament 2004 (any Unreal modders here?), UnrealScript being the language that I knew. The thing with UnrealScript was that every function, variable, class, etc. that was available for use was declared in the base script code that came with the game, so even if there was no guide or explanations on how to use them, by reading their names you could end up learning a lot by trial and error. With Lua it seems different, you can discover many of the available functions/variables inside the "_G" and inside other data by the use of table iterators like the "generic for", but it doesn't seem to be all. I still have to dive more into Lua.org site to have a better understanding of how functions/variables can be found (if at all).

 

Another important aspect I'm trying to learn is which Lua scripts are being called by the engine and when, and which functions/variables inside these scripts are being called by the engine and when. Some of them are explained in the Wunderluft example, like "entry.lua", "device_init.lua", etc., but what else is the engine scannig for in the Lua files?

 

I guess this is my question... how to have an idea of the big picture...

 

Thanks!

My DCS modding videos:

 

Modules I own so far:

Black Shark 2, FC3, UH-1H, M-2000C, A-10C, MiG-21, Gazelle, Nevada map

Link to comment
Share on other sites

  • 2 weeks later...

Update and more questions lol...

 

First the update: The video below shows the velocity vector / flight path marker that I've just created for the mod, and an update to the pitch ladder form the video before, so it now moves centered at the velocity vector. Some cool spatial geometry and trigonometry math coded for this. I've also created the DRIFT C/O input switch to switch the velocity vector between 2 modes: wind drift on and wind drift off. With wind drift on, the velocity vector will show the exact flight path of the aircraft (including wind), while with wind drift off it will show the path as if there was no wind. The pitch ladder stays aligned with the world's horizon, while moving around always centered at the velocity vector, as it all should be in the real aircraft.

 

 

 

 

 

Now back on the topic of finding what functions / variables are available for modders in DCS...

 

Calling get_base_data() from inside the "avLuaDevice" will return me a table with all the functions get_base_data() contains and I can see all of these functions' names by doing a generic for loop on that table.

 

Also, from inside "avLuaDevice" I can call GetDevice() on other devices and that will also return me a table, but it doesn't contain fuctions, it contains a "userdata" which I can't see. BUT I can call getmetatable() for the table and it will give me another table (the table's metatable) and if I use the generic for on this metatable I can find another table inside it (lol...) which contains the functions. Using the generic for on this final table I can see the names of these functions.

 

BUT, trying to use any of these two procedures above to find all the functionality available inside, for example, a HUD element, doesn't work. Calling CreateElement("ceMeshPoly") or CreateElement "ceMeshPoly", for example, returns a userdata that I can't see inside and it has no metatable associated with it. EDIT: It does have a metatable, but it contains two functions: __index and __newindex and trying to call those functions gives me error.... I'd love if someone told me I'm missing something and that there is indeed a way of finding all the functionality inside the element. I've found this VERY helpful post by Gyrovague and it looks like there's no way to see a complete list of functionalities available to modders...

 

EDIT: Lol, forgot to add the link to the helpful post:

 

https://forums.eagle.ru/showthread.php?p=3035016#post3035016


Edited by PeaceSells

My DCS modding videos:

 

Modules I own so far:

Black Shark 2, FC3, UH-1H, M-2000C, A-10C, MiG-21, Gazelle, Nevada map

Link to comment
Share on other sites

CreateElement(ceMeshPoly) does create something, so there is nothing to read back. just look at basicly an mod/plane to see how its used and what addition paramters are available

'controlling' the Ka50 feels like a discussion with the Autopilot and trim system about the flight direction.

Link to comment
Share on other sites

CreateElement(ceMeshPoly) does create something, so there is nothing to read back.

 

Yes, but this something that is created does have properties, for example it has a something.material, a something.primitivetype, something.vertices, something.indices, etc... you can call and assign values to them in Lua... but for that you need to know their names first... I guess my question is "Can everything that is available for use inside of Lua be seen somehow before you call them so you know they exist?"

 

just look at basicly an mod/plane to see how its used and what addition paramters are available

 

Yes, I've done that (wouldn't be able to do that HUD if I didn't, would I?), but what about the parameters that weren't used in those mods?

My DCS modding videos:

 

Modules I own so far:

Black Shark 2, FC3, UH-1H, M-2000C, A-10C, MiG-21, Gazelle, Nevada map

Link to comment
Share on other sites

  • 4 weeks later...
Good job, if you can just share the source code ! it'll be awesome :)

 

That's my intention, but I have to warn you that it's not what you're expecting. This is not the DCS engine's own radar simulation, as I don't know if it's possible for us to interface with that. So I improvised and I'm writting a radar simulation of my own. Since this is not DCS radar, it's not reckognized and it seems that it's not possible to guide weapons or cause a RWR alarm on the target with it. But we are able to write our own logic for detection, tracking, performance limitations, etc.

 

It needs work before I can share it (in case someone is still interested), and on the next days I need to work in something else not DCS related.


Edited by PeaceSells

My DCS modding videos:

 

Modules I own so far:

Black Shark 2, FC3, UH-1H, M-2000C, A-10C, MiG-21, Gazelle, Nevada map

Link to comment
Share on other sites

Understanding, thank you and keep forward ;) nice work

right choice, when we go with a complet independet MOD for DCS, we have to get the systems, instuments and special the fun things WEAPONS and sensors working right, we are keep learning from others and from what thery share, to more understing how DCS works then to design et MOD such as thigs.

Stating from HUB, MFDS, RWR, RADAR, TV POD, MAPS ... specialy for model aircrafts :D

 

Thank you for your time and the share. Waiting for the final job

MOD Logo - 100.png

Link to comment
Share on other sites

Understanding, thank you and keep forward ;) nice work

right choice, when we go with a complet independet MOD for DCS, we have to get the systems, instuments and special the fun things WEAPONS and sensors working right, we are keep learning from others and from what thery share, to more understing how DCS works then to design et MOD such as thigs.

Stating from HUB, MFDS, RWR, RADAR, TV POD, MAPS ... specialy for model aircrafts :D

 

Thank you for your time and the share. Waiting for the final job

 

This is most likely not possible... the probability that we'll find improvised ways around to each one of these limitations is very low... in my current opinion, at least.

My DCS modding videos:

 

Modules I own so far:

Black Shark 2, FC3, UH-1H, M-2000C, A-10C, MiG-21, Gazelle, Nevada map

Link to comment
Share on other sites

i dont have quick access to my dev-pc right now so i'll post the relevant code stuff when i am back. just saying a radar connected to the weapons is possible (and at least the AI is responding to it)

 

'controlling' the Ka50 feels like a discussion with the Autopilot and trim system about the flight direction.

Link to comment
Share on other sites

I was planning on sharing code only after this alternate radar was a bit more advanced, but considering that the main curiosity around this is probably how to get target data in your cockpit lua environment, I guess I should show the working code behind that. On top of that we can add our own logic for simulating a real radar's detection limitations (which I plan on gradatively try and implement), but looking at it at the state it is right now has the advantage that it becomes easier to visualize the channel used for communicating enemy data (not just enemy, any possible unit) to the cockpit environment.

 

So far (I still haven't investigated this thoroughly), the current lua environment for cockpit scripts seems to give us no access to data from other units flying around (such as position, etc.). The environment for the Export script does have access to these data, so we need to bridge the two environments. One possible bridge is "cockpit argument values", since the Export script can set_argument_value() on your mainpanel, and your avLuaDevice (for example) can get_cockpit_draw_argument_value() from your mainpanel. All you have to do is create new gauges in your mainpanel_init.lua (through the CreateGauge() function) and have the Export script write the target's position coordinates to these gauge's argument values. Then have your avLuaDevice read these argument values. We won't export anything, despite working in the Export script. Basic code for that is in the zip file attached.

 

Good news is that it's relatively simple. Getting enemy data inside you cockpit is by far the easiest part in making a target designator box appear on your HUD and superimpose his exact position. That's why I included in the code attached the part that transforms the target's world coordinates in local coordinates for your aircraft, calculates where exactly he appears to you from your point of view when looking through the HUD, and draws a box there (despite no one asked). Without coding something like that, having the target's data inside the cockpit environment is completely useless.

 

So you should be able to get a working radar target designator box on HUD in your mod if you incorporate the code attached into the corresponding scripts in your mod. Since your HUD device, page, elements, etc. probably have different sizes and positions than mine, you'll probably have to adjust the numbers. Also, since your entire cockpit and mod setup is probably different than mine, I expect that other adjustments will be necessary. I can't predict at the moment what these adjustments will be, so tell me if it doesn't work.

 

Also, I only tested this so far on a mission that has only myself (must be set as "Player" in the mission editor, and not as "Client") and another unit - the F-15 that you see in the video. The code will get the unit that's not you and treat it as the target, no matter where he is in the map and who he is. If you have additional units, I guess it will lock on a random unit, might lock on tanks etc... If he is exactly behind you, the target box will wrap around and appear in front of you, because I haven't done yet the angle restrictions.

 

Naturally, this will not guide any weapons or cause a RWR alarm on the target. As far as DCS's engine is concerned, this isn't a radar. The objective of this simulation is to simulate, so we can practice our coding skills and try to simulate the workings of a radar. This not an attempt to do a fully functional aircraft...

RadarSimulation.zip

My DCS modding videos:

 

Modules I own so far:

Black Shark 2, FC3, UH-1H, M-2000C, A-10C, MiG-21, Gazelle, Nevada map

Link to comment
Share on other sites

(and at least the AI is responding to it)

 

Wouldn't the AI be actually responding to the weapon launch, instead of to the radar, because I would find it pretty spooky if the AI was responding to this radar simulation...

My DCS modding videos:

 

Modules I own so far:

Black Shark 2, FC3, UH-1H, M-2000C, A-10C, MiG-21, Gazelle, Nevada map

Link to comment
Share on other sites

it is no simulation. its a real DCS radar. so it comunicates with the rest of the simulation. its hard to see in the video obviously but the first few missles were "chaffed" by the enemy. the last missle went stupid because i unlocked the target. so yes the AI is responding to the actual weapon launch

'controlling' the Ka50 feels like a discussion with the Autopilot and trim system about the flight direction.

Link to comment
Share on other sites

  • 1 year later...

 

Now back on the topic of finding what functions / variables are available for modders in DCS...

 

Calling get_base_data() from inside the "avLuaDevice" will return me a table with all the functions get_base_data() contains and I can see all of these functions' names by doing a generic for loop on that table.

 

https://forums.eagle.ru/showthread.php?p=3035016#post3035016

 

Hey PeaceSells

 

Could you explain/show code on how exactly you were able to pull out all the function names? are you using debug messages or somehow saving out to a log file. just starting to get my head around all this but the ability to call/save/display all values in a table would be super helpful.

 

Cheers

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...