JeViCo Posted December 30, 2019 Posted December 30, 2019 I know that variable access speed higher for local variables. Does this work on functions as well? Can i do something like this at the beginning of the script: local tocolor = tocolor local dxGetTextWidth = dxGetTextWidth local dxGetFontHeight = dxGetFontHeight local dxDrawText = dxDrawText local dxDrawImage = dxDrawImage local getElementPosition = getElementPosition local getElementRotation = getElementRotation local getPedCameraRotation = getPedCameraRotation local getDistanceBetweenPoints2D = getDistanceBetweenPoints2D local dxGetMaterialSize = dxGetMaterialSize local getElementData = getElementData
Moderators IIYAMA Posted December 30, 2019 Moderators Posted December 30, 2019 (edited) 2 hours ago, JeViCo said: Does this work on functions as well? In general it does matter. A function name is a variable after all. But for MTA(C++) functions you have to make an exception. For some unknown reason they are just as fast as localized functions. (I tested that a while back.) For self created functions, yes localized is faster accessible. Feel free to re-test it. Loop i= 1000 + getTickCount Note, this matters: (but not because it is localized, but because it pre-indexed) local tableRemove = table.remove Edited December 30, 2019 by IIYAMA 1 Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now