While loops, or "while-true-do" loops, are one of the simplest loops in Lua. β¨
They're like if-statements, but they check the condition infinitely until stopped. π
Here's an example π
If the condition is true, the code inside the loop will run. π
If it's false, the loop will check again the next frame! π
This means that any code AFTER the loop will NEVER run, unless the loop is stopped. β
To create a while loop, simply write "while X do", replacing X by a condition. After that comes your code and don't forget to close it with an "end". π€
Like this π
βIMPORTANT π
All these loops are just examples. In reality, the code would crash if you tried to use these. β
π
Why is that? π€
It's because the loop would try to run infinitely each frame. We always need to include some sort of delay, so the loop pauses and "cools down" βοΈ
So, while loops are very easy to learn if you already know about if-statements. π
If you didn't understand something, click on my profile and read the previous threads. π€
If you'd like to learn more, follow @notactulurus to stay updated about tomorrow's thread - which is about the FOR-LOOP β¨
If we surpass @AntcarTweets in follower count, my last follower will get 1k R$! πΈ
β’ β’ β’
Missing some Tweet in this thread? You can try to
force a refresh
Variables - their purpose is to store data inside a script. ποΈ
They consist of a name and a value. π€
Their name is used to ACCESS the variable (read or write) and their value can be a number, string, boolean or even a table. I'll go over all the types later π
The name of a variable can contain any alphanumerical characters, but must NOT START with a number! π’