for sure its a silly question but i just need to understand this:
whats the difference from . to : in programming or at least in love 2d?
love.load
menu:load
one its under love but than in menu we got two?
how does it works?
difference is???
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: difference is???
It depends on how the module is made.
Most libraries and modules use the ':' for module functions and '.' for the variables, since they stem from classes.
Yes, you may say that love.load is not a variable but a function, it stems from the LÖVE engine (i think).
It all then depends on you making the library, but the "':' for module functions and '.' for the variables" thing is more cleaner and organized (that's my opinion, which will be disputed eventually by someone who is more experienced than I am).
It may also be from Lua. You can search that on the internets too.
Most libraries and modules use the ':' for module functions and '.' for the variables, since they stem from classes.
Yes, you may say that love.load is not a variable but a function, it stems from the LÖVE engine (i think).
It all then depends on you making the library, but the "':' for module functions and '.' for the variables" thing is more cleaner and organized (that's my opinion, which will be disputed eventually by someone who is more experienced than I am).
It may also be from Lua. You can search that on the internets too.
~ CRxTRDude || Will be out of touch for a wee longer than expected. Will keep in touch with soon enough. Sorry bout that.
Re: difference is???
are most program languages use . and : in the same way like love2d????
also you said LIBRARY..
can you tell me whats a LIBRARY exactly in programming? and in a library . is use more or : ????
also you said LIBRARY..
can you tell me whats a LIBRARY exactly in programming? and in a library . is use more or : ????
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: difference is???
Okay, it is very simple: if you see function a:b(c), it is the same as function a.b(self, c). If you see a:b(c) it is the same as a.b(a, c).
Since there is only the global love table, love.load doesn't need to get that table passed in as its first argument.
Libraries are collections of code that don't do anything of themselves, but are used in another program. For example, LÖVE uses PhysFS to provide love.filesystem, Freetype to handle fonts, SDL to handle windows and stuff, and OpenGL for the actual drawing of things. Your game can use libraries too, those are generally written in Lua.
Since there is only the global love table, love.load doesn't need to get that table passed in as its first argument.
Libraries are collections of code that don't do anything of themselves, but are used in another program. For example, LÖVE uses PhysFS to provide love.filesystem, Freetype to handle fonts, SDL to handle windows and stuff, and OpenGL for the actual drawing of things. Your game can use libraries too, those are generally written in Lua.
Help us help you: attach a .love.
Re: difference is???
A library is basically some (3-rd party) code that you include in your project.pielago wrote:also you said LIBRARY..
can you tell me whats a LIBRARY exactly in programming?
In Lua, these are sometimes called "modules" or "packages".
Typically the "." operator means change in "scope".pielago wrote:are most program languages use . and : in the same way like love2d????
So when you write: a.b You are saying "access variable b from scope a"
The ":" operator means a function call.
Like robin said a:c() is the same as a.c(a)
The ":" operator is basically syntactic sugar when working with "objects".
It basically passes the object reference(a) as the first parameter to the function(c).
Re: difference is???
ohh cool thanks..
so for library i can make one as well right???? to use it in the future?
so for library i can make one as well right???? to use it in the future?
Re: difference is???
Well, you could. It's more organized to separate code that can be redundant to the entire game (eg. collisions, manipulation of stuff). There are many people who made such libraries for specific tasks that anyone can use and, with enough experience, you can as well.pielago wrote:ohh cool thanks..
so for library i can make one as well right???? to use it in the future?
Heck, I've been using other libraries for the thing I'm making right now, but if I see something to my liking (like attack calculations) and I can code something like that, I could make a library for those such calculations.
Objects are like libraries as well, only specific to your game. That can include your player and some obstacles.
(BTW, sorry that my other post seems confusing to you. I'll try to make it a little more easy for the eyes next time.)
~ CRxTRDude || Will be out of touch for a wee longer than expected. Will keep in touch with soon enough. Sorry bout that.
Who is online
Users browsing this forum: No registered users and 4 guests