|
| 09 Feb 2015 09:42 AM |
| What are they and how are they used? |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 09 Feb 2015 09:46 AM |
Constructors are those things like Instance.new, or Vector3.new
You don't really have to worry about the whole 'constructors' idea until you start working with C and similar languages. |
|
|
| Report Abuse |
|
|
|
| 09 Feb 2015 09:48 AM |
I see, it's just that I remember them from this guy's Java tutorials and I didn't understand them.
|
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 09 Feb 2015 09:49 AM |
| They're an OOP concept, and you'll get them a lot on C#, Java, and similarly built OOP related languages. |
|
|
| Report Abuse |
|
|
| |
|
LucasLua
|
  |
| Joined: 18 Jun 2008 |
| Total Posts: 7386 |
|
|
| 09 Feb 2015 09:53 AM |
In Java constructors are used to make objects from classes. Constructors set instance variables based on input.
In Lua you can create a similar concept using tables and metamethods but unless you are dead set on using it constantly you'll wind up switching back to the procedural paradigm. Check out the "MiddleClass" git on github by kikito to set up Object Oriented Lua.
OO Lua comes in handy when using LOVE2D but not Roblox because of Roblox already having objects made for you. |
|
|
| Report Abuse |
|
|
|
| 09 Feb 2015 09:59 AM |
| You could think of it similar to the Main method. Except rather than an overall program starting point, it's a class's starting point. You use constructor methods to set up variables (if any) and call additional methods (if needed). |
|
|
| Report Abuse |
|
|