0 votes

Hello!
Sorry if this is a bad question, but I can't figure it out.
I tried google ing it, but maybe my terminology was wrong, as I couldn't find any answers.

My problem is that one of the labels of a small test game I have created won't update on the HTML build version.
This is especially weird since I tried all methods of changing the label's value, and the label's script currently looks like this:

extends Label

func _process(delta):
    text = 'Highscore: ' + str(Globals.highscore)

I know that's maybe not the standard version of updating a label, but I can't figure out what the problem is, since it works just fine in the version of the game that I run in the engine, but when I go to export it, the HTML version won't update the highscore label.

For more information that might be related to my issue, the highscore is updated every time the score exceeds its value, and is saved in the Globals.gd script, which is a singleton (I also use it to display the score, which works just fine in the build). This is the script snippet I use to update the highscore:

Globals.score += 1
if Globals.score > Globals.highscore:
    Globals.highscore = Globals.score

Thank you in advance for any help that you might want to offer, and sorry for the long post, I just wanted to explain my problem as well as possible. Have a great day!

Godot version v3.2.2.stable.official
in Engine by (12 points)

Why do it on the _process function instead of emitting a signal each time the score value changes?

You can post it as an answer, because using signals seems to fix the issue.
I did this because I wanted to complete a project from start to finish, this being my first one mainly to see how the exporting process is in godot. I was basically too lazy to learn how to create a signal for a variable change, but this morning I did that and it worked.
Still don't know what the original issue was caused by, but using signlas seems to work perfectly.
Thanks a lot!
(You can post this as an answer and I'll give you best answer if it helps you)

It's all good, Internet points are worthless anyways, glad to hear it worked!
Signals are a great bit of functionality that I don't know if I'm gonna be able to work with if I ever migrate from Godot.

1 Answer

0 votes

Não sei exatamente a causa do seu problema, se é um erro seu ou da engine. Mas vc pode mudar o modo de verificação do highscore, por exemplo.
vc pode adicionar um nó Timer para verificar se a pontuação é maior q o highscore toda vez q for emitido o signal timeout. ponha um wait time pequeno, para funcionar como um func _process provisório

by (18 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 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 webmaster@godotengine.org with your username.