"Run" works with CPM but not when loaded directly with Corona Simulator

As the subject states I can’t run my project if I load it directly with the Corona Simulator, I have tried publishing it but to no avail.

The error I get is

[lua] Runtime error: module ‘menu’ not found:resource (menu.lu) does not exist in archive
no field package.preload[‘menu’]
no file ‘/Users/iZeal/Documents/Corona Projects/iDwarfs!menu/menu.lua’
no file ‘/Applications/CoronaSDK/Corona Simulator.app/Contents/Resources/menu.lua’
no file ‘/Applications/CoronaSDK/Corona Simulator.app/Contents/Resources/menu.blu’
stack traceback:
[C]: ?
[C]: in function ‘require’
?: in function ‘gotoScene’
…s/iZeal/Documents/Corona Projects/iDwarfs!?/main.lua:17: in main chunk [/lua]

the menu.lua file is in the same directory as everything else. Anyone got an idea on how to solve this? [import]uid: 129450 topic_id: 22615 reply_id: 322615[/import]

Yeah, I think you’re calling the menu module wrong, something like this:

menu = require(“menu.lua”)

…when you need to be calling it like this:

menu = require(“menu”)

Notice there’s no suffix on that file name.

That *may* not be your problem, but that error message rings a bell.

On the other hand, post what’s on line 17 of main.lua and I can make a better guess. :slight_smile:

Jay
[import]uid: 9440 topic_id: 22615 reply_id: 90190[/import]

I concur with Jay it appears as the error states on line 17 in your main.lua file it should be as Jay said. I like the Director Class my self and use a template for everything so I use the following:

local director = require(“director”)
local mainGroup = display.newGroup()

local function main()
mainGroup:insert(director.directorView)
director:changeScene(“loadmenu”)
return true
end

main()

This uses the directore class to call your menu.lua file.

It depends on what you are comfortable with.

[import]uid: 104728 topic_id: 22615 reply_id: 90232[/import]

Its your call and depends on the size and complexity of the app. [import]uid: 104728 topic_id: 22615 reply_id: 90233[/import]

One thing to check is the case of the file names being loaded. If you are doing a require “menu” but the file is actually “Menu”, it will work in the simulator (CPM) but give you an error on the device since the device is case-sensitive. [import]uid: 7559 topic_id: 22615 reply_id: 90235[/import]

I actually use storyboard for my project, my main file looks like this

[lua]
_W = display.contentWidth
_H = display.contentHeight

_M = math

local storyboard = require( “storyboard” )

– Hide status bar
display.setStatusBar ( display.HiddenStatusBar )

– load first screen
storyboard.gotoScene( “menu” )
Wierd thing is that I’am able to run it when I start it with CPM and everything works fine, it also works if I make an android build and try it on my phone. It is only when I try to run it directly through Corona Simulator I get the error. [import]uid: 129450 topic_id: 22615 reply_id: 90448[/import]

Is there really a ?! in the path or is that some weird error?
iDwarfs!?

Corona Projects/iDwarfs!?/main.lua [import]uid: 10389 topic_id: 22615 reply_id: 90451[/import]

Yes that’s the name of the folder. However thanks to you I tried to publish the project to a folder without the !? (which I thought I had already tried btw) and it works!

Still find it strange that CPM don’t pick this up.

Thanks for the help everyone! [import]uid: 129450 topic_id: 22615 reply_id: 90452[/import]

Computers really do not like ? or ! in paths as they specify certain abilities to paths.

A ? stands for an unknown character.

eg on Windows CMD:

dir te?t.txt

will show

text.txt
test.txt
teat.txt

! can specify abilities too so you should only use alphanumeric characters and _ and -
Anything else should not be used. :slight_smile:

Glad it’s worked out now! [import]uid: 10389 topic_id: 22615 reply_id: 90454[/import]

CPM is using the Corona Simulator to simulate the app. I assume when you say “Corona Simulator” you mean the iOS Simualtor on the Mac.

Generally, when things work on the Corona Simulator and not on a certain device, it comes down to characters used in the file name or case sensitivity. It’s very hard to detect and flag those types of problems in the Corona Simulator. The iOS Simulator generally mimics the functionality of the iOS devices.

With that said, it’s best to limit your file name characters to alpha-numeric, underscore ("_") and dash ("-"). [import]uid: 7559 topic_id: 22615 reply_id: 90571[/import]