system
1
|
|
|
|
Attention |
Topic was automatically imported from the old Question2Answer platform. |
|
Asked By |
wombatTurkey |
|
Old Version |
Published before Godot 3 was released. |
For example, I have a file called GameFunctions.gd
I can access all its functions by doing GF.myFunctionHere
Problem is, I’m trying to connect a signal outside of this file but using a function thats inside GF
.
Example / Problem:
temp_monster.connect("mouse_enter", self, "GF.MonsterHover")
temp_monster.connect("mouse_exit", self, "GF.MonsterOut")
Obviously this won’t work, as the parameter is a string Not sure if I’m having a brain fart, or just missing something stupid, thanks!
system
4
|
|
|
|
Reply From: |
wombatTurkey |
Hmm. I found a temporary solution. This is kind of annoying, but I mean, it works.
temp_monster.connect("mouse_enter", self, "MonsterHover", [temp_monster])
temp_monster.connect("mouse_exit", self, "MonsterOut", [temp_monster])
Then just use GF.call and pass the node as a parameter
func MonsterHover(node):
GF.call("MonsterHover", node)
func MonsterOut(node):
GF.call("MonsterOut", node)
If anyone has a better solution, please let me know and I’ll accept you as Best Answer
system
5
|
|
|
|
Reply From: |
CowThing |
Replace the self
with GF
. The second argument of connect
is the target of the function.
temp_monster.connect("mouse_enter", GF, "MonsterHover")
temp_monster.connect("mouse_exit", GF, "MonsterOut")
This should be accepted answer.
splite | 2016-08-02 10:33