extends HSlider

@export
var audio_bus_name := "music"

@onready
var _bus: int 

func _ready():
	_bus = AudioServer.get_bus_index(audio_bus_name)
	value_changed.connect(_on_value_changed)
	value = db_to_linear(AudioServer.get_bus_volume_db(_bus))

func _on_value_changed(changed_value: float) -> void:
	AudioServer.set_bus_volume_db(_bus, linear_to_db(changed_value))

func change_volume(changed_value: float) -> void:
	AudioServer.set_bus_volume_db(_bus, linear_to_db(changed_value))
