Can't get love frames 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
guassmith
Prole
Posts: 5
Joined: Sat Oct 11, 2014 3:42 pm

Can't get love frames to work

Post 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.
Attachments
button.love
The love file for what i'm doing
(2.95 MiB) Downloaded 242 times
User avatar
artofwork
Citizen
Posts: 91
Joined: Mon Sep 15, 2014 1:17 am
Location: East Coast USA

Re: Can't get love frames to work

Post 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.
User avatar
Nikolai Resokav
Party member
Posts: 140
Joined: Wed Apr 28, 2010 12:51 am
Location: United States

Re: Can't get love frames to work

Post 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.
guassmith
Prole
Posts: 5
Joined: Sat Oct 11, 2014 3:42 pm

Re: Can't get love frames to work

Post 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.
User avatar
Dattorz
Citizen
Posts: 66
Joined: Sat Oct 27, 2012 12:32 am
Contact:

Re: Can't get love frames to work

Post 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.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 2 guests