Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function getProperties(class, disallowedTags)
- local properties = { }
- if not disallowedTags then
- disallowedTags = { }
- end
- for i, v in pairs(parse(data)) do -- The Parse function works without any problems, no matter what I do, so it's not that
- if v.type == "Property" then
- if type(class) == "string" then
- if class == v.Class then
- local tagged = false
- for i, v in pairs(v.tags) do
- if checkIfIn(disallowedTags, i) then
- tagged = true
- end
- end
- if not tagged then
- properties[v.Name] = v
- end
- end
- else
- if class:IsA(v.Class) then
- local tagged = false
- for i, v in pairs(v.tags) do
- if checkIfIn(disallowedTags, i) then
- tagged = true
- end
- end
- if not tagged then
- properties[v.Name] = v
- end
- end
- end
- end
- end
- return properties
- end
- function getStringVersion(value, intsTab) -- TODO: Add Region3 and other minor data types
- if type(value) == "string" or type(value) == "boolean" or type(value) == "number" then
- if type(value) == "string" then -- String
- return "\""..value.."\""
- else -- Boolean, Number
- return tostring(value)
- end
- end
- if type(value) == "table" then -- Table, obviously.
- local str = "{"
- local num = 0
- for i, v in pairs(value) do
- num = num + 1
- if num == 1 then
- str = str.."["..getStringVersion(i).."] = "..getStringVersion(v).."\n"
- else
- str = str..", ["..getStringVersion(i).."] = "..getStringVersion(v).."\n"
- end
- end
- str = str.."}"
- end
- if test(value, "X", "Y") then
- if test(value, "Z") then -- Vector3
- if test(value, "lookVector") then -- CFrame
- return "CFrame.new("..table.concat({value:components()}, ", ")..")"
- else
- return "Vector3.new("..value.X..", "..value.Y..", "..value.Z..")"
- end
- elseif test(value.X, "Offset", "Scale") then -- UDim2
- return "UDim2.new("..value.X.Scale..", "..value.X.Offset..", "..value.Y.Scale..", "..value.Y.Offset..")"
- else -- Vector2
- return "Vector2.new("..value.X..", "..value.Y..")"
- end
- end
- if test(value, "Color", "Name", "Number") then -- BrickColor
- return "BrickColor.new(\""..value.Name.."\")"
- end
- if test(value, "r", "b", "g") then -- Color3
- return "Color3.new("..value.r..", "..value.b..", "..value.g..")"
- end
- if test(value, "Name", "Value") then -- Enumerator
- return "\""..value.Name.."\""
- end
- if test(value, "Offset") then -- UDim
- return "UDim.new("..value.Scale..", "..value.Offset..")"
- end
- if test(value, "Origin", "Direction") then -- Ray. I have no idea how to do Region3, so I'll skip that for now.
- return "Ray.new("..getStringVersion(value.Origin)..", "..getStringVersion(value.Direction)..")"
- end
- if test(value, "Parent", "IsA") then -- Instance (I'm not entirely sure what I'm doing here!)
- for i, v in pairs(intsTab) do
- if v == value then
- return "obj"..i
- end
- end
- if value ~= game then
- return "game."..value:GetFullName()
- else
- return "game"
- end
- end
- return "nil"
- end
- local dTags = {"readonly", "RobloxScriptSecurity", "RobloxSecurity", "LocalUserSecurity", "writeonly", "WritePlayerSecurity", "RobloxPlaceSecurity", "backend"}
- local function cmdCompile(obj)
- local str = "Create(\""..obj.ClassName.."\"){\n"
- local num = 0
- for i, v in pairs(getProperties(obj.ClassName, dTags)) do
- local strV = getStringVersion(obj[i], { })
- str = str..i.." = "..strV..";\n"
- num = num + 1
- end
- for i, v in pairs(obj:GetChildren()) do
- str = str..cmdCompile(v)..";\n"
- end
- str = str.."}"
- return str
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement