TeamSyndi / syndibox

SyndiBox - A powerful text engine for dialog-heavy Godot projects
MIT License
91 stars 9 forks source link

[BUG] Instant Print off tag does not shut off Instant Print #36

Closed zaknafean closed 3 years ago

zaknafean commented 3 years ago

Describe the bug When using the [i] and [n] tags in mid dialog, the [*n] does not end the instant scroll.

To Reproduce Steps to reproduce the behavior:

  1. Create a dialog using [i] and either [n] or [*r] for example:
    • Frei:[*i]HEY![*n] Only people who live upstairs can come behind the bar.
  2. Observe as the first few characters 'type' as normal.
  3. As soon as it hits the [*i] tag however, all the rest of the line of dialog immediately prints out.

Expected behavior Expected behavior would be that only the dialog between [i] and either [n] or [*r] appear immediately, then the default print speed resumes.

Device Info (please complete the following information):

Additional context The dialog is being set via the start(string) method in case that is a factor.

I am not using the Instant Print checkbox at all in this example, purely the tags.

zaknafean commented 3 years ago

Looking at the code I imagine the problem is here around like 534:

# Speed Effects #
func speed_check(string):
    if emph.substr(0,2) == "[*":
        string.erase(step,emph.length())
        string = string.insert(step,char(8203))
        if !INSTANT_PRINT:
            if emph[2] == "*":
                speed = float(emph.substr(3,emph.length()))
            match emph:
                "[*1]": # Fastest
                    speed = 0.01
                "[*2]": # Fast
                    speed = 0.03
                "[*3]": # Normal
                    speed = 0.05
                "[*4]": # Slow
                    speed = 0.1
                "[*5]": # Slowest
                    speed = 0.2
                "[*i]": # Instant
                    INSTANT_PRINT = true
                "[*n]": # Non-Instant
                    INSTANT_PRINT = false
                    speed = def_speed
                "[*r]": # Reset
                    INSTANT_PRINT = def_print
                    speed = def_speed
    return string

Seems if INSTANT_PRINT is active, it stops looking at speed related tags. Adding an else clause fixed it for me, and I'll open a pull request so you guys can see if its a good solution or not.