Jump to content

Announcing BGSC: Beginners Guide to Systems Coding


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 post
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 post
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 post
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 post
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 post
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 post
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 post
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 post
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 post
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 post
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 post
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 post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...