Animation-CobOverview: Difference between revisions
Evil4Zerggin (talk | contribs) New page: ==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... |
m →Further information: nuke wanted page |
||
| (10 intermediate revisions by 5 users not shown) | |||
| Line 5: | Line 5: | ||
==BOS== | ==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. | The code that gets compiled into a .cob is written in a .bos file. A program called [[Map,_Game,_And_Unit_Development_Programs#Scripting_And_Unit_Stats_files|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=== | ===BOS versus C=== | ||
| Line 15: | Line 15: | ||
Differences: | Differences: | ||
*Not case sensitive. | |||
*Only one data type. There is only one type of data in COB, which is basically a 32-bit integer. | *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 | *Variable declaration. | ||
You can declare a static variable, whose scope encompasses the entire script, using | |||
static-var x; | static-var x; | ||
| Line 29: | Line 32: | ||
*No pointers or arrays. | *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. | *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. | ||
*Functions are called using | *Function calls. | ||
Functions are called using | |||
call-script Function(args); | call-script Function(args); | ||
| Line 37: | Line 42: | ||
start-script Function(args); | start-script Function(args); | ||
See [[ | See [[Animation-CobThreads|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. | ||
==Further information== | |||
Greater detail can be found on the following pages | |||
*[[Animation-CobAnimation]] | |||
*[[Animation-CobCallins]] | |||
*[[Animation-CobConstants]] | |||
*[[Animation-CobHitByWeaponID]] | |||
[[Category:Animation]] | |||
Latest revision as of 21:44, 27 October 2013
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