I'm making a little to plugin for Escoria to get used to gdscript. Is a bunch of simple dialogs to get user data and generate the full tree assigning the data so I don't need to put the info in different nodes, or forgot anything, and make the life a little easier.
It works ok, but I can't find how to assign external scripts to the tree. If I do it with the editor, the .tscn file starts with:
[gd_scene load_steps=4 format=1]
[ext_resource path="res://globals/player.gd" type="Script" id=1]
[ext_resource path="res://scenes/testplayer_anims.gd" type="Script" id=2]
[sub_resource type="SpriteFrames" id=1]
But my code generate a .tscn that starts with:
[gd_scene load_steps=3 format=1]
[ext_resource path="res://globals/player.gd" type="Script" id=1]
[sub_resource type="SpriteFrames" id=1]
CODE:
func _on_ConfirmationDialog_confirmed():
var dir = Directory.new()
var scene_name = get_node("vbox/hbox1/filePath_txt").get_text()
var telekinetic = get_node("vbox/hbox2/Telekinetic_checkbox").is_pressed()
var anims_script = scene_name.get_base_dir() + "/"+ scene_name.get_file().basename() + "_anims.gd"
var player
dir.copy("res://addons/Easycoria/templates/player_anims_empty.gd", anims_script)
player = preload("res://addons/Easycoria/templates/player.tscn").instance()
player.set_animations(anims_script)
player.set_telekinetic(telekinetic)
# TODO Add anims script as external resource
var packed_scene = PackedScene.new()
packed_scene.pack(player)
ResourceSaver.save(scene_name, packed_scene)
I suppose that the main problem is that I created the setanimations and settelekinetic functions in the original player.gd script from escoria and It doesn't add the script, only assign it. But I can't find the code to add it.
Thanks