is godot auto completion not work well? i extends richtextlabel in script.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By bgegg

i make timer with this tutorial.but , i can not show set_text() function by auto complete.

Of course i can understand if i look at the reference.
However, it is inconvenient that there is no code complete

:bust_in_silhouette: Reply From: Dlean Jeans

set_text is a setter. Setters and getters are hidden by default. To enable them enable Project > Debug > Gdscript > Autocomplete Setters and Getters (scroll to the bottom).

It’s better to just assign the text property which is autocompleted:

text = '%s:%s.%s' % [str(m).pad_zeros(2), str(s).pad_zeros(2), ms]

Btw, that would show the time as 00:00.0 instead of 0:0:0 like in the video

EDIT: Shorter alternative - click to run:

text = '%02d:%02d.%s' % [m, s, ms]

There’s a typo in the second method call, it should be s.pad_zeros(2) instead of s.pad_zero(2) :slight_smile:

Calinou | 2019-06-11 15:54

Oh yeah, thanks for the heads up!

Dlean Jeans | 2019-06-11 16:23

thanks i can show setter by it setting.
But the code you got gives me an error
What’s wrong?

extends RichTextLabel
var ms = 0
var s = 0
var m = 0

func _process(delta):
	if ms >9:
		s +=1
		ms = 0

	if s >59:
		m +=1
		s = 0


#	set_text(str(m) + ":" + str(s) + ":" + str(ms))
	text = '%s:%s.%s' % [m.pad_zero(2), s.pad_zero(2), 2]
func _on_Timer_timeout():
	ms += 1

bgegg | 2019-06-12 01:48

It’s pad_zeros with an s at the end. Just copy and paste the code in my answer.

Dlean Jeans | 2019-06-12 02:14

text = ‘%s:%s.%s’ % [m.pad_zeros(2), s.pad_zeros(2), ms]
thanks i paste this .but i get this error.
why i get this ?

invaild call nonexistend function pad_zeros in base int

bgegg | 2019-06-12 08:40

Oops, I didn’t really run the code. Try:

text = '%s:%s.%s' % [str(m).pad_zeros(2), str(s).pad_zeros(2), ms]

Dlean Jeans | 2019-06-12 08:55

Even shorter:

text = '%02d:%02d.%s' % [m, s, ms]

Click to test this

Dlean Jeans | 2019-06-12 08:59

thanks. this is work well

bgegg | 2019-06-12 09:45