string_char_at(str,index)

str = The string where the character at the index of index will be returned from.

index = The position of the character in the string str.

 

Example #1:

var returned_char;

returned_char = string_char_at("Hello",3);

 

The function string_char_at returns the character in the string of str, at the position of index. The following piece of code shows how to use string_char_at to get the third character in the string of "Hello".  This is very useful for creating a simple dialogue script (with a typewriter effect), as shown in the example below.

 

Example #2:

//Declare the variables to be used in this example code

var text,new_text,position;

 

//This variable, "text", is the string that will get typed out

text = "Place a message here.";

 

//This variable, "new_text", is the variable that will store the typed out string

new_text = "";

 

/*

This code will scroll through the string "text" while the variable "position" is

less than or equal to the amount of characters in "text".

*/

for(position = 1; position <= string_length(text); position += 1;)

{

   //Add the character in the variable texting at the position of "position" to "new_text"

   new_text += string_char_at(text,position);

 

   //Draw the variable "new_text" to the screen

   draw_text(0,0,new_text);

 

   //Refresh the screen with the text drawn above

   screen_refresh();

 

   //Pause the game for 50 milleseconds so that way you can watch the letters type onto the screen

   sleep(50);

}

 

Melee-Master - Revision #1