Problem with importing lua file

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
RBXcpmoderator12345
Citizen
Posts: 59
Joined: Sat Mar 07, 2015 11:53 pm

Problem with importing lua file

Post 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.
Attachments
newgame.love
(2.26 MiB) Downloaded 84 times
User avatar
slime
Solid Snayke
Posts: 3134
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Problem with importing lua file

Post 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.
RBXcpmoderator12345
Citizen
Posts: 59
Joined: Sat Mar 07, 2015 11:53 pm

Re: Problem with importing lua file

Post by RBXcpmoderator12345 »

I have a new problem.
It says that levelprocessor is a boolean value.
Attachments
newgame.love
(2.26 MiB) Downloaded 76 times
RBXcpmoderator12345
Citizen
Posts: 59
Joined: Sat Mar 07, 2015 11:53 pm

Re: Problem with importing lua file

Post by RBXcpmoderator12345 »

Nevermind, solved it
turns out my module didn't return any functions, that is why it returned nil
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 71 guests