Finally figured it out using ChatGPT!!
j/k lol don't kill me I did it myself π Thank you @xyz
func _process(delta):
turret.rotation.y = rotate_toward(turret.rotation.y, get_8_direction_input(), 2 * delta)
func get_8_direction_input():
var node3d_rotation = node3D.rotation_degrees.y
node3D.look_at(player.global_transform.origin,Vector3.UP)
var sector = wrapi(snapped(node3d_rotation, 45) / 45, 0, 8)
return ([0, PI/4, PI/2, 3*PI/4, PI, -(3*PI/4), -PI/2, -PI/4][sector])