help

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
elijahsomeone
Prole
Posts: 1
Joined: Thu Aug 24, 2017 12:19 pm

help

Post by elijahsomeone »

Hey, in a lot of other peoples code I see things like :new() :create(), :update() and much more. What exactly are these? I'm not very smart so i'll need a really good example. While you're hear I also need a good explanation of metatables I done really get them, thanks in advance!
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: What are these things for and what are metatables?

Post by grump »

Those are function calls. Try to read the Lua documentation. You first need to understand the very basics like functions and how to call them before you can understand metatables.

By the way, "help" is the worst and laziest title you can choose for your questions. Don't do that.
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: help

Post by zorg »

Also, apart from "don't do that", what you -should- do is edit your post to change the title.

The colon (:) notation is similar to the dot (.) notation, but there's an extra implicit parameter added (whether or not we're talking about function definition or calls), basically, it's syntax sugar and you don't even need to use it. I had a nifty post on here that explained all this in a very compact way, but i can't be bothered to search for it.

Explaining metatables in so many words is hard, as others may also say, it's probably one of the "hardest" topics in lua. A very basic explanation could be this: lua metatables modify how lua works "behind the scenes" when you work with "normal" tables that have a metatable defined on them.

It can have many effects, it can override how arithmetic works, how indexing works, how it should behave if you try to index a missing element, and so on; the lua documentation lists all the metamethods you can use.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Post Reply

Who is online

Users browsing this forum: Google [Bot], Semrush [Bot] and 1 guest