Page 1 of 1

Creating Matrices with a Loop

Posted: Wed May 16, 2012 3:31 am
by Nickmaster24
I've done it before, just not with Love. What is wrong with my code?

Code: Select all

function love.load()
Tiles = {}

	for i = 1, XWindow/10 do
		for q = 1, YWindow/10 do
			Tiles[i][q][1] = math.random(1, 255-i)
			Tiles[i][q][2] = math.random(1, 255-q)
			Tiles[i][q][3] = math.random(1, 255-q/i)
		end
	end
	
end
It keeps telling me to stop indexing nil values, smh.... :x

Re: Creating Matrices with a Loop

Posted: Wed May 16, 2012 7:08 am
by bartbes
You should set Tiles and Tiles[q] to tables too.

Re: Creating Matrices with a Loop

Posted: Wed May 16, 2012 1:48 pm
by Nickmaster24
Thank you; I'll try that.