class = require ("Middleclass.middleclass")
-- https://github.com/kikito/middleclass
Person = class('Person')
function Person:initialize()
self.name = ""
end
Error on main.lua:
line = myperson = cls.Person:new()
error = attempt to index global 'cls' (a boolean value)
It is treating cls as a table. I think. I want it to instantiate the PERSON class in myclasses.lua file. It works if I dump it all into main.lua but I want to keep my classes together in a separate file for editability reasons.
You have to return the value that represents the module from the module file (i.e. return the 'Person' table from myclasses.lua). If you don't do that then the value will be 'true' (i.e. cls will be 'true', and thus you get that error).
There's another issue in the code. One reason to use modules is so that you don't have to create/use globals, but instead only use local variables. The code you posted currently defines 'cls', 'myperson', 'class' and 'Person' as globals. I suggest reading the manual about variables and local declarations.
(Also, none of this has anything to do specifically with the middleclass library.)