Yeah, I've been trying to understand types for quite some time. I can work out most of it except when I try to set types in OOP using players and characters. No matter what I do I end up with bunches of red lines throughout the code. I remove the types and the code works just fine so I never understand what to do. What types are a player, character and humanoid and how do I set it up?
Thank you man, it feels feels like you help bridge the gaps of intermediate to advanced. Alot of the questions I find myself asking I can't find good answers for until I look at your channel
Great video! This is something I didn't quite understand about scripting yet, but it makes a lot more sense now. You should do a video about metatables sometime, they can be really powerful and I see a lot of people struggling with them.
This video made me wonder: What if I type define a table called Car and use the Lua OOP concept that is in roblox's devfourms and combine to type define an object called Car to code efficiently.
this is cool lol also can make a tutorial on how to make it so the bezier curve still going even when it reached to the end point I’m trying to make an attack that basically shoot paintballs up then fall down into players
i feel so lucky right now, ive been learning type-checking and i couldnt find out how to designate a variable as a table. i kept googling it but i was getting a bunch of irrelevant stuff lol
i told chat gpt 3.5 that : can you write a script using lua and using generics to print of input type is int value or bool value or string value and replay that : Certainly! In Lua, we can create a function that uses generics to handle different input types and print messages based on the type of the input. While Lua does not have a formal generics system like some other languages, we can achieve similar functionality by checking the type of the input. Here's a Lua script that demonstrates this: function printType(value) local valueType = type(value)
if valueType == "number" then if math.floor(value) == value then print("The input is an int value: " .. value) else print("The input is a number (not an int): " .. value) end elseif valueType == "boolean" then print("The input is a bool value: " .. tostring(value)) elseif valueType == "string" then print("The input is a string value: " .. value) else print("The input is of an unhandled type: " .. valueType) end end -- Test cases printType(42) -- int value printType(42.5) -- number (not int) printType(true) -- bool value printType("Hello, world") -- string value printType(nil) -- unhandled type printType({}) -- unhandled type can any one explain that?
@@CogTheSuit it does, the whole point of typechecking is to help you not make mistakes in your code. Typechecking doesn’t waste time and is here to help you
Yeah Im honestly confused to Its pretty cool and could help if you are using the function and don't know what to type in argument but that should be rarely the case, I thought it would stop the function when it detected the wrong output type or argument type which would make it a useful tool but that is not the case after I played with it a little bit. Im interested to see how other people apply it.
Have y’all heard of generics?
never
Yeah, I've been trying to understand types for quite some time. I can work out most of it except when I try to set types in OOP using players and characters. No matter what I do I end up with bunches of red lines throughout the code. I remove the types and the code works just fine so I never understand what to do. What types are a player, character and humanoid and how do I set it up?
yup, i code in Java
@@mile.9768 Same, Can also use generics with classes and variables
me when programming in Java
This is not something I would waste much time studying but knowing the basics of generics is enough for most developers
I just spent 2 hours last week wrapping my head around this and you create this NOW?!?
I used to code in C# so a lot of this made sense to me, but I didnt even know lua could do that. Epic!
only luau, vanilla lua doesn't have this
Thank you man, it feels feels like you help bridge the gaps of intermediate to advanced. Alot of the questions I find myself asking I can't find good answers for until I look at your channel
Looks like something that would come straight from math exams
this showed me what types are in like 2 minutes thanks
Great video! This is something I didn't quite understand about scripting yet, but it makes a lot more sense now. You should do a video about metatables sometime, they can be really powerful and I see a lot of people struggling with them.
underrated vid 😢
This video made me wonder: What if I type define a table called Car and use the Lua OOP concept that is in roblox's devfourms and combine to type define an object called Car to code efficiently.
Will make OOPs more customizable.
typechecking with OOP is not a thing yet
nice video!😁
Keep up the good work with the videos
this is cool lol
also can make a tutorial on how to make it so the bezier curve still going even when it reached to the end point
I’m trying to make an attack that basically shoot paintballs up then fall down into players
It's simple but its abstract, I think that's what scares people away
i wanna ask where did you get those informations, i never knew all off those that your channel covered
i knew some of em before thiss vid but not all
type annotation and generics are powerful
ByteBlox if he was good:
Lol I don’t have a problem w him but his fan base is a lil crazy in his comments
@@stewiepfing539 his fans are horrible
@@stewiepfing539fr
Could you send some examples of use for this because i dont know why id use this
W tutorial
i feel so lucky right now, ive been learning type-checking and i couldnt find out how to designate a variable as a table. i kept googling it but i was getting a bunch of irrelevant stuff lol
Suphi Kaner’s type checking tutorial is a very useful resource for this stuff.
i told chat gpt 3.5 that : can you write a script using lua and using generics to print of input type is int value or bool value or string value
and replay that :
Certainly! In Lua, we can create a function that uses generics to handle different input types and print messages based on the type of the input. While Lua does not have a formal generics system like some other languages, we can achieve similar functionality by checking the type of the input.
Here's a Lua script that demonstrates this:
function printType(value)
local valueType = type(value)
if valueType == "number" then
if math.floor(value) == value then
print("The input is an int value: " .. value)
else
print("The input is a number (not an int): " .. value)
end
elseif valueType == "boolean" then
print("The input is a bool value: " .. tostring(value))
elseif valueType == "string" then
print("The input is a string value: " .. value)
else
print("The input is of an unhandled type: " .. valueType)
end
end
-- Test cases
printType(42) -- int value
printType(42.5) -- number (not int)
printType(true) -- bool value
printType("Hello, world") -- string value
printType(nil) -- unhandled type
printType({}) -- unhandled type
can any one explain that?
you should tell him use LuaU not Lua, Lua doesn't have generics so chat gpt made random stuffs
whats the difference between what you did and just " : any"
any could be any data type. T is the type of the datatype you send in
what's the point of doing that, it just wastes time
it reduces possibilities for bugs
type checking for intellisense and autofill is incredibly useful
It's only useless if you don't do native code
@@nebularzz Not sure about that
@@CogTheSuit it does, the whole point of typechecking is to help you not make mistakes in your code. Typechecking doesn’t waste time and is here to help you
isn't that hard 😳
0:14
seems useless.
Yeah Im honestly confused to Its pretty cool and could help if you are using the function and don't know what to type in argument but that should be rarely the case, I thought it would stop the function when it detected the wrong output type or argument type which would make it a useful tool but that is not the case after I played with it a little bit. Im interested to see how other people apply it.