Documentation

This is the boring part, therefore I'll go over it as quickly as humanly impossible while trying to keep it informative.
First, I'll have to make one thing clear, 'A' is not 'a', 'Main()' would give you an error, 'main()' would not.
With that out of the way, I'll give you some examples, I'll draw up a function:
#include <mokoi> //An include file

new variable = 0; //Create a global variable

main() // A function header
{        // A start bracket

    if(variable == 0) //If 'variable' equals zero
    {
        variable = 1; //Set 'variable' to 1
    }
    else //If 'variable' does not equal zero
        variable = 0; //Set 'variable' to 0

}        // An ending bracket

I'll start by saying that this code is completely useless whatsoever, BUT, it fills one purpose, as it displays a lot of syntax in Pawn.

Look at the first line.
#include <mokoi> //An include file
'#' tells us that this is a compiler function, which means that the compiler will do something here.
"include <mokoi>" is what is told to the compiler. It's supposed to include a file, in this case, a file called "mokoi.inc". The '.inc' is not required, as it is a default extension.

After a "//", everything is ignored, that means that the rest of that line is commented out, and is ignored when the entity is compiled.

"new variable = 1;" This initializes a variable, "A short identification containing a number".
"new" indicates that it's creating a variable, not reading from it.
"variable" is it's name.
In this case, we want it to be created with a value, therefore, we directly use "= 1" to give it this value.
A similar allowed version, would be
"new variable;"
"new variable = 32203798;"
Or whatever.
What you, on the other hand, cannot do, is try to create a variable without the 'new' command in front of it. Omitting this, would make the program try to read and edit the variable, instead of creating it.
For example, placing only "variable = 320;" without first using "new variable;" would produce an error.
Also, a variable cannot be modified outside a function, except when being created.
Notice as well, how everything is ended with ";". this is good practice, as errors may occur if you do not use these definite endings. And a function is what we will get to now:
main()
{
Stuff...
}
"main" is the name of the function we are now creating, notice how it is lower-case, this is normal in most programming languages today.
() contains information that can be sent to the function, you create variables in these brackets that store information sent to the function when it is called, these are always needed, even if there is no information to be retrieved.
An opposite example would be:''
main(//new number//)
{
Stuff...
}
This would create a function called main, that accepts 1 piece of information, in this case, following what it looks like, it would accept a variable number, as it would be created in the same way as the variable we created earlier.
But, in this particular function, we will NEVER add variables that it can accept. the main() function is called from within Mokoi to all scripts in the game, allowing them to execute. What good would ThisFunction() do if it was never called from somewhere? One more thing.
"{}". these hold the code in a function.
main()
{
//Anything HERE, is inside the function, as it is between the brackets.
}

Notice how the header uses (), while the code in the function is surrounded by {}, always remember this, as anything else will produce a large amount of nasty errors.

This isn't everything, but it should be enough to get you started when looking at scripts or writing them yourself.


Comments

Comming Soon