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.
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); return 1; } static int ldtPresentOptions(lua_State * l) { [ldtRecipe presentOptions]; ldtRecipe.sc->YieldPause(); return (lua_yield(l, 0)); } @implementation Ch7_LuaDecisionTree /* Logic callback */ -(int) logic:(NSString*)str { int num = 0; if([str isEqualToString:@"Put guns down"]){ gunsDown = YES; }else if([str...