Page 1 of 1

Problem with importing lua file

Posted: Thu Dec 03, 2015 6:18 am
by RBXcpmoderator12345
My code in main.lua is:

Code: Select all

levelprocessor = require "levelprocessor.lua"

function love.load()
healthbar = love.graphics.newImage("ui/Untitled.png")
good_health = love.graphics.newQuad(0, 0, 100, 36, healthbar:getDimensions())
caution_health = love.graphics.newQuad(100,36,102, 36, healthbar:getDimensions())
warning_health = love.graphics.newQuad(102,36,204,36,healthbar:getDimensions())
grass_top_singular = love.graphics.newImage("blocks/grassdirt/grass.png")
 end

function love.draw()
	love.graphics.draw(grass_top_singular, 0,568,0,2,2); 
	levelprocessor.processFile("level1.lua")
end
The error is too large to show here, so I will make a .love of this.

Re: Problem with importing lua file

Posted: Thu Dec 03, 2015 6:38 am
by slime
Require's argument needs to be a module name without the .lua extension (and preferably with . instead of / if it's in a directory), so if you do require "levelprocessor" instead of require "levelprocessor.lua" it should work.

Re: Problem with importing lua file

Posted: Thu Dec 03, 2015 7:06 pm
by RBXcpmoderator12345
I have a new problem.
It says that levelprocessor is a boolean value.

Re: Problem with importing lua file

Posted: Thu Dec 03, 2015 7:27 pm
by RBXcpmoderator12345
Nevermind, solved it
turns out my module didn't return any functions, that is why it returned nil