blockooJoin Date: 2007-11-08 Post Count: 17202 |
@Notunknown
This is what I had until I quit, I tried saving typing and time by creating a table of every property and the code snippet needed to create it:
objects = {"inst0 = game.ReplicatedStorage"}
currentObjNum = 1
properties = {{"AttachmentForward", ".AttachmentForward = Vector3.new()"}, {"AttachmentPos", ".AttachmentForward = Vector3.new()"}, {"AttachmentRight", ".AttachmentRight = Vector3.new()"},
{"AttachmentUp", ".AttachmentUp = Vector3.new()"}, {"AnimationId", ".AnimationId = "}, {"Name", ".Name = ''"}, {"Offset", ".Offset = Vector3.new()"},
{"Scale", ".Scale = Vector3.new()"}, {"VertexColor", ".VertexColor = Vector3.new()"}, {"angularvelocity", ".angularvelocity = Vector3.new()"},
{"maxTorque", ".maxTorque = Vector3.new()"}, {"P", ".P = "}, {"force", ".force = Vector3.new()"}, {"D", ".D = "}, {"position", ".position = Vector3.new()"},
{"location", ".location = Vector3.new()"}, {"maxForce", ".maxForce = Vector3.new()"}, {"velocity", ".velocity = Vector3.new()"},
{"HeadColor", ".HeadColor = BrickColor.new()"}, {"LeftArmColor", ".LeftArmColor = BrickColor.new()"}, {"LeftLegColor", ".LeftLegColor = BrickColor.new()"},
{"RightArmColor", ".RightArmColor = BrickColor.new()"}, {"RightLegColor", ".RightLegColor = BrickColor.new()"}, {"TorsoColor", ".TorsoColor = BrickColor.new()"},
{"MaxActivationDistance", ".MaxActivationDistance = "}, {"BrickColor", ".BrickColor = BrickColor.new()"}, {"Material", ".Material = ''"},
{"Reflectance", ".Reflectance = "}, {"Transparency", ".Transparency = "}, {"Position", ".Position = Vector3.new()"}, {"Rotation", ".Rotation = Vector3.new()"},
{"RotVelocity", ".RotVelocity = Vector3.new()"}, {"Velocity", ".Velocity = Vector3.new()"}, {"Anchored", ".Anchored = "}, {"CanCollide", ".CanCollide = "},
{"Locked", ".Locked = "}, {"Elasticity", ".Elasticity = "}, {"Friction", ".Friction = "}, {"Size", ".Size = Vector3.new()"}, {"CFrame", ".CFrame = CFrame.new()"},
}
function stringify(obj, num, parentNum)
local instNum = "inst"..num
local objProperties = {}
local objLine = instNum.." = Instance.new('"..obj.ClassName.."') "..instNum..".Parent = inst"..parentNum.." "
local input =
for i, v in pairs(properties) do
local success = pcall(function() local test = obj[v[1]] end)
if (success == true) then
if (v[2]:find("Vector3.new()") or v{2]:find("CFrame.new()") or v[2]:find("BrickColor.new") or v[2]:find("Color3.new")) then
objLine = objLine..v[2]:sub(1, -2)..tostring(obj[v[1]])..") "
elseif (v[2]:find("''")) then
objLine = objLine..v[2]:sub(1, -2)..obj[v[1]].."' "
else
objLine = objLine..v[2]..tostring(obj[v[1]])
end
end
for i, v in pairs(objProperties) do
end
if (obj:IsA("Hat") or obj:IsA("Accoutrement")) then
table.insert(objects, instNum.." = Instance.new('"..obj.ClassName.."') "..instParent..instNum..".AttachmentForward = Vector3.new("..tostring(obj.AttachmentForward)..") "..instNum..".AttachmentPos = Vector3.new("..tostring(obj.AttachmentPos)..") "..instNum..".AttachmentRight = Vector3.new("..tostring(obj.AttachmentRight)..") "..instNum..".AttachmentUp = Vector3.new("..tostring(obj.AttachmentUp)..") "..instNum..".Name = '"..obj.Name.."'")
elseif (obj:IsA("Animation")) then
table.insert(objects, instNum.." = Instance.new('Animation') "..instParent..instNum..".AnimationId = '"..obj.AnimationId.."' "..instNum..".Name = '"..obj.Name.."'")
elseif (obj:IsA("BodyColors")) then
table.insert(objects, instNum.." = Instance.new('BodyColors') "..instParent..instNum..".HeadColor = BrickColor.new("..obj.HeadColor.Number..") "..instNum..".LeftArmColor = BrickColor.new("..obj.LeftArmColor.Number..") "..instNum..".LeftLegColor = BrickColor.new("..obj.LeftLegColor.Number..") "..instNum..".RightArmColor = BrickColor.new("..obj.RightArmColor.Number..") "..instNum..".RightLegColor = BrickColor.new("..obj.RightLegColor.Number..") "..instNum..".TorsoColor = BrickColor.new("..obj.TorsoColor.Number..") "..instNum..".Name = '"..obj.Name.."'")
elseif (obj:IsA("BlockMesh") or obj:IsA("CylinderMesh")) then
table.insert(objects, instNum.." = Instance.new('"..obj.ClassName.."') "..instParent..instNum..".Offset = Vector3.new("..tostring(obj.Offset)..") "..instNum..".Scale = Vector3.new("..tostring(obj.Scale)..") "..instNum..".VertexColor = Vector3.new("..tostring(obj.VertexColor)..") "..instNum..".Name = '"..obj.Name.."'")
elseif (obj:IsA("BodyAngularVelocity")) then
table.insert(objects, instNum.." = Instance.new('BodyAngularVelocity') "..instParent..instNum..".angularvelocity = Vector3.new("..tostring(obj.angularvelocity)..") "..instNum..".maxTorque = Vector3.new("..tostring(obj.maxTorque)..") "..instNum..".P = "..obj.P.." "..instNum..".Name = '"..obj.Name.."'")
elseif (obj:IsA("BodyForce")) then
table.insert(objects, instNum.." = Instance.new('BodyForce') "..instParent..instNum..".force = Vector3.new("..tostring(obj.force)..") "..instNum..".Name = '"..obj.Name.."'")
elseif (obj:IsA("BodyGyro")) then
table.insert(objects, instNum.." = Instance.new('BodyGyro')
end
end
end
end
function prepareDescendants(item, itemNum)
for i, v in pairs(item:GetChildren()) do
currentObjNum = currentObjNum + 1
stringify(v, currentObjNum, itemNum)
if (#v:GetChildren() > 0) then
prepareDescendants(v, currentObjNum)
end
end
end
_G.StoreInstance = function(instance)
stringify(instance, 1, 0)
prepareDescendants(instance, 1)
end
_G.LoadInstance = function(request) |