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.
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 the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.