C# Luainterface two dots

343 Views Asked by At

Is there any way to change the access to my C# object methods in Lua by turning two dots into one? I want to change this:

Object:DoSomething();

Into this:

Object.DoSomething();

Without getting any errors. Any ideas? Thanks in advance.

2

There are 2 best solutions below

2
Colonel Thirty Two On BEST ANSWER

The two lines do different things. Object:DoSomething() is syntax sugar for Object.DoSomething(Object). It's what turns a regular object lookup+function call into a method call.

So no, there's no way to do this.

0
Tom Blodget On

No. Here's an alternative...

You can consider Object:DoSomething() to be a .NET extension method. Just like a .NET extension method, you can choose to call it like the "static" method it is:

Object.DoSomething(Object);