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 » Wed Apr 05, 2017 6:27 pm

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 » Wed Apr 05, 2017 6:36 pm

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 » Wed Apr 05, 2017 7:07 pm

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 » Wed Apr 05, 2017 7:19 pm

Ahh, got it. Thanks.

Post Reply

Who is online

Users browsing this forum: No registered users and 62 guests