Copying my old Custom Objects guide on the wiki,
[lua]
Int = {}
function Int:new(one, two, three)
newTB = {x, y, z}
newTB.x = one
newTB.y = two
newTB.z = three
function newTB.SetInt() --Here we create a method called SetInt()
newTB.x = 90
newTB.y = 900
newTB.z = 9000
end
return newTB
end
a = Int.new(5, 8, 10)
print(a.x) --5
print(a.y) --8
print(a.z) -- 1
a:SetInt()
print(newTB.x) --90
print(newTB.y) --900
print(newTB.z) --9000
[/lua]
The result:
umm?
Oh hey - I don't know what I did - but it works now.
[lua]
Int = {}
function Int:new(one, two, three)
newTB = {x, y, z}
newTB.x = one
newTB.y = two
newTB.z = three
function newTB.SetInt() --Here we create a method called SetInt()
newTB.x = 90
newTB.y = 900
newTB.z = 9000
end
return newTB
end
a = Int.new(5, 8, 10)
print(a.x) --5
print(a.y) --8
print(a.z) -- 1
a:SetInt()
print(newTB.x) --90
print(newTB.y) --900
print(newTB.z) --9000
[/lua]
The result:
wth? Wrote:8
10
nil
90
900
9000
umm?
Oh hey - I don't know what I did - but it works now.