This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
–1 vote

This is the code I have:
$"/root/World/UI/InteractionInfoLabel".text = getcollider().getname()

It's under an interaction script and basicly sets text in the screen to the name of the thing at the end of interaction raycast. It works with single object like Shotgun it works but with things that has multiple of them like ammo boxes engine automaticly gives that node a number like Ammo Box1 or Ammo Box 2 and in label it shows that number. I wanna remove it

Godot version 3.3
in Engine by (81 points)

2 Answers

+1 vote

Unless you know in advance the length of the string you need to display (in that case you can use left() or right() method to remove the numbers), i guess you have to use something else to show it
eg use a custom "type" variable: print(raycast_collision_result.type) or using the class name of the node print(raycast_collision_result.get_class()) .

by (1,514 points)
+1 vote

I believe the string rstrip function coul help here.

$"/root/World/UI/InteractionInfoLabel".text = getcollider().getname().rstrip("0123456789")

by (244 points)

works like a charm
IntcText.text = IntcText.text.rstrip("0123456789")

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 Frequently asked questions and 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 [email protected] with your username.