How to run the compiled lua in assets/?

How to run the compiled lua in assets/?
0.0 0


in cocos2d-2.1beta3-x-2.1.0/samples/HelloLua
1.1 i compiled lua files by using luac (luac - o hello.lua hello.lua;luac -o hello2.lua hello2.lua)
1.2 i changed AppDelegate.cpp to pEngine ->executeScriptFile("hello.lua") in android platform
1.3 then build and run the android project. But it can’t load the lua file and show me black screen….

【question 1】Can’t cocos2d-x(android) load compiled lua in assets/ ?? in cocos2d-x, it run fine…
2.1 i copy the hello.lua hello2.lua to /mnt/sdcard/
2.2 i changed AppDelegate.cpp to
pEngine->addSearchPath("/mnt/sdcard"); pEngine->executeString("package.path='?.lua;./?.lua;/mnt/sdcard/?.lua;'..package.path"); pEngine->executeScriptFile("/mnt/sdcard/hello.lua") in android platform
2.3 then build and run the android project. it can run! but it show Notification “Get data from file(assets/hello2.lua) failed![](“
2.4 then i edit hello.lua, changed that @require “hello2”@ to @require “/mnt/sdcard/hello2”@. compile and copy hello.lua to /mnt/sdcard. It runs fine without any Notifications)
【question 2】Do i have to require”absolute path” in the lua files that run at sdcard??

Thank you.


I have same problems about that,
I download new script a.lua into /data/data/project_xxxxx/download/xxxx/a.lua
then I addsearchpath and add path into package.path with absolute file path
but the result is iOS ok and android show error loading model ‘my absolute path’.
I’m trying to fix this problem, some body has any ideals?


Finally, I solved my problems,
when Cocos2D-X Lua engine execute lua script,
It’s will cache the script which you had executed ever.
So don’t use the same name file one times. :smiley: