CRYENGINE – about Lua programming – part 1.

First I make this tutorial because lua language is used not only CryEngine …
Most game engines used this language programming.
Because I used the 64 bits into Cry Engine I will use the LuaCompiler from this folder :
About Lua if you read the official website you will see this :
Lua is a powerful, fast, lightweight, embeddable scripting language.
Lua combines simple procedural syntax with powerful data description constructs based on associative arrays and extensible semantics. Lua is dynamically typed, runs by interpreting bytecode for a register-based virtual machine, and has automatic memory management with incremental garbage collection, making it ideal for configuration, scripting, and rapid prototyping.

Also you can read about lua and windows OS here :
Now let’s make a simple example with this programming language.
First we need to deal with three file type: .cgf , .lua and .ent .
The .cgf cry engine file is a file will load into game.
The .lua file is a lua program file.
… and .ent file is a cry engine file ( entity file ).
So I make this files : test001.ent and test001.lua.
I save the test001.ent with this path : C:\CRYENGINE\GameSDK\Entities
and test001.lua come with this path: C:\CRYENGINE\GameSDK\Scripts\Entities\Physics
The content of the test001.ent:

The content of the test001.lua:

The next step is to open your Cry Engine Editor and will see your script working.
Now about the lua script ( test001.lua) is very simple to understand how it’s working.
First line is the name , in this case is test001.
All about this is store with {} and after that will come the functions: OnInit , OnReset and PhysicalizeThis.
Because all this functions come from test001 then the syntax is: test001:your_function() and will end with this word: end.
Also be advice about ; and , under Properties and after that is need to see how is the diff when we use:
self: and self.
All of this tips can be found if you read the test001.lua and try to understand that script.
Also you need to following prefixes on the value name…
Prefix Type
b – boolean
f – float
i – integer
s – string
clr – color
object_ – an object compatible with CryENGINE: a CFG, CGA, CHR or CDF file

You also can read this webpage.