OblivionSkull21
Member
I've been trying all day to get my dialogue system to work properly. The system works in the sense that I can only press SPACE to go to the next line of text if the text has finished displaying (typewriter-style). I'm wanting an alarm to be set once the player reaches a certain line of text (the last one). The alarm will take them to a different room. So, instead of pressing SPACE again to close out the text, the alarm will be so short that it takes the player by surprise.
I use several scripts in this system...
scr_add_dialogue_line:
scr_DisplayConvoText (this is the main one I've been working with):
scr_initialize_dialogue:
scr_draw_dialogue:
And then I have my obj_dialogue.
Create Event:
Step Event:
Draw Event:
Alarm 0:
Going back to my scr_DisplayConvoText, I have it set so that the player can only press SPACE to continue the dialogue if the text has finished displaying. This works, so I decided to put count = count + 1 under this code, meaning that when the player presses space AND the next line of text is displayed, the count goes up by 1 (starting at 0). If the dialogue is no longer active, count = 0 (so it can restart each dialogue).
Going to my step event, I set it so that when count == 10 (the last line of text), blahblahblah happens. But this isn't working, and I have no idea why. :\ Please help!
I use several scripts in this system...
scr_add_dialogue_line:
Code:
// @description Add Dialogue to our text array;
// @param sprite_index
// @param string text
dialogue[convoDialogueCount, 0] = argument0; //sprite index (avatar)
dialogue[convoDialogueCount++, 1] = argument1; //text
Code:
count = 0; //for timing of events
if (currCharIndex < string_length(dialogue[convoIndex, 1])+1) //checks to see if line hasn't finished
{
spriteToDisplay = dialogue[convoIndex, 0];
currChar = string_char_at(dialogue[convoIndex, 1], currCharIndex);
stringToDisplay += currChar;
currCharIndex += 1;
}else{
if (keyboard_check_pressed(vk_space)) //go to next line
{
convoIndex++; //works
stringToDisplay = ""; //works
currCharIndex = 1; //works
count = count + 1; //doesn't work
if (convoIndex == convoDialogueCount)
{
active = false;
count = 0; // doesn't work
}
}
}
if (keyboard_check_pressed(ord('Z'))) //skip text/go to next line
{
convoIndex++;
stringToDisplay = "";
currCharIndex = 1;
if (convoIndex == convoDialogueCount)
{
active = false;
}
}
Code:
for (i = 0; i < 20; i++)
{
dialogue[i, 0] = -1; // sprite index
dialogue[i, 1] = ""; // convo dialogue
}
active = false;
convoDialogueCount = 0; // number of lines in a specific conversation
convoIndex = 0; //current index towards our convoDialogueCount
spriteToDisplay = -1; // avatar to display
stringToDisplay = ""; // conversation line to display
currCharIndex = 1; //current character index of string to apply
currChar = "";
//dialogue display properties
avatarScale = 1;
avatar_xOrigin = view_xview[0] + 32;
avatar_yOrigin = view_yview[0] + 32;
text_xOrigin = view_xview[0] + 64;
text_yOrigin = view_yview[0] + 14;
Code:
//Padding for inside dialogue box
var padding = 32;
//Max width & height
max_width = view_wview - (padding*2);
max_height = (view_hview/4)-(.25*(view_hview/4));
//draw dialogue boxes
var bw = 4; // Border width
if (active) {
draw_set_font(fnt_dialogue);
draw_set_color(c_black);
draw_line_width(view_xview, view_yview + 5 , view_xview, view_yview + 60, bw*400);
draw_set_color(c_white);
draw_line_width(view_xview, view_yview + 5 , view_xview, view_yview+60, bw);
draw_line_width(view_xview-(bw/2), view_yview + 5, view_xview+view_wview, view_yview + 5 , bw);
draw_line_width(view_xview+view_wview-bw/2, view_yview + 5 , view_xview+view_wview-bw/2, view_yview + 60, bw);
draw_line_width(view_xview - 2, view_yview + 60, view_xview+view_wview, view_yview + 60, bw);
draw_set_color(c_white)
draw_text(text_xOrigin, text_yOrigin, stringToDisplay);
draw_sprite_ext(spriteToDisplay, -1, avatar_xOrigin, avatar_yOrigin, avatarScale, avatarScale, 0, c_white, 1);
}
And then I have my obj_dialogue.
Create Event:
Code:
scr_initialize_dialogue();
active = true;
if (active)
{
convo_valentin1(); //conversation being shown
}
vocalized = false; //irrelevant
count = 0;
Code:
scr_DisplayConvoText();
if (currCharIndex < string_length(dialogue[convoIndex, 1])) //for sound, irrelevant
{
spriteToDisplay = dialogue[convoIndex, 0];
currChar = string_char_at(dialogue[convoIndex, 1], currCharIndex);
stringToDisplay += currChar;
currCharIndex += 1;
if (currChar != " ") {
audio_play_sound(snd_readables, 5, false);
}
}
if keyboard_check_pressed(ord('Z')){
count = count + 1;
}
if instance_exists(self) //irrelevant{
room_speed = 15;
}
else{
room_speed = 30;}
if (count == 10) //if the last line is displayed{
alarm_set(0,room_speed * 2.7);
}
if !(active){ //if text is skipped, jump straight to next scene
room_goto(room_dark);
instance_deactivate_object(obj_valentin_scary);
instance_deactivate_object(obj_valentin2);
instance_deactivate_object(obj_view);
instance_destroy(obj_valentin);
if (global.boy) {
instance_destroy(obj_nonplayer1_s1);
}
if (global.girl) {
instance_destroy(obj_nonplayer2_s1);
}
}
Code:
scr_draw_dialogue();
Code:
//once final line of dialogue displays, alarm is set. When alarm goes off, this happens.
room_goto(room_dark);
instance_deactivate_object(obj_valentin_scary);
instance_deactivate_object(obj_valentin2);
instance_deactivate_object(obj_view);
instance_destroy(obj_valentin);
if (global.boy) {
instance_destroy(obj_nonplayer1_s1);
}
if (global.girl) {
instance_destroy(obj_nonplayer2_s1);
}
Going to my step event, I set it so that when count == 10 (the last line of text), blahblahblah happens. But this isn't working, and I have no idea why. :\ Please help!