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)
Written by martin mauchauffée
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Script
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#