When programming mods for BeamNG, you’ll likely be using these languages:
Please check source code location for information about where your files should go.
While you should learn how to program and how to program Lua on your own, here’s the most absolute basics of the language:
Table
: The basic and only type of container used in Lua. Depending on how you use a table, the table will resemble an array (a list) or a dictionary (a map).Array
: A Lua table that contains only integer keys from 1 to infinity. Can be counted correctly with #tbl
Dictionary
(dict
): A lua table that contains all kinds of keys. Cannot be counted with #tbl
.Module
: The traditional Lua module
is deprecated. Do not use itPackage
: the normal
Lua package
. Used, but please use Extensions if possible. See
here
and also
here
.For convenience, the Lua language sometimes offers different ways to identically behaving code. For example:
myTable.ident
is equivalent to myTable['ident']
myObject:name(args)
is syntactic sugar for myObject.name(myObject, args)
myFunction{fields}
is syntactic sugar for myFunction({fields})
myFunction'string'
(or myFunction"string"
or myFunction[[string]]
) is syntactic sugar for myFunction('string')
function t.a.b.c:foobar(params) body end
is syntactic sugar for t.a.b.c.foobar = function(self, params) body end
If you feel this programming documentation is too high level, too low level, is missing important topics, is erroneous anywhere, etc, please write a
post at this thread
and ping me personally by typing @stenyak
so I will get notified.