ef2-ubertools-gdk/Documentation/content/scripting_syntax.html

506 lines
21 KiB
HTML
Raw Permalink Normal View History

2003-08-18 00:00:00 +00:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title><EFBFBD>berTools Game Development Kit</title>
<link rel="stylesheet" href="style.css">
<script type="text/javascript">
/***********************************************
* Switch Menu script- by Martial B of http://getElementById.com/
* Modified by Dynamic Drive for format & NS4/IE4 compatibility
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
if (document.getElementById){ //DynamicDrive.com change
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')
document.write('</style>\n')
}
function SwitchMenu(obj){
if(document.getElementById){
var el = document.getElementById(obj);
var ar = document.getElementById("masterdiv").getElementsByTagName("span"); //DynamicDrive.com change
if(el.style.display != "block"){ //DynamicDrive.com change
for (var i=0; i<ar.length; i++){
if (ar[i].className=="submenu") //DynamicDrive.com change
ar[i].style.display = "none";
}
el.style.display = "block";
}else{
el.style.display = "none";
}
}
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<a name="top"></a>
<table width="702" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3"><img src="../images/header.jpg" width="702" height="101" border="0"></td>
</tr>
<tr>
<td width=158 valign="top"><table border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" class="menu">
<!-- Keep all menus within masterdiv-->
<div id="masterdiv">
<img src="../images/navigation.jpg" width="158" height="27"><br>
UberTools GDK
<div class="menutitle" onclick="SwitchMenu('sub0')">&raquo; Introduction &amp; Contents</div>
<span class="submenu" id="sub0">
&nbsp;&nbsp;&nbsp;&nbsp;<a href="../start.html">Introduction</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="../start.html#2">Utilities</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="../start.html#3">Source Files</a><br>
</span>
<br>Level Design<br>
<div class="menutitle" onclick="SwitchMenu('sub1')">&raquo; Setting Up UberRadiant</div>
<span class="submenu" id="sub1">
&nbsp;&nbsp;&nbsp;&nbsp;<a href="radiant_setup.html">That Scary Error Msg</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="radiant_setup.html#2">General Tab</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="radiant_setup.html#3">Display Tab</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="radiant_setup.html#4">User Interface Tab</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="radiant_setup.html#5">Keyboard Shortcuts Tab</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="radiant_setup.html#6">Colors Tab</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="radiant_setup.html#7">Game / Paths Tab</a><br>
</span>
<div class="menutitle" onclick="SwitchMenu('sub2')">&raquo; Building Your First Room</div>
<span class="submenu" id="sub2">
&nbsp;&nbsp;&nbsp;&nbsp;<a href="radiant_firstroom.html">Editor Interface Basics</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="radiant_firstroom.html#2">Choosing Your Textures</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="radiant_firstroom.html#3">Building The Room</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="radiant_firstroom.html#4">Adding a Light</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="radiant_firstroom.html#5">Adding a Player Start</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="radiant_firstroom.html#6">Compiling Your Level</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="radiant_firstroom.html#7">Viewing the Level</a><br>
</span>
<div class="menutitle" onclick="SwitchMenu('sub3')">&raquo; Constructing Terrain</div>
<span class="submenu" id="sub3">
&nbsp;&nbsp;&nbsp;&nbsp;<a href="radiant_terrain.html">Setting up the Tools</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="radiant_terrain.html#2">Creating Terrain</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="radiant_terrain.html#3">Modifying the Textures</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="radiant_terrain.html#4">Adding More Terrain</a><br>
</span>
<div class="menutitle" onclick="SwitchMenu('sub4')">&raquo; Additional Reference</div>
<span class="submenu" id="sub4">
&nbsp;&nbsp;&nbsp;&nbsp;<a href="ldesign_lighting.html">Lighting System</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="ldesign_terrain.html">Terrain Texture Blending</a><br>
</span>
<br>Scripting<br>
<div class="menutitle" onclick="SwitchMenu('sub5')">&raquo; Scripting Tutorials</div>
<span class="submenu" id="sub5">
&nbsp;&nbsp;&nbsp;&nbsp;<a href="scripting_syntax.html">Scripting Syntax</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="scripting_waves.html">Spawning Waves</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="scripting_flying.html">Creating Flying Creatures</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="scripting_tripwires.html">Setting Up Tripwires</a><br>
</span>
<div class="menutitle" onclick="SwitchMenu('sub6')">&raquo; Global Script Synopsis</div>
<span class="submenu" id="sub6">
&nbsp;&nbsp;&nbsp;&nbsp;<a href="scripting_globalscripts.html">Introduction</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="scripting_globalscripts_accelmove.html">global_accelerated</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="scripting_globalscripts_accelmove.html">Movement.scr</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="scripting_globalscripts_archetype.html">global_archetype.scr</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="scripting_globalscripts_array.html">global_array.scr</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="scripting_globalscripts_cinefx.html">global_cinematicFX.scr</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="scripting_globalscripts_common.html">global_common.scr</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="scripting_globalscripts_debug.html">global_debugUtils.scr</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="scripting_globalscripts_flyin.html">global_flyin.scr</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="scripting_globalscripts_math.html">global_math.scr</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="scripting_globalscripts_ploadout.html">global_playerLoadout.scr</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="scripting_globalscripts_soundpan.html">global_soundPan.scr</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="scripting_globalscripts_spawnwave.html">global_spawnWave.scr</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="scripting_globalscripts_transport.html">global_Transport.scr</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="scripting_globalscripts_tripwire.html">global_tripwire.scr</a><br>
</span>
<div class="menutitle" onclick="SwitchMenu('sub7')">&raquo; Classes Reference</div>
<span class="submenu" id="sub7">
&nbsp;&nbsp;&nbsp;&nbsp;<a href="allclasses_g.html">Game Module</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="allclasses_cl.html">Client Module</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="allclasses_cg.html">Client Game Module</a><br>
</span>
<br>Older Documentation<br>
<div class="menutitle" onclick="SwitchMenu('sub8')">&raquo; Heavy Metal FAKK2</div>
<span class="submenu" id="sub8">
&nbsp;&nbsp;&nbsp;&nbsp;<a href="fakk2_camera.html">Camera Documentation</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="fakk2_clientsidecmds.html">Client Side Commands</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="fakk2_gui.html">GUI Documentation</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="fakk2_ingameutils.html">In-Game Utilities</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="fakk2_max2skl.html">MAX2SKL Reference</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="fakk2_shadermanual.html">Shader Manual</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="fakk2_soundsystem.html">Sound System</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="fakk2_tiki.html">TIKI Model System</a><br>
</span>
<br>Other<br>
<div class="menutitle" onclick="SwitchMenu('sub9')">&raquo; Web Links &amp; Credits</div>
<span class="submenu" id="sub9">
&nbsp;&nbsp;&nbsp;&nbsp;<a href="other_links.html">Web Links</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="other_credits.html">Credits</a><br>
</span>
</div>
</td>
</tr>
</table></td>
<td width="13" background="../images/vert_line.jpg"><img src="../images/vert_line.jpg" width="13" height="1"></td>
<td valign="top" width="533"><p class="header"><br>
scripting syntax</p>
<p class="subheader">General rules</p>
<ol>
<li> Execution starts in the main function (main is just a normal function).<br>
<br>
</li>
<li> A function must be declared before it is used:<br>
This means either the entire function has to be located before any calls
to it or you have to add a function declaration for it (preferably at
the top of the file). A function declaration is just the header part
with a semicolon at the end.<br>
<br>
For example: <span class="menu">set_fade_color( int color );</span><br>
<br>
</li>
<li> You need a <span class="menu">;</span> at the end of each command<br>
<br>
</li>
<li> Including other files:<br>
Format : <span class="menu">#include &#8220;filename&#8221;</span><br>
For example: <span class="menu">#include &#8220;scripts/utils.scr&#8221;</span><br>
<br>
</li>
<li> Comments:<br>
// comments out everything to the right of the // on this line only<br>
/* */ comments out everything between the /* and the */</li>
</ol>
<p class="subheader">Functions</p>
<p> All functions adhere to this general format: </p>
<blockquote>
<p class="menu"> return_type function_name( paramtype parameter1, paramtype
parameter2 )<br>
{<br>
commands;<br>
}</p>
</blockquote>
<p> For example:</p>
<blockquote>
<p class="menu"> void set_sky_color( float sky_color )<br>
{<br>
global_sky_color = sky_color;<br>
}</p>
</blockquote>
<p> The function declaration for the above example would be as follows:</p>
<blockquote>
<p class="menu"> void set_sky_color( float sky_color );</p>
</blockquote>
<p> There are two ways to call a function:</p>
<ul type="square">
<li> <b>function();</b><br>
This calls the function and stops execution of the calling function
until the called function returns.<br>
<br>
</li>
<li><b> thread function();</b><br>
This calls the function with a new thread so that the calling function/thread
can keep going.</li>
</ul>
<p> Calling format: </p>
<blockquote>
<p class="menu"> function_name( parameter1, parameter2 );</p>
</blockquote>
<p> The number of parameters is determined by the function declaration.
Functions can return values.</p>
<p> For example:</p>
<p class="menu"> color = get_sky_color(); </p>
<p class="subheader"> Entities</p>
<p> Map entities are referenced like this:</p>
<blockquote>
<p class="menu"> $entity_name.command_name( parameters );</p>
</blockquote>
<p> For example:</p>
<blockquote>
<p class="menu"> $monster1.attackplayer();</p>
</blockquote>
<p> Only use the dollar sign ($) if the referenced entity is a map entity.
If you are using a normal entity variable don&#8217;t use the dollar sign.</p>
<p> It is possible to get a variable for an entity if you know the name
of it as follows:</p>
<blockquote>
<p class="menu"> entity temp_entity;<br>
temp_entity = getentity( entity_name );</p>
</blockquote>
<p class="subheader">Basic language commands</p>
<p> <b>while</b> <br>
Loops until the while condition equals 0 or false. This is checked at
beginning of each loop.</p>
<p>Format:</p>
<blockquote>
<p class="menu"> while( condition )<br>
{<br>
commands<br>
}</p>
</blockquote>
<p> For example:</p>
<blockquote>
<p class="menu"> while( waveindex &lt;= 15 )<br>
{<br>
thread WAVE();<br>
wait( 1 );<br>
waveindex = waveindex + 1;<br>
}</p>
</blockquote>
<p> <b>do/while</b><br>
Loops until the while condition equals 0 or false. This is checked at
end of each loop.</p>
<p> Format:</p>
<blockquote>
<p class="menu"> do<br>
{<br>
commands<br>
} while ( condition );</p>
</blockquote>
<p> For example:</p>
<blockquote>
<p class="menu"> do<br>
{<br>
thread FLIP_ARCH_STEPS( &quot;archstep&quot;, stepindex, stepheight
);<br>
wait( 0.5 );<br>
stepindex = stepindex + 1;<br>
stepheight = stepheight - 25.6;<br>
} while( stepindex &lt;= 15 );</p>
</blockquote>
<p> <b>for</b> <br>
This looping construct executes until condition is false.</p>
<p> Format:</p>
<blockquote>
<p class="menu"> for( init commands ; condition ; per loop commands )<br>
{<br>
}</p>
</blockquote>
<p> The init commands are evaluated just once, usually to initialize variables.
Then the condition is evaluated - if it is false, the statement terminates,
and if it is true, the statement executes. After that, the per loop commands
are executed and the loop starts over.</p>
<p> For example:</p>
<blockquote>
<p class="menu"> for( t = 0; t &lt; endtime; t++ )<br>
{<br>
i += t;<br>
}</p>
</blockquote>
<p> <b>if/else</b> <br>
This loop executes a block of commands if the condition is true. If false
it executes the block of commands after the else (else part is optional).</p>
<p> Format:</p>
<blockquote>
<p class="menu"> if ( condition )<br>
{<br>
commands<br>
}<br>
else<br>
{<br>
}</p>
</blockquote>
<p> For Example:</p>
<blockquote>
<p class="menu"> if ( sky_color == 1 )<br>
{<br>
new_color = 2;<br>
}<br>
else<br>
{<br>
new_color = 1;<br>
}</p>
</blockquote>
<p> <b>return</b><br>
Returns from the current function/thread and optionally returns a value.</p>
<p> Format:</p>
<blockquote>
<p> <span class="menu">return;</span> or<br>
<span class="menu">return value;</span></p>
</blockquote>
<p class="subheader">scripting commands</p>
<p>Please see the <a href="/content/allclasses_g.html">Game Module Classes
reference</a> for a list of scripting commands.</p>
<p class="subheader"> Variable types available</p>
<ul type="square">
<li> <b>float</b> - a floating-point number.</li>
<li> <b>vector</b> - composed of 3 floating point numbers, written as
'x y z'.</li>
<li> <b>entity</b> - an entity that exists in the game.</li>
<li> <b>string </b>- a string, written as &quot;characters&quot;.</li>
<li> <b>void </b>- no return type.</li>
</ul>
<p class="subheader">Math operators</p>
<ul type="square">
<li> <b>+=<br>
</b> Equivalent to x = x + y; (works for strings as well)<br>
<br>
</li>
<li> <b>-=<br>
</b> Equivalent to x = x - y;<br>
<br>
</li>
<li> <b>*=</b><br>
Equivalent to x = x * y;<br>
<br>
</li>
<li> <b>/=</b><br>
Equivalent to x = x / y;<br>
<br>
</li>
<li> <b>++<br>
</b> Increments variable by one.<br>
<br>
</li>
<li> <b>--<br>
</b> Decrements variable by one.<br>
<br>
</li>
<li> <b>*<br>
</b> Multiplication.<br>
<br>
</li>
<li> <b>/</b><br>
Division.<br>
<br>
</li>
<li> <b>-</b><br>
Subtraction.<br>
<br>
</li>
<li> <b>+<br>
</b> Addition (works for strings as well).<br>
<br>
</li>
<li> <b>=<br>
</b> Sets variable equal to.<br>
<br>
</li>
</ul>
<p class="subheader">Comparison operators</p>
<ul type="square">
<li> <b>&lt;</b><br>
Tests if less than.<br>
<br>
</li>
<li> <b>&gt;</b><br>
Tests if greater than.<br>
<br>
</li>
<li> <b>&lt;=</b><br>
Tests if less than or equal.<br>
<br>
</li>
<li> <b>&gt;=</b><br>
Tests if greater than or equal.<br>
<br>
</li>
<li> <b>==</b><br>
Tests if equal.<br>
<br>
</li>
<li> <b>!=</b><br>
Test if not equal.<br>
<br>
</li>
</ul>
<p class="subheader">Logic operators</p>
<ul type="square">
<li> <b>&amp;&amp;<br>
</b> AND<br>
<br>
</li>
<li> <b>||</b><br>
OR<br>
<br>
</li>
<li> <b>!<br>
</b> Logical negation (true if argument to its right is false, false
otherwise).</li>
</ul>
<p class="subheader">Bit operators</p>
<ul type="square">
<li> <b>&amp;</b><br>
Bitwise AND a variable.<br>
<br>
</li>
<li> <b>|</b><br>
bitwise OR a variable.<br>
<br>
</li>
<li> <b>&amp;=</b><br>
equivalent to x = (x &amp; y);<br>
<br>
</li>
<li> <b>|= </b><br>
equivalent to x = (x | y);<br>
<br>
</li>
</ul>
<p class="subheader">Format operators</p>
<ul type="square">
<li> <b>;</b><br>
All statements must end in this.<br>
<br>
</li>
<li> <b>,</b><br>
Used to separate function arguments.<br>
<br>
</li>
<li> <b>(</b><br>
Opening for a function call, grouping for mathematical functions.<br>
<br>
</li>
<li> <b>)</b><br>
Closing for a function call, grouping for mathematical functions<b>.</b></li>
<li> <b>#</b><br>
Prefix for #include and #define.<br>
<br>
</li>
<li> <b>...</b><br>
<br>
</li>
<li> <b>.</b><br>
<br>
</li>
<li> <b>[</b><br>
Opening for array index<b>.<br>
<br>
</b></li>
<li> <b>]</b><br>
Closing for array index<b>.<br>
<br>
</b></li>
<li> <b>{</b><br>
Opening for a block of statements<b>.<br>
<br>
</b></li>
<li> <b>}</b><br>
Closing for a block of statements. </li>
</ul>
<p>&nbsp;</p></td>
</tr>
<tr>
<td colspan="3"><img src="../images/footer.jpg" width="702" height="36" border="0" usemap="#Map"><br>
<img src="../images/hor_line.jpg" width="702" height="1"></td>
</tr>
<tr>
<td colspan="3" class="legal"><table width="100%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td class="legal"> Copyright &copy;2003 Ritual Entertainment, Inc. All rights reserved.<br>
Please do not email Ritual Entertainment with questions about the
UberTools Game Development Kit. It is provided as is and is not supported by Ritual Entertainment.</td>
<td><a href="http://www.ritual.com/tech/overview.html" target="_blank"><img src="../images/uber_logo.jpg" width="43" height="56" hspace="4" border="0"></a></td>
<td><a href="http://www.ritual.com" target="_blank"><img src="../images/ritual_logo.jpg" width="100" height="56" hspace="4" border="0"></a></td>
</tr>
</table>
<p align="center">&nbsp;</p></td>
</tr>
</table>
<map name="Map">
<area shape="rect" coords="601,10,693,28" href="#top">
</map>
</body>
</html>