Call download lua script in app

298 views Asked by At

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:

  1. Modified the main.lua:

    package.path = package.path .. ";src/" to be: package.path = package.path .. ";sdcard/scripts/"

  2. 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.

1

There are 1 answers

1
llogiq On BEST ANSWER

From C++, you could call luaL_dofile with the path to your file directly, then just call the function the usual way.