syntax error when trying to use AnAL

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
Dr_shenanigans
Prole
Posts: 10
Joined: Wed Jan 05, 2011 11:18 pm

syntax error when trying to use AnAL

Post by Dr_shenanigans »

trying to recreate example 14 in AnALto be honest I don't know what I screwed up. it probably looks painfully obvious, but to me it's a spy hidden in the crowd >_<

Code: Select all

Error
Syntax Error: main.lua:10 '(' expected near "="

Traceback

[C]:?
[C]:in function 'require'
[C]:in function 'xpcall'
code

Code: Select all

-- Example: Create and use an Animation
--love.filesystem.load("AnAL.lua")()
require ("AnAL")


function love.load()
	-- Set a lovely pink background color.
	love.graphics.setBackgroundColor(246, 198, 222)
		
	function anim1 = newAnimation(anim-boogie.png, 24, 24, 0.1, 6)
			function animation:addFrame(0,0,31,30,3)end
			function animation:addFrame(33,0,31,30,3)end
			function animation:addFrame(65,0,31,30,3)end
			function animation:addFrame(0,34,31,30,3)end
			function animation:addFrame(34,34,31,30,3)end
			function animation:addFrame(64,34,31,30,3)end	
end

function love.update(dt)
	-- The animation must be updated so it 
	-- knows when to change frames.
	function anim1:update(dt)
end

function love.draw()
	-- Draw the animation the center of the screen.
	anim1:draw(400, 300, 0, 1, 1)
end
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: syntax error when trying to use AnAL

Post by Robin »

function. It's not supposed to be there.

Try changing this:

Code: Select all

   function anim1 = newAnimation(anim-boogie.png, 24, 24, 0.1, 6)
         function animation:addFrame(0,0,31,30,3)end
         function animation:addFrame(33,0,31,30,3)end
         function animation:addFrame(65,0,31,30,3)end
         function animation:addFrame(0,34,31,30,3)end
         function animation:addFrame(34,34,31,30,3)end
         function animation:addFrame(64,34,31,30,3)end   
to this:

Code: Select all

   anim1 = newAnimation("anim-boogie.png", 24, 24, 0.1, 6) -- also note, filename is a string, and needs " "
         animation:addFrame(0,0,31,30,3)
         animation:addFrame(33,0,31,30,3)
         animation:addFrame(65,0,31,30,3)
         animation:addFrame(0,34,31,30,3)
         animation:addFrame(34,34,31,30,3)
         animation:addFrame(64,34,31,30,3)   
There is a huge difference between defining functions and calling them.

EDIT: also remove the word "function" in love.update.
Help us help you: attach a .love.
Dr_shenanigans
Prole
Posts: 10
Joined: Wed Jan 05, 2011 11:18 pm

Re: syntax error when trying to use AnAL

Post by Dr_shenanigans »

changed, got a new error though

Code: Select all

Error

.\AnAL.lua50: attempt to call method 'getWidth' (a nil value)

Traceback

.\AnAl.lua:50:in function 'newAnimation'
main.lua:10 in function 'load'
[C]: in function 'xpcall'
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: syntax error when trying to use AnAL

Post by BlackBulletIV »

I don't know what your latest error is about, but where is the variable "animation" defined? Do you mean "anim1"?
Dr_shenanigans
Prole
Posts: 10
Joined: Wed Jan 05, 2011 11:18 pm

Re: syntax error when trying to use AnAL

Post by Dr_shenanigans »

BlackBulletIV wrote:I don't know what your latest error is about, but where is the variable "animation" defined? Do you mean "anim1"?
I was just going by the AnAL documentation (animation:addFrame (x, y, w, h, delay) ), I'm a complete and utter newb so I don't know what you can or can't do with coding in lua/love :(

changing the "animation" variables doesn't do anything to change the error.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: syntax error when trying to use AnAL

Post by Robin »

Dr_shenanigans wrote:I was just going by the AnAL documentation (animation:addFrame (x, y, w, h, delay) ), I'm a complete and utter newb so I don't know what you can or can't do with coding in lua/love :(
Ah, sorry, I wasn't paying attention.

You should replace "animation" by "anim1", because that is the animation object you defined (in the line anim1 = newAnimation("anim-boogie.png", 24, 24, 0.1, 6))

The documentation mentions "animation:addFrame()" because it is assumed you know that you should replace it with whatever name you're using.
Help us help you: attach a .love.
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: syntax error when trying to use AnAL

Post by BlackBulletIV »

Dr_shenanigans wrote:changing the "animation" variables doesn't do anything to change the error.
I wouldn't expect it to. Your current is occurring in the call to newAnimation somewhere (you might want to check out the source code of this library you're using). My suggestion was just preventing yet another error from occurring after you fix your current one.
Dr_shenanigans
Prole
Posts: 10
Joined: Wed Jan 05, 2011 11:18 pm

Re: syntax error when trying to use AnAL

Post by Dr_shenanigans »

BlackBulletIV wrote:
Dr_shenanigans wrote:changing the "animation" variables doesn't do anything to change the error.
I wouldn't expect it to. Your current is occurring in the call to newAnimation somewhere (you might want to check out the source code of this library you're using). My suggestion was just preventing yet another error from occurring after you fix your current one.
well shucks almighty, I guess I'm stuck then. :( I can't figure out the AnAL source.
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: syntax error when trying to use AnAL

Post by BlackBulletIV »

Well the problem is coming because of the fact that AnAL is trying to call a method that doesn't exist. This is probably because you're passing a wrong parameter type to the newAnimation() function. That's all I've got to offer for now.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests