Jump to content

Announcing BGSC: Beginners Guide to Systems Coding


fl0w

Recommended Posts

Beginners Guide to Systems Coding



BETA ACCESS

___________________________________________________________

 

WARNING:
Everything shown here in this guide is not final and does not represent the official outcome determined.

This guide is still very much WIP and will be constantly worked on.

 

Hello, everybody. As for a long time now in DCS, we have seen rapid growth and progression of mods being released by the community, for the community. Many of them here are just simple mods, that involve new models imported, graphic/texture fixes, and flyable aircraft. Out of all of these many flyable aircraft that we have seen released in the modding subforums here, only a mere percent of them have we call an ESM. As seen from the title, the 3 letters "ESM" is an abbreviated term that stands for "External Systems Model," a folder with a set amount of files containing code that define the systems of an aircraft. However, for keeping thing simple, this guide will be referred to as BGSC, abbreviated for the Beginners Guide to Systems Coding. This can range from any type of aircraft, from a helicopter to plane; from a starship to a flying Port-a-John. However, there has always been this one lacking issue when it came to developing an ESM inside of DCS: where to start. When many people first begin trying to code one, they are often feared by the number of files that they have to look through and get an understanding of how things work on the inside, which can often convince those at first to not bother at all with the idea of learning one. Not only that but to build onto that with the fact that not many in the DCS modding community are knowledgeable of how to make one themselves.

 

Because of that, I have here to present a work in progress (WIP) state of a document of mine, that has spent the last few months in the making. This guide is by far one of the most in-depth, giving step by step procedures on how to code your own systems. This does not mean, however, that you are able to just copy and paste this code and say that you just learned it. In this guide, you will be given pictures of systems code and set files that will help you start off. From there, everything you see is something you have to write in your files yourself. This helps the user learn by participating in the document about what functions and events do what within the DCS API. In no means is this guide finished, and everything will be constantly worked on to the fullest of my extent, along with anyone who is willing to help contribute.

 

With that being said, there are a set of prerequisites in order for you to correctly follow through with this guide. Here they are listed below. (These are also stated as so in the guide)

 

Programming

  1. You need to know how to make a basic mod structure. This includes the gear positions, canopy, pylons, cockpit implementation, and collision model apart of the folder structure.
  2. You need to know how Lua works. If you have absolutely no idea or are foreign to the subject of programming itself, then it may be very unlikely that you are going to get far in learning how to program an ESM for DCS World. It is highly recommended for someone to understand how to code anything in a programming language, more preferably Lua itself in order to understand what code you are going to be dealing with.
  3. You need to know how to work with debugging and working with certain code statements within DCS. The core infrastructure that the DCS API works with, especially when dealing with Lua, acts as a framework. (A framework is a predefined set of functions to write inside of a script that is being inherited by an overall class like script or package) Being able to debug your own code (ie. using the dcs.log folder in your C:\Users\<< insert username here >>\Saved Games\DCS\Logs directory) is a huge must in order to find out the issue in your script(s).

 

3D Modeling

  1. You need to know how to animate models in 3DS Max by using the argument number method. If you are unaware of this or have no idea whatsoever on how to do this, then please go here: https://www.megabotix.com/wp-content/uploads/dcs/animation-dcs.mp4
  2. You need to have the current .EDM conversion plugin or one that works for 3DS Max. As of to requirement no. 1: ftp://srv0files.eagle.ru/mods/edm_plugins/

 

If you would like to participate or contribute to this guide, then please contact me either via. Discord at Sirius#0002 or by in the forums.

 

Links

 

Link:

Version:
v.1.0


Edited by Sirius
i ran out of discord nitro, #tag changed. :(
Link to comment
Share on other sites

Jan 2019 Update

 

January 2019 Update

_______________________________

 

So far, things have gone off well for the guide this month! For almost 2 days now, this thread has already reached 1000 views and is slowly gaining recognition. (as a side-note and not intending to brag) We hope to make this guide even better in the future as more and more updates will come helping to expand the limiting knowledge on this subject with the Lua programming language.

 

With that being said, we do have a few updates that I would like to give on the current status of the guide.

 

  • Suggestions are now open! You are able to make a comment on the guide as to what is and is not helpful, or if you want to help to add more information. This, of course, will be looked at before making the changes.
  • More information has been added to the Training Missions section. This section, however, has currently been paused as there is a debate on whether or not this is needed within the guide and would fit more in a general spectrum for Mission Editor making.
  • Introduction to the Pointer types section. This section is still WIP but aims to help give users knowledge on what all of the different functions are for in the clickabledata.lua file for the systems coding guide.
  • "Completion" of the Helpers section. As it is currently listed as an incomplete section, all that is currently remaining is an image that shows how to set it up in 3DS Max. All the information you need is already written down, making the image just serve as a visual aid to ensure that everything is being done correctly.

 

This may be somewhat as a small update, this guide has set a new mark in helping modders learn how to code systems, which has been a huge feat since there has not yet been much knowledge expanding on said topic. We hope to add even more to the guide. We are also questioning still whether or not we should allow users to be able to download the files for systems coding as that contradicts one of our core beliefs of how a guide should work.

 

Sincerely,

Sirius.

Link to comment
Share on other sites

I would like to see more info on reading and setting the controls in the cockpit like being able to write a tutorial on startup and checking that the user did the checklist in the correct order and set the panels in the correct configuration before allowing the user to go to the next item the also able to check if the user is flying the correct heading and altitude if not let the ai letthem knowtheyare off course ands correction is needed.

BlackeyCole 20years usaf

XP-11. Dcs 2.5OB

Acer predator laptop/ i7 7720, 2.4ghz, 32 gb ddr4 ram, 500gb ssd,1tb hdd,nvidia 1080 8gb vram

 

 

New FlightSim Blog at https://blackeysblog.wordpress.com. Go visit it and leave me feedback and or comments so I can make it better. A new post every Friday.

Link to comment
Share on other sites

I would like to see more info on reading and setting the controls in the cockpit like being able to write a tutorial on startup and checking that the user did the checklist in the correct order and set the panels in the correct configuration before allowing the user to go to the next item the also able to check if the user is flying the correct heading and altitude if not let the ai letthem knowtheyare off course ands correction is needed.

 

We do have some information of that on pages 16-17. Do you mean something by training procedures? There is a training mission part on page 30 but it's been paused so far.

 

I like your idea, some kind of AI correction in the code would indeed be very nice. :)

Link to comment
Share on other sites

Mini-update

 

Dear all,

 

I have not spent awhile on the BGSC guide, (mainly due to personal life reasons) but I hope to finish the Training Missions section very soon. A new section, for coding systems for reacting to a damage model, is also being considered to help those wanting to re-create the outcomes of a damaged aircraft. An example of this would be the iconic F-14 Tomcat module to soon be released into DCS World as of the time of this writing. I have also noticed that the code for the electrical system sample in the guide shown is outdated, and as that result, I will be re-coding a new example for those to copy down.

 

The ability of those to download pre-coded files of the systems is also being considered, but this has been expressed as something that contradicts the belief of how the guide should work and teach the user instead of giving them free scripts. I hope to share more with you guys soon. :)

 

- Sirius

Link to comment
Share on other sites

In-depth look: Gear system

 

Hello, everyone.

 

As a way to expand onto the guide, I wanted to help users out a little bit more with understanding about how some systems work in particular. In this example, the gear system will be our first in-depth look on the matter. I must warn you, however, that before looking at this code, I highly recommend for those who do not understand this to read Section 1-A in the guide first on avLuaDevice before proceeding. With that being said, I will now delve in.

 

As stated in the guide, in order for you to have a working system (in this case, landing gears) you need these 3 things:

  • The internal DCS ID declared/listened
  • a SetCommand() function to check if the ID is called
  • and an update() function to loop the animation transitions

 

Since the time of writing the guide, I have found out that you are able to add a "fluid" animation transition to also clickable elements in your cockpit. This includes, but is not limited to: 2-way switches, and levers. 3 new variables will be introduced in the script: GearParam, GEAR_STATE_PARAM, and GEAR_WEIGHT. These do the following as shown:

  • GEAR_WEIGHT: Checks if there is any weight being applied to the wheels/suspension in effect. Grabs information from the sensor_data variable.
  • GEAR_STATE_PARAM: a new variable to declare the position from 0 to 1 of the parameter handle's "state" or position.
  • GearParam: a new variable to grab the parameter handle for our clickable element in the cockpit.

 

Linked below is a script attached for solely this interest. There is more code in an advanced version that I have created, but I thought that it would rather be fairer to let people get a little bit of it and from there build up knowledge on how the process works. With this method, you can also apply this to systems like your flaps and canopy. (Some extra code may be required, however.)

 

P.S., Remember to change "GEAR_LEVER" in the get_param_handle() function to whatever your parameter is named!

 

Link: https://pastebin.com/fy0wFJ3s

(Credit to BR=55=Sevas for giving advice on the gear forced value limits)

 

- Sirius


Edited by Sirius
Link to comment
Share on other sites

P.S., Remember to change "GEAR_LEVER" in the get_param_handle() function to whatever your parameter is named!

- Sirius

 

Need a little bit help here... :cry:

 

 

 

What does it mean or to what it is referring to?

 

 

The Pointer within the 3DS Max File?

The argument wich i choosed to animate the gear lever in the Pit?

or what else???

CPU: Intel i7-5820K 3,3GHz

Motherboard: ASUS X99-A

Grafik Card: NVIDIA Geforce GTX1080 Ti 337.50

RAM: 32GB

PIMAX 5k+ BE

Hotas Warthog with Simped Pedals

WIN 10 64bit

DirctX 11.0

Link to comment
Share on other sites

  • 2 weeks later...

Feb 2019 Update

 

February 2019 Update

________________________________

 

Hello, everybody. It has been a while since any updates have been made to this guide. However, I shall continue to try my best to keep this as updated as possible and relevant with information that works inside of DCS. While most of our updates may have been more of a re-vamp, I do hope to bring more content into the guide soon.

 

With that being said, here is currently what has been updated:

 

  • Beginning to re-word areas with the assistance of proofreaders.
  • Introducing "figures," a method to refer to images or text shown within the guide.
  • Re-structured the looks of the guide. This includes organizing text and moving the margins further to the sides, allowing for less page count and more text to fill in.
  • Cleaned up the footer and header areas for better text flow, and appeal.
  • Adding in-depth looks -- this means that all further in-depth looks, including (at the time of this writing) the gear system script as examples that serve along with the guide as to what can be created.

 

In the next update, we will certainly see the completion of these areas:

 

  • Training Missions
  • Re-write of Section 1-B's script along with another in-depth look. (Electrical systems)
  • Pointer types
  • Helpers

 

As much information as this guide shows, it will never be able to replace well-known resources, such as the Wunderluft. I hope to make this guide be able to follow along with the BGDAM guide, acting as an "extension" to how to create your own aircraft systems. I hope to share more soon with you guys in the next update. :)

 

Sincerely,

Sirius.

Link to comment
Share on other sites

  • 10 months later...

Hey Sirius,

 

Fantastic guide, thank you for putting it together.

 

I'm pretty far into coding my own mod, so far I've got almost everything in place including a functional HUD & MFDs etc...

 

However working with the clickabledata.lua file and the SetCommand() function is killing me.

 

I am able to animate a Battery switch using a custom parameter as you described; however I've since come to understand that this may not be necessary - do you have any information on animating switches purely using the switch type functions in clickabledata?

 

I've tried defining my battery as a 2_pos_tumb, and then in my SetCommand() i tried using the 'value' parameter to control animation - I just can't get it to work right though! Usually it will animate the switch once, and then after that the SetCommand() value parameter starts spitting out some funky numbers (usually 10.25) and refuses to animate the switch anymore.

 

I can make it work by defining it as a gauge with a custom parameter; but I'm noticing most modules/mods don't do that and thinking there must be a more efficient way.

 

Can anyone help?

 

EDIT: Got it working by deleting my scripts (I had started with the WunderLuft mod) and creating fresh ones. I used essentially the same code, so I assume I had a corruption/old/outdated code in there somewhere

 

Thanks


Edited by MikeNolan
Link to comment
Share on other sites

It’s December now and no updates since February I do have a problem on how to do but I’ve seen it done in campaign for sale and video introduction how can that be accomplished

BlackeyCole 20years usaf

XP-11. Dcs 2.5OB

Acer predator laptop/ i7 7720, 2.4ghz, 32 gb ddr4 ram, 500gb ssd,1tb hdd,nvidia 1080 8gb vram

 

 

New FlightSim Blog at https://blackeysblog.wordpress.com. Go visit it and leave me feedback and or comments so I can make it better. A new post every Friday.

Link to comment
Share on other sites

  • 3 weeks later...
Hey Sirius,

 

Fantastic guide, thank you for putting it together.

 

I'm pretty far into coding my own mod, so far I've got almost everything in place including a functional HUD & MFDs etc...

 

However working with the clickabledata.lua file and the SetCommand() function is killing me.

 

I am able to animate a Battery switch using a custom parameter as you described; however I've since come to understand that this may not be necessary - do you have any information on animating switches purely using the switch type functions in clickabledata?

 

I've tried defining my battery as a 2_pos_tumb, and then in my SetCommand() i tried using the 'value' parameter to control animation - I just can't get it to work right though! Usually it will animate the switch once, and then after that the SetCommand() value parameter starts spitting out some funky numbers (usually 10.25) and refuses to animate the switch anymore.

 

I can make it work by defining it as a gauge with a custom parameter; but I'm noticing most modules/mods don't do that and thinking there must be a more efficient way.

 

Can anyone help?

 

EDIT: Got it working by deleting my scripts (I had started with the WunderLuft mod) and creating fresh ones. I used essentially the same code, so I assume I had a corruption/old/outdated code in there somewhere

 

Thanks

 

Do you have a line calling to mainpanel_init? Some thumbs for clickabledata.lua also have preset animations like levers. The set command is general for parameter gauges.

Link to comment
Share on other sites

It’s December now and no updates since February I do have a problem on how to do but I’ve seen it done in campaign for sale and video introduction how can that be accomplished

 

Sorry bud! I have been busy with my Junior year of high school, and especially now that I have a real life job with final exams, I am very limited. This guide has not been ignored but put to the side. I hope to redo the guide soon to make more sense.

Link to comment
Share on other sites

  • 2 years later...

Hello everyone. It's been a couple of years since I've last made changes to the guide, and there's been some request lately to look into updating it.

Currently, we're looking at bringing the guide under the ownership of Vapour Labs, an OSS-based modding team for DCS World. Our eventual goal is to make almost everything modding-related open-sourced for developers to use, and we want to lead that front. In order to meet this goal, we have to consider how to make it easier for modders to contribute to the documentation. There are plenty of things missing in this guide, and it's admittedly very premature - it doesn't do a very good job at explaining some concepts. There's a lot that could be made as digestible content but simply isn't.

So, here's some options I'm willing to commit to, based on circumstances:

  1. Rewrite our guide as documentation for code tailoring specifically to DCS aircraft modding. (This excludes MOOSE and similar frameworks)
    1. If we do this, we'll make a new repository on our GitHub organisation. The tech stack would be reStructuredText, Python and Sphinx.
    2. We'll begin looking for volunteers to help collaborate on rewriting crucial aspects of the guide.
  2. Rewrite our guide to become more of a "wiki."
    1. There are some good places to consider joining this with. I think Hoggit Wiki would be a great place if the staff there are interested in this.
  3. Re-create the guide to be a "workouts" example. This would be creating a repository that serves as a DCS mod boilerplate and has examples for numerous Lua devices and techniques.

Currently, I'm leaning on option 1 here. I think it's the best route for us to take, and one with the least resistance for keeping open-source possible. Please let me know what you think, this essentially dictates the future of updates to BGSC.

  • Thanks 1
Link to comment
Share on other sites

@fl0w

This is desperately needed. I am trying to "mod" a mod, it is impossible to just figure out. 

The tutorials that are available are missing steps or are unavailable altogether which probably discourages or altogether stops people with the drive to take on the task of making a mod.

I have spent over 100 hours now trying to accomplish something that I know should work but it doesnt and there is really no help available to figure out.

For example, I have a mod aircraft that has a HUD with only a pipper gunsight. Im trying to add HUD information and countermeasures from another mod that allows free use of their systems. If I swap out the whole cockpit the HUD works but most else does not. From there I have deduced that somewhere in the cockpit files I should be able to project HUD info onto the other mod but looking through the files with no guidance has been futile.

There are no real guides that even teach me how to build my own HUD either.

You would be doing the community a great service by updating it and making it available to the public. 

Thanks, Money

Intel i9-13900k, Asus Z790-E Gaming Wifi II mobo, 64gb Corsair DDR5-6400 RGB ram 2x32gb XMP2 profile, 2TB Crucial T700 PCIE 5.0 SSD internal, 2TB Samsung 980 Pro PCIE 4.0 SSD internal, Asus Tuf Gaming overclocked Nvidia RTX 4090, Corsair 7000X Case with 5 x 120mm intake fans and 4 x 140mm exhaust fans, side mounted Corsair H150i Elite Capellix 360mm liquid cooler w/Elite LCD with 6 x 120mm fans in push-pull intake configuration 2 x 32" Asus 2560x1440 displays, TrackIR5 w/pro clip, Thrustmaster Warthog stick and throttle, CH Fighterstick Pro and Pebble Beach Velocity pedals. 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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