Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

What is self and how can I use this thing called self?

Asked by 4 years ago
Edited 4 years ago

On the devforum, I see that programs typically use something like this:

function CameraModule:LockMouse()
    if self.activeCameraController then
        local mouseLockOffset = self.activeMouseLockController:GetMouseLockOffset()
        self.activeCameraController:SetIsMouseLocked(true)
        self.activeCameraController:SetMouseLockOffset(mouseLockOffset*3)
    end
 end
--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!

0
Search Results Featured snippet from the web 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. Haker902c 18 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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.

Ad

Answer this question