This is the testing Godot forums! All forum posts unique to this forum will be deleted! Please use the main forums here for any posts you want to keep. All forum rules still apply.

Script library: how?

slapinslapin Posts: 62Member

What is best practice to maintain your library of functions?
i.e. I have AI.gd and want to run functions from it in a few places over script attached to scene. How can I do it?
Is it possible to do the same for .vs?

Best Answer

  • slapinslapin Posts: 62
    Accepted Answer

    Found quick answer:

    #global
    var vs
    
    func _ready()
        vs = Reference.new()
        var script = load("res://statemachine.vs")
        vs.set_script(script)
    

    then functions are available on vs.func_name()
    allows better quality of life with GDScript and VisualScript.

Answers

  • slapinslapin Posts: 62Member
    Accepted Answer

    Found quick answer:

    #global
    var vs
    
    func _ready()
        vs = Reference.new()
        var script = load("res://statemachine.vs")
        vs.set_script(script)
    

    then functions are available on vs.func_name()
    allows better quality of life with GDScript and VisualScript.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.