diff --git a/src/devices/data_logging/data_logging.gd b/src/devices/data_logging/data_logging.gd index 8485cde..c451bb6 100644 --- a/src/devices/data_logging/data_logging.gd +++ b/src/devices/data_logging/data_logging.gd @@ -21,7 +21,7 @@ var connection_command = NAN # called everytime a signal is received from main.gd to save it func _scene_signal_received(scene_name): scenes["new"] = scene_name.get_file().split(".")[0].replace("_", "") - # When logging in on, initiate a new file (trial) and update current scene if new + # When logging in on, update current scene if new if scenes["current"] != scenes["new"]: # If a trial was in progress (i.e. previous scene is not blank), end it if scenes["current"] != "": @@ -32,7 +32,13 @@ func _scene_signal_received(scene_name): scenes["current"] = scenes["new"] update_data() - if logging["current"] == true and Globals.main.has_node("PythonBridge"): + + # If new trial is not empty, create one + if ( + logging["current"] == true + and scene_name != "" + and Globals.main.has_node("PythonBridge") + ): Globals.main.get_node("PythonBridge").send("create_trial", data, "once") diff --git a/src/main.gd b/src/main.gd index d059d8a..88233ff 100644 --- a/src/main.gd +++ b/src/main.gd @@ -39,6 +39,8 @@ func load_scene(path: String): func unload_scene(): if _current_scene_node: _current_scene_node.queue_free() + if (Config.get_value("devices.data_logging.enabled")) == true: + SignalBus.session_scene.emit("") func _current_scene(_connection):