28 Apr 2013, 14:03
Generic-user-small

Lloyd Blake (5 posts)

Hello,

When I try and run the ‘LoadingAndSaving’ project I get the following error messages:

013-04-28 15:02:37.719 Corona Simulator[1576:707] WARNING: Cannot create path for resource file ‘files/level01.txt ‘. File does not exist.

2013-04-28 15:02:37.719 Corona Simulator[1576:707] Runtime error …e/NetBeansProjects/code/LoadingAndSaving/loading.lua:25: bad argument #1 to ‘open’ (string expected, got nil) stack traceback: [C]: ? [C]: in function ‘error’ ?: in function ‘gotoScene’ …lake/NetBeansProjects/code/LoadingAndSaving/main.lua:6: in main chunk

I’ve looked at the file that is causing the error and it looks fine (I even tried a blank file with same name) but I still go the same error message. The file structure looks fine so not sure what the issue is? The ‘LoadingAFile’ project runs OK

Lloyd

28 Apr 2013, 14:49
Silvias_temp_avatar_pragsmall

Silvia Domenech (35 posts)

Lloyd,

That’s probably due to the \r\n end of line character in the chapter code files. Since we’re reading a whole line to get each level’s file name, @fh:read()@ is taking an extra character on Mac.

When working in the Windows simulator, the program opens the file normally because \r\n is a line break on Windows. On Mac, it considers the \r trailing character as part of the string when calling @read()@ because it reads up to the \n line break.

It’s a quick fix, though. In the loadLevelInfo method, add this just after the function starts:

levelName = string.gsub( levelName, "\r", "" )

</code>

That should do the trick. Thanks for mentioning this bug!

Silvia

30 Apr 2013, 14:24
Generic-user-small

Lloyd Blake (5 posts)

Hi Silvia,

I’ll update my code as suggested.

Lloyd

  You must be logged in to comment