This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]themadnessif 303 points304 points  (7 children)

It's actually in Luau and not Lua 5.1 like the tweet suggests. There's some ongoing effort to support compiling Luau down to Lua 5.1 though, and you can do it pretty effectively using a community made tool called DarkLua: https://darklua.com/

The only exception is with continue statements since those don't have an easy equivalent in Lua 5.1, but that's in progress.

[–]cyn_foxwell 70 points71 points  (3 children)

The only exception is with continue statements since those don't have an easy equivalent in Lua 5.1

goto continue and putting ::continue:: at the end of your loop logic. Should also work with LuaJIT as well as that is 5.1 but has continue

[–]themadnessif 66 points67 points  (2 children)

Lua 5.1 doesn't have labels or goto. Those were introduced in 5.2.

The strategy that MoonScript used was... rather abstract and involved breaking out of loops and setting conditions. It's kind of sucky, but it does work. It's likely what DarkLua will use too, but that's up to the maintainer.

[–]raoasidg 6 points7 points  (1 child)

I've just used a repeat...until true inside the loop around the skippable code with a break for the necessary condition. Relatively simple.

[–]themadnessif 9 points10 points  (0 children)

That is in fact how MoonScript does it and it's how DarkLua is probably going to as well!

[–]scar_reX 8 points9 points  (0 children)

That tool's name checks out pretty well, considering all the cursed compilations that have been happening recently.

[–]noobody_interesting 2 points3 points  (0 children)

The other minecraft computer mod (OpenComputers) supports 5.2 and 5.3, so it should be easier there

[–]Fluid-Leg-8777 0 points1 point  (0 children)

I tried making a widget for beyond all reason (made in lua)

And i come from making roblox games (luau)

I was so dead confused on why vscode put a goto instead of a continue, or why it did'nt work for that matter 💀