require "x" works on simulator but not on iPad

Hi,

I have a problem that I can’t find a way to solve.

_G.currentLevel is 1 when the method is first invoked. It will be 2 after the player passes the level.

My problem is, this works on simulator but the require “x” part does not on my test device, iPad 3. Any ideas?

[lua]function getData()
local levelData = {}
levelData.background = “images/levels/level1/background.jpg”
levelData.music = “sounds/1-4-house.ogg”
levelData.noOfObjectsToFind = 4

levelData.timeRequired = “04:00” --IN MINUTES

levelData.coinReward = 20
levelData.objects =
{
grasshopper =
{
src = “images/levels/level1/grasshopper.jpg”,
imageWidth = 43,
imageHeight = 33,
x = 170,
y = 83,
},
guitarPick =
{
src = “images/levels/level1/guitarpick.jpg”,
imageWidth = 28,
imageHeight = 26,
x = 311,
y = 55,
},
tie =
{
src = “images/levels/level1/tie.jpg”,
imageWidth = 36,
imageHeight = 136,
x = 430,
y = 66,
},
dice =
{
src = “images/levels/level1/dice.jpg”,
imageWidth = 36,
imageHeight = 35,
x = 350,
y = 66,
},
}

return levelData
end[/lua]

[lua]–THIS WORKS
local commonSetup = require(“levels.setup.commonSetup”)
local commonData = commonSetup.getCommonData()

–BUT THIS DOES NOT WORK
local levelSetup = require(“levels.setup.level” … _G.currentLevel … “setup”)
local levelData = levelSetup.getData()[/lua]

_G.currentLevel is 1 when the method is first invoked. It will be 2 after the player passes the level.

My problem is, this works on simulator but the require “x” part does not on my test device, iPad 3. Any ideas? [import]uid: 154911 topic_id: 34789 reply_id: 334789[/import]

Uhm, i cant see any point where you define what \_G.currentLevel is

but i suppose you have something in the code that defines that \_G.currentLevel = 1 if so you shouldnt use the _G. part in the require, you only have to use it where you define the variable. simply write:

 local levelSetup = require("levels.setup.level" ..currentLevel .. "setup")

And if you dont have anything that defines what _G.currentLevel, its not that strange since that would be nil in your code example.
[import]uid: 134049 topic_id: 34789 reply_id: 138274[/import]

I defined the currentLevel variable in another file so I forgot to include it here.

I used _G.currentLevel as a global variable and that was the reason to write it that way. Also, I tried your solution and it worked on simulator but again, not on iPad.

It gives an error and I found that by using the method in http://gamedevnation.com/game-development/using-print-from-a-device-kinda/

When I try to invoke the require, it does not work on iPad but it works in the simulator without any problem. [import]uid: 154911 topic_id: 34789 reply_id: 138276[/import]

what does the error say ? [import]uid: 134049 topic_id: 34789 reply_id: 138279[/import]

right, i might know what it is now…

the simulator is not case sensetive, but the ipad is.
so if the file you require has any upper case letters in it, thats probably it. [import]uid: 134049 topic_id: 34789 reply_id: 138280[/import]

Ah, I see.

Thank you so much. It worked. [import]uid: 154911 topic_id: 34789 reply_id: 138282[/import]

Glad i could help :slight_smile: [import]uid: 134049 topic_id: 34789 reply_id: 138283[/import]

Uhm, i cant see any point where you define what \_G.currentLevel is

but i suppose you have something in the code that defines that \_G.currentLevel = 1 if so you shouldnt use the _G. part in the require, you only have to use it where you define the variable. simply write:

 local levelSetup = require("levels.setup.level" ..currentLevel .. "setup")

And if you dont have anything that defines what _G.currentLevel, its not that strange since that would be nil in your code example.
[import]uid: 134049 topic_id: 34789 reply_id: 138274[/import]

I defined the currentLevel variable in another file so I forgot to include it here.

I used _G.currentLevel as a global variable and that was the reason to write it that way. Also, I tried your solution and it worked on simulator but again, not on iPad.

It gives an error and I found that by using the method in http://gamedevnation.com/game-development/using-print-from-a-device-kinda/

When I try to invoke the require, it does not work on iPad but it works in the simulator without any problem. [import]uid: 154911 topic_id: 34789 reply_id: 138276[/import]

what does the error say ? [import]uid: 134049 topic_id: 34789 reply_id: 138279[/import]

right, i might know what it is now…

the simulator is not case sensetive, but the ipad is.
so if the file you require has any upper case letters in it, thats probably it. [import]uid: 134049 topic_id: 34789 reply_id: 138280[/import]

Ah, I see.

Thank you so much. It worked. [import]uid: 154911 topic_id: 34789 reply_id: 138282[/import]

Glad i could help :slight_smile: [import]uid: 134049 topic_id: 34789 reply_id: 138283[/import]