Jump to content

BSL:Manual: Difference between revisions

275 bytes added ,  26 November 2017
improving instructions on function calling; correcting "some_function" to "prepare_fight"
(workaround to bsl broken if conditions)
(improving instructions on function calling; correcting "some_function" to "prepare_fight")
Line 123: Line 123:
  }
  }


Besides this, you can call the function merely by writing "spawn_team". See [[#Functions|Functions]] for details on declaring functions.
Besides this, you can call the function merely by writing "spawn_team", but the proper new-style syntax is "spawn_team();". See [[#Functions|Functions]] for details on declaring functions.


===Type specification===
===Type specification===
Line 580: Line 580:


===Calling===
===Calling===
You do not use "func" when calling a function. You simply name it:
You do not use "func" when calling a function. You simply use its name:


  some_function(3, "Jojo");
  music_force_stop();


In this case, we are passing a constant value of three into prepare_fight(), defined above, where it will be known as "count", and we are passing a constant string in as "enemy_name", but we could also have passed in variables by name:
Since no parameters are expected by music_force_stop(), we call it with empty parentheses. However, if parameters are expected, it looks like this:
 
prepare_fight(3, "Jojo");
 
In this case, we are passing a constant value of three into prepare_fight() (the function defined at the start of this section), inside of which it will be known as "count", and we are passing a constant string in as "enemy_name", but we could also have passed in variables by name:


  var int num_heroes = 3;
  var int num_heroes = 3;
  var string enemy = "Jojo";
  var string enemy = "Jojo";
  some_function(num_heroes, enemy);
  prepare_fight(num_heroes, enemy);


The values of these variables will still be referred to as "count" and "enemy_name" inside prepare_fight().
The values of these variables will still be referred to as "count" and "enemy_name" inside prepare_fight().