Optimising your script
Luarmor uses Luraph™️ as the obfuscation provider. So if you’re experiencing lags, fps drops, or even crashes, you must use certain macros
in your script. This documentation will show you everything about the LPH_NO_VIRTUALIZE
macro
Why does obfuscation affect performance?
Because Luraph™️ is a VM based obfuscator that generates its own instructions that are interpreted by Luraph, which, in turn, is interpreted by the Lua interpreter. So the number of instruction cycles increases exponentially.
Normally, Lua is extremely fast, therefore you will not notice any performance impact. But when your code runs hundreds of times per second, there will be obvious lags, fps drops, or even freezes during the execution of the instructions above.
A good example would be RenderStepped connections. At this point, everyone knows that you love wrapping your wallhack render function inside this RenderStepped event.
Here is a second example. A metamethod hook on __index
:
How to deal with this problem?
Do not wrap your entire script in LPH_NO_VIRTUALIZE as it defeats the purpose of virtualization (obfuscation). Only use this macro if a function runs more than 30 times per second.
You have to exclude these chunks from obfuscation. You can either use loadstring()
, or LPH_NO_VIRTUALIZE
.
It is recommended to use LPH_NO_VIRTUALIZE
instead of loadstring while excluding chunks from obfuscation, because it is generally harder to view the code when you’re using LPH_NO_VIRTUALIZE
.
How to use LPH_NO_VIRTUALIZE
?
LPH_NO_VIRTUALIZE
takes one constant argument which must be a function, and returns a function that can be called.
It is important to add this on top of your script, so you won’t have issues while running the original code.
You will find some examples below on how to properly use LPH_NO_VIRTUALIZE
:
Where to use LPH_NO_VIRTUALIZE
?
RenderStepped
connectionsHeartbeat
connections__index
metamethod hooks__namecall
metamethod hooks (optional)while true
loops with no delay- GC scan loops
function
s, if they are called by one of those above