#why dosent this work after a first iteration it justs never finishes

1 messages · Page 1 of 1 (latest)

foggy orbit
#

extends CanvasLayer

@onready var dialognode = $dialog
@onready var dialogtext = $dialog/dialog
@onready var dialogbox = $dialog/box
@export var done = false
enum typestate {TYPING,FINISHED, CF}

signal dialog_finished

var statetype = typestate.FINISHED
var dialogon = false
var state = 0
var lineslength = 0
var lines : Array = []
func hide_dialog():
dialognode.visible = false
dialogtext.text = ""

func show_dialog():
dialognode.visible = true

func add_text(text: String):
dialognode.visible = true
statetype = typestate.TYPING

dialogtext.text = text
dialogtext.visible_characters = 0

for i in range(text.length() + 1):
    dialogtext.visible_characters = i
    await get_tree().create_timer(0.04).timeout

statetype = typestate.FINISHED

func dialog(liness : Array ):
done = false
lines = liness
lineslength = lines.size()

dialogon = true
state = 0

show_dialog()
add_text(lines[state])

func _ready() -> void:
hide_dialog()

func _input(event: InputEvent) -> void:
if event.is_action_pressed("next"):
if statetype == typestate.TYPING :
print("nah")
return
if dialogon == true:

        if lineslength -1 == state:
            dialog_finished.emit()
            hide_dialog()
            state = 0
            done = true
            dialogon = false
            statetype = typestate.CF
        else:
            print("yes")
            dialogtext.text = ""
            state = state + 1
            add_text(lines[state])

**PICTURE 1 **
thats the node tree of the system

eager zealotBOT
frosty canopy
#

What do you mean by "doesn't work" and "never finishes"? I copied your code into a new project, replicated the node structure and called dialog() with an array containing some strings, it displays all of them and then at the end hides the box with no issues.

wise heathBOT
#
Embedding code in discord messages
Inline Code

When you surround some words with single backticks like `this`, it will be formatted as code.

Code Blocks

You can also include code blocks by surrounding the code with three backticks. If you add "swift" then you will also get basic syntax highlighting:
```swift
print("hello world")
```
Discord will then show it as a code block like this:

print("hello world")
Upload

If your code snippet is rather long, you can upload it to a text paste site. One option that supports syntax highlighting for GDScript is https://bpa.st/

nova trail
#

Also, #1235176210477355098 is for questions that are very specific, often require technical knowledge of the engine's internals, and where the asker doesn't require a walkthrough to solve the problem, only pointers or hints. This doesn't seem to fit that, you might have better luck in #1235175950241628273

foggy orbit
#

I mean dosent wnd

#

*end