1
\$\begingroup\$

So i have most system set up im just at loss on make it so that the player has to click through the dialog. Currently all the dialog is stored in text files that are read into dictionary's like so.

var dic = {}

func test():
    var index = 1
    popup_centered(Vector2(0,2000))
    var line = dic[str(index)]
    $Text.set_text(line)


#loads file into dictionary
func load_file(filepath):
    dic = {}
    var file = File.new()
    file.open(filepath, 1)
    var index = 1
    while not file.eof_reached():
        var line = file.get_line()
        print("the line:")
        print(line)
        dic[str(index)] = line
    index += 1
    file.close()
    print(dic)
    test()

Where the test function is like i said above i want the code to wait for the players input and print the next line in the dictionary and then close when the dictionary is empty. Being new to Godot i dont know if there is a simple way to do this. Any help is appreciated and thank you in advance.

Also aside, i know there are a lot of plug-ins for Godot that can handle dialog if i download them, but i want to build this myself so i can learn, so please don't just say use a plug in.

\$\endgroup\$
1
\$\begingroup\$

Figured out a solution, Godot has built in functions that catch inputs that you can use. In this case its _input(). Example as follows;

func _input(event):
if event.is_action_released("left_mouse") and active:
    print("left mouse clicked yay!")
    index += 1
    test()

It pays to read the documentation.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ "It pays to read the documentation." is the pro tip here! The next level is to read the engine's source code when necessary ;) \$\endgroup\$ – Vaillancourt Aug 12 at 10:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.