Simple Text Problem


Hiya! <3

Still bit new to game maker, little slow.

Followed Shaun Spaldings platformer video on Signposts.

Everything is working just as it should. I'm using the string variable trick to make it easier to change later on.

The only question I have is I am unsure how to make multiple pages of dialogue/text appear using his system. How can I change his code for longer dialogue/multiple pages?

Text Object Code:

Create Event:

spd = 0.25;
letters = 0;
text = "test string!";
length = string_length(text);
text_current = "";
w = 0;
h = 0;
border = 10;
Step Event:
letters += spd;
text_current = string_copy(text,1,floor(letters));

if (h == 0) h = string_height(text);
w = string_width(text_current);

//Destroy when done
if (letters >= length) && (keyboard_check_pressed(vk_anykey))
    with (oCamera) follow = oHannah;

Draw Event:

var halfw = w * 0.5;

//Draw The Box

//Draw text
DrawSetText(c_white, fText, fa_center, fa_top);


It's a tricky thing actually. Will be tough if you're new. Here's just some bullet points to consider...

  • You need to decide a way to break your text into multiple strings. For instance, you use a character like # to indicate a new page.
  • Your code will need to loop through your string looking for that character and copy each section into an array of strings (text[0],text[1],text[2],etc). So if you don't already know how to use arrays as well as functions like string_copy(), string_pos() you'll need to get familiar with them.
  • You'll need to track how many strings were created so you know how many pages will be displayed. Then each time you display text, you'll track what page you are on. (1 or 1, 1 of 2, 2 of 2) etc.
  • When you are on the last page, pressing a button closes the text box. When you have another page to display, pressing a button will change the page to the next page and reset variables like letters so your typewriter text will start again as well as h and w so it will resize again.

It might be difficult, but if you can work through each issue one a time this is actually a great exercise to learn from.


Thank you so much! <3
Last, my only question is, do you have any resources where I can learn how these functions work and how to properly use them? Thanks again. <3


The Manual tells you how all this works. The first 14 articles tell you how the language works, and the Index tab lets you look up any built-in keyword, variable or function.

The biggest problem on the Q&A section is people blindly following tutorials without understanding or looking up basic syntax elements and built-in functions.