Make the plugin support non-primitive types

This commit is contained in:
Lucien Greathouse
2019-02-11 10:55:03 -08:00
parent b9ee14a0f9
commit 5f062b8ea3
5 changed files with 155 additions and 104 deletions

View File

@@ -0,0 +1,32 @@
local primitiveTypes = {
String = true,
Bool = true,
Int32 = true,
Float32 = true,
Enum = true,
}
local directConstructors = {
CFrame = CFrame.new,
Color3 = Color3.new,
Vector2 = Vector2.new,
Vector2int16 = Vector2int16.new,
Vector3 = Vector3.new,
Vector3int16 = Vector3int16.new,
}
local function rojoValueToRobloxValue(value)
if primitiveTypes[value.Type] then
return value.Value
end
local constructor = directConstructors[value.Type]
if constructor ~= nil then
return constructor(unpack(value.Value))
end
local errorMessage = ("The Rojo plugin doesn't know how to handle values of type %q yet!"):format(tostring(value.Type))
error(errorMessage)
end
return rojoValueToRobloxValue