How to output a different value?
Asked Answered
E

6

0

Example: I have created a clicker game and I want the values of "1000" to be output as "1k".

Ender answered 30/12, 2023 at 18:17 Comment(0)
T
0

str(x / 1000) + "k"

Tungus answered 30/12, 2023 at 18:51 Comment(0)
E
0

Tungus Parse Error: Identifier "x" not declared in the current scope.

Ender answered 30/12, 2023 at 20:16 Comment(0)
T
0

How much coding experience do you have?

Tungus answered 30/12, 2023 at 20:17 Comment(0)
E
0

Tungus

 extends Node2D

var points = 0

func _ready():
	$Label.text = str(points)
	

func _on_texture_button_pressed():
	points+= 1
	$Label.text =  str(points)
Ender answered 30/12, 2023 at 20:18 Comment(0)
E
0

Tungus Very very small

Ender answered 30/12, 2023 at 20:19 Comment(0)
T
0

Replace:
str(points)
with:
str(points / 1000) + "k"

Tungus answered 30/12, 2023 at 20:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.