Well, I was wondering what are “:” for in Lua? Thanks
Calling a method on an object.
It is the same as doing this:
In the first one, you can use the object inside the function by using self.
[lua]function object.method(object, arguments)
Ok thanks. I understand now
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?
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 Thanks
You can find all of this information on the wiki.
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
Almost all objects in Source are entitys - players, props, etc.
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]