Page 1 of 1

Can't get love frames to work

Posted: Mon Nov 10, 2014 11:46 pm
by guassmith
So i'm attempting to use loveframes to make a button, however no matter what I do, if there is a button on the screen and I have loaded an image in, whenever I hover over the button the window just closes. I use ZeroBrane Studio and the console from there gives me this error after the crash:

Code: Select all

Error: libraries/loveframes/objects/base.lua:790: attempt to call field 'insert' (a nil value)
stack traceback:
	libraries/loveframes/objects/base.lua:790: in function 'CheckHover'
	libraries/loveframes/objects/button.lua:49: in function 'update'
	libraries/loveframes/objects/base.lua:45: in function 'update'
	libraries/loveframes/init.lua:204: in function 'update'
	main.lua:11: in function 'update'
	[string "boot.lua"]:434: in function <[string "boot.lua"]:399>
	[C]: in function 'xpcall'
Program completed in 1.25 seconds (pid: 4540).
I have no idea what i'm doing wrong, but it seems that the button only works if I don't load an image anywhere in my code. This also happens with every other object from loveframes.

Re: Can't get love frames to work

Posted: Tue Nov 11, 2014 1:16 pm
by artofwork
I tried it out and it opened up and then crashed, then i went into the main.lua file and changed table to tables on both lines 5 & 16 after that it ran without error.

Other than that there is no code to do anything else, those errors might be from you using a different version of love because i didn't get any of those errors listed.

Re: Can't get love frames to work

Posted: Wed Nov 12, 2014 4:46 am
by Nikolai Resokav
On line 5 in main.lua you have:

Code: Select all

table = love.graphics.newImage("resources/images/table.png")
That line of code replaces Lua's built-in table library with your image. Love Frames needs the table library to function correctly, so you should replace that line with something like:

Code: Select all

tableimg = love.graphics.newImage("resources/images/table.png")
That should fix the problem.

Re: Can't get love frames to work

Posted: Thu Nov 13, 2014 9:27 pm
by guassmith
Nikolai Resokav wrote:On line 5 in main.lua you have:

Code: Select all

table = love.graphics.newImage("resources/images/table.png")
That line of code replaces Lua's built-in table library with your image. Love Frames needs the table library to function correctly, so you should replace that line with something like:

Code: Select all

tableimg = love.graphics.newImage("resources/images/table.png")
That should fix the problem.
Thank you, table was a normal color for me for some reason so I didn't realize.

Re: Can't get love frames to work

Posted: Thu Nov 13, 2014 10:22 pm
by Dattorz
Another fix would be to make the variable local by adding "local table" at the top of the file. This will tell Lua that you are referring to a variable that exists only in that file, and that it's a different one from Lua's built-in "table".

Of course, this will cause conflicts if you want to use Lua's table library in that file. Personally I'd suggest both changing the variable name and making it local, as keeping variables local where possible is considered good practice.