<undefined>
0
-1
-1
-1
<undefined>
<undefined>
1
603
7
0
0
-1
2
self
0
0
1
///Initialize dialog when created
dialog_init();
dialog_import();
1
603
7
0
0
-1
2
self
0
0
1
///Say the room start dialog after objects have been drawn
switch(room) {
case rDemo:
dialog_from_array(0, 1);
break;
}
1
603
7
0
0
-1
2
self
0
0
1
///Deal with questions
//Dealing with input is done in End Step after the instances have been activated,
//allowing other instances to be affected.
if(currentOption != -1 && dialog_count() == 1) {
//If you do not want to ask for confirmation uncomment the following:
//diaPos = string_length(dialog_get());
//Also, remove both the 'diaPos = 0;' lines from below and do the
//necessary changes to the dialog_draw() event
//Change options with up/down. Loop if gone past the last one
if(keyboard_check_pressed(vk_down)) {
diaPos = 0; //Set diaPos to 0 to make the user confirm after changing option
currentOption = (currentOption + 1) % optionCount;
} else if(keyboard_check_pressed(vk_up)) {
diaPos = 0;
currentOption = ((currentOption - 1) + optionCount) % optionCount;
}
} else if(!dialog_count() && currentOption != -1) {
/* If you prefer, you can figure out what the question was in other ways too.
This is, in my opinion, the simplest way. If you find an easier one please
tell me.*/
//Save the question
var question = questionAsked, answer = currentOption;
//Clear values. Must be done before handling in case you want to ask another question
questionAsked = "";
currentOption = -1;
switch(question) {
case "Are you a boy or a girl?": //I suggest copy/pasting the question to prevent typos
switch(answer) {
case 0: //Boy
dialog_from_array(2);
break;
case 1: //Girl
dialog_from_array(3);
break;
case 2: //Other
dialog_from_array(4);
break;
case 3: //I don't know
dialog_from_array(5);
break;
case 4: //Prefer not to say
dialog_from_array(6);
break;
}
dialog_from_array(7, 8);
break;
default: //Give a failure message to make debugging easier
dialog_from_array(9);
break;
}
}
1
603
7
0
0
-1
2
self
0
0
1
///Deal with string input
if(is_string(inputValue) && dialog_count() == 1) {
//Change the input value
//Uncomment the next line if you don't want a confirm
//diaPos = 1;
//Also remove the 'diaPos = 0;' line from below
if(inputValue != keyboard_string) {
inputValue = keyboard_string;
diaPos = 0; //Reset diaPos if the string has changed to make the player confirm again
}
} else if(is_string(inputValue) && !dialog_count()) {
/* This works essentially the same as with options.
Feel free to change the method of determining the question here too. */
//Save question and answer
var question = questionAsked, answer = inputValue;
//Clear input values
questionAsked = "";
inputValue = 0;
keyboard_string = "";
switch(question) {
case "What is your name?":
//I would recommend validating the input in some way here
if(answer != "" && string_length(answer) <= 10) {
Player.name = answer;
if(answer == "Luke") {
dialog_from_array(10);
} else {
dialog_from_array(11);
}
} else {
//If it was wrong, tell them something and ask it again
dialog_from_array(12);
dialog_from_array(8);
}
break;
default:
dialog_from_array(9);
break;
}
}
1
603
7
0
0
-1
2
self
0
0
1
///Actions on regular messages
if(!dialog_count()) {
//Similar to questions, but without answers.
switch(lastMessage) {
case "You have read this sign. Now you will die!": //I suggest copy/pasting the question to prevent typos
game_end();
break;
//Do nothing by default
}
lastMessage = ""; //Clear last message
}
1
603
7
0
0
-1
2
self
0
0
1
///Update dialog variables
/*
Here all variables that are to be used in strings must be included.
Make sure that the value actually exists before setting it.
These variables can only use letters, numbers and underscores (_),
similar to regular variables.
*/
if(instance_exists(Player)) {
dialog_var("PLAYERNAME", Player.name);
}
1
603
7
0
0
-1
2
self
0
0
1
///Set alarm for drawing messages
//Do room start messages 1 frame in so that the objects draw once
//If you don't want the sprites to show up until the dialog is finished,
//put the dialog_msg()'s in here.
alarm[0] = 1;
1
603
7
0
0
-1
2
self
0
0
1
///Draw dialog
if(dialog_count()) {
//Pause the game (if not already paused)
if(!sprite_exists(Controller.sPause)) {
game_pause();
}
//Darken the surroundings if you want to draw attention to the dialog
//Remove these 4 lines if you don't
draw_set_alpha(0.2);
draw_set_color(c_black);
draw_rectangle(0, 0, window_get_width(), window_get_height(), false);
draw_set_alpha(1);
/****************************************************/
//Draw the sprites, box, and message on top of sPause
dialog_draw();
}
1
603
7
0
0
-1
2
self
0
0
1
///Go to next message, or skip to the end
dialog_next();
//Reactivate instances if there are no more messages
//Reactivating them here ensures there is no frame where they aren't drawn
if(!dialog_count()) {
game_unpause();
}
0
0
0
0.5
0.100000001490116
0
0.100000001490116
0.100000001490116
0.200000002980232
-1
0