Lua in SpringRTS/Units


Each unit in the game has a corresponding so called unit definition file. All unit defintion files can be found in the "units" folder of a mod. Each unit definition file is practically just a text file that holds information about a specific unit.
For example in the BA mod there is a file called "armcom.fbi" in the units folder that hols all the information for the arm commander. If this file is deleted then the arm commander won't be able to appear in the game.
This file is necessary for the unit because this file is what the engine uses to define a unit. With defining a unit we just mean some way so the engine knows that there should be this specific unit in the game and an explanation of how it should look and its general behaviour.

So what the unit definition file does is that it keeps all information regarding a unit. The most necessary information kept in the file is the line that links the unit with the 3d model. A unit without a 3d model cannot exist.
That line looks like this:


This informs the engine that the 3d model has the name "ARMCOM". Keep in mind that names are not case sensitive and don't need the format extension of the file.
In the above example the file armcom.3do is linked to the unit. That file as all 3d models are found in the folder Objects3d of the mod.