Last Updated: February 25, 2016
·
8.367K
· moechofe

How to import script in Godot

In Godot, script file are class. You can't import script but you can load (or preload) it.

Here is the script res://foo.gd:

var foo

func _init(bar):
    foo = bar

func get():
    return foo

And a Node Script:

Extends Node

var instance

func _ready():
    instance = load("res://foo.gd").new(123)
    assert(insance.get() == 123)