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.
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 C function static int dslAppendMessage(lua_State * l) { //Pass lua string into append message method [dslRecipe appendMessage:[NSString stringWithUTF8String:lua_tostring(l,1)]]; return 0; } @implementation Ch7_DynamicScriptLoading -(CCLayer*) runRecipe { //Superclass initialization [super runRecipe]; //Set callback pointer ...