Hi everyone,
I am using a file I found online to implement OOP in my game. This class file uses a metatable when defining a new class type.
I have a vector class that uses this and I am wondering how I can setup equality checking of two vectors together. I am not exactly keen on how metamethods work in order to figure this out on my own. Am I out of luck with the metatable being used already?
Need help creating equality metamethod
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- the_spice_must_flow
- Prole
- Posts: 13
- Joined: Thu Jan 04, 2018 10:49 pm
Re: Need help creating equality metamethod
Code: Select all
function Vec2:__eq(rhs)
return self.x == rhs.x and self.y == rhs.y
end
- the_spice_must_flow
- Prole
- Posts: 13
- Joined: Thu Jan 04, 2018 10:49 pm
Re: Need help creating equality metamethod
Thanks, this is the correct answer.
Who is online
Users browsing this forum: Ahrefs [Bot] and 2 guests