Topic was automatically imported from the old Question2Answer platform.
Asked By
peterhoglund
I have lots of loops where I want to do the same task several times but not iterate through a data set. For example to spawn x amount of something, I do:
var amount
for i in range(amount):
var scene = packedScene.instance()
add_child(scene)
I do this quite often. Now, this leaves me with many warnings saying “Local variable i is declared but never used”. My warnings are stacking up are getting cluttered with these warnings I can’t really do anything about.
What would be the best way to avoid this? Would love for gdscript to have something like:
for _i in range(amount):
var scene = packedScene.instance()
add_child(scene)
Thank you, I did not know that! That also solved all my “The argument ‘xxxx’ is never used in the function…”-warnings. Do you also know how to solve the warning “The function ‘connect()’ returns a value, but the value is never used”, if you don’t want to use the value?
peterhoglund | 2020-07-30 21:36
extends Object
class_name Utility
# for connect and int warnings
static func ok(e: int) -> void:
if e != OK:
print_debug("Error: %s" % e)
# for tween and bool warnings - to be removed in 4
static func stfu(_ignore) -> void: pass