UDizzle
|
  |
| Joined: 21 Nov 2015 |
| Total Posts: 24 |
|
|
| 26 Nov 2015 09:26 PM |
| some uses so I can practice? |
|
|
| Report Abuse |
|
|
| |
|
|
| 26 Nov 2015 09:30 PM |
| Open a piece of code then smash your face into the keyboard. Then bam! You learn it. (Yes this is off that ad) |
|
|
| Report Abuse |
|
|
|
| 26 Nov 2015 09:32 PM |
OOP makes things easier if you're running a large scale project.
I don't know, make a player wrapper or something that presents the hierarchy in a less complicated way (especially with the character). |
|
|
| Report Abuse |
|
|
|
| 26 Nov 2015 10:16 PM |
Whats OOP
Instance.new("BodyVelocity",SenseiWarrior).velocity = CFrame.new(SenseiWarrior.Torso.Position,YourGirlsDMs.Position).lookVector * 10 |
|
|
| Report Abuse |
|
|
|
| 26 Nov 2015 11:43 PM |
Here's a few from a game I'm making:
> Tween local tween = Tween.new(1, "InOutQuad", function(ratio) ... end) tween:Run() tween.Finish:wait()
> Snowball local snowball = Snowball.new(player) snowball:Throw()
> ListenerList local listeners = ListenerList.new() listeners:Connect(button.MouseButton1Click, function() ... end) listeners:Connect(part.Touched, function(part) ... end) listeners:DisconnectAll()
As you can see, creating Objects for your game allows you to encapsulate a lot of game logic into nice modules. For instance, with my Snowball object, all I have to do is create a Snowball object and then call Throw. Behind the scenes, the Snowball object does a lot of work to accomplish what needs to happen.
Proper OOP in Lua also saves you memory. With the uses of metatables, you can have hundreds of objects that use the same set of functions (not duplicates), but each method call can still refer to the correct object. For instance, in my game, I can have nearly 500 NPCs roaming around. Instead of having 500 duplicates of functions/methods, they all share the same set of methods. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 26 Nov 2015 11:48 PM |
Almost everything you do that is Roblox-related is OOP. part.BrickColor (inheritance) = blah part:Destroy() (again) |
|
|
| Report Abuse |
|
|
UDizzle
|
  |
| Joined: 21 Nov 2015 |
| Total Posts: 24 |
|
|
| 26 Nov 2015 11:49 PM |
@crazyman32
that's awesome, thanks for the information
after learning how to set up basic OOP and some concepts around it, the next step for me would be to apply it to my own scripting, and your response definitely helped me understand more about the uses for OOP and how i can apply it to my own games. |
|
|
| Report Abuse |
|
|