+2 votes

Hi friends, I am trying since yesterday making some code work that is dependent on a custom signal.I am having some problems making it work, maybe it is the way my setup works.

This is the signal:

add_user_signal("go_to_next_text",[{"name": "current_chapter", "type": TYPE_STRING},{"name": "current_dialog", "type": TYPE_STRING}, {"name": "current_text_finalized", "type": TYPE_INT},{"name": "total_texts", "type": TYPE_INT}])

Then, on the needed part, I connect it, together with the needed arguments that are:

connect("go_to_next_text", self,"go_to_next_text", [chapter, dialog, start_at, dialog_array.size()])

The mentioned function go_to_next_text:

func go_to_next_text(chapter, dialog, start_at, total_text):
    print("FUNC STARTED!", chapter, dialog, start_at, total_text) # testing purpose
    var accept = Input.is_action_pressed("ui_accept")
    while not accept:
        if accept:
            emit_signal("go_to_next_text",chapter, dialog, start_at, total_text)

but it looks like the function is never called as I don't get even the print "FUNC STARTED"

I have already read the documentation about signals and even the reddit posts relevant to the theme... but I wasn't able to figure it out what I am doing wrong

Also, I know this is another kind of doubt, I can create another question, but since I am on the theme, is it possible to simplify this process by making a yield(object, "go_to_next_text", array_with_arguments) and pass the arguments directly on the yield somehow?

asked Aug 7, 2016 in Engine by brunosxs (222 points)
edited Aug 7, 2016 by volzhs

Can you make a sample project for it?

I dont know add_user_signal method, but if i do simple

extends Node
signal go_to_next_text(chapter, dialog, start_at, total_text)

func _goto(chapter, dialog, start_at, total_text):

func _ready():
    self.connect("go_to_next_text", self, "_goto")

    emit_signal("go_to_next_text", null, null, null, null)

it works as expected (print out "gotcha!" :) )


var accept = Input.is_action_pressed("ui_accept")
while not accept:
        if accept:
            emit_signal("go_to_next_text",chapter, dialog, start_at, total_text)

really? :)

# let accept be false, so:
while !false # = true, ok, go to cycle
    if false # do nothing
        emit # never called
    # stay forever in loop (accept never change)
_activate_doomsday_device() # dont worry :)


# let accept be true, so:
while !true # = false, do nothing
    if false # never called
        emit # never called
    _activate_doomsday_device() # dont worry :)

edit: minor formatting issues
edit2: added silly joke with doomsday device :))

Hey friend, thanks for replying.

I got the help of one of the devs and looked like I was trying to get blood from a rock

The signal is kinda like a shortcut to add_user_signal, other than that, they work the same.

I solved my problem by making global variables that could be changed based on the results of other functions...
Not the most elegant sollution, but it is now working flawlessly.

It was the last thing I was trying to correct/tweak before releasing my plugin to the public


Looks sweet, i will give it a try (would be very cool to have texts in xml & external editor for translators), but right now, i cant make it work (pretty sure its PEBKAC).

Btw & OT, "smrt" means "dead" (as in "black dead") in my language :D

Another friend from the community pointed me that, which was not the intention at all.
It came from the Simpsons, when the original voice actor for homer, mispelled SMART when talking how smart homer is... The situation was so funny they left it there.

The video

Why the name? Well... I always felt SMRT(an idiot, not death haha) while making this plugin, as I was creating while learning. Since it is not offensive, I kept the name.

Please log in or register to answer this question.

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 How to use this Q&A? before posting your first questions.