I'm relatively new to Love, so I hope I'm not making some dumb mistake here. I'm running Lua 5.3.5 on macOS Catalina and have made a "class" in a file at renderer/renderer.lua in my project. It currently looks like
Code: Select all
local Renderer = {}
function Renderer:Create(o)
print('creating')
t = o or {}
setmetatable(t, self)
self.__index = self
return t
end
-- setup the renderer state based on the engine state
function Renderer:Update(engine)
print('update renderer')
end
-- pass in the engine and choose the correct renderers to draw based on engine.states
function Renderer:Draw(engine)
print('draw renderer')
end
return Renderer
Code: Select all
local Renderer = require('./renderer/renderer')
local renderer = nil
function love.load()
renderer = Renderer:Create()
end
function love.update()
-- no updating here, yet
end
function love.draw()
renderer:Draw()
end
Code: Select all
function love.update()
renderer:Update()
end
Code: Select all
Error: main.lua:16: attempt to call method 'Update' (a nil value)
stack traceback:
[string "boot.lua"]:777: in function 'Update'
main.lua:16: in function 'update'
[string "boot.lua"]:612: in function <[string "boot.lua"]:594>
[C]: in function 'xpcall'