Jump to content

BSL:Manual: Difference between revisions

24 bytes removed ,  28 June 2022
m
fixing WP redirect; other link tweaks
m (link fixes)
m (fixing WP redirect; other link tweaks)
Line 64: Line 64:
  dprint "Hello"
  dprint "Hello"


and the more strict style, called "new style", which resembles the syntax of [[wikipedia:C_(programming_language)|C]]:
and the more strict style, called "new style", which resembles the syntax of [[wp:C (programming language)|C]]:


  dprint("Hello");
  dprint("Hello");
Line 448: Line 448:


===bool===
===bool===
'''(Note: See warning at bottom of this section; the bool type is not recommended for variables.)''' A [[wikipedia:Boolean data type|Boolean]] number has one of two possible states. Thus, a bool can be assigned a value with the keywords "true" and "false".
'''(Note: See warning at bottom of this section; the bool type is not recommended for variables.)''' A [[wp:Boolean data type|Boolean]] number has one of two possible states. Thus, a bool can be assigned a value with the keywords "true" and "false".


  var bool example = true;
  var bool example = true;
Line 464: Line 464:


===int===
===int===
A 32-bit signed [[wikipedia:Integer|whole number]]; that is, it can be positive, negative or zero, with a maximum value of 2,147,483,647 and a minimum value of -2,147,483,648.
A 32-bit signed [[wp:Integer|whole number]]; that is, it can be positive, negative or zero, with a maximum value of 2,147,483,647 and a minimum value of -2,147,483,648.


  var int example = -1000;
  var int example = -1000;
Line 485: Line 485:


===float===
===float===
A [[wikipedia:Floating point|floating-point]] number. Bungie West actually never used floats in their scripts for Oni, which explains why there are certain rough aspects to them. For instance, floats are limited to six decimal places of precision:
A [[wp:Floating-point arithmetic|floating-point]] number. Bungie West actually never used floats in their scripts for Oni, which explains why there are certain rough aspects to them. For instance, floats are limited to six decimal places of precision:


  var float good_example = 10.5; # returns as "10.500000"
  var float good_example = 10.5; # returns as "10.500000"
Line 726: Line 726:
The above documentation for functions and variables explains how to create your own functions and variables. But, like any game, Oni provides access to a number of built-in functions and variables; these are used to write level scripts in BSL.
The above documentation for functions and variables explains how to create your own functions and variables. But, like any game, Oni provides access to a number of built-in functions and variables; these are used to write level scripts in BSL.


Built-in functions and variables such as "ai2_allpassive" and "ai2_blind" are hardcoded into Oni, that is, they were defined in C along with the rest of the engine code and then registered as accessible from BSL. This means that they are essentially [[wikipedia:Black_box|black boxes]]: you are only given an external description of the input they take and the outcome of this input, but you cannot see the actual code behind them.
Built-in functions and variables such as "ai2_allpassive" and "ai2_blind" are hardcoded into Oni, that is, they were defined in C along with the rest of the engine code and then registered as accessible from BSL. This means that they are essentially [[wp:Black box|black boxes]]: you are only given an external description of the input they take and the outcome of this input, but you cannot see the actual code behind them.


When using the developer console, you can manually call a built-in function, and can get and set the value of a built-in variable. However, you cannot actually define functions or declare variables through the console.
When using the developer console, you can manually call a built-in function, and can get and set the value of a built-in variable. However, you cannot actually define functions or declare variables through the console.