Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warning: delta is never used in function process #21186

Closed
LinuxUserGD opened this issue Aug 19, 2018 · 9 comments
Closed

warning: delta is never used in function process #21186

LinuxUserGD opened this issue Aug 19, 2018 · 9 comments
Assignees
Milestone

Comments

@LinuxUserGD
Copy link
Contributor

LinuxUserGD commented Aug 19, 2018

Godot version:
master (5d09877)

related issue: #21180

OS/device including version:
Linux

Issue description:
Do I have to ignore this warning or can I replace delta with another String that doesn't trigger the warning?

Steps to reproduce:

func _process(delta):
   pass
@rcorre
Copy link
Contributor

rcorre commented Aug 19, 2018

pylint will not complain about unused variables starting with _. Should godot do the same?

[rcorre@desktop-arch tmp]$ echo -e 'def forp(thing):\n    return 1' > test.py
[rcorre@desktop-arch tmp]$ pylint test.py -d missing-docstring
************* Module test
test.py:1:9: W0613: Unused argument 'thing' (unused-argument)

--------------------------------------------------------------------
Your code has been rated at 5.00/10 (previous run: -5.00/10, +10.00)

[rcorre@desktop-arch tmp]$ echo -e 'def forp(_thing):\n    return 1' > test.py
[rcorre@desktop-arch tmp]$ pylint test.py -d missing-docstring

-------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 5.00/10, +5.00)

It also respects dummy and _, though I prefer _delta as it is obvious what the variable is if it is needed in the future.

@akien-mga
Copy link
Member

See #19993 (comment)

@vnen
Copy link
Member

vnen commented Aug 19, 2018

I'll add the underscore prefix convention to ignore the unused variable.

@aaronfranke
Copy link
Member

aaronfranke commented Aug 20, 2018

@vnen Also do this for functions with names starting with underscores, so that default Godot functions like _process() don't have to be changed (and delta looks cleaner than _delta IMO).

@vnen
Copy link
Member

vnen commented Aug 20, 2018

@aaronfranke No because then there's no way to opt-in for this type warning. You can change argument names at will, but the names of those virtual functions are forced. Also _delta might not look clean, but if you're actually using the argument then you don't need the underscore.

@akien-mga akien-mga added this to the 3.1 milestone Aug 22, 2018
@LinuxUserGD
Copy link
Contributor Author

LinuxUserGD commented Aug 22, 2018

I still get this warning:

The argument 'delta' is never used in the function '_process'.
----------

@aaronfranke
Copy link
Member

aaronfranke commented Aug 22, 2018

Change your code to this:

func _process(_delta):

We might wish to make this the default for the template for new scripts.

@ghost
Copy link

ghost commented Mar 11, 2020

now my godot just crashes the game window and doesnt even give any errors what should i do

edit: here is my code


extends Sprite

func _ready():
	pass

func _process(_delta):
	if Input.is_key_pressed(KEY_W):
		self.position.y-= 1
	if Input.is_key_pressed(KEY_S):
               self.position.y+= 1

@LinuxUserGD
Copy link
Contributor Author

@Coder6969696
Which Godot version?
Does it also crash if just delta is used?
If it's latest master, it could crash because of using self directly. Better open a new issue with add a minimal reproduction project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants