I want to identify the line number in a godot script, similar too PHP code __LINE_ and __FILE__

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

Line reference: Is there a possibility of identifying the line number in a godot script, similar too PHP code _LINE and FILE
ex: print(jeuId, " Nous jouons au Pendu sql.gd l. 80)
This is what I do to identify my print statement .
Every time I do change my code, I change the line number for ‘debug’ purpose.

:bust_in_silhouette: Reply From: AlexTheRegent

Yes, it is possible to identify the line number in a godot script. You can use print_stack() function to print current stack or get it as array using get_stack().

Thank you User AlexTheRegent - Godot Engine - Q&A.
These lines are in my script
print(jeuId, " Nous jouons au Pendu ******** ", get_stack())
print(dernierJoueur, " Dernier joueur en filière ******** ", get_stack())
print(dernierNiveau, " Dernier niveau en filière ******** ", get_stack())

This is the answer I have.
1 Nous jouons au Pendu ******** [{function:_ready, line:80, source:res://scripts/sql.gd}]
0 Dernier joueur en filière ******** [{function:_ready, line:81, source:res://scripts/sql.gd}]
10 Dernier niveau en filière ******** [{function:_ready, line:82, source:res://scripts/sql.gd}]

It is working fine, you save me a lot of work.
Merci Michel Bélair, Montréal, Canada

mabelair88 | 2021-10-05 01:15