Nesting files?

Hi!

I’ve just been told that using sub-directories with files when building for a device is not allowed. Can someone elaborate? My CBEffects folder uses sub-directories, and I’ve nested all of my helper files in folders - so when I build, I’ll have to change all of that? [import]uid: 147322 topic_id: 33993 reply_id: 333993[/import]

Hello Caleb,
Subdirectories are fine for most files, but there are some things you must keep inside the root project directory. This includes font files (for custom fonts), your icon image files (the app icons that will appear on various devices), your “main.lua” file, “config.lua”, and “build.settings” files, and perhaps a few other things that I’m not remembering at this exact moment. :slight_smile: Otherwise, you can definitely put audio files, images, text files, SQLite databases, etc. inside subdirectories.

Hope this helps,
Brent
[import]uid: 200026 topic_id: 33993 reply_id: 135139[/import]

Hm. Look at this, at the bottom comments.

Any idea why that’s happening? [import]uid: 147322 topic_id: 33993 reply_id: 135142[/import]

I’d be surprised if that was the issue; I have several test apps that use subfolders (including one where I modified Lime to run out of a subfolder) and it runs on device just fine.

I haven’t tried multiple levels deep yet though, and you do have to change how you refer to those sub-folder lua files, I think it’s like “folder.file” right? [import]uid: 41884 topic_id: 33993 reply_id: 135144[/import]

@richard9:
I’m wondering, though. I am requiring the files with the dot instead of the slash, so that’s correct - but the problem seems to be eliminated when the files are moved out of the folder. So that’s why I thought it was strange. [import]uid: 147322 topic_id: 33993 reply_id: 135146[/import]

Oh, by the way, I’m not nesting several folders deep. I have one folder - CBEffects - that has all of the files inside of it in the main folder. [import]uid: 147322 topic_id: 33993 reply_id: 135147[/import]

Hmm. Well maybe I can take a look at it tonight when I get back to the dev machine. Would the error pop up if I try to include it into an otherwise blank project? [import]uid: 41884 topic_id: 33993 reply_id: 135149[/import]

I don’t know… I’ve never built for a device before. I was just going by the people’s comments. [import]uid: 147322 topic_id: 33993 reply_id: 135151[/import]

Hi Caleb (or Richard),
Can you give me a quick example of one of these “requires” you’re doing? And also a basic example of the folder structure, as in “Folder > File / File / File” ?

Thanks! [import]uid: 200026 topic_id: 33993 reply_id: 135152[/import]

Here’s my require code for CBEffects main library -
[lua]local masterPresets=require(“CBEffects.ParticlePresets”)
require(“CBEffects.ParticleHelper”)
local masterPhysics=require(“CBEffects.ParticlePhysics”)[/lua]

And here’s the directory map:
[text]
-Main Directory
(whatever the other folders were)
-CBEffects (inside of Main Directory, not nested in anything else)
-Library.lua
-ParticlePresets.lua
-ParticleHelper.lua
-ParticlePhysics.lua
-And some art (.png files)
[/text]
And apparently it works like this:
[text]
-Main Directory
(whatever the other folders were)
-Library.lua
-ParticlePresets.lua
-ParticleHelper.lua
-ParticlePhysics.lua
-And some art (.png files)
[/text] [import]uid: 147322 topic_id: 33993 reply_id: 135154[/import]

Yeah I use local myLibrary = require("foldername.myLibrary") as well.

Not sure what happens when you require in a folder’d lib without assigning a variable, but nothing seems wrong there. Anyway if Brent doesn’t see anything first I’ll check when I have dev access tonight. [import]uid: 41884 topic_id: 33993 reply_id: 135157[/import]

Hi Caleb and Richard,
It appears that your “require” call and directory is correct. Are you implementing this is in different Storyboard or Director scenes or something? My suspicion is that Lua isn’t able to call the various CBEffects module(s) properly from external modules, or something like that… but I need to learn more details about your usage before I can make that assumption fairly.

Keep me posted,
Brent
[import]uid: 200026 topic_id: 33993 reply_id: 135174[/import]

Good: Just using a blank main.lua and adding in CBEffects as a folder, I’m not getting any error messages.
Bad: I must really suck at following documentation because I don’t get any screen output using this code:

[code]local CBE = require(“CBEffects.Library”)
print(“Test”)

local CBObject = CBE.new{
{
preset = “hyperspace”,
}
}

CBObject:start()[/code]

No errors either, mind you, but…have no idea what it actually takes to get that package working. [import]uid: 41884 topic_id: 33993 reply_id: 135181[/import]

If you modules are designed correctly you should be able to do the following and get a table (after doing the require):

print( CBE )

If it comes out nil then it’s not finding the library.

Also pay attention to the case of the file names. Make sure everything matches.

You should get in the habit of using the form label = require( "name" ) to avoid issues in the future. [import]uid: 7559 topic_id: 33993 reply_id: 135212[/import]

Hey, @richard9 -
This isn’t the CBEffects forum page, but here’s how:
[lua]local CBObject = CBE.new{
{
preset = “hyperspace”,
title=“ThisVent” – Give each a unique title
}
}
CBObject:start(“ThisVent”) – Call your previously named vent
–OR
–CBObject:startMaster() – Starts all vents inside of the CBObject, regardless of title.[/lua]

Caleb [import]uid: 147322 topic_id: 33993 reply_id: 135232[/import]

Caleb: :stuck_out_tongue: I just wanted something to test your issue with. (Though my post works just as well at telling you I failed your PDF guide test :wink:

Alright, so here’s the sample code I used. Dirt simple as all bug testing code should be.

[code]–main.lua
– Testing whether CBEffects works from a folder via a storyboard scene.
local storyboard = require(“storyboard”)
storyboard.gotoScene(“example”)

– example.lua
local CBE = require(“CBEffects.Library”)
local storyboard = require(“storyboard”)
local scene = storyboard.newScene()

function scene:createScene(event)
local CBObject = CBE.new{
{
preset = “hyperspace”,
}
}

CBObject:startMaster()
end

scene:addEventListener( “createScene”, scene )

return scene[/code]

Results :
* Simulator: Fine
* iPhone:Fine (and looks great btw!)

So realistically either
(a) these problem reports are due to some other bug and we can’t test for it unless they can give some sample code, or
(b) they have made a case typo somewhere (a common problem when requiring in files and folders with mixed case names) and don’t realize that (AFAIK) those problems aren’t reported by Corona during the build process. [import]uid: 41884 topic_id: 33993 reply_id: 135258[/import]

Hello Caleb,
Subdirectories are fine for most files, but there are some things you must keep inside the root project directory. This includes font files (for custom fonts), your icon image files (the app icons that will appear on various devices), your “main.lua” file, “config.lua”, and “build.settings” files, and perhaps a few other things that I’m not remembering at this exact moment. :slight_smile: Otherwise, you can definitely put audio files, images, text files, SQLite databases, etc. inside subdirectories.

Hope this helps,
Brent
[import]uid: 200026 topic_id: 33993 reply_id: 135139[/import]

Hm. Look at this, at the bottom comments.

Any idea why that’s happening? [import]uid: 147322 topic_id: 33993 reply_id: 135142[/import]

I’d be surprised if that was the issue; I have several test apps that use subfolders (including one where I modified Lime to run out of a subfolder) and it runs on device just fine.

I haven’t tried multiple levels deep yet though, and you do have to change how you refer to those sub-folder lua files, I think it’s like “folder.file” right? [import]uid: 41884 topic_id: 33993 reply_id: 135144[/import]

@richard9:
I’m wondering, though. I am requiring the files with the dot instead of the slash, so that’s correct - but the problem seems to be eliminated when the files are moved out of the folder. So that’s why I thought it was strange. [import]uid: 147322 topic_id: 33993 reply_id: 135146[/import]