Animation-CobOverview: Difference between revisions
fix link and add links + category |
m fixed links I hadn't fixed properly... |
||
| Line 42: | Line 42: | ||
start-script Function(args); | start-script Function(args); | ||
See [[COB-Threads]] for details. | See [[Animation-CobThreads|COB-Threads]] for details. | ||
*Multiple threads. This isn't as exciting as it sounds. Again, see [[COB-Threads]] for details. | *Multiple threads. This isn't as exciting as it sounds. Again, see [[Animation-CobThreads|COB-Threads]] for details. | ||
*Spring-specific features. There are too many here to name; please consult the other COB articles. | *Spring-specific features. There are too many here to name; please consult the other COB articles. | ||
| Line 52: | Line 52: | ||
*[[Animation-CobCallins]] | *[[Animation-CobCallins]] | ||
*[[Animation-CobConstants]] | *[[Animation-CobConstants]] | ||
*[[Animation-CobHitByWeaponID]] | *[[Animation-CobHitByWeaponID]] | ||
[[Category:Animation]] | [[Category:Animation]] | ||
Revision as of 22:10, 23 August 2009
What is COB?
COB is the Spring engine's scripting system. Each unit has a .cob bitfile which defines many of its major behaviors, including animation and weapon aiming. Of course, COB is also capable of doing a lot more if you wish. When Spring is actually running, it interprets the bitfile for each unit as necessary. This interpreter runs in a very straightforward way, without any fancy optimizations, so don't expect great performance from it.
BOS
The code that gets compiled into a .cob is written in a .bos file. A program called Scriptor generally does this compilation. BOS uses a C-like syntax, although it has many Spring-specific features and isn't as powerful as C.
BOS versus C
Similarities:
- Function syntax. A function is defined by FunctionName(args).
- Block delimiters. Like C, a statement block is delimited by curly braces ({}).
- General syntax. For example, to add two variables and assign the result to a third, you say x = y + z;
Differences:
- Not case sensitive.
- Only one data type. There is only one type of data in COB, which is basically a 32-bit integer.
- Variable declaration.
You can declare a static variable, whose scope encompasses the entire script, using
static-var x;
You can declare multiple variables at once by separating them with commas.
Alternately, you can declare a local variable:
var x;
The scope is limited to the function that it is in.
- No pointers or arrays.
- No internal return values. When the script receives a callin, it may return a value to the "outside"; however, there is no way to return a value directly to another function within the script. You will have to use a static variable.
- Function calls.
Functions are called using
call-script Function(args);
or
start-script Function(args);
See COB-Threads for details.
- Multiple threads. This isn't as exciting as it sounds. Again, see COB-Threads for details.
- Spring-specific features. There are too many here to name; please consult the other COB articles.
Further information
Greater detail can be found on the following pages