Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What does the global "continue" mean?

Asked by 4 years ago

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
0
What do you think it does? JesseSong 3916 — 4y
0
Idk... Continue the script? If you were in a while true do loop or something. youtubemasterWOW 2741 — 4y
0
Yes JesseSong 3916 — 4y
0
oh youtubemasterWOW 2741 — 4y
0
Also lua does not support the function continue therefore it will probably return nil. JesseSong 3916 — 4y

1 answer

Log in to vote
2
Answered by 4 years ago
Edited 4 years ago

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.

1
Isn't there a "continue" global in Roblox Studio? Try it in a script. youtubemasterWOW 2741 — 4y
0
There isnt a function called continue sadly even if you try to do it it will return nil since it does not exist JesseSong 3916 — 4y
0
oh youtubemasterWOW 2741 — 4y
Ad

Answer this question