Difference between revisions of "LavishScript:Script Syntax"

From Lavish Software Wiki
Jump to navigation Jump to search
 
(32 intermediate revisions by 3 users not shown)
Line 1: Line 1:
== Overview ==
+
#REDIRECT [[LavishScript:Language and Engine Overview]]
Scripts consist of <tt>preprocessor directives</tt>, <tt>preprocessor macros</tt>, <tt>comments</tt>, <tt>functions</tt>, <tt>code blocks</tt> and <tt>commands</tt>.  All scripts must have a function called '''main'''.
 
 
 
=== Preprocessor Directives ===
 
Preprocessor directives are things that the script handler should do ''before'' the script is executed.  This may include replacing certain words with others throughout the script, or adding another file to be read into this script. 
 
 
 
Until LavishScript 1.08, the only preprocessor directive handled was #include (This is currently the case for [[Fury]]).
 
 
 
==== #include ====
 
* #include "filename"
 
 
 
(see [[LavishScript:Preprocessor|Preprocessor]])
 
 
 
=== Preprocessor Macros ===
 
Preprocessor macros are not yet implemented.
 
 
 
=== Comments ===
 
Comments must be on their own line, never at the end of another line.  Any line that starts with a semi-colon is considered a comment, and will not be handled by the script.
 
 
 
=== Functions ===
 
Functions are defined like so:
 
function MyFunc1()
 
{
 
  ''commands''
 
}
 
function MyFunc2(parameter1,parameter2,parameter3)
 
{
 
  ''commands''
 
}
 
function MyFunc3(string parameter1,int parameter2)
 
{
 
  ''commands''
 
}
 
 
 
Functions may have any number of parameters, and each will default to the string type if a type is not given.  Each function '''must''' have its own code block.  The function ends either at the final '''}''', or from a '''return''' command.  Either way, execution proceeds after the previous call statement, or ends the script if the function is '''main'''.
 
 
 
=== Code Blocks ===
 
Code blocks are defined by having a '''{''' to begin, and '''}''' to end, on their own lines.  These blocks are used to define the scope of a function, and are also used by certain commands such as [[Command:If|If]] and [[Command:While|While]].
 
 
 
=== Commands ===
 
Commands are simply LavishScript commands, as may be entered in a console or command file.
 
 
 
== Examples ==
 
* Obligatory "Hello World" script
 
function main()
 
{
 
    echo Hello World
 
}
 

Latest revision as of 04:36, 16 May 2006