-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Inventory] Invalid call when using add_item() function for the InventoryBag node #29
Comments
OK. That's probably a big problem of how I "faked" static variables. Just to test things, could you please test deferring the call to add the item into the bag? Either by
in the
in the Problem here is that the bag (and the special slot) require internal initialization that is deferred because the tree is not fully built when the code is run. The result of that is the internal variable is null until the next main loop iteration. Now, even if this works, please just notify me without closing the issue. I will use this as a reminder that I need to review the code and try to find a better solution related to the initialization in order to avoid this kind of problem. |
@Kehom |
That happens because when the button is pressed it's almost certain that the initialization will be completed when it is pressed. I doubt someone will be able to press it on the very first frame of execution! The thing is, the initialization of the inventory system only finishes at the end of the very first frame in which it was loaded. This means that certain operations will fail if executed before that initialization could occur. Buttons rely on events that occur after this initialization. I will review the code and try to find a solution that removes the requirement of delaying the call. And if I can't find one, try to make it more clear about this limitation. |
While I tried to follow some of your Inventory addon tutorials I stumbled upon some issues, I managed to rewrite the "_generate_item()" function as "_get_item(id, category)" so that its being used to load valid (I think?) item entries that gets added to a dictionary variable, now when I use this "_get_item(id, category)" function to add a item to the InventoryBag node I get this error:
Invalid call. Nonexistant function 'disabled_slots_occupied' in base 'Nil'.
When I use the "add items" code example and try to add the item that way I get the same error.
Debugger output:
Node2D, InvDemo.gd script: https://ghostbin.com/paste/km8Ek
Node, Init.gd script: https://ghostbin.com/paste/8yRFk
The text was updated successfully, but these errors were encountered: