0 votes

I have been trying to solve this for many hours. I have other examples where it works but often I get this error and I can't for the life of me figure out why.

The script is in a Table Scene which has a Dealer Node. Both nodes are Node2D. The Dealer node is itself a Scene and has a script attached which does contain the freshDeck() function

func _on_FreshDeckButton_pressed():
print("Calling " + str(get_node("Dealer")) + " for a fresh deck")
get_node("Dealer").freshDeck();

This throws the error
Invalid call. Nonexistent function 'freshDeck' in base 'Node2D'

It seems to be saying the Dealer node is a base node (Node2D) and so doesn't have the function in Dealer. But I have other examples where this works perfectly.
It appears to be random. Sorry, couldn't upload the image of the project. It kept taking over the whole window

in Engine by (38 points)

1 Answer

0 votes

Invalid call. Nonexistent function 'freshDeck' in base 'Node2D'

This tells you that the node you're getting with get_node("Dealer") extends a Node2D. But neither that base-class (Node2D) nor the additions you made to it in the script attached your node include any function called freshDeck. It's impossible to fix your problem with the information you've given - but it's very unlikely to be "random". ;)

by (10,483 points)

I explicitly said the Dealer Node is a scene itself and that the Script associated with it does have a function freshDeck()

That is DealerScript.gd
includes the following lines:

extends Node2D

......

func freshDeck():
print("Reached Dealer.freshDeck()")
get_node("Deck").freshDeck()

Which is just a simply relay down to the next level

I have a much simpler example which does the same kind of thing but it DOES work. I'm sure it isn't random, that I'm missing something crucial, but I can't see it.

I have a zip file of the project, and images of the engine at the point the call is made, both of which I could post if I were reporting a bug, but I see no way to post them here.

You can upload your project somewhere else (WeTransfer, EasyUpload.io, whatever, pick your poison ;)) and provide a link to it here.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.