Dynamically loading Lua scripts

Part of the power of a scripting language like Lua, is that scripts can be loaded and re-loaded at run-time. This means you can test your game logic without having to re-compile your Objective-C++ code. In this recipe, we will load a remote script from a local web server.

Dynamically loading Lua scripts

Getting ready

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

How to do it...

Execute the following code:

#import "mcLua.hpp" #import "Reachability.h" @interface Ch7_DynamicScriptLoading : Recipe { class mcLuaManager * lua_; } @end //Callback pointer Ch7_DynamicScriptLoading *dslRecipe = nil; //Static append message ...

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.