Type Annotation in Roblox Studio!

Поділитися
Вставка
  • Опубліковано 26 лис 2024

КОМЕНТАРІ • 56

  • @creatersbr
    @creatersbr 7 місяців тому +7

    man, your content its the best of roblox studio community, like you teach everything that's nobody teach in youtube, and for the beginners this content help so much

  • @haxking2
    @haxking2 8 місяців тому +7

    I was literally learning this from devforum a few hours ago how can your timing be so perfect

  • @MichaelObamaSon
    @MichaelObamaSon 8 місяців тому +3

    thank you so much for listening to viewers! this video really helped me out with type annotations!! :D

    • @MichaelObamaSon
      @MichaelObamaSon 8 місяців тому +1

      also, thanks so much for chapters too, its a really nice touch

  • @cryptic2742
    @cryptic2742 8 місяців тому +2

    I adore how this man actually listens to his comments

  • @Alexandre94fr
    @Alexandre94fr 8 місяців тому +1

    Thank you very much for your video. 😄
    Lua's dynamic typing has its advantages, however being able to define types for its functions, arguments, as well as variables is really important (for me) in order to have understandable, and predictable code.

  • @Kitsune_Dev
    @Kitsune_Dev 8 місяців тому

    I didn’t know how to use Literal types, Intersection, Type casting and Generics
    you improved my understanding of type annotations 👍🏻

  • @RoboGameOfficial
    @RoboGameOfficial 8 місяців тому +1

    You could also write intersection types like this:
    type a = {
    num: number
    }
    type b = a& {
    str: string
    }
    Also, I think you forgot to talk about being able to export types outside of a module script!

    • @crusherfire1
      @crusherfire1  8 місяців тому

      Yup, thanks for bringing that up! You can export types from a module script using the export keyword!

  • @lua_programmer
    @lua_programmer 8 місяців тому +1

    This is an amazing tutorial right here!

  • @ifthenelse2469
    @ifthenelse2469 8 місяців тому

    I NEED THESE CUSTOM TYPES ON MY LIFE

  • @VizaVizor
    @VizaVizor Місяць тому

    Very good information, thank you.

  • @KiloDev
    @KiloDev 8 місяців тому

    I really didn't know this, thank you! Hmph, I kind of wish there was a way to make studio error when you pass the wrong type using type annotation so that we don't have to add a check for the type. I know it shows a warning but studio doesn't error and the function will continue to execute.

  • @Noon1263
    @Noon1263 8 місяців тому

    thanks for covering this!

  • @dxlorean2938
    @dxlorean2938 4 місяці тому

    amazing tutorial, thanks man

  • @mrstarfish
    @mrstarfish 7 місяців тому

    Idk if you cover this, but I recently found out you can do:
    Local table = {
    State = “Idle”,
    Test = 5
    }
    Type T = typeof(table)
    This was pretty useful for me with long tables that get passed around in functions. And for the state variable you can also do this:
    Type T = {
    State: “Idle” | “Combat”
    } & typeof(table)
    ^ uses table from previous example, and with the & symbol it will still auto fill the ‘Test’ variable.

    • @crusherfire1
      @crusherfire1  7 місяців тому +1

      Not covered in the video, but yes, you can use the typeof() function for creating types. In fact, you can pass virtually anything to it, including instances.
      Let's say you have some kind of standard-instance in your game you need to use for something and want the autofill capabilities for grabbing properties, children, and other stuff in that instance. Use the typeof() function on it and store the result in a new type and then you can use it anywhere!

  • @rocketcamel729
    @rocketcamel729 8 місяців тому

    Great video on type annotation! (I totally didn’t see your community post sorry!)see a lot of people asking about your font. Sorry to make you check, but for your roblox studio script editor theme do you use a plugin of some sort? And if so, can you provide the theme you use? I like it more than the default theme where the functions are yellow instead of orange for example. I've seen a theme called toasty that looks similar to yours. Cheers!

  • @Jamal.frl_13
    @Jamal.frl_13 8 місяців тому

    Every thing I learn you make a tutorial about it 1 week later 😭

  • @Sand.
    @Sand. 8 місяців тому

    you make tutorials on more obscure parts of roblox luau, thanks so much!

  • @SinstixMain
    @SinstixMain 8 місяців тому +1

    Finally!!!

  • @jam5936
    @jam5936 8 місяців тому

    Needed this

  • @VSurge
    @VSurge 5 місяців тому

    What is your color scheme for the scripts?

  • @SupposedlyChase
    @SupposedlyChase 8 місяців тому +1

    Can you go back to PRI

  • @notdaycrucial5179
    @notdaycrucial5179 8 місяців тому +1

    do you think you could show us your code editor color palette?

    • @crusherfire1
      @crusherfire1  8 місяців тому

      Sure, I can post it on a community post soon

    • @embry4117
      @embry4117 8 місяців тому

      @@crusherfire1 please do, it looks soo clean

  • @jesterlow
    @jesterlow 8 місяців тому

    didnt watch the whole vid but its kinda similar to typescript right

  • @m3s5_0f_numb3r5
    @m3s5_0f_numb3r5 8 місяців тому

    I understand now, but…I don’t really…see what the point is? I dunno maybe it’s just the way I script but…I don’t really see the point in using type annotation. Maybe generic functions, but other than that I don’t exactly see how it could help me. Thanks for covering it anyway though! You never know when something like this might come in handy, so I’m not really complaining. 👍👍👍

    • @embry4117
      @embry4117 8 місяців тому

      I use it for tab completion sometimes such as passing player through a function. If I did player.Character it wouldnt autocomplete "Character" unless if I have func(player : Player)

    • @wclxb
      @wclxb 8 місяців тому

      it's extremely useful when working with more than one person. when using modules / modifying other scripts, seeing the expected types is one less thing you have to think about when reading a script written by someone else.

  • @workindad
    @workindad 7 місяців тому

    @Crusherfire I’m just not getting type inferencing when using on touch events. When I try to get the character and/or humanoid I just get red lines. Is this wrong way to use types?

  • @Noon1263
    @Noon1263 8 місяців тому

    hi i came back because i want to use multiple arguments for my function, but not sure how to declare them, like set them as a variable, using the dots like you did here: 17:10

    • @crusherfire1
      @crusherfire1  8 місяців тому

      You would want to store the unknown amount of arguments into a table so you can loop through them.
      Example:
      local args = {...}

    • @Noon1263
      @Noon1263 8 місяців тому

      @@crusherfire1 yes but how would you define them is what im saying, so like
      local args = {...}
      args.Argument1 = true
      args.Argument2 = "this is a string"
      that seems to me the most logical way of settings and defining the arguments, but it dosent work that way unfortunetly

  • @ilovecinnamonbuns
    @ilovecinnamonbuns 8 місяців тому +1

    what font do you use in the script editor?

  • @MrNobody-vb8rf
    @MrNobody-vb8rf 6 місяців тому

    quick question how do your change your font in scripts?

    • @LeviBannister
      @LeviBannister 2 місяці тому

      It is in the studio settings. Click on the file button thingy then go down to where it says studio settings.

  • @SlightlySchizophrenic
    @SlightlySchizophrenic 8 місяців тому

    feel like this is a stupid question but wtf is the difference between lua and luau

    • @crusherfire1
      @crusherfire1  8 місяців тому

      Luau is a scripting language derived from Lua 5.1

  • @AlteFore
    @AlteFore 8 місяців тому +22

    No views in 0 minutes? Bro fell off 😔

    • @crusherfire1
      @crusherfire1  8 місяців тому +8

      I've fallen and I can't get up!

    • @Developer_Max
      @Developer_Max 8 місяців тому

      ​@@crusherfire1 Should i call 911?

    • @crusherfire1
      @crusherfire1  8 місяців тому +2

      @@Developer_Max Call David Baszucki!

  • @korigamik
    @korigamik 11 днів тому

    This isn’t really Lua then is it

  • @_beyi
    @_beyi 8 місяців тому

    luau is great :D
    lua has no type annotation :\

  • @qquaded
    @qquaded 8 місяців тому

    what is the coding font you use in scripting?

    • @crusherfire1
      @crusherfire1  8 місяців тому

      JetBrains Mono

    • @qquaded
      @qquaded 8 місяців тому

      @@crusherfire1 theres no font in studio called jetbrains mono

    • @qquaded
      @qquaded 8 місяців тому

      @@crusherfire1 nevermind thanks

    • @dunlng
      @dunlng 8 місяців тому

      how did you find it? I don't see a font called jetbrains mono@@qquaded

  • @NORMAL_ACCOUNT...
    @NORMAL_ACCOUNT... 8 місяців тому

    what is the purpose of learning this

  • @henumeramon08
    @henumeramon08 8 місяців тому

    mewo