Hi
Could someone kindly tell me how to for loop through each char of a string? I'm unsure how this is done with pico 8.
given string s,
for i=1,#s do local c = sub(s, i, i) -- do stuff with c end |
I put "local" here because it's typically faster that way, but it is optional.
Yes, though I'm basing that claim on lua in general more than Pico-8. From what I've read, local variables in general tend to be faster to access. My guess is it's because underlying code has to wade through all the variables and functions available in the scope being used, and local scope has less to wade through.
Very good to know.
I will definitely keep that in mind. Thank you!
Here is a pretty decent explanation of it: https://stackoverflow.com/questions/9132288/why-are-local-variables-accessed-faster-than-global-variables-in-lua
[Please log in to post a comment]