Level = {}
function Level:get(map)
if map ~= nil then
level = map
else
level = "../levels/levelCrash"
end
return level
end
function Level:draw(level)
Map = require level
Map:create()
end
return Level
The exact error is: levelLoader.lua:16: '=' expected near 'Map'
Can someone help me fix this problem?
Require is not a magic word, it is a function. With functions as long as you only have one argument and it's a string, then you do not need parenthesis. If you use a variable or concatenate a string, you'll need to enclose it.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
I just wanted to say that that is some very strange code. You have your level object overriding what it is in the get method, which means that the level would lose the methods you've attached to it.
Also in your draw method, you are calling require and create map. That doesn't make any sense for something you would expect to be called in rendering.