This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+1 vote

Not sure why the code block works wrong. I apologize in advance.

I have this game where i would like to keep track of the dialogs that have been played in order to give the player a "item"/"key" or show a new dialog.
I managed to make dialogs appear and disappear by creating buttons.
I would like that once the X button is pressed, the button will emit the visual dialog (this is working atm), and write itself inside a list that is located on a Global singleton (in order to keep a track of the texts.

The has a var called Data shown below

var Data = {
"Texts" : []

The objective of this "item" would be to keep a track of which dialog has already been played in order to: show a new dialog, open a new room.

My code for the button trying to get the "item" to appear on the global list

  extends Button

var mouse_enter = false
var clickable = true

# Called when the node enters the scene tree for the first time.
func _ready():
    $".".connect("mouse_entered", self, "_mouse_entered")
    $".".connect("mouse_exited", self, "_mouse_exited")

func _process(delta):
    if !$".".get_overlapping_areas():
        clickable = true

func _mouse_entered():
    mouse_enter = true

func _mouse_exited():
    mouse_enter = false

func _unhandled_input(_event):
    if Input.is_action_just_pressed("mouse_click") and mouse_enter == true and clickable == true:

My code for the scene that has the button and emits the signal (simplified)

extends Node2D


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

func onFarmer0pressed():
if get
nodeornull('DialgNode') == null:
get_tree().paused = false
var dialog = Dialogic.start('Farmer0')

dialog.pausemode = Node.PAUSEMODE_PROCESS

    dialog.connect('timeline_end', self, 'unpause')


func onFarmer1pressed():
if get
nodeornull('DialgNode') == null:
gettree().paused = false
var dialog = Dialogic.start('Farmer1')
dialog.connect('timelineend', self, 'unpause')

Godot version 3.4.3
in Engine by (28 points)

1 Answer

0 votes
Best answer

Found a solution to the issue.
The way to make it work was to add the variable inside the signal pressed.

func _on_Woman1_pressed():
var a = "Woman1"
if !"a" in Global.Data["Texts"]:

if !"Cane" in Global.Data["Collected Objects"]:
    if get_node_or_null('DialgNode') == null:
        get_tree().paused = false
        var dialog = Dialogic.start('Farmer1')
#       dialog.pause_mode = Node.PAUSE_MODE_PROCESS
        dialog.connect('timeline_end', self, 'unpause')

after it it was needed to add the function to hide in case that the name was on the list already

by (28 points)
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.