JujuAdams / Scribble

Efficient, internationalized, multi-effects text renderer for GameMaker
https://www.jujuadams.com/Scribble/
MIT License
335 stars 47 forks source link

When using brackets with typist and .sound_per_char(), sounds are still made for text that isn't there and it takes a while to show. #550

Closed OrangeeInkling closed 1 week ago

OrangeeInkling commented 2 months ago

I have a typewriter system for my game using Scribble and when I print text that has the square brackets with different formatting stuff in it, it takes about 1 - 5 seconds for it to fully print 1 sprite or an effect and it makes sounds for the things in the square brackets. Is there any way to fix this?

JujuAdams commented 2 months ago

Think about this from my position. Is this enough information to understand the problem?

Please provide more details, including the string you are drawing and Scribble method calls.

OrangeeInkling commented 2 months ago

So sorry!! I was kinda in a rush typing that, here's the string: "Testin- [shake]W-wait...[/shake]\n[scale, 2]HEY![/scale]What do you think you're doing?!\nI thought that no one would mess\nwith the files of this.\n[scale, 0.5]Huh... Must've been wrong.\n[/scale]Well... [jitter]Go get 'em, person![/]" The code that I am using is inside of its own Script, it looks exactly like this:

function ScrollingText(txtx, txty, stringid, textspeed, txtsleep, sound, pitchmin, pitchmax) 
{
    typist = scribble_typist()
    typist.in(textspeed, 0)
    typist.sound_per_char(sound, pitchmin, pitchmax, 0, 1)
    typist.character_delay_add(".,!?", txtsleep)

    //actually draw the text
    scribble(stringid).draw(txtx, txty, typist)

}

This is a video of what it looks like, sorry if it's really bad. https://github.com/user-attachments/assets/c95904ea-153b-40c7-90ac-795fb4a76f06

If you need any more info, please let me know!

JujuAdams commented 1 month ago

Video much appreciated, thank you.

I am very confused why it's doing this! I am looking at this now.

JujuAdams commented 1 month ago

Can't reproduce this my end. I do notice some problems with your code, however. I am unsure if these are the root cause of the problem but we should address these problems first.

Please make these changes and let me know if the behaviour you're seeing still occurs.

OrangeeInkling commented 1 month ago

Alright, I made some changes and I'm not too sure if it's a good idea for me to do this, but I initialize the typist when the game starts. Not sure if that's a good thing or not, but its initialization code looks like this:

//init typist for whenever it needs to be used (not sure if this is a good idea)
global.typist = scribble_typist() 
global.typist.in(0.5, 0)
global.typist.sound_per_char(sd_nisralvoice, 1, 1, "\n", 1)
global.typist.character_delay_add(".", 15)
global.typist.character_delay_add(",", 15)
global.typist.character_delay_add("!", 15)
global.typist.character_delay_add("?", 15)

And I slightly changed the code for the "ScrollingText" thing which should just print the text as expected, it looks like this now:

function ScrollingText(txtx, txty, stringid, textspeed, txtsleep, sound, pitchmin, pitchmax) 
{
    //global.typist = scribble_typist()
    global.typist.in(textspeed, 0)
    global.typist.sound_per_char(sound, pitchmin, pitchmax, "\n", 1)
    global.typist.character_delay_add(".", txtsleep)
    global.typist.character_delay_add(",", txtsleep)
    global.typist.character_delay_add("!", txtsleep)
    global.typist.character_delay_add("?", txtsleep)

    //actually draw the text

    scribble(stringid).draw(txtx, txty, global.typist)
}

But what's weird is that the text still has the issues and for whatever reason is a lot more chaotic! I'm not sure what I did wrong, but it doesn't look too good! And from what I've seen with my font and everything there, it is still making sounds for the formatting things in the text. And yes, it is the same string and getting referenced from the same thing that I mentioned before.

This video shows what's going on: https://github.com/user-attachments/assets/6bddada9-4382-42f5-93ed-e375dd746807

Hopefully I understood what you told me to do, and hopefully we can get this all figured out soon! Thank you for your help!

JujuAdams commented 1 month ago

Please refer to the typist example: https://github.com/JujuAdams/Scribble/tree/master/objects/obj_example_big_textbox

You should avoid calling methods on a typist every frame, and especially functions that set up behaviour like .character_add(). You should be creating new typists as needed and not reusing the same global typist over and over.

JujuAdams commented 1 week ago

Closing due to inactivity.