startTile is always the same as the last call to getTile. So in the example above, startTile is the same as endTile, but only after I call endTile = self:getTile. I can't figure it out. Probably something small I'm missing, I've been staring at it too long.
test = {}
test.__index = test
function test:new(x)
local newTest = {}
setmetatable(newTest, test)
self.x = x
return newTest
end
t1 = test:new(1)
t2 = test:new(2)
print(t1, t2)
print(t1.x, t2.x)
local ClassName = {};
function ClassName.new()
local self = {};
local baz = 'Foo is Löve, All is Löve' -- Private attribute
self.bazooka = true -- Public attribute
-- Private function
local function bar()
-- Do stuff
end
-- Public function
function self:foo()
-- Do stuff
end
return self;
end
return ClassName;
local ChildClass = {};
function ChildClass.new()
local self = ParentClass.new(); -- Use the table from the parent class.
return self;
end
return ChildClass;
It's how I code all my Lua projects. I like the simplicity and the clean code it gives you.
marco.lizza wrote:
in my opinion. There's no point in using the
Just to seem helpful, gonna link this post in here as well, as to not duplicate what has once already been written down.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.