Scene works, Dock doesn't.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Sylkie

Trying to build a plugin after doing the two tutorial projects. It’s very simple, two Labels and a LineEdit. Primary node is a Control. Script attached to Primary node.



name="Golden Mean"
description="Calculate the Golden Mean values for any Integer or Float."
author="Richard E. Rogers"

extends EditorPlugin

var dock

func _enter_tree():
    # Initialization of the plugin goes here
    # Load the dock scene and instance it
    dock = preload("res://addons/golden_mean/GoldenMean.tscn").instance()

    # Add the loaded scene to the docks
    add_control_to_dock(DOCK_SLOT_RIGHT_BR, dock)
    # Note that LEFT_UL means the left of the editor, upper-left dock

func _exit_tree():
    # Clean-up of the plugin goes here
    # Remove the dock
     # Erase the control from the memory

extends Control

func _ready():

func _on_LineEdit_text_entered(new_text):

    if new_text.is_valid_integer(): 
        $VBoxContainer/Label.text = "Major Axis: " + str(int(float($VBoxContainer/LineEdit.text) * 1.61803398875))
        $VBoxContainer/Label2.text = "Minor Axis: " + str(int(float($VBoxContainer/LineEdit.text) / 1.61803398875))
    elif new_text.is_valid_float():
        $VBoxContainer/Label.text = "Major Axis: " + str(float($VBoxContainer/LineEdit.text) * 1.61803398875)
        $VBoxContainer/Label2.text = "Minor Axis: " + str(float($VBoxContainer/LineEdit.text) / 1.61803398875)
        $VBoxContainer/Label.text = "What the fuck you talkin' about son?!?"
        $VBoxContainer/Label2.text = "Give me a valid number!" 


func _on_LineEdit_focus_entered():

I’ve saved the scene to addons/golden_mean.

The Scene works perfectly when run from the editor.

But as a dock, the controls show up, on the proper dock, but there is no functionality. If I enter a number and press return, nothing happens.

It’s as if there was no script attached, so I’m assuming I’ve made some kind of initiation error.

Have you tried adding the tool keyword in the beginning of your script?

SIsilicon | 2019-09-24 01:42

That’s it. I was so concentrated on looking for misspellings I missed that simple missing bit. Thank you! Works a treat now.

Sylkie | 2019-09-24 02:48

:bust_in_silhouette: Reply From: SIsilicon

Have you tried adding the tool keyword in the beginning of your script?