|
|
|
|
Reply From: |
Wakatta |
More code is needed for a proper evaluation but from what i can see you’re passing in a string on your connect function when you should be passing in a node reference hence the error since connect is a virtual function of Object and not of type String.
So instead of
extra_arg_0.connect("pressed", self, "on_button_pressed", ["Player"])
its supposed to call a reference from the dict like this
extra_arg_0.connect("pressed", self, "on_button_pressed", [SPRITE_DICT["Player"]])
hmm I tried it out and at first it didn’t try and tell me something was wrong, but after clicking on the buttons in-game, I got the same
"Invalid Call. Nonexistent function ‘connect’ in base ‘String’. error
I think this means it has something to do with when I added the extra call in the advanced menu, any idea why it’s still doing this?
Spafnar | 2021-02-26 23:43
The code you’ve provided is not enough
For instance “res://Player.tscn::1” what is that a reference to?
also you have func _on_ButtonO_pressed
but in your connect you have "on_button_pressed"
You have simply not provided enough information to get a proper response.
Normally one would do all signal connections in the _ready():
function but here you’re connecting them on button_press which is extremely weird considering there are no disconnects so once again unless more code is provided its hard to say if the problem is not somewhere else entirely
Wakatta | 2021-02-27 00:05
Ah good catch, as far as the path, thats the SpriteFrame resource for the “new skin”, and all the current skins’ paths are what is in the dictionary.
I tried changing the coding from the on_button_pressed
to match what it is on all the functions, for example :
func _on_ButtonO_pressed(extra_arg_0):
extra_arg_0.connect("pressed", self, "on_ButtonO_pressed", [SPRITE_DICT["Player"]])
_buy(0, 0)
(Global.button_sound())
But the error code still appears. I don’t want to frustrate anyone with my impotence so if there’s any code in particular you need to see I can show it to you. I don’t know myself why the buttons are all being connected instead of putting them in the ready function, I’m just doing what was recommended. Essentially, player hits button; it purchases skin, player selects skin with button, it tells game to load in that skin via the dictionary.
Spafnar | 2021-02-27 00:29
No need to worry whats actually happening is that SPRITE_DICT["Player"]
returns a string from your dictionary "res://Player.tscn::1"
but you need a node reference can you post a pic of your scene tree
Wakatta | 2021-02-27 00:38
How do I import the screenshots it looks like I can only put an image url and it doesn’t seem to be working
Spafnar | 2021-02-27 04:32
the link alone is fine
Wakatta | 2021-02-27 04:41
Ok also I just figured out I was actually wrong earlier and what you said was correct, i misread the other guy’s original suggestion. I fixed it now, so all the buttons now are connected to the ready function. As far as the picture you want i’m still confused on how exactly to upload it, its on a folder in my computer I took three screenshots im not sure what you mean by link.
Spafnar | 2021-02-27 05:02
Hakuna Matata, glad you got it resolved.
Wakatta | 2021-02-27 05:17