0 votes

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.

Godot version v.3.2.3 stable
in Engine by (29 points)

1 Answer

0 votes

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().

by (1,312 points)

Thank you https://godotengine.org/qa/user/AlexTheRegent.
These lines are in my script
print(jeuId, " Nous jouons au Pendu ******** ", getstack())
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

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.