Does love.graphics.line take in vectors (tables) as parameters? Can't get it to work.

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
sakvojaz
Prole
Posts: 4
Joined: Sun Mar 12, 2017 10:59 am

Does love.graphics.line take in vectors (tables) as parameters? Can't get it to work.

Post by sakvojaz »

Getting this error: Image

Script:

Code: Select all

vector = require('vrld-hump-22d0fb6/vector')

function love.load()
	list = {}
	root = branchCreate(startp, endp)

	for i = 1, 5 do
		list[i] = root
	end
end

function love.update(dt)

end

function love.draw()
	love.graphics.translate(love.graphics.getWidth()/2, love.graphics.getHeight())
	for i = 1, 1 do
		list[i] = branch.draw(startp, endp)
		list[i] = branch.grow()
	end
end

function branchCreate()
	branch = {}
	branch.draw = function()
			startp = vector.new(0, 0)
			endp = vector.new(0, -100)
			love.graphics.line(startp, endp)
	end
	branch.grow = function()
	end
end
User avatar
airstruck
Party member
Posts: 650
Joined: Thu Jun 04, 2015 7:11 pm
Location: Not being time thief.

Re: Does love.graphics.line take in vectors (tables) as parameters? Can't get it to work.

Post by airstruck »

I don't think it works like that. As far as I know all vertices need to be in a single table, with sequential indices.
User avatar
Sir_Silver
Party member
Posts: 286
Joined: Mon Aug 22, 2016 2:25 pm
Contact:

Re: Does love.graphics.line take in vectors (tables) as parameters? Can't get it to work.

Post by Sir_Silver »

https://love2d.org/wiki/love.graphics.line

Supply your vertices as individual arguments passed to the function or as a numerically indexed table.

It does not take a vector, pass your x and y values instead.
sakvojaz
Prole
Posts: 4
Joined: Sun Mar 12, 2017 10:59 am

Re: Does love.graphics.line take in vectors (tables) as parameters? Can't get it to work.

Post by sakvojaz »

Ahh, got it. Thanks.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 90 guests