Page 1 of 1

beginner OOP problem with rxi classic

Posted: Sat Jan 18, 2020 4:08 pm
by drfractal
I am studing an OOP approach to develop my löve game so I included this library in my code:

https://github.com/rxi/classic/blob/master/classic.lua

my basic code is like this:

Object = require 'libraries/classic-master/classic'
function love.load()
Stage = Object:extend()

function Stage:new(name)
self.name = name
end
scene = Stage.new("splash")
end

that gives me error in ____ self.name = name ____ line telling me that I am attempting to index global a nil value...
Can someone kindly explain me what is it doing wrong and help me deduce what I have not understood in objects and reference or maybe just in the english sentence of the error message...
Thank you

Re: beginner OOP problem with rxi classic

Posted: Sun Jan 19, 2020 11:42 am
by pgimeno
You need : in the second call:

Code: Select all

scene = Stage:new("splash")
I think this may work as well:

Code: Select all

scene = Stage("splash")