Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | godot.ma.desive.logo |
Is there some function like:
var x = get_stream_name()
in Godot and how to use them?
Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | godot.ma.desive.logo |
Is there some function like:
var x = get_stream_name()
in Godot and how to use them?
Reply From: | njamster |
If you want the full path of the stream:
$AudioStreamPlayer2D.stream.resource_path
If you are only interested in the filename:
$AudioStreamPlayer2D.stream.resource_path.get_file()
If you want to remove the file’s extension:
$AudioStreamPlayer2D.stream.resource_path.get_file().get_basename()
Thank you very much, but I need to find out the name of the node. The thing is, I have 100 audio streams and in one function I select one to play according to a certain key. And I need to find out the name of the selected stream retrospectively (in another function).
godot.ma.desive.logo | 2020-08-28 16:23
I need to find out the name of the node
I need to find out the name of the selected stream
What now? The name of the node (Which node? The AudioStreamPlayer-node?)? That’s simple: $AudioStreamPlayer2D.name
. Or the name of the stream? That’s what I have described in my answer. Not sure what else you might be looking for…
If you want to keep track of which AdioStreamPlayer-node is playing, simply save the active node to a variable and access it through that variable. It’s hard to provide you with concrete advice regarding that without knowing your code though.
njamster | 2020-08-29 10:14
print( $AudioStreamPlayer.get_name() )
I’ve already solved it yet, but thank you very much!
godot.ma.desive.logo | 2020-08-31 10:01