Week 2, here we go. Just like last week's assignment this week too was more about integrating existing systems that were provided to us. This week we integrated Lua libraries into out project to allow the asset building system to use Lua functionality to build assets. Since the Lua libraries are an external library in our folder library we placed it in the externals section in our solution hierarchy.
The lua script is in a file called BuildAssets.lua. This file was provided to us, we simply had to include it in out project. I chose to place this file in a separate folder called Scripts inside my solution folder. The reason for doing so was that I wanted the script files to be separate from my C code since the script files are not compiled as part of the project. Also, personally I like having all my scripts in one place.
The BuildAssets.lua contains information about the authored assets like its timestamps for file generation, file path etc, as well as scripts to compile and build the assets. The actual asset files are passed as command line arguments to the BuildAssets project. The AssetBuilder project then uses the script file data and functions to build the actual assets into the target folder. For the purpose of this assignment all the script file does is copies the built asset files to the target location. This is how the authored assets are built in the engine.
For the above reasons Lua is a good option to use for video games. It is fast and has excellent integration with C++ allowing us to write functions in C++ and use them through Lua code and vice-versa. The actual extent to which Lua is used in video games varies with the project. It can range from something simple such as managing game settings via a lua script to complex game systems and possibly the whole game itself being written in Lua. Using Lua comes with its advantages and disadvantages. Some of the benefits are:
- Changes in script files do not require the whole project to be rebuilt.
- Allows separation of operations, game code can be developed independent of engine code.
- Security. Buggy scripts will not crash the whole program.
- Certain things are easier to implement in Lua than C++. Using more than one language that can interface well gives us the best of both worlds.
There are certain disadvantages too:
- Debugging scripted code is harder.
- Scripts don't integrate well with the IDE.
Additionally, we also changed the data for the Vertices which are passed to the Shader to print another triangle on our output screen. This version puts 2 triangles that form a square printed in out "game".
Download DirectX_64 build here
Download OpenGL_32 build here