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
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.
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!
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.
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.
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!
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!
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. 👍👍👍
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)
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.
@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?
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 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
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
I was literally learning this from devforum a few hours ago how can your timing be so perfect
thank you so much for listening to viewers! this video really helped me out with type annotations!! :D
also, thanks so much for chapters too, its a really nice touch
I adore how this man actually listens to his comments
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.
I didn’t know how to use Literal types, Intersection, Type casting and Generics
you improved my understanding of type annotations 👍🏻
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!
Yup, thanks for bringing that up! You can export types from a module script using the export keyword!
This is an amazing tutorial right here!
I NEED THESE CUSTOM TYPES ON MY LIFE
Very good information, thank you.
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.
thanks for covering this!
amazing tutorial, thanks man
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.
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!
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!
Every thing I learn you make a tutorial about it 1 week later 😭
you make tutorials on more obscure parts of roblox luau, thanks so much!
Finally!!!
Needed this
What is your color scheme for the scripts?
Can you go back to PRI
do you think you could show us your code editor color palette?
Sure, I can post it on a community post soon
@@crusherfire1 please do, it looks soo clean
didnt watch the whole vid but its kinda similar to typescript right
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. 👍👍👍
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)
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.
@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?
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
You would want to store the unknown amount of arguments into a table so you can loop through them.
Example:
local args = {...}
@@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
what font do you use in the script editor?
JetBrains Mono!
quick question how do your change your font in scripts?
It is in the studio settings. Click on the file button thingy then go down to where it says studio settings.
feel like this is a stupid question but wtf is the difference between lua and luau
Luau is a scripting language derived from Lua 5.1
No views in 0 minutes? Bro fell off 😔
I've fallen and I can't get up!
@@crusherfire1 Should i call 911?
@@Developer_Max Call David Baszucki!
This isn’t really Lua then is it
luau is great :D
lua has no type annotation :\
what is the coding font you use in scripting?
JetBrains Mono
@@crusherfire1 theres no font in studio called jetbrains mono
@@crusherfire1 nevermind thanks
how did you find it? I don't see a font called jetbrains mono@@qquaded
what is the purpose of learning this
to be epic
mewo