Nealz
|
  |
| Joined: 29 Nov 2008 |
| Total Posts: 126 |
|
|
| 10 Apr 2012 11:31 AM |
I'm reading the wiki on metatables, they look helpful but I don't see why they would be needed, and why you would need to move to OOP.
Does anyone have aany examples of use? |
|
|
| Report Abuse |
|
|
Nealz
|
  |
| Joined: 29 Nov 2008 |
| Total Posts: 126 |
|
|
| 10 Apr 2012 11:36 AM |
| I Forgot to mention, I'm Gergy008 on a friends account. I'm banned you see for stupid reasons. Just so you guys know ;3 |
|
|
| Report Abuse |
|
|
lah30303
|
  |
| Joined: 15 Feb 2008 |
| Total Posts: 10027 |
|
|
| 10 Apr 2012 12:16 PM |
| I think xLEGOx used them to create an editable class system on ROBLOX or something like that. I don't really know much about them, so I'm not very sure. |
|
|
| Report Abuse |
|
|
Oysi
|
  |
| Joined: 06 Jul 2009 |
| Total Posts: 9058 |
|
| |
|
|
| 10 Apr 2012 02:00 PM |
| OOP makes everything SO MUCH EASIER |
|
|
| Report Abuse |
|
|
nightname
|
  |
| Joined: 10 Jun 2008 |
| Total Posts: 8960 |
|
|
| 10 Apr 2012 02:09 PM |
| Object Oriented Programming simplifies game programming amazingly. By treating different things as objects, you can easily handle their properties. |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2012 02:13 PM |
| You don't _NEED_ to use metatables, but they can make scripting easier. |
|
|
| Report Abuse |
|
|
Nealz
|
  |
| Joined: 29 Nov 2008 |
| Total Posts: 126 |
|
|
| 10 Apr 2012 02:34 PM |
| What could I treat as an object, and how could I learn more about them? I always love making my scripting easier but it looks awfully confusing. |
|
|
| Report Abuse |
|
|
Tenal
|
  |
| Joined: 15 May 2011 |
| Total Posts: 18684 |
|
|
| 10 Apr 2012 02:36 PM |
In RBX.Lua, nothing. There's really no point to them. Most alternatives of metatables are much more simpler to read and understand. |
|
|
| Report Abuse |
|
|
gergy008
|
  |
| Joined: 16 Mar 2008 |
| Total Posts: 7039 |
|
| |
|
gergy008
|
  |
| Joined: 16 Mar 2008 |
| Total Posts: 7039 |
|
|
| 10 Apr 2012 02:38 PM |
| Tenal, it makes my scripts look more sophisticated and I'd love to know how to use them just for the fun of it. |
|
|
| Report Abuse |
|
|
Oysi
|
  |
| Joined: 06 Jul 2009 |
| Total Posts: 9058 |
|
| |
|
Tenal
|
  |
| Joined: 15 May 2011 |
| Total Posts: 18684 |
|
|
| 10 Apr 2012 02:47 PM |
| Around a year back I created an alternative to the __add metamethod. It was much simpler, too. |
|
|
| Report Abuse |
|
|
Tenal
|
  |
| Joined: 15 May 2011 |
| Total Posts: 18684 |
|
|
| 10 Apr 2012 02:48 PM |
@gergy Oh, I personally try to make my scripts simple, but the outcome very complex and intricate. |
|
|
| Report Abuse |
|
|
Oysi
|
  |
| Joined: 06 Jul 2009 |
| Total Posts: 9058 |
|
| |
|
|
| 10 Apr 2012 03:18 PM |
tenal if you can't see any point you don't truly know lua
I thought I did a year or so ago but I too saw no point in metatables. Now I do. |
|
|
| Report Abuse |
|
|
Jaccob
|
  |
| Joined: 19 Oct 2008 |
| Total Posts: 986 |
|
|
| 10 Apr 2012 05:03 PM |
Tenal calls me a exploiter.. for whatever reason. I join a game, and I'm exploiting some how.. (by Tenal standards)
From what I can tell.. from past forum posts and this one she doesn't seem very advanced ^_^ |
|
|
| Report Abuse |
|
|
Oysi
|
  |
| Joined: 06 Jul 2009 |
| Total Posts: 9058 |
|
| |
|
jode6543
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 5363 |
|
|
| 10 Apr 2012 05:40 PM |
Example usage:
Vector3.new(1,1,1) + Vector3.new(1,1,1) == Vector3.new(2,2,2)
Rather than:
local vectorA = Vector3.new(1,1,1) local vectorB = Vector3.new(1,1,1) local addedVector = Vector3.new(vectorA.x + vectorB.x, vectorA.y + vectorB.y, vectorA.z + vectorB.z)
Top example is cleaner and simpler thanks to metatables. |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2012 05:54 PM |
@jode
you forgot the equality check in the second example xD |
|
|
| Report Abuse |
|
|
MrNicNac
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 26567 |
|
|
| 10 Apr 2012 06:12 PM |
"tenal if you can't see any point you don't truly know lua"
I don't see the point of them in Roblox. |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2012 06:18 PM |
There's countless points of them, not as many in roblox, but they still exist.
Wrapping roblox's object system, to simplify stuff is only possible through metatables (Or a stupidly ugly hax implementation)
OOP is very usefull, not as much in roblox, but it's still VERY usefull.
State systems, as someone brought up a few days ago, are greatly simplified by polymorphism and OOP, and therefore that's another use.
Creating tables which can interact through metamethods for APIs/Libraries
I could list a couple more I'm just tired, it's like 00:18 according to my computer clock. I'm only staying up because of a darn browser game which I'm addicted to |
|
|
| Report Abuse |
|
|
Tenal
|
  |
| Joined: 15 May 2011 |
| Total Posts: 18684 |
|
|
| 10 Apr 2012 07:19 PM |
@trapping So, I have to see the point in metatables in order to know Lua? I really don't understand your logic anymore. |
|
|
| Report Abuse |
|
|
nightname
|
  |
| Joined: 10 Jun 2008 |
| Total Posts: 8960 |
|
|
| 10 Apr 2012 07:21 PM |
@Tenal
I showed you my code for the BigNum library. That had to have metatables, or it would not work. I rewrote how tables behaved, and turned them in pseudo-numbers.
|
|
|
| Report Abuse |
|
|
|
| 10 Apr 2012 07:43 PM |
Noone understands my logic
I didn't say to know lua at all, I'm more asserting that if you don't see the point you clearly don't fully understand lua as a whole. |
|
|
| Report Abuse |
|
|