Change Spritesheet in AnimatedSprite from GDscript

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By KaWa

Hello,

I have a problem with the AnimatedSprite. I want to create one NPC Scene, but in Game the NPCs need to have different Sprites.
I know that I can make a new animations out of the script like:

extends KinematicBody2D

export(String, FILE, "*png") var Sprite_file

onready var animation = $AnimatedSprite

func _ready():
	var sprite : StreamTexture = load(Sprite_file)
	animation.frames = SpriteFrames.new()
	animation.frames.add_animation("idle")
	animation.animation = "idle"
	animation.frames.set_animation_loop("idle", true)
	animation.frames.add_frame("idle", sprite, 0)
	animation.play()

But with that I have to use multiple Files for one Charakter. I can’t use a Spritesheet with that.
Is there any function to get the frames out of a spritesheet?