I am trying to develop a game by using the c++ with lua, and I am using the quick-cocos2d-x engine to help me finish that. The problem is: I need user to download the lua scripts into their sdcard on their iphone/android devices, so that I can call the function in the downloaded lua scripts, but I am not sure for how to implement that?
What I have done but failed:
Modified the main.lua:
package.path = package.path .. ";src/" to be: package.path = package.path .. ";sdcard/scripts/"
In my lua script(internal), call the downloaded script by using:
local testScene = require("sdcard.scripts.DownloadTestScene") display.replaceScene(testScene.new())
So do anyone know how to make it come true, I have the internal lua script, I just want to call the download lua script, and not sure for how to implement that, thanks for anyone who may help me with this problem.
From C++, you could call
luaL_dofile
with the path to your file directly, then just call the function the usual way.