User Tools

Site Tools


scripting:basic_syntax

This is an old revision of the document!


Script Language Syntax

The scripting language supports a limited range of the basic syntactical components that make up most similar-level programming languages

General Rules

  • Each line of script needs to be put on a new line
  • All script code is case-insensitive. (e.g. the variable 'a' is the same as the variable 'A' )
  • All variables are preceeded with $

Conditional Statements

if, else and else if are supported, for example… <codedoc>

if ( $itemNum = 112 )	
{
    *grantskill %PLAYER% Blacksmith
}
else if ( $itemNum = 113 )
{
    *grantskill %PLAYER% Scientist
}
else 
{
    *msg %PLAYER% You didnt learn anything new today
}

</codedoc>

Supported conditions inside an if or else if are:

  • = (or == )
  • <
  • >
  • != (or <> )
  • ( < = )
  • >=

Comments

Code comments are simple C-stylee, e.g <codedoc>

  // Check the item number
  if ( $itemNum = 112 )	
  {

*say Nothing (this line is commented out) } </codedoc> ===== Maths operators ===== Basic maths operators are supported in simple form. Compound operations are not yet supported so each line needs to be kept basic, e.g. : <codedoc> $var = $var + 1 $newvar = $var * 100 </codedoc> Currently only the 4 basic operators ( +, -, /, * ) are supported. ===== Local & Global Variables ===== Local variables can be used at any point without advance declaration. They remain in scope throughout the event or function as you'd expect. Global variables (those that are instantiated outside of an event or function) remain in scope for all events and functions until the script is reloaded or the server is restarted. Example Local variable use : <codedoc> Event( “UseItem”, “Bongos” ) { $myage = $gPlayerAge / 10 if ( $myage = 6 ) { *say I'm in my sixties and im still playing the bongos } } </codedoc> Example global variable use : <codedoc> $mNumberOfBongoPlays = 0 Event( “UseItem”, “Bongos” ) { $mNumberOfBongoPlays = $mNumberOfBongoPlays + 1 *say $mNumberOfBongoPlays people have played the bongos since the script was last restarted } </codedoc>

scripting/basic_syntax.1333702953.txt.gz · Last modified: (external edit)