This is the testing Godot forums! All forum posts unique to this forum will be deleted! Please use the main forums here for any posts you want to keep. All forum rules still apply.

taking user input to another scene

ItsColdItsCold Posts: 21Member
edited December 2018 in GUI

so i tried making some sort of document that player will put their input, like a registration or some sort.
i wonder if i can, for example take their 'name input' to another scene like dialogues or something.

how do i do this?
i tried making the input with richtextlabel instead of label and put another blank label with code that can import those input but ended up failing

any insight on this?

Best Answer

  • o0Rh0mbus0oo0Rh0mbus0o Posts: 3
    Accepted Answer

    You can access another scene by fetching the scene with load(scene) or preload(scene), and then you can access variables in the nodes of that scene using get_node("path/to/node").variable.

    If you have child scenes in a main scene, and you want to access node variables in a different child scene, you can use get_tree().get_root().get_node("root/path/to/node").variable.

    I use the second option to access button-states in the GUI for toggling torches for example.

Answers

  • o0Rh0mbus0oo0Rh0mbus0o Posts: 3Member
    Accepted Answer

    You can access another scene by fetching the scene with load(scene) or preload(scene), and then you can access variables in the nodes of that scene using get_node("path/to/node").variable.

    If you have child scenes in a main scene, and you want to access node variables in a different child scene, you can use get_tree().get_root().get_node("root/path/to/node").variable.

    I use the second option to access button-states in the GUI for toggling torches for example.

  • ItsColdItsCold Posts: 21Member

    thanks for the response, im using the first methid and working andd i got new problem.

    so i'm using the code to make sort of a popup inventory menu, then i make variable that detect player mouse click and area detection for the inventory icon.
    so when both variable are true, the inventory came out.
    but the problem is whenever i click the item, the menu closes.
    i figured that i have to use the second method but i dont quite get it.

    im trying to get the area2D variable which detect mouse collision on menu area and it worked on it's own scene.
    but not when i connect it from main menu scene.

    get_tree().get_root().get_node("root/path/to/node").variable.

    i have no idea what to write on get_node path.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.