Topic was automatically imported from the old Question2Answer platform.
Asked By
Cobaltiz
I want to make a text-based rpg kinda game. So I need to check wether the player has was in a scene already, if yes, then the previous room should change. I tried using bool variables but I will need this again in the future and it’s hard making 5 if’s every time just to check something.
I want to know if it’s possible to emit a signal when the player is in a room. I can’t connect signals from the node panel because I only have one node that I am working with.
Signals are nice but arrays are better. Well in this use case anyway.
var visited = Array()
func _entered_tree():
var scene = get_tree().get_current_scene()
if scene.name in visited:
change_room()
else:
first_entry()
visited.push_back(scene.name)
The above assumes you’re using changing scenes using get_tree().change_scene() however you can easily retailor it as required
Will this work if currently I only have one scene and just couple of nodes I am working with?