help with using libraries (mac)

just tried to add the director class as a library to a very minimal test project

first I added the director class via the preferences option in cpm

director.lua Macintosh HD:Users:macuser:Documents:work:corona development:libraries:director_by_ricardo_rauber_1_4:director.lua

i then created a new project and set it to use a base folder called “test” on the desktop

i then went to tools - code generator and ticked the checkbox next to director.lua and copied the following code to clipboard

  
-- cpmgen main.lua  
  
local director = require("director")  
  

i then opened main.lua in cpm and pasted this code into it and saved it. This is the only code that main.lua contains.

when i do a test launch i get the following error

Runtime error
…R1ngViHfymXo+nGymTFE+++TI/TemporaryItems/11/main.lua:3: module ‘director’ not found:resource (director.lu) does not exist in archive
no field package.preload[‘director’]
no file ‘/var/folders/Jd/JdR1ngViHfymXo+nGymTFE+++TI/TemporaryItems/11/director.lua’
no file ‘/Applications/CoronaSDK/Corona Simulator.app/Contents/Resources/director.lua’
no file ‘/Applications/CoronaSDK/Corona Simulator.app/Contents/Resources/director.blu’
stack traceback:
[C]: ?
[C]: in function ‘require’
…R1ngViHfymXo+nGymTFE+++TI/TemporaryItems/11/main.lua:3: in main chunk
Runtime error: …R1ngViHfymXo+nGymTFE+++TI/TemporaryItems/11/main.lua:3: module ‘director’ not found:resource (director.lu) does not exist in archive
no field package.preload[‘director’]
no file ‘/var/folders/Jd/JdR1ngViHfymXo+nGymTFE+++TI/TemporaryItems/11/director.lua’
no file ‘/Applications/CoronaSDK/Corona Simulator.app/Contents/Resources/director.lua’
no file ‘/Applications/CoronaSDK/Corona Simulator.app/Contents/Resources/director.blu’
stack traceback:
[C]: ?
[C]: in function ‘require’
…R1ngViHfymXo+nGymTFE+++TI/TemporaryItems/11/main.lua:3: in main chunk

any ideas what the problem is?

cpm Version 2.7.1 (2)
corona Version 2011.268 (2011.1.20) [import]uid: 11642 topic_id: 15109 reply_id: 315109[/import]

solved this one - i realise I need to add the director.lua file to my assets

in this case I am not really grasping the benefits of adding the library files - is it simply to ease adding the require line of code in the code generator? [import]uid: 11642 topic_id: 15109 reply_id: 55897[/import]

In the next major version of CPM the libraries feature will get an overhaul or go away – I haven’t decided yet.

If you have a file in Libraries and check that box in the Code Generator, it should add the require() line and copy a link to that asset into your new project.

Saves a couple steps, but not really as earth-shattering as I’d like it to be. :slight_smile:

Jay
[import]uid: 9440 topic_id: 15109 reply_id: 55924[/import]

thanks for the reply. Just to clarify: you said

If you have a file in Libraries and check that box in the Code Generator, it should add the require() line and copy a link to that asset into your new project.

It didn’t appear to copy a link to that asset into my project - I had to add the asset using the add asset button [import]uid: 11642 topic_id: 15109 reply_id: 55933[/import]

thanks for the reply. Just to clarify: you said

If you have a file in Libraries and check that box in the Code Generator, it should add the require() line and copy a link to that asset into your new project.

It didn’t appear to copy a link to that asset into my project - I had to add the asset using the add asset button [import]uid: 11642 topic_id: 15109 reply_id: 55934[/import]

thanks for the reply. Just to clarify: you said

If you have a file in Libraries and check that box in the Code Generator, it should add the require() line and copy a link to that asset into your new project.

It didn’t appear to copy a link to that asset into my project - I had to add the asset using the add asset button [import]uid: 11642 topic_id: 15109 reply_id: 55935[/import]

thanks for the reply. Just to clarify: you said

If you have a file in Libraries and check that box in the Code Generator, it should add the require() line and copy a link to that asset into your new project.

It didn’t appear to copy a link to that asset into my project - I had to add the asset using the add asset button [import]uid: 11642 topic_id: 15109 reply_id: 55936[/import]

Hmm seems to have duplicated my reply. Posting from ipad2 [import]uid: 11642 topic_id: 15109 reply_id: 55937[/import]

It is *supposed* to copy the chosen library into the project – I’ll take a look at that.

Also, instead of using Add New Asset to pull in something like Director, if you keep all your “library-type” files in a project, you can switch to that and drag and drop the wanted libraries to your new project folder. A little faster than going through the menu+open dialog.

Jay
[import]uid: 9440 topic_id: 15109 reply_id: 55966[/import]