Hello this is my Scripting tutorial !
Lets go over the basic
- Variables
So variables are something you can change for example
your dog name is Fufu and then you rename it to Fufija
Lets see it in the code
local dogName = "Fufu"
That’s it but why I have " "
there ? It’s because of the type of the Information this type I showed is called string
it’s a fancy way to say it is a word/character and you need to use " "
Ok lets see a number like the dog’s age
local dogsAge = 2
This is a number you don’t need to type something fancy just this
But what if I want to say if he has a computer
local hasComputer = false
This is called a Bolean it’s fancy word to say it can be false or true
Okay first you might be confused by the types but don’t worry you can change the type of the variable when ever you want sou you can make this
local hasComputer = false
hasComputer = "Asus TF"
You can change the type whenever you want
But why did I typed local only once and not twice ?
It’s because I already declared it that means that the computer knows this variable so I don’t need to write local
again
now lets go to the ‘Logic’ part
- If statements
If you need to do something like if the dogs name is Fuju then do something
The code is similar to human language I want you to think over the previous sentence
if the dogs name is Fuju then
It’s very similar to the code
if dogName == "Fuju" then
end
That’s it !
Now lets see the other two opinions else and else if
if dogName == "Fuju" then
else
end
else means if the If isn’t true then else is going to run
Now on else if
if dogName == "Fuju" then
elseif dogName == "Fuji" then
end
elseif is like If but in If statement I know it sounds like very complicated but it isn’t
elseif is for better readability and code arrangement
so it isn’t like this
if dogName == "Fuju" then
end
if dogName == "Fuji" then
end
see the elseif is more readable
and last thing
I know I needed to start with this earlier but lets do this
So what means Print
it’s like printing in real life
In previous chapters when the code ran we didn’t know what is happening
so lets spice it up
if dogName == "Fuju" then
print("Dog's name is Fuju!")
end
That’s it when the dog’s name is Fuju then it will print in the console Dog's name is Fuju!
And that’s it ! This is my Basic Scripting tutorial tell me if I should improve something!