Difference between revisions of "Scripting Tutorial: Basic Scripting Knowledge"
Scripting Tutorial: Basic Scripting Knowledge (edit)
Revision as of 18:22, 30 May 2008
, 18:22, 30 May 2008Formatting
imported>DragoonWraith (updating the OTHER link...) |
imported>Wrye m (Formatting) |
||
Line 4: | Line 4: | ||
You can also comment your scripting code by using the ';' everything after the semicolon will be ignored. | You can also comment your scripting code by using the ';' everything after the semicolon will be ignored. | ||
Scripting-Operations can be divided in two base categories, each with two sub-categories: | Scripting-Operations can be divided in two base categories, each with two sub-categories: | ||
== [[:Category:Commands|Commands]] == | |||
== | |||
A command is a script-operation that controls what happens within the script. Commands regulate how a script is executed, but don't affect the world directly. | A command is a script-operation that controls what happens within the script. Commands regulate how a script is executed, but don't affect the world directly. | ||
There are two sub-categories: ''administrative commands'' and ''statements'': | There are two sub-categories: ''administrative commands'' and ''statements'': | ||
Line 20: | Line 17: | ||
*''Statements'' are [[Set]], [[If]], [[Return]] and the [[Declaring_variables|variable declarations]] Statements aren't required for a script to work, but all but the most simple scripts require them to control '''how''' the script is executed. | *''Statements'' are [[Set]], [[If]], [[Return]] and the [[Declaring_variables|variable declarations]] Statements aren't required for a script to work, but all but the most simple scripts require them to control '''how''' the script is executed. | ||
== [[:Category:Functions|Functions]] == | |||
== | |||
Functions are script operations that interact with the game-world. This is by far the larger category of script operations. Every function returns a value which can be used as condition for [[If|"if"-Statements]] or to set variables with the [[Set|"set"-statement]]. | Functions are script operations that interact with the game-world. This is by far the larger category of script operations. Every function returns a value which can be used as condition for [[If|"if"-Statements]] or to set variables with the [[Set|"set"-statement]]. | ||
There are two sub categories: ''passive'' and ''active'' functions: | There are two sub categories: ''passive'' and ''active'' functions: | ||
Line 33: | Line 27: | ||
*''Active functions'' do changes to the game-world and usually return a boolean value ("1" or "0") to return if the action was successful or not. [[RemoveSpell]] for example removes a spell from the target and returns "1" if this was successful (i.e. the target had the spell in the first place). [[PlaceAtMe]] creates an object at the caller's location and returns the Reference to this object. | *''Active functions'' do changes to the game-world and usually return a boolean value ("1" or "0") to return if the action was successful or not. [[RemoveSpell]] for example removes a spell from the target and returns "1" if this was successful (i.e. the target had the spell in the first place). [[PlaceAtMe]] creates an object at the caller's location and returns the Reference to this object. | ||
==[[Reference|References]] and [[:Category:Variables|Variables]] == | |||
== | |||
Functions affect the "calling object" (That on which the script is running) by default, but you can redirect them to another object by using the object's [[Reference|reference]]. When you want a script to affect the player for example, use the player's reference ("Player") and a '.' to redirect the function-call to the player instead of the calling object. | Functions affect the "calling object" (That on which the script is running) by default, but you can redirect them to another object by using the object's [[Reference|reference]]. When you want a script to affect the player for example, use the player's reference ("Player") and a '.' to redirect the function-call to the player instead of the calling object. | ||
player.additem gold_001 100 | player.additem gold_001 100 | ||
To gain more flexibility, you can use [[:Category:Variables|variables]] instead of numeric values whenever a function requires such input. | To gain more flexibility, you can use [[:Category:Variables|variables]] instead of numeric values whenever a function requires such input. |