local Hi = {}
function Hi.Destroy()
----
end
or also
local Hi = {}
function Hi:ChangeValueToInfinite()
----
end
local Hi = {}
function Hi.Destroy()
----
end
or also
local Hi = {}
function Hi:ChangeValueToInfinite()
----
end
doing:
local car = {
start = function()
print("starting car")
end,
move = function()
print("moving at 20 MPH")
end
}
is equivalent to doing:
local car = {}
function car.start()
print("starting car")
end
function car.move()
print("moving at 20 MPH")
end
so basically doing that is another way of defining a method of an object (or as you might call it a table in Lua)..
you can do object.X = Y;where X is a property name, and Y is the value of the property, but if you really think about it, there isn't the same syntax for methods without using function object.methodName().. which would only limit you to do:
object = {methodName = f()} or
object.methodName = f()
This discussion is preserved as it was. New answers, comments, and votes are closed.
4 comments
You forgot metamethods
@Fearhren this kinda tells all that.. Metamethods are declared just like other method, with underscores prefixing
Not at all
@Fearhren you can define a metamethod like this: function MetaTable.__MetaMethod()