on base: 'Nil' in editor plugIN
Asked Answered
U

2

0

hello,
Whenever i restart godot 4 i get a 'nil' error related to a get_node label

res://addons/tiletest/tiletest.gd:100 - Invalid set index 'text' (on base: 'Nil') with value of type 'String'.

if i use this:

	if ( label1 != null ):
		if ( mG.x > 0 ):
			label1.text = "DOCK: " + str( mG );
		else:
			label1.text = "DOCK: ";

the error right away passes to the lower lines:

res://addons/tiletest/tiletest.gd:105 - Invalid get index 'position' (on base: 'Nil').

It seems everything is 'nil' on the frist run, the only way to get rid of the error is to uncheck/check the plugIn in project settings
Is there a way to fix the error ?

The plugIn can be found here on gitHub:
https://github.com/jonSP12/TileDrawPlugIN_test01

Uraeus answered 12/2 at 16:13 Comment(0)
M
0

you have an export somewhere that has not been assigned.
or it's some other problem with unassigned variables.

"Nil" means a reference is null (empty, not pointing to anything)

Try following the errors and the code. Read what it says, post it here verbatim if you don't understand or look it up.
for example, the variable label1 could be unassigned or assigned to a node that doesn't exist or doesn't have the same name and path as written in the code.

Maxiemaxilla answered 13/2 at 1:56 Comment(0)
U
0

Ive assigned everything on func enter tree
its on github, but its the tiletest.gd in addons folder:
https://github.com/jonSP12/TileDrawPlugIN_test01/blob/main/addons/tiletest/tiletest.gd



@tool
extends EditorPlugin



const editorAddon = preload("res://addons/tiletest/tilePlugTest.tscn");
const tileDrawNode = preload("res://addons/tiletest/tileDrawNode.gd");
const tileDrawIcon = preload("res://addons/tiletest/icon.png");
const editorDraw = preload("res://addons/tiletest/editor_draw.tscn");


var subVcont;
var subVport;
var label1;
var label2;


func _enter_tree():

	subVcont = dockedScene.get_node("SubViewportContainer");
	subVport = dockedScene.get_node("SubViewportContainer/SubViewport");

	label1 = dockedScene.get_node("Label");
	label2 = dockedScene.get_node("Label2");

the error passes on to the next line of code if i check for null... i guess most of them are null.
But iam not sure were to put them func ready or enter tree, i think it doesnt matter much... but the "add_custom_type", and "dockedScene " must be in func _enter_tree():

Plus he always throws an error "Control was not in dock." i have a check on func _physics_process(delta):

	if not is_instance_valid(dockedScene) || dockedScene.visible == false:
		return;

It means label1 is valid and not null since its a part of "dockedScene"
label1 = dockedScene.get_node("Label");

Iam not sure plugINs are supossed to work except maybe for minor things, like small edits on nodes

Uraeus answered 13/2 at 9:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.