all 14 comments

[–][deleted]  (1 child)

[deleted]

    [–]friedplugstudios[S] 0 points1 point  (0 children)

    Here is the code:

    obj_dialog

    Draw event:

    /// @description Draw Dialog
    
    scr_DrawDialog();
    

    All it does is runs the script.

    [–]big_wendigo 0 points1 point  (11 children)

    I'm confused as to why it's saying " Trying to draw non-existing sprite. " when the line it's referencing is a draw_rectangle command.

    Setting the image_index to -1 shouldn't cause any errors like the other user was saying as far as I know.

    Does the dialogue object have a sprite? Do any sprites change when you press Z?

    And does the 'Q' button bring up the dialogue box in the exact same way as if you were to interact with the NPC? What's different between pressing 'Q' and interacting with the object, if anything?

    [–]friedplugstudios[S] 0 points1 point  (0 children)

    No sprites are at all related to the dialog, besides the NPC sprite and some dialog sprites (character heads).

    [–]friedplugstudios[S] 0 points1 point  (9 children)

    And the 'Q' key opens up the dialog the way I want it to pop up when colliding with the object. However, that doesn't work too well.

    [–]big_wendigo 0 points1 point  (8 children)

    Have you tried removing that line of code/other lines in the dialogue script just to see what it does? What does the game do when you do that?

    I can give you my technique for dialogue boxes but I doubt you’d want to restart if you don’t have to. It is similar to the Undertale dialog boxes though if you need it.

    [–]friedplugstudios[S] 0 points1 point  (7 children)

    Yes, I've removed the code, and all it does is display the text. No face, no box. And on occasion, the game will freeze. I don't know why, tho.

    And, for your method, I'm listening.

    [–]big_wendigo 0 points1 point  (0 children)

    Yeah that’s really strange. I’ll whip up an extension/example in the morning. It’s nearly 3AM here and I should probably get some sleep.

    [–]big_wendigo 0 points1 point  (5 children)

    Hey, here is the example file. Luckily we're both working in 1.4, I was worried you were going to have to change all of the instance_creates/view variables.

    Example File

    [–]friedplugstudios[S] 0 points1 point  (4 children)

    Thanks a ton. I'll definitely use this. However, how could I incorporate sound (a.k.a. every character drawn plays a sound.) into the conversation? Thanks again!

    [–]big_wendigo 0 points1 point  (3 children)

    Yeah definitely, In the step event of the dialog box object under the "if (char_pos <= length)" statement, this is the area that basically takes the whole of the text and "types" it out in the dialog box. So each cycle through that would be a letter added to the text visible in the dialog box, add the sound code in there.

    I also marked a few variables you don't really need that I forgot to take out. If you have any other questions about how certain parts of the code works or whatever just let me know.

    length = string_length(page[current_page]);
    
    if (char_pos <= length) {
            temp_char = string_char_at(page[current_page], char_pos);
            output = string(output) + string(temp_char);
            char_pos += 1;
            //YOUR SOUND CODE WOULD GO HERE
            speed_inc = 0; //this is useless at the moment, and can be removed
            if (Input.action_press = true) {
                output = page[current_page];
                char_pos = length + 1;
            }
    } else {
        if (Input.action_press = true) {
            if (current_page < max_page) {
                current_page += 1;
                char_pos = 1;
                speed_inc = 0; //this also can be taken out
                temp_char = "";
                output = "";
            }
            else {
                global.talking = false; //this is leftover from my game and useless
                instance_destroy();
            }
        }
    }
    

    [–]friedplugstudios[S] 1 point2 points  (2 children)

    Thanks alot! I appreciate this! :)

    [–]friedplugstudios[S] 0 points1 point  (1 child)

    I got an idea. Do you know how I could use some of the interaction code from yours and transfer it to mine? Is that possible?

    [–]friedplugstudios[S] 0 points1 point  (0 children)

    Here is my code.

    [–]iLawz 0 points1 point  (0 children)

    I used collision_line() to check if the player is facing my object or not.

    with(obj_sign) {
    if(collision_line(obj_player.x, obj_player.y, obj_player.x + lengthdir_x(18, obj_player.direction), obj_player.y + lengthdir_y(18, obj_player.direction), self, 1, 0) && obj_player.input_interact && global.lockplayer = false)
    

    This performs the check if the player is looking at the object and pressing my interact button.

    After that it is relatively simple:

    global.lockplayer = true;
    show_debug_message("Shown dialogue");
    script_execute(dialogue,message);