Problem with tables

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
DB
Prole
Posts: 3
Joined: Wed Oct 31, 2012 1:40 pm

Problem with tables

Post by DB »

Hey guys,

I got a small problem with retrieving information out of a 2d table, anyone mind giving me a hand? Basically what I'm trying to do is retrieve information out of a table for cutting up my spritesheet with quads.

Code:


Code: Select all

local tilequads=
{
	{40,0},
	{40,0},
	{80,0}
}

for i = 1, #tilequads do
		local info = #tilequads[i]
		--print(info[1])
		--tile[i] = love.graphics.newQuad(info[1], info[2], Grid.tilewidth, Grid.tileheight, tilesetW, tilesetH)
end
The solution to my problem probably is very easy but some help would be appreciated :) Thanks in advance.
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: Problem with tables

Post by micha »

Just remove the #-sign before tilequads. In your version "info" will be the number 2 (length of the entries) and not the content of your table.

Should work like this:

Code: Select all

for i = 1, #tilequads do
      local info = tilequads[i]
      --print(info[1])
      --tile[i] = love.graphics.newQuad(info[1], info[2], Grid.tilewidth, Grid.tileheight, tilesetW, tilesetH)
end
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests