To make this simple, I'm going to take a chunk of code as an example.
I tried my main.lua file, down in my love.draw function, I used to have the typical "love.graphics.setBackgroundColor(1, 1, 1)" in my love.draw function - and it worked just fine.
Then, to shorten that, I made a separate file called "wrapper.lua" - which contains the following code:
Code: Select all
function BGColor(r, g, b)
love.graphics.setBackgroundColor(r, g, b)
end
Code: Select all
require "wrapper"
Code: Select all
function love.draw()
BGColor(1, 1, 1)
end
"attempt to call global 'BGColor' (a nil value)"
HOWEVER, when I replace my "require" function with all the code in "wrapper.lua" instead - it works wonderfully.
Yes, "wrapper.lua" is in the same folder as "main.lua".
And yes, I tried require ("wrapper") with the parenthesis instead - which also didn't work.
And just in case, I also renamed wrapper.lua to something random (lookadis.lua) in case it was the file name for some weird reason, but that didn't work either.
Can anyone let me know what I'm doing wrong?