Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local API = {} --(c)Missing Studios
- EncoderAssist = {
- ["Surface"] = {
- Smooth = 0,
- Glue = 1,
- Weld = 2,
- Studs = 3,
- Inlet = 4,
- Universal = 5,
- Hinge = 6,
- Motor = 7,
- SteppingMotor = 8,
- Unjoinable = 9,
- SmoothNoOutlines = 10,
- };
- ["Material"] = {
- Plastic = 0,
- SmoothPlastic = 1,
- Wood = 2,
- Marble = 3,
- Slate = 4,
- Concrete = 5,
- Granite = 6,
- Brick = 7,
- Pebble = 8,
- CorrodedMetal = 9,
- DiamondPlate = 10,
- Foil = 11,
- Grass = 12,
- Sand = 13,
- Fabric = 14,
- Ice = 15,
- Metal = 16,
- WoodPlanks = 17,
- Cobblestone = 18,
- Neon = 19,
- };
- ["BasePart"] = {
- Part = 0,
- WedgePart = 1,
- CornerWedgePart = 2,
- TrussPart = 3,
- Seat = 4,
- SkateboardPlatform = 5,
- VehicleSeat = 6,
- FlagStand = 7,
- SpawnLocations = 8,
- Terrain = 9
- };
- ["Shape"] = {
- Ball = 0,
- Block = 1,
- Cylinder = 2
- };
- ["Face"] = {
- Top = 1,
- Bottom = 2,
- Right = 3,
- Left = 4,
- Back = 5,
- Front = 6
- };
- ["SurfaceInput"] = {
- NoInput = 0,
- LeftTread = 1,
- RightTread = 2,
- Steer = 3,
- Throttle = 4,
- UpDown = 5,
- Action1 = 6,
- Action2 = 7,
- Action3 = 8,
- Action4 = 9,
- Action5 = 10,
- Constant = 11,
- Sin = 12
- };
- ["Mesh"] = {
- BlockMesh = 0,
- CylinderMesh = 1,
- SpecialMesh = 2,
- };
- ["MeshType"] = {
- Head = 0,
- Torso = 1,
- Wedge = 2,
- Sphere = 3,
- Cylinder = 4,
- FileMesh = 5,
- Brick = 6,
- Prism = 7,
- Pyramid = 8,
- ParallelRamp = 9,
- RightAngleRamp = 10,
- CornerWedge = 11,
- };
- ["Light"] = {
- SpotLight = 0,
- PointLight = 1,
- };
- ["SpecialPartInfo"] = {
- B = {TextureId = "rbxassetid://150281996"};
- W = {MeshId = "http://www.roblox.com/asset/?id=1033714"};
- R = {MeshId = "http://roblox.com/asset/?id=2251534"};
- };
- }
- function EncoderAssist:GetValueFromInt(TableName,Int)
- if EncoderAssist[TableName] then
- for i,v in pairs(EncoderAssist[TableName]) do
- if v == Int then return tostring(i) end
- end
- end
- end
- function EncoderAssist:ConstructInstanceFromData(data,Chamber)
- local Part = data
- local G = Part[1]
- local CF = Part[2]
- local S = Part[3]
- local I = Part[4]
- local NewPart = Instance.new(EncoderAssist:GetValueFromInt("BasePart",G[1]),Chamber)
- if NewPart:IsA("FormFactorPart") then NewPart.FormFactor = "Symmetric" end
- NewPart.Anchored = true
- NewPart.Locked = true
- NewPart.Name = G[6]
- NewPart.Material = EncoderAssist:GetValueFromInt("Material",G[3])
- NewPart.Transparency = G[4]
- NewPart.Reflectance = G[5]
- NewPart.BrickColor = BrickColor.new(G[2])
- NewPart.BackSurface = EncoderAssist:GetValueFromInt("Surface",I[1])
- NewPart.BottomSurface = EncoderAssist:GetValueFromInt("Surface",I[2])
- NewPart.FrontSurface = EncoderAssist:GetValueFromInt("Surface",I[3])
- NewPart.LeftSurface = EncoderAssist:GetValueFromInt("Surface",I[4])
- NewPart.RightSurface = EncoderAssist:GetValueFromInt("Surface",I[5])
- NewPart.TopSurface = EncoderAssist:GetValueFromInt("Surface",I[6])
- NewPart.Size = Vector3.new(S[1],S[2],S[3])
- NewPart.CFrame = CFrame.new(CF[1],CF[2],CF[3]) * CFrame.Angles(math.rad(CF[4]),math.rad(CF[5]),math.rad(CF[6]))
- spawn(function()
- local class = G[6]:sub(1,1)
- if class == "Y" or class == "Z" then
- NewPart.Name = class == "Y" and "X2" or class == "Z" and "X3" or "X"
- elseif class == "B" then
- for _,w in pairs(Enum.NormalId:GetEnumItems()) do
- local texture = Instance.new("Decal",NewPart)
- texture.Texture = EncoderAssist.SpecialPartInfo.B.TextureId
- texture.Face = w
- end
- elseif class == "W" then
- local mesh = Instance.new("SpecialMesh",NewPart)
- mesh.MeshType = "FileMesh"
- mesh.MeshId = EncoderAssist.SpecialPartInfo.W.MeshId
- elseif class == "R" then
- local mesh = Instance.new("SpecialMesh",NewPart)
- mesh.MeshType = "FileMesh"
- mesh.MeshId = EncoderAssist.SpecialPartInfo.R.MeshId
- if NewPart.Size.X ~= 2 then
- mesh.Scale = Vector3.new(.5,.5,.5)
- end
- elseif class == "L" then
- local light = Instance.new("PointLight",NewPart)
- light.Color = NewPart.BrickColor.Color
- light.Shadows = true
- elseif class == "C" then
- Instance.new("CylinderMesh",NewPart)
- elseif class == "M" then
- Instance.new("SpecialMesh",NewPart)
- elseif class == "N" then
- NewPart.CanCollide = false
- end
- end)
- if NewPart:IsA("VehicleSeat") then NewPart.HeadsUpDisplay = false end
- if G[6] == "o" then NewPart.CanCollide = false end
- if G[7] then
- local bindCode = Instance.new("IntValue",NewPart)
- bindCode.Name = "BindCode"
- bindCode.Value = G[7]
- end
- if I[7] then
- NewPart.Shape = EncoderAssist:GetValueFromInt("Shape",I[7])
- end
- wait()
- end
- function API:GenPass()
- local Seed = string.sub(string.reverse(game.Workspace.DistributedGameTime),1,4)
- local Quantifier = string.sub(game.JobId,1,3)
- return "#"..string.reverse( ( Quantifier or 0 ) .."-"..Seed..string.char(math.random(65,126))..math.floor(math.random()*100).."-"..string.char(math.random(65,90))..string.char(math.random(65,90)).."-"..math.random(0,9))
- end
- function API:EncodeModel(model)
- local http = game:GetService("HttpService")
- local BaseParts = {}
- local ChunksEncoded = -1
- local IsFinished = false
- function GetBP(scope)
- for _,w in pairs(scope:GetChildren()) do
- if w:IsA("BasePart") then
- table.insert(BaseParts,w)
- end
- GetBP(w)
- end
- end
- GetBP(model)
- local TablesPerDataChunk = 200
- local Times = math.floor(#BaseParts/TablesPerDataChunk)
- local Data = {}
- for iteration = 0,Times do
- spawn(function()
- local DataChunk = {}
- local start = iteration * TablesPerDataChunk + 1
- local finish = start + TablesPerDataChunk - 1
- if finish > #BaseParts then finish = #BaseParts end
- for z = start,finish do
- local Part = BaseParts[z]
- local P = {
- {
- EncoderAssist.BasePart[Part.ClassName],
- Part.BrickColor.Number,
- EncoderAssist.Material[Part.Material.Name],
- Part.Transparency,
- Part.Reflectance,
- string.sub(Part.Name,2,2),
- };
- {
- Part.CFrame.x; Part.CFrame.y; Part.CFrame.z;
- Part.Rotation.x; Part.Rotation.y; Part.Rotation.z;
- };
- {Part.Size.x,Part.Size.y,Part.Size.z};
- {
- EncoderAssist.Surface[Part.BackSurface.Name];
- EncoderAssist.Surface[Part.BottomSurface.Name];
- EncoderAssist.Surface[Part.FrontSurface.Name];
- EncoderAssist.Surface[Part.LeftSurface.Name];
- EncoderAssist.Surface[Part.RightSurface.Name];
- EncoderAssist.Surface[Part.TopSurface.Name];
- };
- }
- for i,v in pairs(P[2]) do
- if string.find(v,"e") then
- local pos = string.find(v,"e")
- P[2][i] = string.sub(v,1,pos <= string.len(math.floor(v))+4 and pos - 1 or string.len(math.floor(v))+4)..string.sub(v,pos)
- else
- local wh,fr = math.modf(v)
- if string.len(fr) > 5 then
- local new = string.sub(v,1,string.len(wh)+4)
- if new == "0" or new == "-0" then
- P[2][i] = 0
- else
- P[2][i] = new
- end
- end
- end
- end
- for i,v in pairs(P[3]) do
- local wh,fr = math.modf(v)
- if string.len(fr) > 5 then
- local new = string.sub(v,1,string.len(wh)+4)
- if new == "0" or new == "-0" then
- P[3][i] = 0
- else
- P[3][i] = new
- end
- end
- end
- if tonumber(Part.Name:sub(3,3)) then P[1][6] = Part.Name:sub(2,3) end
- if Part:IsA("Part") then P[4][7] = EncoderAssist.Shape[Part.Shape.Name] end
- if Part:findFirstChild("BindCode") and Part.BindCode.Value ~= 0 then P[1][7] = Part.BindCode.Value end
- if z == 1 then print(http:JSONEncode(P)) end
- table.insert(DataChunk,P)
- end
- table.insert(Data,DataChunk)
- ChunksEncoded = ChunksEncoded + 1
- print(ChunksEncoded,Times)
- end)
- end
- repeat wait() until ChunksEncoded == Times
- print("Complete.")
- print(string.len(http:JSONEncode(Data)))
- return http:JSONEncode(Data)
- end
- ----------------------------------
- function API:SaveDataToCloud(data,namespace,scope)
- local StrLimit = 55000
- local pass = namespace and namespace or API:GenPass()
- local user = scope and scope or "CyberCloudCreations"
- local CCC = game:GetService("DataStoreService"):GetDataStore(pass,user)
- local Number = math.ceil(string.len(data)/StrLimit)
- local Saved = 0
- local DoneSaving = 0
- local datacopy = data
- for i = 1,Number do
- local chunk = string.sub(datacopy,1,StrLimit)
- spawn(function()
- Saved = Saved + 1
- CCC:SetAsync(i,chunk)
- print(string.len(chunk).."STR")
- DoneSaving = DoneSaving + 1
- print(DoneSaving.."/"..Number)
- end)
- datacopy = string.sub(datacopy,StrLimit + 1)
- end
- repeat wait() until DoneSaving == Number
- CCC:SetAsync("Entries",Number)
- return pass,user,Number
- end
- ----------------------------------
- function API:GetEncodedDataFromCloud(Code,scope)
- local GDS = game:GetService("DataStoreService"):GetDataStore(Code,scope or "CyberCloudCreations")
- local CodeDone = 1
- local Entries = GDS:GetAsync("Entries")
- local ModelData = ""
- for x = 1, Entries do
- spawn(function()
- local DataChunk = GDS:GetAsync(x)
- repeat wait() until CodeDone == x
- ModelData = ModelData..DataChunk
- CodeDone = CodeDone + 1
- print(CodeDone.."/"..Entries)
- end)
- end
- repeat wait() until CodeDone == Entries + 1
- return ModelData
- end
- ----------------------------------
- function API:ConstructModelFromCloud(Code,scope,parent)
- local GDS = game:GetService("DataStoreService"):GetDataStore(Code,scope or "CyberCloudCreations")
- local Chamber = Instance.new("Model",parent)
- Chamber.Name = "Construction"
- local CodeDone = 1
- local Entries = GDS:GetAsync("Entries")
- local ModelData = ""
- for x = 1, Entries do
- spawn(function()
- local DataChunk = GDS:GetAsync(x)
- repeat wait() until CodeDone == x
- ModelData = ModelData..DataChunk
- CodeDone = CodeDone + 1
- print(CodeDone.."/"..Entries)
- end)
- end
- repeat wait() until CodeDone == Entries + 1
- ModelData = game:GetService("HttpService"):JSONDecode(ModelData)
- CodeDone = 0
- for _,w in pairs(ModelData) do
- spawn(function()
- local Data = w
- for _,v in pairs(Data) do
- EncoderAssist:ConstructInstanceFromData(v,Chamber)
- end
- CodeDone = CodeDone + 1
- print(CodeDone,#ModelData)
- end)
- end
- repeat wait() until CodeDone == #ModelData
- Chamber:MakeJoints()
- return Chamber
- end
- ----------------------------------
- function API:ConstructModelFromData(data,parent)
- local Chamber = Instance.new("Model",parent)
- Chamber.Name = "Construction"
- local ModelData = game:GetService("HttpService"):JSONDecode(data)
- local CodeDone = 0
- for _,w in pairs(ModelData) do
- spawn(function()
- local Data = w
- for _,v in pairs(Data) do
- spawn(function()
- EncoderAssist:ConstructInstanceFromData(v,Chamber)
- end)
- end
- CodeDone = CodeDone + 1
- print(CodeDone,#ModelData)
- end)
- end
- repeat wait() until CodeDone == #ModelData
- Chamber:MakeJoints()
- return Chamber
- end
- ----------------------------------
- function API:CountParts(model)
- local Count = 0
- function int(scope)
- for _,w in pairs(scope:GetChildren()) do
- if w:IsA("BasePart") then
- Count = Count + 1
- end
- int(w)
- end
- end
- int(model)
- return Count
- end
- ----------------------------------
- function API:AnchorModel(model,anchor)
- local function int(scope)
- for _,w in pairs(scope:GetChildren()) do
- if w:IsA("BasePart") then
- model.Anchored = anchor
- end
- int(w)
- end
- end
- int(model)
- return model
- end
- ----------------------------------
- function API:ManipulateParts(model,tableofproperties)
- local function int(scope)
- for _,w in pairs(scope:GetChildren()) do
- spawn(function()
- if w:IsA("BasePart") then
- for _,v in pairs(tableofproperties) do
- w[_] = v
- end
- end
- int(w)
- end)
- end
- end
- int(model)
- return model
- end
- ----------------------------------
- return API
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement