Thursday, March 18, 2010

J1N Games

Jason Kim's Personal Journey Into Game Development

C++ Lua Script Integration

Posted by Jason On October - 6 - 2009

Game developers and Software Developers often make use of a scripting language to integrate with their C++ applications.  One common one is a free scripting package known as Lua.
Lua was developed for C, but is fully functional with C++.  This example shows how to effect variables,call functions,and create classes in both C++ and Lua, and how they pass data back and forth between each other.
Scripting is a very important process in software development, it allows the developer to quickly change values in a script file and see immediate changes in their application without having to completely rebuild the app.
An example would be lets say in a video game, you have a Player, and his values need to be balanced for the amount of damage he does, or his speed.  Going into source engine and changing this value would take up a lot of time as you would have to rebuild the entire application/engine, instead with script you can just change a few values in a script file and launch the application to see your changes.  This allows for quick-iteration between builds and faster progression testing/application tweaks.

For this code example you will need Lua, available at http://www.lua.org/
I also make use of luna.h an addon for Lua for C++ binding (included in source files) also available from lua.org

C++ Lua Script Integration

Add A Comment

You must be logged in to post a comment.