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

Is it possible to Overload Comparison Operands?

Started by Ashtoruin, 03 June 2012 - 06:55 PM
Ashtoruin #1
Posted 03 June 2012 - 08:55 PM
I know its possible to overload them in other languages, but I was wondering how you do it in Lua if it is possible, I've been surfing the internet for about 15-30 minutes now and can't really find a decent guide or definate answer that you can do it. But my google skills are pretty bad…

an example is that I want to compare Alpha and Beta, and I want it to recognize that Alpha < Beta and Beta < Gamma, etc.
MysticT #2
Posted 03 June 2012 - 09:11 PM
You can do it with tables, setting the corresponding keys in it's metatable. For other types it's not possible.
Here's the list of the keys you can use.