This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes
var paths = []
const path_dir="res://Paths"

func _ready():

func random_path():
    return paths[randi()% paths.size()]

func loadPaths():
    var dir =
    var files =dir.get_next()

    while files!="":
        var path = load(path_dir+ files)
        if path && caminho is Curve2D:  
        file =dir.get_next()

What I'm doing wrong?

in Engine by (15 points)

2 Answers

+1 vote
Best answer

If the error is pointing at return paths[randi()% paths.size()], the problem is that you are trying to modulo paths.size() which is zero.

If you're using 3.0.2, there was a problem with the operators reported by that error. I reported it here: It's been fixed in the latest master and will be correct in 3.0.3.

by (346 points)
selected by
+1 vote

I am not familiar with your code but shouldn't it be files rather than file in the second last line i.e files = dir.get_next()

by (116 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 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.