P
Piyo
Guest
Hello! I'm trying out a dialogue system where when the player interacts with an object, the respective dialogue pops up. Since I'm just starting out, I'd like to get the 'gist' of GML before beginning to code efficiently by using scripts/etc. ^^
My DRAW and DRAW GUI events have no problems - the main problem lies within the STEP_1 EVENT.
The first part of the STEP_1 EVENT works fine. (the 'startup' one)
But the second loop seems to contain bugs >w<
It only draws the first two characters of the string then stops.
To be more clear, this is how I see the code. Please correct me if I'm mistaken~!
(STEP_1 EVENT)
//CREATE EVENT
//STEP_1 EVENT
//STEP_2 EVENT (works fine)
My DRAW and DRAW GUI events have no problems - the main problem lies within the STEP_1 EVENT.
The first part of the STEP_1 EVENT works fine. (the 'startup' one)
But the second loop seems to contain bugs >w<
It only draws the first two characters of the string then stops.
To be more clear, this is how I see the code. Please correct me if I'm mistaken~!
(STEP_1 EVENT)
//CREATE EVENT
Code:
message[0] = "This is a sign post.";
message[1] = "Read what it says?";
startup = true;
message_current = 0;
message_end = 1;
message_draw = "";
increase = 1;
characters = 0;
hold = 0;
message_length = string_length(message[message_current]);
//STEP_1 EVENT
Code:
if (startup == true) {
if (characters < message_length) {
hold = keyboard_check(ord("Z"));
characters += increase * (1 + hold);
message_draw = string_copy(message[message_current], 0, characters);
}
else {startup = false;}
}
else {
if (keyboard_check_pressed(ord("Z"))) {
if (message_current < 1) {
message_current += 1;
message_length = string_length(message[message_current]);
characters = 0;
message_draw = "";
if (characters < message_length) {
hold = keyboard_check(ord("Z"));
characters += increase * (1 + hold);
message_draw = string_copy(message[message_current], 0, characters);
}
else {
message_current = -1
instance_destroy();
obj_player.spd = 5;
}
}
}
}
//STEP_2 EVENT (works fine)
Code:
if (message_current == 1) {
instance_create(256,416,obj_yn);
}
if (keyboard_check_pressed(ord('X'))) {
instance_destroy();}