|
| 29 Dec 2012 10:57 PM |
Well, here I am again with this compiler script. Most of you probably ignored the 20 or so threads I previously made about this :L
Anyway, a new problem has arisen, and I have absolutely no idea as to why it has or how to fix it.
In two lines, I changed a bit of string manipulation (thanks to kingkiller1000:) ), but sadly now, I get an error message saying 'string expected'. That's it. I can't actually test the output for the function itself causes hundreds of errors when testing for properties and gets the errors I need discarded... hehe...
The script DID work before this change, and I am positive these are the only changes made to the script since!
Two lines were changed in total, I'll show the changes here.
compilation=compilation.." local o"..tostring(num).."=Instance.new(\""..obj.ClassName.."\","..obj.Parent:GetFullName()..")"
was changed to
compilation=compilation.." local o"..tostring(num).."=Instance.new(\""..obj.ClassName.."\",game"..obj.Parent:GetFullName():gsub("[^%.]+", "[\"%1\"]"):gsub("%.", "")..")"
and
endcomp=endcomp.." o"..tostring(num).."."..ObjectProperties[i].."="..obj[ObjectProperties[i]]:GetFullName()
was changed to
endcomp=endcomp.." o"..tostring(num).."."..ObjectProperties[i].."=game"..obj[ObjectProperties[i]]:GetFullName():gsub("[^%.]+", "[\"%1\"]"):gsub("%.", "")
:GetFullName():gsub("[^%.]+", "[\"%1\"]"):gsub("%.", "") alone performed on an object has no errors, and does return a string value!
(Thanks for the help in advance)
I truly don't understand what is happening here... and I know people are going to be all "Gimmeh teh whole scropt11"
Well, I'll post it. Shield your eyes.
_G.Compile=function(object) ypcall(function()
-- Just tables with properties here ---------------------------------------- local TextProperties={"SoundId","MeshId","TextureId","C0","C1","MaxVelocity","ShirtTemplate","Graphic","PantsTemplate","Face","BottomSurface","TopSurface","LeftSurface","RightSurface","Part0","Part1","MeshType","Name","Value","MaxValue","MinValue","Text","Reflectance","Transparency","Heat","TeamName","Health","MaxHealth","Brightness","FogEnd","FogStart","Size","D","P","Elasticity","FormFactor","Friction","Shape","GeographicLatitude","Texture","BackgroundTransparency","Image"} local BoolProperties={"Anchored","CanCollide","Disabled","Value","Locked","CharacterAutoLoads","Visable","Sit","Jump","PlatformStand"} local BrickColorProperties={"BrickColor","Color","TeamColor","HeadColor","TorsoColor","LeftLegColor","LeftArmColor","RightLegColor","RightArmColor","Value"} local Color3Properties={"Color","SecondaryColor","Ambient","ColorShift_Bottom","ColorShift_Top","ShadowColor","FogColor","Value","BorderColor3","BackgroundColor3"} local Vector3Properties={"Size","Position","maxForce","maxTorque","position","Velocity","RotVelocity","Value"} local ObjectProperties={"Torso","Head","RightLeg","LeftLeg","Part0","Part1"}
-- end of the tables of properties----------------------------------------------
local compilation="" local endcomp="" local nom=0
function compile(obj,num) if obj.ClassName~="Status"and obj.Parent~=game and obj.Parent~=Players and obj~=game then
-- CHANGED LINE compilation=compilation.." local o"..tostring(num).."=Instance.new(\""..obj.ClassName.."\",game"..obj.Parent:GetFullName():gsub("[^%.]+", "[\"%1\"]"):gsub("%.", "")..")" -- CHANGED LINE
for i=1,#TextProperties do ypcall(function() if obj[TextProperties[i]]and obj[TextProperties[i]]~=obj:FindFirstChild(TextProperties[i])then compilation=compilation.." o"..tostring(num).."."..TextProperties[i].."=\""..obj[TextProperties[i]].."\"" end end) end
for i=1,#BoolProperties do ypcall(function() if obj[BoolProperties[i]]and obj[BoolProperties[i]]~=obj:FindFirstChild(BoolProperties[i])then compilation=compilation.." o"..tostring(num).."."..BoolProperties[i].."="..obj[BoolProperties[i]] end end) end
for i=1,#BrickColorProperties do ypcall(function() if obj[BrickColorProperties[i]]and obj[BrickColorProperties[i]]~=obj:FindFirstChild(BrickColorProperties[i])then compilation=compilation.." o"..tostring(num).."."..BrickColorProperties[i].."=BrickColor.new(\""..obj[BrickColorProperties[i]].."\")" end end) end
for i=1,#Color3Properties do ypcall(function() if obj[Color3Properties[i]]and obj[Color3Properties[i]]~=obj:FindFirstChild(Color3Properties[i])then compilation=compilation.." o"..tostring(num).."."..Color3Properties[i].."=Color3.new("..obj[Color3Properties[i]]..")" end end) end
for i=1,#Vector3Properties do ypcall(function() if obj[Vector3Properties[i]]and obj[Vector3Properties[i]]~=obj:FindFirstChild(Vector3Properties[i])then compilation=compilation.." o"..tostring(num).."."..Vector3Properties[i].."=Vector3.new("..obj[Vector3Properties[i]]..")" end end) end
for i=1,#ObjectProperties do ypcall(function() if obj[ObjectProperties[i]]and obj[ObjectProperties[i]]~=obj:FindFirstChild(ObjectProperties[i])then
-- CHANGED LINE endcomp=endcomp.." o"..tostring(num).."."..ObjectProperties[i].."=game"..obj[ObjectProperties[i]]:GetFullName():gsub("[^%.]+", "[\"%1\"]"):gsub("%.", "") -- CHANGED LINE
end end) end
for _,v in pairs(obj:GetChildren())do nom=nom+1 compile(v,nom) end end end compile(object,nom) return compilation..endcomp end) end |
|
|
| Report Abuse |
|
|
| |
|
|
| 29 Dec 2012 11:03 PM |
| I'm requesting for help. This is the correct forum. |
|
|
| Report Abuse |
|
|
|
| 29 Dec 2012 11:07 PM |
| Did you get a line number? |
|
|
| Report Abuse |
|
|
|
| 29 Dec 2012 11:08 PM |
| No, the error was given by another script calling the function. If I call the function from within that script, the error message gets discarded. |
|
|
| Report Abuse |
|
|
|
| 29 Dec 2012 11:12 PM |
Nevermind.
I deleted most of the properties temporarily (none that would affect the function being called in this instance)
Still, there was no error except
00:11:21 - String expected 00:11:21 - Script "Workspace.Script", Line 67 00:11:21 - stack end
Line 67(Just one line more than the posted script, calling the function): Workspace.Message.Text=_G.Compile(Workspace.Message) |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
| |
|
|
| 31 Dec 2012 01:28 PM |
when indexing an instance, the index must be a string.
that's what i can get from that error. you tried to index an instance by a non-string object.
¬ LuaLearners Elite/Writer |
|
|
| Report Abuse |
|
|
|
| 31 Dec 2012 01:33 PM |
The index is a string.
each starts off like this:
" local o"..tostring(num).."=Instance.new(\""classname",game["Serviice"]["Object"]["Parent"]"\")" etc
the ## is always changing, as in the compile function one of the parameters is 'num'. num changes after each object has been compiled into a string, so it starts off with the first object being o0, then o1, then o2, then o3, etc. It does stay a string :/ |
|
|
| Report Abuse |
|
|
|
| 31 Dec 2012 01:34 PM |
| and I made sure to put a space before each time I index a new string/make a line to change properties so that can't be the problem, either, incase anyone thinks that in the future. |
|
|
| Report Abuse |
|
|
|
| 31 Dec 2012 01:36 PM |
well i don't know then. all i can tell you is to check again. i don't have the patience to sift through your entire script :\
¬ LuaLearners Elite/Writer |
|
|
| Report Abuse |
|
|
C0D3Y
|
  |
| Joined: 24 Jul 2010 |
| Total Posts: 1692 |
|
|
| 31 Dec 2012 01:44 PM |
| What is " local o"..tostring(num).."=Instance.new(\""classname",game["Serviice"]["Object"]["Parent"]"\")" supposed to be? Can you show me what it would print out if you just put it in a print()? I think I can help, but I'm not exactly sure where each part ends. |
|
|
| Report Abuse |
|
|
|
| 31 Dec 2012 01:54 PM |
print(_G.Compile(Workspace.Message))
would be
local o0=Instance.new("Message",game["Workspace"]) o0.Name="Message" o0.Text=""
I just did a test when I got rid of all but 1 property from each table, and it worked when I called it... I wonder if one of the properties is the reason why it breaks? I don't understand why, they're all in ypcalls... could it be the sheer number of errors it causes?
But even so, why would that cause the function not to return a string? So confused :l |
|
|
| Report Abuse |
|
|
C0D3Y
|
  |
| Joined: 24 Jul 2010 |
| Total Posts: 1692 |
|
|
| 31 Dec 2012 02:00 PM |
" local o"..tostring(num).."=Instance.new(\"--Ends the text
"classname",game["Serviice"]["Object"]["Parent"]"\")"--Breaks it
You can't have TextLabel.Text = "Test1""Test2" It will do nothing. That's your problem. You _can_ however, have TextLabel.Text = ' "Test1""Test2" ' which will not error. Hope that helps a bit. |
|
|
| Report Abuse |
|
|
|
| 31 Dec 2012 02:03 PM |
Nevermind. I got it to work, I just added a few lines to get rid of the error messages before printing the compiled object
wait(1) for i=1,500 do print(" ")end wait(1) print(compilation..endcomp)
and it worked. Mostly.
The only problem is that all the objects created are in the exact same position, so when I compiled my character, my head, hats, legs, and arms are all inside my torso. I wonder how I can fix that... |
|
|
| Report Abuse |
|
|
|
| 31 Dec 2012 02:04 PM |
@c0dy the \ operator exempts a character from execution but keeps it as a string, so the first " there would not end the string, but when printed an actual quote would still come out. But thanks anyway |
|
|
| Report Abuse |
|
|