Author Topic: Simple "Hello World" Script  (Read 2475 times)

To start we are going to make a "Hello World" script.  First we are going to make a function.  So we are going to type function as seen below.  We also need to name are command or else we cant use it.  So name it helloworld()  the "()" is required for your script to run, if you don't have them your script will return errors.  So look at the code below and make it look like that.
Code: [Select]
function helloworld()
 Next we want to add a "{" so you can start your main code.   This code will be called when you type "helloworld();".  So now we want to add a "{"  Without it the "{" your script would return errors again.  Also hit the "ENTER" key two times after you type "{", then type "}"  That is the closing bracket  to tell the function then the script is ending.  If you have an else command it will keep going.  So make your code look like the code below.
Code: [Select]
function helloworld()
{

}

Now that you have that lets add our main code.   Lets make a messageBox incase you don't know how to enter the console at this point.  Type in the code as seen below.

Code: [Select]
function helloworld()
{
MessageBoxOK("Hello","\nHello World!");
}

See how i typed it between the brackets?  Thats where your code always go's.   Now save it in a script file then run whatever game your scripting on.  You will need the console to uset it.  Use (~) to open the console then type helloworld();.  Your script should work.

The "save it in a script file" isn't really descriptive now is it?

Yes, thats the part Spation asked me about xD

Executing it? Using code outside of brackets? Putting it in add-ons? Definitions of "script" files and other Torque files? What a \n means? What each part of the messageBoxOK does (Title, text)?

Not a very good introduction to Torque.


So you shouldn't be writing tutorials. Those who can, do, those who can't, teach.

Yes, thats the part Spation asked me about xD
Yeah, because I'm a total moron who can't copy a cs, rename it and edit the contents. I'm not very clever you see.

Yes, thats the part Spation asked me about xD
Yeah, because I'm a total moron who can't copy a cs, rename it and edit the contents. I'm not very clever you see.
hOw 2 kopy cs? pls tell no pix no clix tho.