0 votes

https://godotengine.org/qa/105314/how-to-instance-for-every-count-of-an-element-inside-an-array this is the same i don't know what happened...
This is how I make the arrays, I don't know where i'm wrong

var elements = [1,2,3]
var contain_elements = []

func _physics_process(delta):
    _check_elements()

func _spawn_aqua_elements():
    for i in contain_elements:
        i = elements[1]
        var aquabo = contain_elements.count(i)
        if aquabo == 0:
            continue
            for x in range(aquabo):
                var aqua = preload("res://Entities/Player/Scenes/THREE/Aqua.tscn").instance()
                self.get_node("Elements").add_child(aqua)
                aqua.transform = get_parent().global_transform


if Input.is_action_just_pressed("aqua"): #WATER
    contain_elements.insert(contain_elements.size() , 2)

func _check_elements():
    if contain_elements.size() > 3:
        contain_elements.pop_front()
in Engine by (46 points)

1 Answer

0 votes

https://docs.godotengine.org/en/stable/getting_started/scripting/gdscript/gdscript_basics.html#language

The continue keyword will skip to the next iteration of the for loop. That means that the inner for loop will never run. I think you have it indented one tab too much.

by (7,336 points)
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.