Using Lua for dialogue trees

Lua lets the programmer write against a generic interface and worry about the implementation later. This separation between game logic, and the nuts and bolts of presenting the audio/visual elements of the game, is an important part of any game engine. In this recipe, we will use Lua to create a small story-based adventure game.

Using Lua for dialogue trees

Getting ready

Please refer to the project RecipeCollection03 for full working code of this recipe.

How to do it...

Execute the following code:

//Static C functions static int ldtLogic(lua_State * l) { int num = [ldtRecipe logic:[NSString stringWithUTF8String:lua_tostring(l,1)]]; lua_pushnumber(l,num); ...

Get Cocos2d for iPhone 1 Game Development Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.