What am I doing wrong here?

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.
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: What am I doing wrong here?

Post by Jasoco »

Yeah, I played around with it and came up with something. It's odd, but now it works how I need it to. I want my Adventure engine to have as good of a drag and drop object/actor library as it can get.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: What am I doing wrong here?

Post by bartbes »

Really looking forward to it.
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: What am I doing wrong here?

Post by Jasoco »

Now you're putting too much pressure on me. :o What if I fail!!!!!???? OH NOES!!

Nah, I won't.
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: What am I doing wrong here?

Post by BlackBulletIV »

Jasoco wrote:Here's a question.

How's come I can do this:

Code: Select all

enemySet.goomba = {}

function enemySet.goomba:setup(v)
  ...
end
But I can't do this:

Code: Select all

enemySet["goomba"] = {}

function enemySet["goomba"]:setup(v)
  ...
end
Yeah, I've come across that many times; Lua syntax doesn't allow it for some reason.
User avatar
miko
Party member
Posts: 410
Joined: Fri Nov 26, 2010 2:25 pm
Location: PL

Re: What am I doing wrong here?

Post by miko »

Jasoco wrote:Here's a question.

How's come I can do this:

Code: Select all

enemySet.goomba = {}

function enemySet.goomba:setup(v)
  ...
end
But I can't do this:

Code: Select all

enemySet["goomba"] = {}

function enemySet["goomba"]:setup(v)
  ...
end
Lua is about speed. I think the parser could be changed to support this type of grammar, but it wouldn't bring any benefit (you could use alternative ways), and it would slow down the parsing phase.

You could try this:

Code: Select all

enemySet["goomba"] = {}

enemySet["goomba"].setup=function(self, v)
  ...
end
My lovely code lives at GitHub: http://github.com/miko/Love2d-samples
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: What am I doing wrong here?

Post by Robin »

I think it is because the function blah () ... end form uses an identifier rather than an expression. a.b and a:b are simply special cases. Like miko said, that way it is probably faster.
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: What am I doing wrong here?

Post by BlackBulletIV »

Robin wrote:I think it is because the function blah () ... end form uses an identifier rather than an expression. a.b and a:b are simply special cases. Like miko said, that way it is probably faster.
Yeah I'd say that's it.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 5 guests