The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

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 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 (31 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,656 points)

Thank you
These lines are in my script
print(jeuId, " Nous jouons au Pendu ******** ", getstack())
print(dernierJoueur, " Dernier joueur en filière ******** ", get
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/}]
0 Dernier joueur en filière ******** [{function:
ready, line:81, source:res://scripts/}]
10 Dernier niveau en filière ******** [{function:_ready, line:82, source:res://scripts/}]

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