What are : for?

Well, I was wondering what are “:” for in Lua? Thanks

Calling a method on an object.

[lua]object:method(arguments)[/lua]

It is the same as doing this:
[lua]object.method(object, arguments)[/lua]

[editline]03:59PM[/editline]

In the first one, you can use the object inside the function by using self.

[lua]function object:method(arguments)
print(self.Value)
end[/lua]

same as:

[lua]function object.method(object, arguments)
print(object.Value)
end[/lua]

Ok thanks. I understand now :slight_smile:

Also I was wondering about something else, I was wanting to make an entity and I wondered how I Would go about this. Currently I’m looking at the moneyprinter script from DarkRP and figuring it out, but is there a list of things which can be used for entities?

(Like these)
self:SetModel(“models/props_c17/consolebox01a.mdl”)
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)

One final thing, could someone explain exactly what a hook is? Someone explained before but I’m still not too sure.

If someone could help I would be very greatful :slight_smile: Thanks

You can find all of this information on the wiki.

[editline]04:10PM[/editline]

**[Entity

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Entity)**
**[Hook

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Hook)**

Thanks again :slight_smile:
I still don’t quite get what an hook is though. Is it a condition? Like when a player spawns could that be a hook?

Edit - I mean hook not entity :slight_smile:

Almost all objects in Source are entitys - players, props, etc.

Fixed.

Hook is essentially a pretty name for events. You hook your functions to events and they get called when this event occurs.

Ok thanks. So it’s called a “hook” as you’re hooking together an event and function?

Can’t you just do something like this or is hooking the only way?
onevent(event) do function

Hooking is the only way.

[lua]hook.Add(“PlayerConnect” , “ThisHookRemovesItself” , function§ hook.Remove(“PlayerConnect” , “ThisHookRemovesItself”) end )[/lua]

Ok thanks. :slight_smile: