N
Nambuc
Guest
Hi!
First of all, I'm a beginner. Be nice with me
I'm trying to build a dialogue system for my narrative game, but I'm having issues with one specific
line of code. I've created an object containing my dialogue lines and branching. I've also put a kind of menu that appears when a choice needs to be made (when we meet a branching). Here's the create event :
And here is the Draw event :
The Press Enter Event (when the menu appears to make a choice):
And the Press Space event:
Just in case here are the Step and Clean up events (but there's no problem with them, I guess)
Here's my problem: when I run the game, everything works fine (the dialogue starts and we can keep going pressing space) until the first branching: the interactive menu appears all right, but when I pick a choice (any of them) I've got this fatal error message:
Any ideas of what I did wrong?
THANKS A LOT.
PS: I followed some tutorials for this as I am not a pro. One was for the dialogue system, the other was for the menu buttons: I tried to mix them in a single object...
First of all, I'm a beginner. Be nice with me
I'm trying to build a dialogue system for my narrative game, but I'm having issues with one specific
line of code. I've created an object containing my dialogue lines and branching. I've also put a kind of menu that appears when a choice needs to be made (when we meet a branching). Here's the create event :
Code:
///Interactive menu
menu_x = x;
menu_y = y;
button_h = 32;
//buttons
button[0] = "Provoke"
button[1] = "Reassure"
button[2] = "Interpret"
button[3] = "Keep silent"
buttons = array_length_1d(button);
menu_index = 0;
last_selected = 0;
///Text
textMap = ds_map_create();
value = "";
//Booleans (true or false)
question = false;
//Path example
ds_map_add(textMap,"","Paul:\n\nSir...I'm...\nnot going very well these days.");
ds_map_add(textMap,"E","Can't sleep.\nCan't wake up.\nCan't go outside.\n*");
ds_map_add(textMap,"E0", "I'm provoking you.");
ds_map_add(textMap,"E1", "Be reassured, it's alright.");
ds_map_add(textMap,"E2", "I'm trying to interpret something.");
ds_map_add(textMap,"E3", "...");
Code:
draw_set_font(fSpecial_Elite);
draw_set_color(c_black);
draw_set_halign(fa_center);
draw_set_valign(fa_center);
///Find branching in dialogues
txt = ds_map_find_value(textMap,value)
if (string_char_at(txt,string_length(txt)) == "*")
{
question = true;
}
else
{
question = false;
}
//Drawing the txt variable (converted to a string)
draw_text_speed(x,y,string(txt),0.10) //room_speed = one second
//If question is false, you can press space
//If question is true, opens the choices menu
draw_set_font(fSpecial_Elite);
draw_set_color(c_red);
if (question == false)
{
draw_text(x,y + 250/*pixels*/,"(Space) Continue");
}
else //Show interaction menu
{
var i = 0;
repeat(buttons) {
draw_set_font(fDialogChoice);
draw_set_halign(fa_right);
draw_set_color(c_black);
if (menu_index == i) draw_set_color(c_red)
draw_text(menu_x, menu_y + button_h * i, button[i]);
i++;
};
}
Code:
if (question == true) switch (menu_index)
{
case 0:
value += "0";
draw_text_speed("Reset");
case 1:
value += "1";
draw_text_speed("Reset");
case 2:
value += "2";
draw_text_speed("Reset");
case 3:
value += "3";
draw_text_speed("Reset");
}
Code:
if (question == false)
{
value += "E" ;
draw_text_speed("Reset");
}
Code:
menu_move = keyboard_check_pressed(vk_down) - keyboard_check_pressed(vk_up);
menu_index += menu_move;
if (menu_index < 0) menu_index = buttons - 1;
if (menu_index > buttons -1) menu_index = 0;
if (menu_index != last_selected) audio_play_sound(snDialogChoice,1,false);
last_selected = menu_index;
Code:
ds_map_destroy(textMap);
Here's my problem: when I run the game, everything works fine (the dialogue starts and we can keep going pressing space) until the first branching: the interactive menu appears all right, but when I pick a choice (any of them) I've got this fatal error message:
It refers to this :FATAL ERROR in
action number 1
of Draw Event
for object cont_text_ULTIMATE_try:
string_length argument 1 incorrect type (undefined) expecting a String (YYGS)
at gml_Object_cont_text_ULTIMATE_try_Draw_0 (line 14) - if (string_char_at(txt,string_length(txt)) == "*")
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_cont_text_ULTIMATE_try_Draw_0 (line 14)
Code:
if (string_char_at(txt,string_length(txt)) == "*")
{
question = true;
}
else
{
question = false;
}
THANKS A LOT.
PS: I followed some tutorials for this as I am not a pro. One was for the dialogue system, the other was for the menu buttons: I tried to mix them in a single object...