Can't require file from sub-folder?

The require paths for sub-folders does work fine. However, while using corona cards, the require paths for sub folders do not work:

local xml = require("libs.xml")

composer.gotoScene("app.reader", {time=250, effect="crossFade", params = options})

Has this issue been fixed?

What version of CoronaCards are you using? 

For iOS or Android?

Rob

Downloaded the latest version from the website 2 weeks ago.

Link: http://developer.coronalabs.com/downloads/coronacards

I guess I’m a little confused. You say it works, then you say it doesn’t. Can you expand upon this some more?

Are you getting an error message? Can you post the entirety of it?

Sorry for any confusion:

The require paths for sub-folders does work fine while you are testing the code using corona simulator and corona sdk (standalone). However, when you integrate the same code using corona cards within ios/android, the require paths for sub folders do not work:

local xml = require("libs.xml") composer.gotoScene("app.reader", {time=250, effect="crossFade", params = options})

Hope this helps.
 

To add more clarity about the issue:

Attached is the image of how the xcode project is set up: Click Here

Here’s the main.lua code:

local physics = require( "physics" ) physics.start() local sky = display.newImage( "assets/sky.png", system., 160, 195 ) local ground = display.newImage( "assets/ground.png", 160, 445 ) local crate = display.newImage( "assets/crate.png", 180, -50 ) crate.rotation = 5 physics.addBody( ground, "static", { friction=0.5, bounce=0.3 } ) physics.addBody( crate, { density=3.0, friction=0.5, bounce=0.3 } ) 

Engineering is asking for the specific version number and if this is CoronaCards for iOS or CoronaCards for Android.

Thanks

Rob

You can download the framework here

I am testing this on iOS and if this works I want to test this on android before I purchase the license.

I would also greatly appreciate if you can give me reference pointers on how to load images in the temp folder? Sample workflow I am trying to achieve:

  1. Download the zip file from s3
  2. Unzip the file
  3. Corona Cards would load images from the downloaded folder

1 and 2 is built on xcode.

When you run the app, there should be a line in the console log that prints out a bunch of information which includes the build number

Rob

Let me know if this is what you are looking for:

2017-02-14 15:22:19.070 raconteurv2[83073:6108413] Platform: iPhone / x86_64 / 10.2 / Apple Software Renderer / OpenGL ES 2.0 APPLE-13.0.7 / 2016.2992 / en | US | en_US | en

I notice you’re running your test in the Xcode iOS Simulator.  Does the same issue happen on a real device?

What is the exact error message you are seeing?  Please copy and paste it from the device log.

I tried running it on device and no luck. Below is the log:

2017-02-15 10:40:59.324410 raconteurv2[392:82836] Platform: iPhone / iPhone7,2 / 10.2.1 / Apple A8 GPU / OpenGL ES 2.0 Apple A8 GPU - 95.58 / 2016.2992 / en-US | US | en\_US | en 2017-02-15 10:40:59.693226 raconteurv2[392:82836] playBookEvent 2017-02-15 10:40:59.693612 raconteurv2[392:82836] test name 2017-02-15 10:40:59.693725 raconteurv2[392:82836] /var/mobile/Containers/Data/Application/FBB6A84D-7FE7-48FA-951E-15A5C1882AB8/Documents/ 2017-02-15 10:40:59.695595 raconteurv2[392:82836] WARNING: /var/containers/Bundle/Application/1D85B32B-DE94-4E76-A56D-67BC8ECF23AE/raconteurv2.app/main.lua:18: Failed to find image 'assets/sky.png' 2017-02-15 10:40:59.696132 raconteurv2[392:82836] WARNING: /var/containers/Bundle/Application/1D85B32B-DE94-4E76-A56D-67BC8ECF23AE/raconteurv2.app/main.lua:19: Failed to find image 'assets/ground.png' 2017-02-15 10:40:59.696613 raconteurv2[392:82836] WARNING: /var/containers/Bundle/Application/1D85B32B-DE94-4E76-A56D-67BC8ECF23AE/raconteurv2.app/main.lua:21: Failed to find image 'assets/crate.png' 2017-02-15 10:40:59.696746 raconteurv2[392:82836] ERROR: Runtime error /var/containers/Bundle/Application/1D85B32B-DE94-4E76-A56D-67BC8ECF23AE/raconteurv2.app/main.lua:22: attempt to index local 'crate' (a nil value) stack traceback: [C]: ? /var/containers/Bundle/Application/1D85B32B-DE94-4E76-A56D-67BC8ECF23AE/raconteurv2.app/main.lua:22: in function \</var/containers/Bundle/Application/1D85B32B-DE94-4E76-A56D-67BC8ECF23AE/raconteurv2.app/main.lua:8\> ?: in function \<?:169\>

Here’s the lua code:

 

--------------------------------------------------------------------------------------- -- A simple physics example in 8 lines! --------------------------------------------------------------------------------------- local physics = require( "physics" ) physics.start() local function handlePlay( event ) if ( event.phase == "play" ) then print( event.name ) --\> pauseEvent print( event.bName ) --\> otherValue print( event.bPath ) --local base = system.DocumentsDirectory --local path = system.pathForFile( "xo/helloCopy.png", base ) local sky = display.newImage( "assets/sky.png", 160, 195 ) local ground = display.newImage( "assets/ground.png", 160, 445 ) local crate = display.newImage( "assets/crate.png", 180, -50 ) crate.rotation = 5 physics.addBody( ground, "static", { friction=0.5, bounce=0.3 } ) physics.addBody( crate, { density=3.0, friction=0.5, bounce=0.3 } ) end end Runtime:addEventListener( "playEvent", handlePlay )

Now I’m confused … your Lua code doesn’t mention require() at all and the errors you posted indicate missing images.  Also the Lua code is not a complete project so it isn’t useful for investigating the issue.

Can you PM me a small project that reproduces the issue you are seeing?  I understand that I’ll have to run it both in the Simulator and in a CoronaCards app.

Perry,

I was able to resolve this issue. I missed one of the steps during configuration. Let me explain the scenario which may be helpful for others:

  • Firstly, I am converting an existing xcode project to a corona project using corona cards.
  • I followed the instructions from the post here
  • However, I ignored step 4 as this was throwing an error as it was unable to copy. But my sample corona application was working fine.
  • Now I imported my sample corona sdk project into the Corona folder. Here’s the folder structure: link (As you can notice, I have moved some files/assets to assets folder)
  • Now, when I run the application in the simulator, it does not work and throws the above error.
  • After some research, I realized that the files were not bundled into the app when I ran it on simulator
  • I then add the script specified in step 4 and the error came back. After looking at the error closely, I realized the “Corona” folder must be created at the root level (meaning at .xcodeproj file level) and not inside the project folder where you find the AppDelegate files. (I hope you can state this explicitly in the documentation :-))
  • After moving folder to root level, all the images load on the screen fine.

Thank you all for your help.

What version of CoronaCards are you using? 

For iOS or Android?

Rob

Downloaded the latest version from the website 2 weeks ago.

Link: http://developer.coronalabs.com/downloads/coronacards

I guess I’m a little confused. You say it works, then you say it doesn’t. Can you expand upon this some more?

Are you getting an error message? Can you post the entirety of it?

Sorry for any confusion:

The require paths for sub-folders does work fine while you are testing the code using corona simulator and corona sdk (standalone). However, when you integrate the same code using corona cards within ios/android, the require paths for sub folders do not work:

local xml = require("libs.xml") composer.gotoScene("app.reader", {time=250, effect="crossFade", params = options})

Hope this helps.
 

To add more clarity about the issue:

Attached is the image of how the xcode project is set up: Click Here

Here’s the main.lua code:

local physics = require( "physics" ) physics.start() local sky = display.newImage( "assets/sky.png", system., 160, 195 ) local ground = display.newImage( "assets/ground.png", 160, 445 ) local crate = display.newImage( "assets/crate.png", 180, -50 ) crate.rotation = 5 physics.addBody( ground, "static", { friction=0.5, bounce=0.3 } ) physics.addBody( crate, { density=3.0, friction=0.5, bounce=0.3 } )&nbsp;

Engineering is asking for the specific version number and if this is CoronaCards for iOS or CoronaCards for Android.

Thanks

Rob