User:Tomtomn00/Scripting Tutorial: Difference between revisions
>Tomtomn00 |
>Tomtomn00 |
||
Line 61: | Line 61: | ||
==:GetChildren== | ==:GetChildren== | ||
This can be used for selecting multible parts and models. | This can be used for selecting multible parts and models. To make this easier, use variables. | ||
<pre> | <pre> | ||
i=game.Workspace.Model:GetChildren | i=game.Workspace.Model:GetChildren | ||
Line 69: | Line 69: | ||
m=game.Lighting:GetChildren | m=game.Lighting:GetChildren | ||
</pre> | </pre> | ||
==Defining Models== | ==Defining Models== | ||
This explains how to define models. You need to explain where the model is to the script. You use variables and can use :GetChildren with this. | This explains how to define models. You need to explain where the model is to the script. You use variables and can use :GetChildren with this. |
Revision as of 12:24, 27 August 2011
Some of you may be looking for a more basic tutorial than the advanced one, so here is mine!
Output
The output is used to see if scripts are running and to see what is being printed from them. You can see it by opening ROBLOX Studio -> View -> Output.
Print Function
The print function can only be used to print what is going on in output.
You would use this code for printing:
print()
But, before trying you would need to say that it is a string so it will print what is in the string. Example:
print("Hello World")
The output for that would be Hello World. However if you do not want to use "", you can look in the variables section below.
Variables
Variables are most commonly used with the print() function.
A variable is something to show what something is. When using a number as a variable you would just use something like:
roblox=1
- that would mean that roblox is the same as 1. So you can use
print(roblox)
and it would print in the output 1. However, if you want to make the variable a string you would use something like:
roblox="car"
- that would mean that roblox is the same as a car. You could print this now:
print(roblox)
and the output would say car.
Wait Function
The wait function can be used to say how long the script waits to do the next command. Whatever goes in the brackets of wait() is in seconds. This is a demonstration with the wait function.
print("I like to play ROBLOX") wait(1) print("Hello World")
That would print I like to play ROBLOX, wait 1 second, then print Hello World.
Math
Lets say that you want to add with ROBLOX Lua. You will need to use math (above,) variables (2 above) and the print function (3 above.) Say you want to print 3+4, wait 10 then print that with +1 onto it. You would do as follows.
first=3+4 print(first) wait(10) second=first+1 print(first)
That would make the output print 7, then it will wait 10 seconds, then print 8 in the output.
Comparative
Comparative operators are operators that compare two parameters and return a boolean. There are several operators.
== | ~= | > | < | >= | <= |
Equal to | Not equal to | Greater than | Less than | Greater than or equal to | Less than or equal to |
:GetChildren
This can be used for selecting multible parts and models. To make this easier, use variables.
i=game.Workspace.Model:GetChildren
or
m=game.Lighting:GetChildren
Defining Models
This explains how to define models. You need to explain where the model is to the script. You use variables and can use :GetChildren with this.
t=game.Workspace.Model
Defining Parts
This explains how to define parts. You need to explain where the part is to the script. You use Variables and can use :GetChildren with this.
a=game.Workspace.Part
or
b=game.Workspace.Model.Part