string_copy(str,index,count)

str = String to get the new string from.

index = The starting point to get the new string from.

count = The amount of characters from index that you want the new string to consist of.

 

This string function returns a string from string starting at position index, and ending at position count. So basically, if you typed in:

 

var text;

text = string_copy("ABCDEFGHIJKLMNOPQRSTUVWXYZ",1,7);

 

Then it would return the string "ABCDEFG", and assign it to the variable text. This is similar to the string_char_at function, except it can return more than one character in a string at a time, hence making it useful for many things, such as: making a chatbot "read" words, finding a whole word in a string, storing values to a string and then recalling them, or even another method of making a dialogue script, as shown in the example below...

 

//Declare all variables to be used

var text,new_text,position;

 

   //Initialize all variables to be used

 

   //This variable, "text", will be the string you want to have typed

   text = "Insert message here";

 

   //The new string that will hold the value of the typed string

   new_text = "";

 

//Scroll through the string of the variable "text"

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

{

   //Set the variable "new_text" to include all characters in "text" up until "position"

   new_text = string_copy(text,1,position);

 

   //Draw "new_text" to the screen

   draw_text(0,0,new_text);

 

   //Refresh the screen with the drawn text

   screen_refresh();

 

   //Pause for 50 milleseconds so the typing effect is visible

   sleep(50);

}

 

Melee-Master - Revision #1