dialogic-godot / dialogic

💬 Create Dialogs, Visual Novels, RPGs, and manage Characters with Godot to create your Game!
https://dialogic.pro
MIT License
3.42k stars 206 forks source link

Issue with using signals #1679

Closed EizenSmith closed 9 months ago

EizenSmith commented 9 months ago

I'm trying to make the conversation emit a signal when the player chooses to bike to work. The timeline functions fine until i add in the 'bike_signal func'


extends Area2D

var active = false
var bikeChoiceMade = false

func _ready():
    connect("body_entered", self, '_on_bike_body_entered')
    connect("body_entered", self, '_on_bike_body_exited')

#called when the node enters the scene tree for the first time.
func _input(event):
    #check the golbal variable to see if the player has already made their choice
    if gameManager.bikeChoiceMade == false:
        if get_node_or_null('DialogNode') == null:
            if event.is_action_pressed("ui_accept") and active:
                get_tree().paused = true
                var dialog = Dialogic.start('timeline-1688729263.json')
                dialog.pause_mode = Node.PAUSE_MODE_PROCESS
                dialog.connect('timeline_end', self, 'unpause')
                #updates the golbal variable to diable the interaction in the future                 
                gameManager.bikeChoiceMade = true                
                add_child(dialog)
                #connect the signal from the dialogic conversation                
                dialog.connect('dialogic_signal', self, 'bike_signal')                   
                #hides the interaction prompt
                $promptBike.hide()          

func bike_signal(bike):
    if  bike == 'user_chose_bike':
        print('+15')

func unpause(timeline_name):
    get_tree().paused = false

func _on_bike_body_entered(body):
    if body.name == 'Player':
        active = true

func _on_bike_body_exited(body):
    if body.name == 'Player':
        active = false```
EizenSmith commented 9 months ago

i've narrowed it down to the if line of the the bike_signal func as the print works correctly without the if.

something wrong with 'if bike == 'user_chose_bike':

Edit: i commented out the if line again and it didn't work. no idea why it worked once.

EizenSmith commented 9 months ago

So if i trigger another dialogic interaction before this one it works fine. but if it's the first dialogic interaction it doesn't work at all and breaks all other dialogic interactions in the scene.

Jowan-Spooner commented 9 months ago

So this is dialogic 1?

Jowan-Spooner commented 9 months ago

For questions that you expect are not bugs, please use the discord or if that is impossible the discussions.

Also if you want your problem to be answered quickly provide information like:

Jowan-Spooner commented 9 months ago

Hey @EizenSmith, please let us know more about your issue or when we can close it.

EizenSmith commented 9 months ago

Apologies for the delay, had a mental weekend.

there was one mistake in my code, both Connect arguments said 'body_entered' instead of one entered and one exit. But the actually issues was caused by merging files with a friend. the layers & masks were set up incorrectly.

EizenSmith commented 9 months ago

thank you all for looking at this.

Jowan-Spooner commented 9 months ago

Alright, glad you figured it out and sorry to hear your weekened wasn't going as planned. Feel free to ask for help again here (for bugs) or on discord for any misunderstandings/questions/problems with using dialogic in your game.