queue_free() and reload_current_scene() functions in Godot
queue_free() is a shortcut for destroying a node safely at the end of the frame and also removes it from the tree. It is useful if we have a node already outside the tree.
remove_child() is the opposite of add_child(). It removes the node form the scene tree. It does not delete the node, so we can then add it as the child of another node,
free() is the method for deleting an ode from memory. However, it's not always safe to do so. If we delete a node while other nodes may still be processing it.
queue_free() function will tell the engine, "Delete this node as soon as it's safe to do so."
Reload Current Scene with the Scene-manager. We need helps with the scripting for reloading the current scene.
Open Godot engine:
Opening the script tab:
We get this entry form the prompts array. And the error is telling us index 5th we have index 1, 2, 3, 4 things in there. We are looking for the 5th Array. There is no 5th value in the ArrayArray. So we need some logic and we want to keep adding things, or we can also change the functionality. There are many things we can do here. The first thing is that we have to make sure that when we are telling the story done let's get rid of guns to give us the line at it completely let's not let the player type anything right. We are going to remove it from the game. We are not going to write the code here instead of I will make a new function called End game.
Here the Text Box automatically disappears when the story completed.
Here We can write PlayerText.hide() and PlayerText.visible = false these function is used when our story is completed then the text box box will hide from the output panel. And we can use at the end also but PlayerText.show() and PlayerText.visible=true is used for hide the textbox after completion of story. Because they both are working the same. We can also write PlayerText.hide() in place of PlayerText.visible=false and PlayerText.show() in place of PlayerText.visible=true.
We can see get_tree() documentation or any function documentation form click and hold control (ctrl) button on it.
We are doing button alignment at the end.
Textbox disappear when the story is done.
And when we click on the button, then the text comes again!
We can also start a new story from here.
Here we are changing the Label name from Ok to again! .
If we press the button again, we can make a new story from continuing here.
In the next tutorial, we learn about Dictionaries.