Mokoi Gaming uses [http://compuphase.com/pawn/pawn.htm Pawn] as default scripting language, so further references to Pawn will also refer to the default scripting language.
Variables must be declared before they are used in an expression. Pawn is a type-less language, all variables are 'Cell' or a group of 'Cell'. A Cell can hold 32-bit integral number.
add2Static() { //add one to staticvar from main() function staticvar++; } main() { new localvar; //Can only in this function. static staticvar; // Statics variable are added to global scope. add2Static(); }
Public declaration function can be access outside of the script, either by the program or other entity.
new i = 1 new j /* j is zero */ new k = 'a' /* k has character code for letter 'a' */ new a[] = {1,4,9,16,25} /* a has 5 elements */ new s1[20] = {'a','b'} /* the other 18 elements are 0 */ new s2[] = "Hello world..." /* a unpacked string */ new s3[] = !"Hello world..." /* a packed string */ new s4[14 char] = !"Hello world..." /* a packed string */ new b[10]= {1,2,...} /* b=1,2,3,4,5,6,7,8,9,10 */Examples of invalid declarations
new c[3] = 4 /* an array cannot be set to a value */ new i = "Good-bye" /* i must be an array for this initialisers */ new q[] /* unknown size of array */ new p[2] = { i + j, k - 3} /*array initialisers must be constants */
Integrals are the basic variable type in Pawn. These can hold a whole number value between −2,147,483,648 and +2,147,483,647.
Arrays are a group of Cells.
2D Arrays are just a Array of Arrays
// Valid Examples new a0[6] = "valid"; new a1[6] = {'v', 'a', 'l', 'i', 'd', 0 }; new a2[6] = {118, 97, 108, 105, 100, 0 }; // Invalid Examples new b1[6] = {'v', 'a', 'l', 'i', 'd' }; // Invalid string, but valid Array
new author[3] = {1819634533,2013265920, 0 }; // This this a packed string that says 'lukex'. new author[3] = !"lukex"; // ! before the string will pack the string.
To get around the fact the Pawn only has one type, Variables can be tagged to emphasize their usage.
SetBit( &v, n ) { v |= (1 << n); } ClearBit( &v, n ) { v &= ~(1 << n); } ToggleBit( &v, n ) { v ^= (1 << n); } TestBit( v, n ) { return !!(v & (1 << n)); }
Comming Soon