Difference between revisions of "Scripting tutorial lever"

323 bytes added ,  09:09, 2 April 2014
m
imported>Fg109
imported>Karea
 
(One intermediate revision by one other user not shown)
Line 6: Line 6:
=Lever Scripting Tutorial=
=Lever Scripting Tutorial=


In this tutorial, we will be scripting a lever to open one of three doors.  This is my first tutorial, and practically first time editing a wiki, so it's probably not as good as it could be.
In this tutorial, we will be scripting a lever to open one of three doors.  This is my first tutorial, and practically first time editing a wiki, so it's probably not as good as it could be. Please leave comments on the talk page so I know how to make this better.  Is it too long?  Too short?  Not descriptive enough?  Filled with too much unnecessary information?  Did you learn anything about scripting, or did you only learn that you could put this script onto a lever to control 3 doors?


===Lever Design===
===Lever Design===


All levers in the game are basically the same.  Let's take a look at the Dwemer Lever 01.
All levers in the game are basically the same.  Let's take a look at the Dwemer Lever 01 (DweLever01).


[[Image:DwemerLever01.jpg]]
[[Image:DwemerLever01.jpg]]


In the render window, it's shown with the lever in a central position pointing straight up.  However, once it's loaded in the game, the default position is actually pulled down, all the way to the right.  Levers have animations, and these animations can be called by using the scripting functions [[PlayAnimation_-_ObjectReference|PlayAnimation]] or [[PlayAnimationAndWait_-_ObjectReference|PlayAnimation]].  From what I can tell, levers have six animations:
In the render window, it's shown with the lever in a central position pointing straight up.  However, once it's loaded in the game, the default position is actually pulled down, all the way to the right.  Levers have animations, and these animations can be called by using the scripting functions [[PlayAnimation_-_ObjectReference|PlayAnimation]] or [[PlayAnimationAndWait_-_ObjectReference|PlayAnimationAndWait]].  From what I can tell, levers have six animations:


*PushDown
*PushDown
Line 31: Line 31:


Now that we know how the animation for a lever works, we can begin writing a script for it.
Now that we know how the animation for a lever works, we can begin writing a script for it.


===Starting Your Script===
===Starting Your Script===
Line 133: Line 132:




{{ProTip|If you want to learn scripting, you must understand the structure of if-elseif-endif statements.  Basically, you start with "if" to check if a condition is true.  If it is true, then every line after it is executed until you come to either an "elseif" or "endif".  The "elseif" conditional is optional.  It is useful if you want to check for a new condition when you know the previous condition(s) were not true.  Like "if", if the "elseif" condition is true, all the lines after it are executed until you come to another "elseif" or "endif".  The "endif" is used to wrap up all if-elseif-endif structures.  For every "if", you must have an "endif" or else the script won't compile.}}
{{InDepth|If you want to learn scripting, you must understand the structure of if-elseif-endif statements.  Basically, you start with "if" to check if a condition is true.  If it is true, then every line after it is executed until you come to either an "elseif" or "endif".  The "elseif" conditional is optional.  It is useful if you want to check for a new condition when you know the previous condition(s) were not true.  Like "if", if the "elseif" condition is true, all the lines after it are executed until you come to another "elseif" or "endif".  The "endif" is used to wrap up all if-elseif-endif structures.  For every "if", you must have an "endif" or else the script won't compile.}}




Anonymous user