Shoresy Posted March 23 Posted March 23 Here is everyone’s first exercise! Create a program that prints the function “Hello World!” Quote
phir0x Posted March 23 Posted March 23 49 minutes ago, captnconcrete said: in java c++ or python? Taken from the original post => The course would begin with Lua fundamentals and syntax, then progress into writing your own Lua scripts Quote
ET Member Popular Post RNGesus Posted March 23 Author ET Member Popular Post Posted March 23 (edited) Stage 1 - Class 1 What Code Is + Your First Lua Commands Welcome to Stage 1, Class 1 of our Learn To Code with RNGesus series. This course is for people who know absolutely nothing about coding. That is not a bad thing. That is exactly who this class is for. You do not need experience. You do not need to understand computers deeply. You do not need to be good at math. You only need to be willing to learn one small step at a time. In this first class, we are not touching ETLegacy scripting yet. We are starting even more basic than that. We are learning: what code is what Lua is what a script is how to use print() how code runs from top to bottom the difference between text and numbers Class Goal By the end of this lesson, you should be able to: explain what code is in simple words explain what Lua is run a few tiny Lua commands use print() to display text and numbers understand that code runs from the top line down Before We Start For this class, do not worry about ETLegacy yet. We are just learning basic Lua. You can follow along using: a basic Lua interpreter a simple online Lua runner https://onecompiler.com/lua The goal today is understanding, not speed. Part 1: What is code? Code is just a list of instructions for a computer. That is all it is. A computer does not guess what you mean. A computer does not fill in missing steps. A computer only does exactly what you tell it to do. Think of it like this: If you tell a human: make a sandwich A human can guess what you mean. A computer cannot. A computer would need every step clearly written out. Something more like: get bread get ham put ham between bread put sandwich on plate That is what coding is like. It is writing instructions in a way the computer can follow exactly. Important idea Computers are very fast, but very literal. If your instructions are wrong, incomplete, or confusing, the computer will not magically fix them for you. That is why programmers must learn to be clear. Part 2: What is Lua? Lua is a programming language. A programming language is just a way for humans to write instructions for computers. So if someone asks: What is Lua? A very beginner-friendly answer is: Lua is a language used to write code. That is enough for now. Later on, we will use Lua for ETLegacy related scripting, but first we need to learn plain Lua basics. Part 3: What is a script? A script is just a file that contains code. So: Lua = the language Lua script = a file written in Lua If you write a few lines of Lua code in a file, that file is a Lua script. Very simple. Part 4: Your first Lua line Here is your first line of Lua code: print("Hello world") Let us break it apart. print print tells Lua to show something. ( This opens the value we want to give to print. "Hello world" This is text. Text in Lua is placed inside quotes. ) This closes the value for print. So this line means: Show the text Hello world If you run it, the output should be: Hello world Part 5: Try more print() lines Here are a few more examples: print("Welcome to Lua") print("This is my first class") print("Rngesus is cewl") Output: Welcome to Lua This is my first class Rngesus is cewl Each line tells Lua to print one piece of text. Part 6: Code runs from top to bottom Look at this: print("Line 1") print("Line 2") print("Line 3") Output: Line 1 Line 2 Line 3 Lua runs code from the top line downward. This is one of the most important beginner ideas in all of programming. The computer does not jump around randomly. It follows the order of the code. Top to bottom. Part 7: Printing numbers print() can also show numbers. Example: print(5) print(10) print(100) Output: 5 10 100 Notice something important here: The numbers are not inside quotes. That matters. Part 8: Text and numbers are not the same Look at these two lines: print("5") print(5) They may look similar, but they are not the same thing. "5" This is text because it is inside quotes. 5 This is a number because it is not inside quotes. That difference is extremely important in programming. For now, just remember: quotes usually mean text no quotes means it may be a number Part 9: Lua can do simple math Try this: print(5 + 5) print(10 - 3) print(4 * 2) Output: 10 7 8 Lua can calculate math and then print the result. So this: print(5 + 5) does not print: 5 + 5 It prints the answer: 10 Because 5 + 5 is a math expression. Part 10: Quotes change the meaning Compare these: print(5 + 5) print("5 + 5") Output: 10 5 + 5 Why? Because: 5 + 5 without quotes is math "5 + 5" with quotes is just text This is a very good beginner example of how important quotes are. Part 11: Common beginner mistakes Here are a few normal mistakes people make in lesson one. Mistake 1: Forgetting the quotes around text Wrong: print(Hello world) Why it is wrong: Lua will not understand that Hello world is supposed to be text. Correct: print("Hello world") Mistake 2: Forgetting the closing parenthesis Wrong: print("Hello world" Correct: print("Hello world") Mistake 3: Mixing up text and numbers print("5") print(5) These are different. One is text, one is a number. That may not seem important yet, but it will matter a lot later. Part 12: What you learned today If you understood this lesson, you now know that: code is a set of instructions Lua is a programming language a script is a file with code in it print() shows output code runs from top to bottom quotes make something text numbers without quotes can be used for math That is a real start. It may feel tiny, but this is exactly how coding begins. Nobody starts with advanced scripts. Everybody starts with simple lines like this. Edited March 23 by RNGesus typo corrections 5 1 4 Quote
ET Member RNGesus Posted March 23 Author ET Member Posted March 23 For those following along write your own Lua script and post it here. Dont try to be overly elaborate print something cool or do some neat path in a print! See you tomorrow for lesson 2! Quote
80sDUDE Posted March 23 Posted March 23 1 hour ago, RNGesus said: Stage 1 - Class 1 What Code Is + Your First Lua Commands Welcome to Stage 1, Class 1 of our Learn To Code with RNGesus series. This course is for people who know absolutely nothing about coding. That is not a bad thing. That is exactly who this class is for. You do not need experience. You do not need to understand computers deeply. You do not need to be good at math. You only need to be willing to learn one small step at a time. In this first class, we are not touching ETLegacy scripting yet. We are starting even more basic than that. We are learning: what code is what Lua is what a script is how to use print() how code runs from top to bottom the difference between text and numbers Class Goal By the end of this lesson, you should be able to: explain what code is in simple words explain what Lua is run a few tiny Lua commands use print() to display text and numbers understand that code runs from the top line down Before We Start For this class, do not worry about ETLegacy yet. We are just learning basic Lua. You can follow along using: a basic Lua interpreter a simple online Lua runner https://onecompiler.com/lua The goal today is understanding, not speed. Part 1: What is code? Code is just a list of instructions for a computer. That is all it is. A computer does not guess what you mean. A computer does not fill in missing steps. A computer only does exactly what you tell it to do. Think of it like this: If you tell a human: make a sandwich A human can guess what you mean. A computer cannot. A computer would need every step clearly written out. Something more like: get bread get ham put ham between bread put sandwich on plate That is what coding is like. It is writing instructions in a way the computer can follow exactly. Ideia importante Os computadores são muito rápidos, mas muito literais. If your instructions are wrong, incomplete, or confusing, the computer will not magically fix them for you. That is why programmers must learn to be clear. Part 2: What is Lua? Lua is a programming language. A programming language is just a way for humans to write instructions for computers. So if someone asks: What is Lua? A very beginner-friendly answer is: Lua is a language used to write code. That is enough for now. Later on, we will use Lua for ETLegacy related scripting, but first we need to learn plain Lua basics. Part 3: What is a script? A script is just a file that contains code. So: Lua = the language Lua script = a file written in Lua Se você escrever algumas linhas de código Lua em um arquivo, esse arquivo é um script Lua. Very simple. Parte 4: Sua primeira linha em Lua Here is your first line of Lua code: print("Hello world") Let us break it apart. print print tells Lua to show something. ( This opens the value we want to give to print. "Hello world" This is text. Text in Lua is placed inside quotes. ) This closes the value for print. So this line means: Show the text Hello world If you run it, the output should be: Hello world Part 5: Try more print() lines Here are a few more examples: print("Bem-vindo ao Lua") print("Esta é minha primeira aula") print("Rngesus é cewl") Saída: Bem-vindo ao Lua Esta é a minha primeira aula. Rngesus é cewl Cada linha instrui o Lua a imprimir um trecho de texto. Parte 6: O código é executado de cima para baixo. Veja só: imprimir("Linha 1") imprimir("Linha 2") imprimir("Linha 3") Saída: Linha 1 Linha 2 Linha 3 Lua executa o código da primeira linha para a segunda. Essa é uma das ideias mais importantes para iniciantes em toda a programação. O computador não fica pulando de um lado para o outro aleatoriamente. Segue a ordem do código. De cima para baixo. Parte 7: Impressão de números print()Também pode exibir números. Exemplo: imprimir(5) imprimir(10) imprimir(100) Saída: 5 10 100 Observe algo importante aqui: Os números não estão entre aspas. Isso importa. Parte 8: Texto e números não são a mesma coisa Observe estas duas linhas: imprimir("5") imprimir(5) Podem parecer semelhantes, mas não são a mesma coisa. "5" Este texto está entre aspas. 5 Trata-se de um número, pois não está entre aspas. Essa diferença é extremamente importante na programação. Por agora, lembre-se apenas: Aspas geralmente se referem ao texto. Sem aspas significa que pode ser um número. Parte 9: Lua consegue fazer cálculos matemáticos simples Experimente isto: imprimir(5 + 5) imprimir(10 - 3) imprimir(4 * 2) Saída: 10 7 8 Lua consegue realizar cálculos matemáticos e imprimir o resultado. Então isto: imprimir(5 + 5) Não imprime: 5 + 5 Ele imprime a resposta: 10 Porque 5 + 5é uma expressão matemática. Parte 10: As citações alteram o significado Compare estes: imprimir(5 + 5) imprimir("5 + 5") Saída: 10 5 + 5 Por que? Porque: 5 + 5sem aspas é matemática "5 + 5"com aspas é apenas texto Este é um ótimo exemplo para iniciantes de como as citações são importantes. Parte 11: Erros comuns de iniciantes Aqui estão alguns erros comuns que as pessoas cometem na primeira aula. Erro 1: Esquecer as aspas em torno do texto Errado: imprimir(Olá mundo) Por que isso está errado: Lua não entenderá isso Hello worldDeveria ser um texto. Correto: print("Olá mundo") Erro 2: Esquecer o parêntese de fechamento Errado: print("Olá mundo" Correto: print("Olá mundo") Erro 3: Confundir texto com números imprimir("5") imprimir(5) São diferentes. Um é texto, o outro é um número. Isso pode não parecer importante agora, mas será muito importante mais tarde. Parte 12: O que você aprendeu hoje Se você entendeu esta lição, agora sabe que: Código é um conjunto de instruções. Lua é uma linguagem de programação. Um script é um arquivo que contém código. print()mostra a saída O código é executado de cima para baixo. As citações transformam algo em texto. Números sem aspas podem ser usados para matemática. Isso é um ótimo começo. Pode parecer insignificante, mas é exatamente assim que a programação começa. Ninguém começa com scripts avançados. Todo mundo começa com frases simples como esta. Very good. Thanks, dude! Quote
Element' Posted March 23 Posted March 23 print("Hello everyone") print("I like cats") print("and fly fishing") print("and sometimes ET") 🙃 1 1 Quote
ET Member RNGesus Posted March 25 Author ET Member Posted March 25 Part 1: What is a variable? A variable is a place to store information. The easiest way to think about a variable is: A variable is like a labeled box. Imagine you have a box with the label: name And inside that box, you put: RNGesus Now whenever you look in the name box, you find Rngesus. That is basically what a variable does in code. It lets you give a name to a piece of information so you can use it later. Part 2: Your first variable Look at this: name = "RNGesus" This creates a variable called name and stores the text "Rngesus" inside it. Let us break it apart. name This is the variable name. = This means: put the value on the right into the variable on the left "RNGesus" This is the value being stored. So this line means: Store the text RNGesus inside the variable named name Part 3: Printing a variable Now look at this: name = "RNGesus" print(name) Output: RNGesus Important detail: When we write: print(name) we are not printing the word name. We are printing the value stored inside the variable called name. That is a big difference. Part 4: More variable examples Here are a few more: playerName = "RNGesus" score = 25 weapon = "MP40" This creates three variables: playerName stores the text "RNGesus" score stores the number 25 weapon stores the text "MP40" Now print them: playerName = "RNGesus" score = 25 weapon = "MP40" print(playerName) print(score) print(weapon) Output: RNGesus 25 MP40 Part 5: Variable names You get to choose variable names. That means the names should be clear. Good variable names: playerName = "rngesus" kills = 10 mapName = "oasis" Bad variable names: x = "rngesus" a = 10 stuff = "oasis" Why are the first ones better? Because they make the code easier to understand. When beginners read code, clear names help a lot. Part 6: Variables can store different kinds of data A variable can store text: name = "RNGesus" A variable can store a number: score = 50 A variable can even store the result of math: total = 5 + 5 Then: print(total) Output: 10 So variables do not only store words. They can also store numbers and results. Part 7: Using variables together with print This is where variables start feeling useful. Example: name = "RNGesus" kills = 12 print(name) print(kills) Output: RNGesus 12 Now let us combine text and variables: name = "rng" kills = 12 print(name .. " has " .. kills .. " kills") Output: rng has 12 kills Do not worry if the .. looks strange. For now, just think of it like this: .. joins pieces together. So this: name .. " has " .. kills .. " kills" joins: the value in name the text " has " the value in kills the text " kills" into one message. Part 8: Variables can change One of the most important things about variables is that the value inside them can change. Look at this: score = 10 print(score) score = 20 print(score) Output: 10 20 The variable is still called score. But the value inside it changed from 10 to 20. That is why it is called a variable. The value can vary. Part 9: Updating a variable Now look at this: score = 10 score = score + 5 print(score) Output: 15 This is a very important example. Let us go slowly. First line score = 10 Store 10 in score Second line score = score + 5 This means: take the current value of score add 5 put the new result back into score So if score was 10, then: score + 5 becomes 15 now score becomes 15 Then: print(score) prints: 15 Part 10: Very important beginner warning about = In school math, = often means: "is equal to" In programming, = usually means: assign this value to this variable That is why this line is valid in programming: score = score + 5 In math class, that would look wrong. But in programming it makes sense because it means: take the old score, add 5, and store the new score back into score This confuses almost every beginner at first, so if it feels weird, that is normal. Part 11: Step-by-step example Read this slowly: kills = 3 print(kills) kills = kills + 1 print(kills) kills = kills + 1 print(kills) What happens? First line kills becomes 3 First print prints 3 Then kills = kills + 1 That means: old value is 3 add 1 new value becomes 4 Second print prints 4 Then again kills = kills + 1 That means: old value is 4 add 1 new value becomes 5 Final print prints 5 Output: 3 4 5 Part 12: Common beginner mistakes These are very normal mistakes in the variables lesson. Mistake 1: Forgetting quotes around text Wrong: name = rngesus Why it is wrong: Lua will not know that rngesus is supposed to be text. Correct: name = "rngesus" Mistake 2: Putting quotes around numbers when you want a number This is not always an error, but it changes what the value is. score = "10" This stores text. score = 10 This stores a number. That difference matters. Mistake 3: Printing the wrong thing Look at this: name = "Rngesus" print("name") Output: name Why? Because "name" is text. If you want the value inside the variable, write: print(name) Output: Rngesus Mistake 4: Using a variable before giving it a value Example: print(score) If score was never set first, that is a problem. Always make sure the variable has a value before you use it. 3 1 Quote
ET Member RNGesus Posted March 26 Author ET Member Posted March 26 (edited) I apologize for missing yesterday everyone! Part 1: What is a string? A string is text. That is the simple answer. In Lua, text is usually written inside quotes. Example: print("Hello") print("RNGesus") print("Welcome to class") Each of those is a string because each is text inside quotes. So: "Hello" is a string. And: "MP40" is also a string. And: "oasis" is also a string. If it is text in quotes, it is usually a string. Part 2: What is a number? A number is a number value. Examples: print(5) print(25) print(100) These are numbers because they are not inside quotes. So: 5 is a number. And: 25 is a number. And: 100 is a number. Numbers are used for things like: score kills health ammo time Part 3: Strings and numbers are not the same Look at this: print("5") print(5) These may look similar, but they are different. "5" This is a string because it is text in quotes. 5 This is a number because it is not in quotes. Output: 5 5 The output may look the same, but the type of value is different. This is very important. One is text. One is a number. Computers care about that difference even if it looks similar to us. Part 4: Quotes change the meaning Look at these examples: print(10 + 5) print("10 + 5") Output: 15 10 + 5 Why? Because: 10 + 5 without quotes is math "10 + 5" with quotes is just text So quotes do not just decorate something. They change what it is. That is one of the biggest beginner lessons in coding. Part 5: Storing strings in variables You can store strings in variables. Example: name = "RNGesus" weapon = "Thompson" mapName = "oasis" print(name) print(weapon) print(mapName) Output: RNGesus Thompson oasis All three of those variables are storing strings because the values are text in quotes. Part 6: Storing numbers in variables You can also store numbers in variables. Example: kills = 12 health = 100 ammo = 30 print(kills) print(health) print(ammo) Output: 12 100 30 These are numbers because they are not inside quotes. Part 7: Joining strings together In Lua, we use .. to join strings together. This is called concatenation, but you do not need to worry about that word too much yet. For now, just remember: .. joins pieces of text together Example: print("Hello" .. " world") Output: Hello world What happened? Lua joined: "Hello" " world" into one bigger string. Notice the second string has a space at the beginning: " world" That space matters. If you wrote: print("Hello" .. "world") the output would be: Helloworld because there is no space between them. Part 8: Joining strings and variables Now let us do something more useful. name = "RNGesus" print("Hello " .. name) Output: Hello RNGesus Lua takes: the string "Hello " the value inside name and joins them together. Here is another: weapon = "MP40" print("Current weapon: " .. weapon) Output: Current weapon: MP40 This is how you start building custom messages in code. Part 9: Joining strings and numbers You can also build messages that include numbers. Example: kills = 15 print("Kills: " .. kills) Output: Kills: 15 And: health = 100 print("Health is " .. health) Output: Health is 100 This is extremely useful because code often needs to show text plus numbers together. Part 10: Basic math with numbers Numbers can be used for math. Example: print(5 + 5) print(10 - 3) print(4 * 2) Output: 10 7 8 You can also do math using variables. kills = 10 bonus = 5 total = kills + bonus print(total) Output: 15 This is one reason numbers matter so much. You can calculate with them. Part 11: Strings do not behave like numbers Look at this: print("5" .. "5") Output: 55 Why did it not become 10? Because these are strings, not numbers. Lua joined the text together. It did not do math. Now compare that to: print(5 + 5) Output: 10 That works as math because those are numbers, not strings. So: strings can be joined numbers can be added That is a very important difference. Part 12: Side-by-side examples Look at these carefully: print("RNG" .. "esus") print(10 + 5) print("10" .. "5") print("Score: " .. 20) Output: RNGesus 15 105 Score: 20 Breakdown: print("RNG" .. "esus") joins two strings into one string print(10 + 5) adds two numbers print("10" .. "5") joins two strings, so it becomes 105 print("Score: " .. 20) joins text and a number into one message Part 13: Extra Credit! Now That you know all about strings we will move into ETLegacy Lua scripting next class! For extra credit read https://etlegacy-lua-docs.readthedocs.io/en/latest/ which is the official ETLegacy Lua API! Make a simple script that prints something in server console when its loaded! Maybe do a small Lua math equation or make the server console print Rngesus is cewl!! See you guys tomorrow! Excited for it! Edited March 26 by RNGesus fixing typos 2 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.