Last Updated: February 25, 2016
· 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://

var foo

func _init(bar):
    foo = bar

func get():
    return foo

And a Node Script:

Extends Node

var instance

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