Hello. Recently I've been exploring and going deeper in Lua Scripting, and I came across the global variable "continue." What does it mean and what does it do?
continue
I don't believe this is an actual Lua global, but often a global provided by a large variety of other programming languages, such as C. In Lua, the continue global doesn't actually exist, but can be simulated in Lua 5.2 via the goto statement, or simulated in roblox Lua(Lua 5.1) to a limited extent via a boolean flag.
for i = 1, 10 do local ShouldSkip = false if i == 5 then ShouldSkip = true end if not ShouldSkip then -- Acts as a sort of continue with the ShouldSkip = true print(i) end end
Now I'm very much aware there are some redundancies, but this is just to illustrate the point. Essentially, continue works by essentially skipping some code, such as print(i) in this scenario. It's not too relevant in Lua due to the fact that there's no implementation for it, but it's often used in C as a way to essentially "skip" a section of code in a loop.
If there are any corrections regarding this, please let me know in the comments, as well as any information that could be added. From what I could tell from both prior knowledge, as well as some research regarding this topic, it appears as if there's no Lua global as far as I could find, though this could very well not be the case.