Introduction to Object-Oriented Programming with Lua

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 ธ.ค. 2024

ความคิดเห็น • 23

  • @Immow
    @Immow 3 ปีที่แล้ว +9

    Thank you, finally a visual representation of the interaction between these components that show us how they tie together!

  • @exe.m1dn1ght
    @exe.m1dn1ght 2 ปีที่แล้ว +2

    I find objects really good in decomposing a complex problem into smaller parts , which is one of the 4 pillars of programming /computational thinking in general which are decomposition , pattern recognistion , abstraction and algorithms

  • @TheJGX20
    @TheJGX20 10 หลายเดือนก่อน +1

    Finally understood objects in Lua, thank you!

  • @skaruts
    @skaruts 2 ปีที่แล้ว +12

    You don't need to set the metatable's *__index* every time you create a new fighter, though, you can do that only once. You also shouldn't use a colon on the constructor call *(Fighter:new()),* as the constructor is a static method of the class, not of the instances.
    *local Fighter = {*
    -- default class stuff
    *}*
    *Fighter.__index = Fighter* -- set index only once
    *function Fighter.new(info)*
    *local t = setmetatable({*
    *name = info.name or "Unnamed Fighter",*
    *health = info.health or 100,*
    *speed = info.speed or 100,*
    *}, Fighter)*
    *return t*
    *end*
    *local blanka = Fighter.new( {name="Blanka", speed=60} )*
    (youtube's lousy text formatting ruins the underscores...)

    • @umcanalsemvidanoyoutube8840
      @umcanalsemvidanoyoutube8840 3 หลายเดือนก่อน

      I like this way, but setting optional values with *or* isn't good at all, because you can duplicate values, setting the optional values in the table Fighter (the class) you get more performance and avoid duplicating values

  • @thepizzafoogle5481
    @thepizzafoogle5481 3 ปีที่แล้ว +1

    Thank you very much, this is really helping me grasp OOP in Lua, and I now feel much more confident in the game I am making currently!

  • @NonTwinBrothers
    @NonTwinBrothers 3 ปีที่แล้ว +1

    Very awesome!
    I'm familiar with doing OOP with Lua, this video is a lot better than learning what to do from the wiki article, haha

  • @somecharacter01
    @somecharacter01 2 ปีที่แล้ว +2

    Thank you! As someone getting into lua, this really helped with how to use the code :))

    • @pikuma
      @pikuma  2 ปีที่แล้ว

      Glad it helped!

  • @notovertaken8330
    @notovertaken8330 3 ปีที่แล้ว +3

    very underrated best lecturer! please make more courses on udemy and you're website, related to game development or other programming languages

  • @bratzchaki
    @bratzchaki 2 ปีที่แล้ว +2

    Hi professor...I am trying to access your curses but it is dropping down the page.

    • @pikuma
      @pikuma  2 ปีที่แล้ว +1

      Hello Bruno! Something must be going on with my hosting server. I'll check it out. Thanks!

  • @MichaelChin1994
    @MichaelChin1994 2 ปีที่แล้ว +3

    Is there a way to make "Fighter:new" just "new"? That function isn't doing anything special, just Lua's way of creating a class, right?
    If I wanted to have a game that had multiple classes (fighters, gunners, drivers, etc.) it seems a bit silly to have to copy and paste the same exact function, but call it "Fighter:new" "Gunner:new" "Driver:new" and so on.
    In other words, I'd like to do
    Jack = Fighter:new ([Name = Jack])
    John = Gunner:new ([Name = John])
    and it does all that t and self stuff, but it goes to the same "new" function.

    • @skaruts
      @skaruts 2 ปีที่แล้ว

      Check DevJeeper's videos on lua OOP, as he goes into that (which is called inheritance).

  • @Propofol1234
    @Propofol1234 ปีที่แล้ว

    At 14:50 you say "t is not going to be new hopefully". Why do you say that? I thought the whole point was that you are instanciating a new object?

    • @pikuma
      @pikuma  ปีที่แล้ว

      I think the word I tried to say was "nil", as in it was not going to be nil/null. 🥲

  • @alexandrodisla6285
    @alexandrodisla6285 9 หลายเดือนก่อน

    So you have a table.
    And function that will work with it

  • @geriibra1645
    @geriibra1645 2 ปีที่แล้ว

    I wish I could also see some inheritance with this method. Still great video!

    • @pikuma
      @pikuma  2 ปีที่แล้ว

      Next time! :)

  • @dt1926
    @dt1926 ปีที่แล้ว

    It's a shame you didn't continue this

    • @pikuma
      @pikuma  ปีที่แล้ว

      Hi. We did. It's all hosted at pikuma.com.

  • @ankitmajee
    @ankitmajee 3 ปีที่แล้ว +1

    History teacher

  • @SilverAphelion
    @SilverAphelion 3 ปีที่แล้ว

    Jesus amado pq tu nao fez em ptbr mesmo esse inglês não ta bom não fi mas bom tutorial usando a legenda.