Pawn (scripting language)
Encyclopedia
Pawn, formerly known as Small, is an open source
Open source
The term open source describes practices in production and development that promote access to the end product's source materials. Some consider open source a philosophy, others consider it a pragmatic methodology...

 scripting language
Scripting language
A scripting language, script language, or extension language is a programming language that allows control of one or more applications. "Scripts" are distinct from the core code of the application, as they are usually written in a different language and are often created or at least modified by the...

 primarily intended as an embeddable scripting language
Scripting language
A scripting language, script language, or extension language is a programming language that allows control of one or more applications. "Scripts" are distinct from the core code of the application, as they are usually written in a different language and are often created or at least modified by the...

. It is maintained by a Dutch
Netherlands
The Netherlands is a constituent country of the Kingdom of the Netherlands, located mainly in North-West Europe and with several islands in the Caribbean. Mainland Netherlands borders the North Sea to the north and west, Belgium to the south, and Germany to the east, and shares maritime borders...

 company named CompuPhase, which released the first version in 1998. The language was known as Small until version 3 was released in March 2005.

Pawn is a typeless language influenced by Small-C
Small-C
In computing, Small-C is both a subset of the C programming language, suitable for resource-limited microcomputers and embedded systems, and an implementation of that subset...

. and has C-like syntax
C syntax
The syntax of the C programming language is a set of rules that specifies whether the sequence of characters in a file is conforming C source code...



Pawn is used in the San Andreas Multiplayer mod, Half-Life mod, AMX Mod X and Source Engine based SourceMod as well as various other projects.

Design

Pawn code is compiler-oriented. Source code of a Pawn script is kept in a file that has the 'pwn' extension, the contents are equivalent to what would be used in a Textfile, you can read the contents and edit them in various IDE
Integrated development environment
An integrated development environment is a software application that provides comprehensive facilities to computer programmers for software development...

s, as well as in a regular text editor such as Notepad.

The Pawn compiler compiles the source code to P-code
P-code
P-code can refer to:* Precompiled code, for example Java Byte code, MATLAB .p-files, etc.* p-code machine * Code used in the UCSD p-System...

 (or bytecode) that will be written to a file with 'amx' extension.

Features

  • Pawn is a C-like Scripting Language
  • You can include files in Pawn; so you can arrange a neat structure of Pawn code
  • Pawn is a scripting language with a compiler that performs static checks, and an abstract machine
    Abstract machine
    An abstract machine, also called an abstract computer, is a theoretical model of a computer hardware or software system used in automata theory...

     with (static) P-code verification and dynamic checks.
  • For porting
    Porting
    In computer science, porting is the process of adapting software so that an executable program can be created for a computing environment that is different from the one for which it was originally designed...

     purposes, Pawn is written in ANSI C
    ANSI C
    ANSI C refers to the family of successive standards published by the American National Standards Institute for the C programming language. Software developers writing in C are encouraged to conform to the standards, as doing so aids portability between compilers.-History and outlook:The first...

     as much as possible; Endian issues are handled.
  • Pawn supports Unicode/UCS-4 and UTF-8, as well as codepages. The compiler can convert source code entered in a particular codepage to Unicode; it also supports source code files in UTF-8 format.
  • It has been fitted on an Atmel ATmega128 microcontroller, Philips LPC2138 and LPC2106 microcontrollers (ARM7TDMI core with 32 kiB RAM), as well as on a Texas Instrument's MSP430F1611 (MSP430 core with 10 kiB RAM and 48 kiB Flash ROM). Using code overlays that are loaded on demand, pawn is able to run large scripts in little memory.
  • Documenting the source code can be done with "documentation comments;" the pawn compiler extracts those comments, combines them with information it deduces from the source code and writes an XML file that is immediately viewable (and printable) with a web browser.
  • Pawn supports states and automatons in the language, including state-local variables.

Grand Theft Auto: San Andreas Multiplayer

A common use for Pawn is in the popular unofficial Grand Theft Auto: San Andreas
Grand Theft Auto: San Andreas
Grand Theft Auto: San Andreas is a 2004 open world action video game developed by British games developer Rockstar North and published by Rockstar Games. It is the third 3D game in the Grand Theft Auto video game franchise, the fifth original console release and eighth game overall...

modification "San Andreas Multiplayer". This allows server hosts to enable their scripts to perform all the tasks available to players of the single player version of "Grand Theft Auto: San Andreas". This is made possible by the ability for server hosts to create their own "game modes" with the PAWN compiler. The implementation of the PAWN language also allows users to interact with the game in ways previously not possible in the single player environment.

Side-script design

PAWN is designed to be used as a side-script with code from other languages. PAWN does not ship with native functions which can be used for developing, instead Pawn's functions come from "include" files.

Code Examples

Here is an example of code that will print 4 random digits.
  1. include

main {
new digit[4];//Introduces a new variable with an individual digit size of 4.
for(new i=0;i<4;i++)//Will loop 4 times to fill the var 'digit.'
{
digit[i] = random(5000);//Gives the digit a random number in between 0 and 5000.
printf("Digit %d's value is %d.", i, digit[i]);//Prints the digit and the digit's value on screen.
}
return 1;//Returns the number 1.
}


Here is a 'Hello World!' example.

  1. include

main {
print("Hello World!");
}
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK