For loop isn't working

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By JulioYagami

It isn’t working and I don’t know why…

func rand_layer(from, to):
	for y in range(to.y - from.y):
		for x in range(to.x - from.x):
			var t = (simplex.get_noise_2d(x, y) * randi()%2+1) + 1
			tile.set_cellv(Vector2(x, y), t)
	layer += 1

What is the purpose of the layer += 1 at the end there?

xofox | 2019-09-10 17:30

It is part of the random generation logic so it can be ignored.

JulioYagami | 2019-09-10 18:18

:bust_in_silhouette: Reply From: JulioYagami

I found a solution: just replace for this code:

for y in range(to.y, from.y + 1):
		for x in range(from.x, to.x + 1):
            # Do what it should do

Ahh yeah I see that now. NJ.

xofox | 2019-09-10 18:56