Hello Devs, Today, I want to share a small but QoL tip that might save you guys a minute or so in some large projects.
So, as we all can agree that finding a specific block of logic or functions and related functions can be a little time consuming, especially in a large module script.
Lets take a look at a part of a custom camera script.
--$CAMERA_POSITIONING Positioning
function HeadCam:ActivateCamera()
if(self.Active) then return end
self.Active = true
--Attach Camera Positioner
if(typeof(self.PositionerConnection) == "RBXScriptConnection") then
self.PositionerConnection:Disconnect()
end
--Position Camera Accordingly
--$LOGIC_CAMERA_POSITIONING
self.PositionerConnection = RunSer.PreRender:Connect(function()
local camPos = self.CamPos
local camRot = self.CamRot
if(self.Camera == nil) then return end
self.Camera.CFrame = CFrame.new(camPos)
* CFrame.fromOrientation(rad(camRot.X), rad(camRot.Y), rad(camRot.Z))
end)
end
function HeadCam:DeactivateCamera()
if(not self.Active) then return end
self.Active = false
if(typeof(self.PositionerConnection) == "RBXScriptConnection") then
self.PositionerConnection:Disconnect()
end
end
This script of mine is well over 200 lines or so, and finding this specific positioning logic can be a little time consuming.
So what we can do is add a comment,
now you may ask that whats the tip here? We all use comments in our code.
But, comment in a special way by prefixing the comment with a special character like a #
or a $
that is rarely used in lua’s syntax making it stand out from other lines especially when we use find function of the script editor with SHIFT + F
, and also to capitalize the letters, in the very first line of my code, --$CAMERA_POSITIONING Positioning
, you can see this.
Now all I have to do to find this is press SHIFT + F
, then type $CAMER...
and till that the editor will find me this line. We can also add a LOGIC
prefix after $
to let it take us to the exact camera positioning logic block.
Thats all I had to share for this small tip, excuse me if I may have missed anything or suggest some other ways you guys have done it. Thanks,