On the devforum, I see that programs typically use something like this:
1 | function CameraModule:LockMouse() |
2 | if self.activeCameraController then |
3 | local mouseLockOffset = self.activeMouseLockController:GetMouseLockOffset() |
4 | self.activeCameraController:SetIsMouseLocked( true ) |
5 | self.activeCameraController:SetMouseLockOffset(mouseLockOffset* 3 ) |
6 | end |
7 | end |
8 | --This is just an example of someone using the 'self' thing. |
If you see this, there is a thing called self
. What is self
, and what are the practical uses of using self in functions like this?
Any help is appreciated!
https://devforum.roblox.com/t/what-is-self-and-how-can-i-use-it/368697
Now to answer your question, we use self as a way to access the previous argument called in the function, without passing the argument explicitly. self is notably used in Object Oriented Programming Implementation in Lua.