After wanting some typewriter text for my game (so the text gradually appears one letter at a time) I did some searching for a tutorial and quickly found every example I came across was encased in a bunch of RPG 'extras' such as dialogue boxes and multiple answers. All I wanted was the bare-bones and after a bit of trial and error it turns out it's pretty damn easy.
So first of all you'll need to create an object that will be responsible for writing the text on screen. Inside the object's Create event add the following:
vText = "Show Me"; //This is the text we want to display
iText = 0; //This variable controls how many letters are currently shown (e.g. if iText = 8 then the first 8 letters of vText will be shown
alarm = 1; //Here we set the whole script in motion
In the object's alarm event add the following:
//We use an if statement here so the alarm stops once the full text is displayed
if iText <= string_length(vText)
iText += 1; //Here we simply add 1 to iText to show one extra letter
alarm = 10; //This controls how fast the text is written. Increase this if you want it slower
And finally we need to show the text, so in the object's Draw event add the following:
And there you have it, job done!
Currently that will only display a single text string, however it's very easy to modify it so you can have a single object control many different strings. The obvious examples for this would be a dialogue or an inventory screen where the text is changed based on the highlighted item. In these cases all you would need to do is change the vText to the new text, reset the iText back to 0 and restart the alarm.