Invalid call error

Godot Version

4.2.1

Question

I’ve been following a tutorial series on making a Roguelike Deckbuilder on Youtube, my issue occurs specifically on this video, at 43:00: https://www.youtube.com/watch?v=VaeDYC0vX74&list=PL6SABXRSlpH8CD71L7zye311cp9R4JazJ&index=19&t=2249s

The issue also comes up in the video, but he fixes it by removing the temporary testing code that was still in one of the other scripts. I did the same, but I still get the same problem. I’ve spent quite a few hours on trying to fix this and I’m just not getting anywhere.

Basically, what should be happening is that the status_handler adds one stack of the status, waits 2 seconds, adds another stack, waits 2 seconds, removes a stack, waits 2 seconds, and removes the final stack, just to make sure statuses can be applied and remove properly. Instead what I’m getting is the status will appear at 1 stack very, very briefly, disappear, then 2 seconds later do the same, then it crashes with the error “Invalid call. Nonexistent function ‘apply_status’ in base ‘Nil’.”, which is the same as was happening in the video with the unnecessary previous testing code I already removed. These are the scripts:

Any help would be really appreciated, even just being pointed in the right direction for what I should be looking for in order to fix this, as I’m just stumped at the moment.

What are the values for the “mark.tres”-resource?

First rule of debugging is to put print-statements in your methods.
Put some print-calls in the _on_status_changed()-method in the StatusUI:

func _on_status_changed() -> void:
    ...
    if status.can_expire and status.duration <= 0:
        print("DELETING 1")
        queue_free()

    if status.stack_type == ...:
        print("DELETING 2")
        queue_free()

Okay, this prints DELETING 2 both times the status is removed, but the stack type is duration, so shouldn’t this if statement not apply? Have I done my variables incorrectly or something?

okay after you load your test file, print out the stacktype:

var test := ...
print(test.stack_type)

It prints 2 if it’s Duration, I also changed it to Intensity and None to see what it would print, Intensity prints 1 and None prints 0, so that means status type is correct when it’s loaded?

Okay then print the status type in the set_status method of StatusUI:

status = new_status
print("Setting Status: ", new_status.stack_type)

as well as before the if-statement that deletes the statusUI:

print("Current-Status: ", status.stack_type)
if status.stack_type == ...

image

So the set_status method is changing it from Duration to Intensity?

somewhere there yes. put one in the _add_status()-method:

var stackable := ...
print("_add_status-stack_type: ", status.stack_type)

Screenshot 2024-08-13 205554

can you try to call the set_status-method directly and see if something changes?

add_child(new_status_ui)
print("Setting status: ", status.stack_type)
new_status_ui.set_status(status)

Screenshot 2024-08-13 210320

Do you have a value in the export var status or is it set to null in the statusUI-scene?

1 Like

I think you got it, I actually had that set to a different status, I think when I was testing the status ui before implementing the handler I just forgot to change it back. Thanks so much for your help, this has been a good lesson in debugging for me!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.