Jump to content




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


  • You cannot reply to this topic
3 replies to this topic

#1 H4X0RZ

  • Members
  • 1,315 posts
  • LocationGermany

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

#2 LBPHacker

  • Members
  • 766 posts
  • LocationBudapest, Hungary

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.

#3 Yevano

  • Members
  • 376 posts
  • LocationUSA

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


#4 H4X0RZ

  • Members
  • 1,315 posts
  • LocationGermany

Posted 04 November 2013 - 05:19 PM

Oh, I will try it tomorrow :)
Thx for the help!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users