I’ve heard if/elseif’s are slow does switch statement exist in lua?
I want to optimise my game for speed.
Currently using if’s and elseifs but wondering if there is a better solution than this.
They aren’t slow and no Lua doesn’t have switch. Who told you that they were slow? The use of if/elseif clauses shouldn’t be your bottleneck and it is likely something else.
5 Likes
I’m just familiar with different types of code, thank you anyway I will continue to what i’m doing.
Thanks for feedback, yeah i’m just optimising everything I can possibly.
I saw you got your solution, just wanted to put this out here:
print(tick()) print(tick())
Difference was .06 seconds
print(tick()) if 1 == 1 then end print(tick())
Difference was .0015 seconds.
Second one ran faster, which should indicate that there’s nothing about it that would slow the script down, especially by any amount which is noticeable.
3 Likes