Difference between revisions of "Category:Commands"

Jump to navigation Jump to search
369 bytes added ,  01:18, 15 April 2006
Added basic syntax of a script; moved comparison and logical operators into if topic
imported>MofoMojo
imported>Gblues
(Added basic syntax of a script; moved comparison and logical operators into if topic)
Line 1: Line 1:
[[scriptname]] ScriptName
Oblivion's scripting language is customized for the game, but shares much of the structure of a formalized programming language. A basic script has three elements: a script name, a begin statement, and an end statement. Here's an example:


<pre>
ScriptName MyScript
begin OnAdd Player
; do stuff
end
</pre>


[[begin]] [block type]
The [[ScriptName]] command is fairly self-explanatory: it sets the name of the script. It is required, and the name must be unique.


[[end]]
The [[begin]] directive defines the action that triggers the script. If the conditions of the [[begin]] statement are met, all commands between [[begin]] and [[end]] are executed. Every [[begin]] statement must have a corresponding [[end]] statement!


You can also abort execution of your script using the return command. This is useful inside an [[if]] statement where you don't want to continue execution any further.


<nowiki>; comment</nowiki>
You may add comments to your code by starting the line with a semicolon. A comment is ignored by the game, but allows you to leave yourself notes on what a particular script is doing.


See also:


[[Declaring_variables|short]] varNameShort
* [[Declaring_variables|Declaring Variables]]
 
* the [[if]] statement
[[Declaring_variables|long]] varNameLong
* [[set]]
 
* [[List_of_command_appearances_in_scripts]]
[[Declaring_variables|float]] varNameFloat
 
[[Reference_variables|ref]] varNameRef
 
 
set varName to 5
 
 
[[if|if]] ( varName > 100 ) ; greater than
 
elseif ( varName < 20 ) ; less than
 
else
 
endif
 
 
if ( varName == x ) ; equals
 
if ( varName != x ) ; not equal to
 
if ( varName >= x ) ; greater than or equal to
 
if ( varName <= x ) ; less than or equal to
 
 
if ( var1 == 1 ) && ( var2 == 1 ) ; logical and
 
if ( var1 == 1 ) ||  ( var2 == 1 ) ; logical or
 
 
[[return]] ; exits the script -- no lines following will be processed
 
set objectID.varName to 100
 
objectID.getav health
 
[[List_of_command_appearances_in_scripts]]
 


[[Category: Scripting]]
[[Category: Scripting]]
[[Category: Functions]]
[[Category: Functions]]
Anonymous user

Navigation menu