Hello
This is my second basic tutorial about GSC, this time is about Functions, I will explain how are they and how to call them, gsc codes are mostly all inside functions, by calling new functions you do different things in game, a function structure is like this.
The thing I called "Function1" is the name I put to the function, the "( )" is added because without it, is not a function (it is needed). Then there is a opening bracket ( { ), after it is where you are going to place your code and when you have ended writing it, you must close the function with a closing bracket ( } ). An example of function:
Something you cant make on a function is to put 2 functions in 1, example:
By adding a code to a file, it wont be enough to make it work, so, youll have to "thread"/call it. There are many ways, Ill say a few of them, the most used one is this one:
There are also this shortened versions for 2 things I am not explaining here:
To call this function:
You would need to call it like this:
A function name can also have inside the "( )" variables which have some use inside the function, for example:
It will say first what I put in "thing1" and then what I put in "tutorial", for example, I could call it like this:
I hope you have liked it, any questions: just ask.
Thanks for reading, @Yamato
This is my second basic tutorial about GSC, this time is about Functions, I will explain how are they and how to call them, gsc codes are mostly all inside functions, by calling new functions you do different things in game, a function structure is like this.
Code:
Function1( )
{
CODES HERE
}
The thing I called "Function1" is the name I put to the function, the "( )" is added because without it, is not a function (it is needed). Then there is a opening bracket ( { ), after it is where you are going to place your code and when you have ended writing it, you must close the function with a closing bracket ( } ). An example of function:
Code:
SayTheWords()
{
self iPrintLnBold( "You are reading" );
wait ( 1 );
self iPrintLnBold( "Functions tutorial" );
}
Something you cant make on a function is to put 2 functions in 1, example:
Code:
FunctionA()
{
FunctionB()
{
SOMETHING
}
}
By adding a code to a file, it wont be enough to make it work, so, youll have to "thread"/call it. There are many ways, Ill say a few of them, the most used one is this one:
Code:
self thread YOUR FUNCTION NAME;
There are also this shortened versions for 2 things I am not explaining here:
Code:
self YOUR FUNCTION NAME;
YOUR FUNCTION NAME;
To call this function:
Code:
SayTheWords()
{
self iPrintLnBold( "You are reading" );
wait ( 1 );
self iPrintLnBold( "Functions tutorial" );
}
You would need to call it like this:
Code:
self thread SayTheWords();
A function name can also have inside the "( )" variables which have some use inside the function, for example:
Code:
SayTheWords2( thing1, tutorial )
{
self iPrintLnBold( thing1 );
wait ( 1 );
self iPrintLnBold( tutorial );
}
It will say first what I put in "thing1" and then what I put in "tutorial", for example, I could call it like this:
Code:
self thread SayTheWords2( "Hello Itsmods", "You are reading Functions Tutorial" );
I hope you have liked it, any questions: just ask.
Thanks for reading, @Yamato