The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

0 votes

I have two scripts ones a classname called Actions, and the other is a scene with a script that does some ui updates, in the class script I have a signal and a function that gets called when doing an action, in the function I emit a signal, in the other script i connect the signal with self.connect("uiupdate", self, "update_ui") but this never happens because the function inside that script never runs

func _ready():
    self.connect("ui_update", self, "update_ui")

func update_ui():
    print("ui is updating")
    $Player_position.update(MonsterInventories.player_inventory[0])
    $Enemy_position.update(MonsterInventories.enemy_inventory[0])

That is the script what I want to run a function

class_name Actions

signal ui_update

func attack(attacker_inventory, target_inventory, move):
    #print(str(attacker.name) + " used " + str(move.name) + " " + str((move)))
    var attacker = attacker_inventory[0]
    var target = target_inventory[0]
    var new_text = (attacker.name + " attacked with " + move.name)
    #text_scroller(new_text) # UI will become usless unless I change how the ui is controlled
    var data = recieve_damage(move,attacker,target)
    emit_signal("ui_update")

and this script I simply emit the signal but nothing works, either the signal doesnt get emitted or the signal never actually connects and I have to do it this way since this class script isn't in a scene

Godot version 3.3
in Engine by (161 points)

Looking in the debug box it says its a nonexistent signal so the signal doesnt exist yet, how can I go around this?

1 Answer

+1 vote
Best answer

That is because the signal isn't a property of that scene with the receiving method.
You have to connect it in the Actions class like this:

connect("ui_update","your_scene","ui_update")
by (2,018 points)
selected by

where would I put it, in the ready function Does the class still work with the ready function?

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 [email protected] with your username.