Difference between revisions of "Scripting Tutorial: My Second Script"

expanding on comments section
imported>Darkness X
imported>8asrun6aer
(expanding on comments section)
Line 70: Line 70:
   ; Here we will enter what happens when the chest is opened.
   ; Here we will enter what happens when the chest is opened.
End</pre>
End</pre>
'''Click ''Save'' again now.''' The script still doesn't do anything, but at least now we have defined under what conditions it will run.  There are a couple of things to note here.  First, we have ended the current block before beginning a new one—not so important when there's only one block, but as this script gets more complicated we'll need multiple blocks in a single script.  In somewhat more technical terms, '''Begin/End blocks do not nest.'''  The other thing to notice is the semicolon ";" on line 4.  A semicolon marks the rest of the line as ''comment''.  Whatever you type after the semicolon ''on that one line'' will be ignored when the script compiles. You use comments to explain your code, which can help you and others understand what's going on inside the script quickly at a later date.  If you want more than one line of comment, you must have one semicolon for each line.
'''Click ''Save'' again now.''' The script still doesn't do anything, but at least now we have defined under what conditions it will run.  There are a couple of things to note here.  First, we have ended the current block before beginning a new one—not so important when there's only one block, but as this script gets more complicated we'll need multiple blocks in a single script.  In somewhat more technical terms, '''Begin/End blocks do not nest.'''  The other thing to notice is the semicolon ";" on line 4.  A semicolon marks the rest of the line as ''comment''.   
 
===Code Comments===
Comments can be placed in-code with the semicolon character - ; - Whatever you type after the semicolon on the same line will be ignored when the script compiles. If you want more than one line of comment, you must have one semicolon for each line.
 
You use comments inside your scripts to generally explain what you are trying to accomplish in your code, which can help you and others understand what's going on inside the script quickly at a later date.  Comments can also serve as a debugging technique by commenting out lines of code one-by-one to pinpoint the source of some odd or unintended effect in-game. 
 
Note: Because everything appearing on a line after the semicolon is not treated as compilable code, one issue you might face is that you cannot simply put semicolons in strings.  If you need to have a semicolon as part of a string - for example a message in-game - you could instead use the [[OBSE]] "%a" Format Specifier and passing in ASCII character code 59, or use the [[AsciiToChar]] OBSE function.


===Writing text and obtaining decisions from the player===
===Writing text and obtaining decisions from the player===
Anonymous user