Creating Matrices with a Loop

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
Nickmaster24
Prole
Posts: 27
Joined: Sun Jul 03, 2011 5:46 pm

Creating Matrices with a Loop

Post 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
TheNickmaster21
AKA nickmaster24
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Creating Matrices with a Loop

Post by bartbes »

You should set Tiles and Tiles[q] to tables too.
User avatar
Nickmaster24
Prole
Posts: 27
Joined: Sun Jul 03, 2011 5:46 pm

Re: Creating Matrices with a Loop

Post by Nickmaster24 »

Thank you; I'll try that.
TheNickmaster21
AKA nickmaster24
Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests