Jump to content

BSL:Tutorial/Scratch: Difference between revisions

no edit summary
No edit summary
 
No edit summary
Line 1: Line 1:
This page is a short tutorial on how to get started on simple scripts.
This page is a short tutorial on how to get started on simple scripts for those who have had no experience with scripting before.
It will teach you, step by step, how to write a simple script. By the end of this tutorial, you will be able to move on to more advanced scripts.
It will teach you, step by step, how to write a simple script. By the end of this tutorial, you will be able to move on to more advanced scripts.


Line 17: Line 17:


C-Style:
C-Style:
This is compiled much like the popular coding style C. The syntax can be placed into multiple-function lines and functions are divided by a ''';''' . In advanced scripts, this style will allow you to condense your script and the parts will be easier to read/debug. It also allows you to utilse some of the more advanced features easily. The problem with this is, that starting off, it is harder to write if you have had no previous experience with coding.
This is compiled much like the popular coding style C. The syntax can be placed into multiple-function lines and functions are divided by a ''';''' . In advanced scripts, this style will allow you to condense your script and the parts will be easier to read/debug. It also allows you to utilize some of the more advanced features easily. The problem with this is, that starting off, it is harder to write if you have had no previous experience with coding.


Example: [[C-Style]]
Example: [[C-Style]]
Line 28: Line 28:
== Part 2: Starting Off ==
== Part 2: Starting Off ==


Now, I suggest reading the original script files to get a basic idea for how scripts are layed out. This will allow us to jump-start a bit.
Now, I suggest reading the original script files to get a basic idea for how scripts are laid out. This will allow us to jump-start a bit.


Open up your IMGD and look for the following folder: EnvWarehouse.
Open up your IMGD and look for the following folder: EnvWarehouse.
Open it up, and we'll take a look at how it it layed out. There should be several files in here. Open using NOTEPAD, the one titled '''warehouse_main.bsl'''. It should look like this:
Open it up, and we'll take a look at how it it laid out. There should be several files in here. Open using NOTEPAD, the one titled '''warehouse_main.bsl'''. It should look like this:




Line 53: Line 53:
Ignore the contents of the script for now, and notice that the contents of the function <tt>main</tt> are enclosed by a set of brackets ('''{''' and '''}''').
Ignore the contents of the script for now, and notice that the contents of the function <tt>main</tt> are enclosed by a set of brackets ('''{''' and '''}''').


All functions must be enclosed in this set of brakets or it will not be executed.
All functions must be enclosed in this set of brackets or it will not be executed.


Close the file, and rename the folder "EnvWarehouse" "EnvWarehouse_original". Then, create a folder called "EnvWarehouse" and create a script file inside and name it "Tutorial". We will be using this file to show various examples of scripts and finally, write a small script of your own.
Close the file, and rename the folder "EnvWarehouse" "EnvWarehouse_original". Then, create a folder called "EnvWarehouse" and create a script file inside and name it "Tutorial". We will be using this file to show various examples of scripts and finally, write a small script of your own.
----
== Part 3: Basic Commands ==
This is just a small section explaining the commands that will be used in this tutorial. For a complete list of commands, see [http://www.fh-eberswalde.de/user/dkriesch/onistuff/commands.htm Ssg's Site] for more information.
ai2_spawn (name) - creates and starts an AI from a character object
chr_teleport (name) (flag) - teleports a character to a flag
chr_givepowerup (name) (powerup) (amount) - gives a character a powerup
.
.
.
----
== Part 4: First Script ==
This section will teach you how to write a very basic arena script (fighting script). It will create an enemy for you to fight and teleport you to confront of him.
Let's open up our "Tutorial.bsl" file and start typing.
First, declare it the "main" portion of the script by typing "<tt>func void main(void)</tt> at the very beginning of the file. This tells the game which function it is. The "main" function is the function that the game looks at first to determine what is to be executed.
Below that line, type '''{'''. This tells the game that the function has started.
.
.
.
MORE TO COME!
                                                              - Your_Mom
85

edits