This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
H4X0RZ's profile picture

Oo Isn't Working (gui: 62: Expected Number,number)

Started by H4X0RZ, 04 November 2013 - 11:43 AM
H4X0RZ #1
Posted 04 November 2013 - 12:43 PM
Title is bugged

Hello community,
I was working on an API (most for personal uses) which uses OOP, but I allways get an error.
I checked it many times and I'm sure that "self.sx" and "i" are numbers!

Here is the link: http://pastebin.com/QzMBZqx9

The Error

gui: 62: expected numer,number

What is wrong?

Would be cool if anyone can help me :)/>

~Freack100
LBPHacker #2
Posted 04 November 2013 - 12:59 PM
On line 63 self.length is nil, since the constructor assigns self.l to length, not self.length. (It's not the cause of the error, but you should fix that anyway…)
EDIT: Nah, in that case Lua would complain about the for limit not being a number. Sorry.

For the record, use nil, not null. I know that null is not set, so it's nil, but nil makes the code more readable.
Yevano #3
Posted 04 November 2013 - 04:34 PM
The __call metamethod gets passed the table that was being called as its first parameter. Because you take sX as your first parameter, the table gets assigned instead. You need to do this:


function SquareClass.__call(t, ...)
	return SquareClass.new(...)
end
H4X0RZ #4
Posted 04 November 2013 - 05:19 PM
Oh, I will try it tomorrow :)/>
Thx for the help!