These methods are mainly for if you want to do some quick conversions but don’t want to calculate them yourself. The two especially helpful methods in my opinion are the Color3 and BrickColor conversions, since I know I will need them a lot.
I don’t know if this has much purpose, since a lot of these are easily able to be recreated. And why does the module use : if it isn’t using self anywhere?
function Convert:StringToBool(str)
if str == "true" or str == "false" or str == "nil" then
local boolNew
if str == "true" then
boolNew = true
elseif str == "false" then
boolNew = false
elseif str == "nil" then
boolNew = nil
end
return boolNew
else
warn("Parameter must be a string!")
return
end
end
What is the point of this? And nil is not a boolean.
function Convert:BoolToString(bool)
if bool == true or bool == false or bool == nil then
local stringNew
if bool == true then
stringNew = "true"
elseif bool == false then
stringNew = "false"
elseif bool == nil then
stringNew = "nil"
end
return stringNew
else
warn("Parameter must be a boolean!")
return
end
end
Don’t see to much of a point in this either – literally just tostring(bool) – and once more, nil is not a boolean.
function Convert:Color3ToBrickColor(color3)
return BrickColor.new(color3)
end
function Convert:BrickColorToColor3(brickcolor)
return brickcolor.color
end
Is there a reason someone should use your wrapper over just constructing a BrickColor out of Color3 or indexing for the Color property directly?
function ConvertVector3int16ToVector3(vector16)
return Vector3.new(vector16.X, vector16.Y, vector16.Z)
end
function ConvertVector3ToVector3int16(vector3)
return Vector3int16.new(vector3.X, vector3.Y, vector3.Z)
end
You’re missing a ., so these are just global variables in the module that aren’t exposed to scripts that require it. And also, are Vector3int16s used that often outside of terrain stuff? Let alone any use cases for needing to convert a Vector3 to int16 or the other way around?
Yea lol just realized that using : is kind of unnecessary so let me change that rq.
(I do agree with you on this matter)
Although it is not a boolean, all scripters treat them somewhat as booleans, like in the statement if var == nil then return end.
Not all beginner scripters know how to do this. This module isn’t for advanced scripters, but rather to help out the beginners who still have a lot to learn.
There’s a first for anything. Someone may find a way for it to be helpful.
No they don’t, they check if it’s nil, var == nil evaluates to a boolean expression.
They do know how to do this though, it’s literally documented and is a property on the brick color itself, and the overload that takes a Color3 is documented too. I think they’ll have a harder time using your module
You should probably state some use cases for that, I personally have seen udim2 → vector2 be somewhat popular use case so that one is alright.
I also recommend you use type annotations on your code